You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by an...@apache.org on 2019/07/17 14:48:21 UTC
[incubator-dlab] 02/03: [DLAB-867]: spliced project out of filtered
data if no matched resources
This is an automated email from the ASF dual-hosted git repository.
ankovalyshyn pushed a commit to branch DLAB-867
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 7e312597eeca8250108effc33d949e636068449e
Author: Andriana Kovalyshyn <An...@epam.com>
AuthorDate: Wed Jul 17 15:17:32 2019 +0300
[DLAB-867]: spliced project out of filtered data if no matched resources
---
.../resources-grid/resources-grid.component.html | 4 +-
.../resources-grid/resources-grid.component.ts | 72 ++++++++++------------
2 files changed, 34 insertions(+), 42 deletions(-)
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.html b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.html
index bda825c..62c1022 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.html
@@ -157,8 +157,8 @@
</ng-container>
<ng-container matColumnDef="resource-filter">
<th mat-header-cell *matHeaderCellDef class="resources-col">
- <!-- <multi-select-dropdown (selectionChange)="onUpdate($event)" [type]="'resources'"
- [items]="filterConfiguration.resources" [model]="filterForm.resources"></multi-select-dropdown> -->
+ <multi-select-dropdown (selectionChange)="onUpdate($event)" [type]="'resources'"
+ [items]="filterConfiguration.resources" [model]="filterForm.resources"></multi-select-dropdown>
</th>
</ng-container>
<ng-container matColumnDef="cost-filter">
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts
index a3ec44c..a964b52 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts
@@ -117,20 +117,21 @@ export class ResourcesGridComponent implements OnInit {
// PRIVATE
+ private getEnvironmentsListCopy() {
+ return this.environments.map(env => JSON.parse(JSON.stringify(env)));
+ }
+
private getDefaultFilterConfiguration(): void {
const data: Exploratory[] = this.environments;
const shapes = [], statuses = [], resources = [];
- data.filter(elem => elem.exploratory.forEach((item: any) => {
- if (shapes.indexOf(item.shape) === -1)
- shapes.push(item.shape);
- if (statuses.indexOf(item.status) === -1)
- statuses.push(item.status);
+ data.filter(elem => elem.exploratory.map((item: any) => {
+ if (shapes.indexOf(item.shape) === -1) shapes.push(item.shape);
+ if (statuses.indexOf(item.status) === -1) statuses.push(item.status);
statuses.sort(SortUtils.statusSort);
- item.resources.forEach((resource: any) => {
- if (resources.indexOf(resource.status) === -1)
- resources.push(resource.status);
+ item.resources.map((resource: any) => {
+ if (resources.indexOf(resource.status) === -1) resources.push(resource.status);
resources.sort(SortUtils.statusSort);
});
}));
@@ -138,56 +139,47 @@ export class ResourcesGridComponent implements OnInit {
this.filterConfiguration = new FilterConfigurationModel('', statuses, shapes, resources, '');
}
-
-
- private getEnvironmentsListCopy() {
- // let filteredData: any = this.environments.map(env => (<any>Object).create(env));
- return this.environments.map(env => JSON.parse(JSON.stringify(env)));
- }
-
-
-
-
- applyFilter_btnClick(config: FilterConfigurationModel) {
+ private applyFilter_btnClick(config: FilterConfigurationModel) {
this.filtering = true;
let filteredData = this.getEnvironmentsListCopy();
const containsStatus = (list, selectedItems) => {
- debugger;
return list.filter((item: any) => { if (selectedItems.indexOf(item.status) !== -1) return item; });
};
- config && (filteredData.forEach((project: any) => {
-
-
- debugger;
+ if (config)
+ filteredData = filteredData.filter(project => {
+ project.exploratory = project.exploratory.filter(item => {
- project.exploratory = project.exploratory.filter(item => {
+ const isName = item.name.toLowerCase().indexOf(config.name.toLowerCase()) !== -1;
+ const isStatus = config.statuses.length > 0 ? (config.statuses.indexOf(item.status) !== -1) : (config.type !== 'active');
+ const isShape = config.shapes.length > 0 ? (config.shapes.indexOf(item.shape) !== -1) : true;
- const isName = item.name.toLowerCase().indexOf(config.name.toLowerCase()) !== -1;
- const isStatus = config.statuses.length > 0 ? (config.statuses.indexOf(item.status) !== -1) : (config.type !== 'active');
- const isShape = config.shapes.length > 0 ? (config.shapes.indexOf(item.shape) !== -1) : true;
+ const modifiedResources = containsStatus(item.resources, config.resources);
+ let isResources = config.resources.length > 0 ? (modifiedResources.length > 0) : true;
- const modifiedResources = containsStatus(item.resources, config.resources);
- let isResources = config.resources.length > 0 ? (modifiedResources.length > 0) : true;
+ if (config.resources.length > 0 && modifiedResources.length > 0) { item.resources = modifiedResources; }
- if (config.resources.length > 0 && modifiedResources.length > 0) { item.resources = modifiedResources; }
+ if (config.resources.length === 0 && config.type === 'active' ||
+ modifiedResources.length >= 0 && config.resources.length > 0 && config.type === 'active') {
+ item.resources = modifiedResources;
+ isResources = true;
+ }
- if (config.resources.length === 0 && config.type === 'active' ||
- modifiedResources.length >= 0 && config.resources.length > 0 && config.type === 'active') {
- item.resources = modifiedResources;
- isResources = true;
- }
- // && isResources
- return isName && isStatus && isShape;
- })
- }));
+ return isName && isStatus && isShape && isResources;
+ });
+ return project.exploratory.length > 0;
+ });
config && this.updateUserPreferences(config);
this.filteredEnvironments = filteredData;
}
+
+
+
+
showActiveInstances(): void {
this.filterForm = this.loadUserPreferences(this.filterActiveInstances());
this.applyFilter_btnClick(this.filterForm);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org