Skip to content
Snippets Groups Projects
Commit 8e458b23 authored by Joanna Kaźmierczak's avatar Joanna Kaźmierczak
Browse files

search in remote clusters view

parent 7dd93859
No related branches found
No related tags found
1 merge request!188Resolve "Improve new layout"
<div style="display: flex; align-items: center; margin-top:20px"> <div style="display: flex; align-items: center; margin-top:20px">
<div style="margin-right:20px"> <div style=" display:flex; align-items: center;">
<div > <div style="margin-right:20px;">
<button class="btn btn-primary" (click)="modal.show()">New Cluster</button> <button class="btn btn-primary" (click)="modal.show()">New Cluster</button>
</div> </div>
</div> <span class="p-input-icon-right">
<div class="flex" style="margin-right:20px"> <i class="pi pi-search" style="font-size: 13px; top: 16px; margin-right: 5px;"></i>
<input pInputText class="form-control" name="search" id="search"
placeholder="Search" type="text" [(ngModel)]="searchValue" (ngModelChange)="filterClusters()">
</span>
</div> </div>
</div> </div>
...@@ -13,7 +15,7 @@ ...@@ -13,7 +15,7 @@
<div class="background-section"> <div class="background-section">
<p-table <p-table
[value]="clusters" [value]="filteredClusters"
[paginator]="true" [paginator]="true"
[rows]="maxItemsOnPage" [rows]="maxItemsOnPage"
[rowsPerPageOptions]="[15, 20, 25, 30, 50]" [rowsPerPageOptions]="[15, 20, 25, 30, 50]"
...@@ -44,11 +46,11 @@ ...@@ -44,11 +46,11 @@
<ng-template pTemplate="body" let-cluster> <ng-template pTemplate="body" let-cluster>
<tr> <tr>
<td [routerLink]="[cluster.id]">{{cluster.id}}</td> <td [routerLink]="[cluster.id]">{{cluster.id}}</td>
<td>{{cluster.name}}</td> <td [routerLink]="[cluster.id]">{{cluster.name}}</td>
<td>{{cluster.codename}}</td> <td [routerLink]="[cluster.id]">{{cluster.codename}}</td>
<td>{{('CLUSTERS.'+cluster.state.toString().toUpperCase() ) | translate}}</td> <td [routerLink]="[cluster.id]">{{('CLUSTERS.'+cluster.state.toString().toUpperCase() ) | translate}}</td>
<td>{{cluster.creationDate | date: 'dd-MM-yyyy HH:mm'}}</td> <td [routerLink]="[cluster.id]">{{cluster.creationDate | date: 'dd-MM-yyyy HH:mm'}}</td>
<td>{{cluster.modificationDate | date: 'dd-MM-yyyy HH:mm'}}</td> <td [routerLink]="[cluster.id]">{{cluster.modificationDate | date: 'dd-MM-yyyy HH:mm'}}</td>
<td class="text-right"> <td class="text-right">
<span class="dropdown"> <span class="dropdown">
<a style="display: inline-block" class="dropdown-toggle" aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" href="#" role="button"> <a style="display: inline-block" class="dropdown-toggle" aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" href="#" role="button">
......
...@@ -16,6 +16,8 @@ export class ClusterManagerComponent { ...@@ -16,6 +16,8 @@ export class ClusterManagerComponent {
public addedCluster: ClusterManager = new ClusterManager(); public addedCluster: ClusterManager = new ClusterManager();
public updatedFile : File = null; public updatedFile : File = null;
public maxItemsOnPage = 15; public maxItemsOnPage = 15;
public searchValue = '';
filteredClusters: ClusterManager[] = [];
public domains = []; public domains = [];
...@@ -23,49 +25,50 @@ export class ClusterManagerComponent { ...@@ -23,49 +25,50 @@ export class ClusterManagerComponent {
public modal: ModalComponent; public modal: ModalComponent;
constructor(private clusterService: ClusterManagerService, constructor(private clusterService: ClusterManagerService,
private domainService: DomainService private domainService: DomainService) {
) {
this.getAllClusters(); this.getAllClusters();
this.domainService.getAllBase().subscribe(result => { this.domainService.getAllBase().subscribe(result => {
this.domains = result.filter(d => d.id !== this.domainService.getGlobalDomainId()); this.domains = result.filter(d => d.id !== this.domainService.getGlobalDomainId());
}); });
} }
public saveFile(event: any) { public saveFile(event: any) {
console.log(event); console.log(event);
this.updatedFile =event.files[0]; this.updatedFile =event.files[0];
}
public getAllClusters() {
this.clusterService.getAllClusters().subscribe(result => {
console.log(result);
this.clusters = result;
})
}
public closeModalAndSaveCluster() {
this.clusterService.sendCluster(this.updatedFile, this.addedCluster).subscribe(result => {
console.log(result);
this.getAllClusters();
this.modal.hide();
this.updatedFile = null;
this.addedCluster = new ClusterManager();
}, error => {
console.error(error);
} }
)
}
public onDomainSelection(event: any) {
console.log(event);
this.addedCluster.domainNames = [event]
}
public getAllClusters() {
this.clusterService.getAllClusters().subscribe(result => {
console.log(result);
this.clusters = result;
this.filterClusters();
})
}
public closeModalAndSaveCluster() {
this.clusterService.sendCluster(this.updatedFile, this.addedCluster).subscribe(result => {
console.log(result);
this.getAllClusters();
this.modal.hide();
this.updatedFile = null;
this.addedCluster = new ClusterManager();
}, error => {
console.error(error);
})
}
public onDomainSelection(event: any) {
console.log(event);
this.addedCluster.domainNames = [event]
}
filterClusters() {
const value = this.searchValue?.toLowerCase() || '';
this.filteredClusters = this.clusters.filter(cluster =>
cluster.name?.toLowerCase().includes(value) ||
cluster.codename?.toLowerCase().includes(value) ||
cluster.id?.toString().includes(value)
);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment