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 {
//private apiUrlBase = 'https://www.x-tee.ee/catalogue/EE/wsdls/';
public apiUrlBase = 'http://localhost/';
private limit: number = 15;
private limit: number = 10;
private offset: number = 0;
private nonEmpty: boolean = false;
private apiService = 'index.json';
private apiUrl = this.apiUrlBase + this.apiService;
private subsystems: Subsystem[];
......@@ -34,19 +35,33 @@ export class MethodsService {
}
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[] {
return this.filtered(this.subsystems);
}
filterNonEmpty(checked: boolean) {
console.log(checked)
if (checked) {
this.limit = 5;
} else {
this.limit = 10;
setNonEmpty(nonEmpty: boolean) {
this.nonEmpty = nonEmpty;
this.signalRefresh();
}
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();
}
......
......@@ -5,8 +5,18 @@
<div class="card-body">
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1"
[(ngModel)]="nonEmpty" (change)="methodsService.filterNonEmpty(nonEmpty)">
<label class="form-check-label" for="exampleCheck1">Show only nonempty subsystems</label>
[(ngModel)]="nonEmpty" (change)="methodsService.setNonEmpty(nonEmpty)">
<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>
......
......@@ -9,6 +9,7 @@ import { MethodsService } from '../methods.service';
export class SearchComponent implements OnInit {
nonEmpty: boolean = false
limit: number = 10
constructor(private methodsService: MethodsService) { }
......
......@@ -7,11 +7,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<!--script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<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-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous">
</head>
<body>
<app-root></app-root>
......
Markdown is supported
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