Commit 717b2280 authored by Vitali Stupin's avatar Vitali Stupin
Browse files

Adding output limit and filtering producers

parent ffcee140
...@@ -11,8 +11,9 @@ export class MethodsService { ...@@ -11,8 +11,9 @@ export class MethodsService {
//private apiUrlBase = 'https://www.x-tee.ee/catalogue/EE/wsdls/'; //private apiUrlBase = 'https://www.x-tee.ee/catalogue/EE/wsdls/';
public apiUrlBase = 'http://localhost/'; public apiUrlBase = 'http://localhost/';
private limit: number = 15; private limit: number = 10;
private offset: number = 0; private offset: number = 0;
private nonEmpty: boolean = false;
private apiService = 'index.json'; private apiService = 'index.json';
private apiUrl = this.apiUrlBase + this.apiService; private apiUrl = this.apiUrlBase + this.apiService;
private subsystems: Subsystem[]; private subsystems: Subsystem[];
...@@ -34,19 +35,33 @@ export class MethodsService { ...@@ -34,19 +35,33 @@ export class MethodsService {
} }
private filtered(data: Subsystem[]): Subsystem[] { private filtered(data: Subsystem[]): Subsystem[] {
return data.slice(this.offset, this.limit); return data
.filter(subsystem => (!this.nonEmpty || subsystem.methods.length))
.slice(this.offset, this.limit);
} }
getMethods(): Subsystem[] { getMethods(): Subsystem[] {
return this.filtered(this.subsystems); return this.filtered(this.subsystems);
} }
filterNonEmpty(checked: boolean) { setNonEmpty(nonEmpty: boolean) {
console.log(checked) this.nonEmpty = nonEmpty;
if (checked) { this.signalRefresh();
this.limit = 5; }
} else {
this.limit = 10; setLimit (limit: string) {
switch(limit) {
case '20':
this.limit = 20;
break;
case '50':
this.limit = 50;
break;
case 'All':
this.limit = 1000000;
break;
default:
this.limit = 10;
} }
this.signalRefresh(); this.signalRefresh();
} }
......
...@@ -5,8 +5,18 @@ ...@@ -5,8 +5,18 @@
<div class="card-body"> <div class="card-body">
<div class="form-group form-check"> <div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1" <input type="checkbox" class="form-check-input" id="exampleCheck1"
[(ngModel)]="nonEmpty" (change)="methodsService.filterNonEmpty(nonEmpty)"> [(ngModel)]="nonEmpty" (change)="methodsService.setNonEmpty(nonEmpty)">
<label class="form-check-label" for="exampleCheck1">Show only nonempty subsystems</label> <label class="form-check-label" for="exampleCheck1">Show only producer subsystems</label>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Amount of subsystems to display</label>
<select class="form-control" id="exampleFormControlSelect1"
[(ngModel)]="limit" (change)="methodsService.setLimit(limit)">
<option>10</option>
<option>20</option>
<option>50</option>
<option>All</option>
</select>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -9,6 +9,7 @@ import { MethodsService } from '../methods.service'; ...@@ -9,6 +9,7 @@ import { MethodsService } from '../methods.service';
export class SearchComponent implements OnInit { export class SearchComponent implements OnInit {
nonEmpty: boolean = false nonEmpty: boolean = false
limit: number = 10
constructor(private methodsService: MethodsService) { } constructor(private methodsService: MethodsService) { }
......
...@@ -7,11 +7,9 @@ ...@@ -7,11 +7,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
<!--script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script-->
</head> </head>
<body> <body>
<app-root></app-root> <app-root></app-root>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment