summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts')
-rw-r--r--catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts61
1 files changed, 37 insertions, 24 deletions
diff --git a/catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts b/catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts
index 5298e7e0d3..1a43ecf049 100644
--- a/catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts
+++ b/catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts
@@ -24,10 +24,19 @@ import { SdcUiCommon, SdcUiServices } from "onap-ui-angular";
import { CacheService, CatalogService } from "app/services-ng2";
import { SdcConfigToken, ISdcConfig } from "../../config/sdc-config.config";
import { SdcMenuToken, IAppMenu } from "../../config/sdc-menu.config";
-import { Component, ICategoryBase, IMainCategory, ISubCategory, IConfigStatuses, ICatalogSelector, CatalogSelectorTypes } from "app/models";
+import {
+ Component,
+ ICategoryBase,
+ IMainCategory,
+ ISubCategory,
+ IConfigStatuses,
+ ICatalogSelector,
+ CatalogSelectorTypes
+} from "app/models";
import { ResourceNamePipe } from "../../pipes/resource-name.pipe";
import { EntityFilterPipe, IEntityFilterObject, ISearchFilter} from "../../pipes/entity-filter.pipe";
-import { DEFAULT_MODEL_NAME } from "app/utils/constants";
+import {DEFAULT_MODEL_NAME} from "app/utils/constants";
+import {DataTypeCatalogComponent} from "../../../models/data-type-catalog-component";
interface Gui {
onComponentSubTypesClick:Function;
@@ -81,9 +90,9 @@ export class CatalogComponent {
public filteredCategories:Array<IMainCategory>;
public confStatus:IConfigStatuses;
public componentTypes:{[key:string]: Array<string>};
- public catalogItems:Array<Component>;
- public catalogFilteredItems:Array<Component>;
- public catalogFilteredSlicedItems:Array<Component>;
+ public catalogItems:Array<Component | DataTypeCatalogComponent>;
+ public catalogFilteredItems:Array<Component | DataTypeCatalogComponent>;
+ public catalogFilteredSlicedItems:Array<Component | DataTypeCatalogComponent>;
public expandedSection:Array<string>;
public version:string;
public sortBy:string;
@@ -195,7 +204,8 @@ export class CatalogComponent {
private buildChecklistModelForTypes() {
this.componentTypes = {
Resource: ['VF', 'VFC', 'CR', 'PNF', 'CP', 'VL'],
- Service: null
+ Service: null,
+ 'TOSCA Type': ['Data Type']
};
this.typesChecklistModel = new SdcUiCommon.ChecklistModel(this.checkboxesFilterKeys.componentTypes._main,
Object.keys(this.componentTypes).map((ct) => {
@@ -268,6 +278,7 @@ export class CatalogComponent {
this.checkboxesFilter = <IEntityFilterObject>{};
this.checkboxesFilter.selectedComponentTypes = [];
this.checkboxesFilter.selectedResourceSubTypes = [];
+ this.checkboxesFilter.selectedToscaTypes = [];
this.checkboxesFilter.selectedCategoriesModel = [];
this.checkboxesFilter.selectedStatuses = [];
this.checkboxesFilter.selectedModels = [];
@@ -404,16 +415,11 @@ export class CatalogComponent {
};
}
- public raiseNumberOfElementToDisplay(recalculate:boolean = false): void {
- const scrollPageAmount = 35;
+ public raiseNumberOfElementToDisplay(): void {
if (!this.catalogFilteredItems) {
this.numberOfItemToDisplay = 0;
- } else if (this.catalogFilteredItems.length > this.numberOfItemToDisplay || recalculate) {
- let fullPagesAmount = Math.ceil(this.numberOfItemToDisplay / scrollPageAmount) * scrollPageAmount;
- if (!recalculate || fullPagesAmount === 0) { //TODO trigger infiniteScroll to check bottom and fire onBottomHit by itself (sdc-ui)
- fullPagesAmount += scrollPageAmount;
- }
- this.numberOfItemToDisplay = Math.min(this.catalogFilteredItems.length, fullPagesAmount);
+ } else {
+ this.numberOfItemToDisplay = this.catalogFilteredItems.length;
this.catalogFilteredSlicedItems = this.catalogFilteredItems.slice(0, this.numberOfItemToDisplay);
}
}
@@ -431,7 +437,7 @@ export class CatalogComponent {
if (forceReload || this.componentShouldReload()) {
this.loaderService.activate();
- let onSuccess = (followedResponse:Array<Component>):void => {
+ let onSuccess = (followedResponse:Array<Component | DataTypeCatalogComponent>):void => {
this.updateCatalogItems(followedResponse);
this.loaderService.deactivate();
this.cacheService.set('breadcrumbsComponentsState', this.$state.current.name); //catalog
@@ -471,7 +477,7 @@ export class CatalogComponent {
}
}
- private updateCatalogItems = (items:Array<Component>):void => {
+ private updateCatalogItems = (items:Array<Component | DataTypeCatalogComponent>):void => {
this.catalogItems = items;
this.catalogItems.forEach(this.addFilterTermToComponent);
this.filterCatalogItems();
@@ -501,7 +507,7 @@ export class CatalogComponent {
private filterCatalogItems() {
this.catalogFilteredItems = this.makeFilteredItems(this.catalogItems, this.checkboxesFilter, this.search, this.sortBy, this.reverse);
- this.raiseNumberOfElementToDisplay(true);
+ this.raiseNumberOfElementToDisplay();
this.catalogFilteredSlicedItems = this.catalogFilteredItems.slice(0, this.numberOfItemToDisplay);
}
@@ -524,7 +530,11 @@ export class CatalogComponent {
this.checkboxesFilter.selectedComponentTypes = this.checkboxesFilterKeys.componentTypes._main;
Object.keys(this.checkboxesFilterKeys.componentTypes).forEach((chKey) => {
if (chKey !== '_main') {
- this.checkboxesFilter['selected' + chKey + 'SubTypes'] = this.checkboxesFilterKeys.componentTypes[chKey].map((st) => st.substr(chKey.length + 1));
+ if (chKey === 'TOSCA Type') {
+ this.checkboxesFilter['selectedToscaTypes'] = this.checkboxesFilterKeys.componentTypes[chKey].map((st) => st.substr(chKey.length + 1));
+ } else if (chKey === 'Resource') {
+ this.checkboxesFilter['selected' + chKey + 'SubTypes'] = this.checkboxesFilterKeys.componentTypes[chKey].map((st) => st.substr(chKey.length + 1));
+ }
}
});
@@ -639,6 +649,8 @@ export class CatalogComponent {
// rebuild the checkboxes to show selected
this.buildCheckboxLists();
}
+ }).catch(function (err) {
+ console.log(err.name + ":", err.message);
});
this.applyFilterParamsToView(this.filterParams);
}
@@ -685,13 +697,15 @@ export class CatalogComponent {
return sortedCategories;
}
- private addFilterTermToComponent(component:Component) {
- component.filterTerm = component.name + ' ' + component.description + ' ' + component.tags.toString() + ' ' + component.version;
- component.filterTerm = component.filterTerm.toLowerCase();
+ private addFilterTermToComponent(component:Component | DataTypeCatalogComponent) {
+ if (component instanceof Component) {
+ component.filterTerm = component.name + ' ' + component.description + ' ' + component.tags.toString() + ' ' + component.version;
+ component.filterTerm = component.filterTerm.toLowerCase();
+ }
}
- private makeFilteredItems(catalogItems:Array<Component>, filter:IEntityFilterObject, search:ISearchFilter, sortBy:string, reverse:boolean) {
- let filteredComponents:Array<Component> = catalogItems;
+ private makeFilteredItems(catalogItems:Array<Component | DataTypeCatalogComponent>, filter:IEntityFilterObject, search:ISearchFilter, sortBy:string, reverse:boolean) {
+ let filteredComponents:Array<Component | DataTypeCatalogComponent> = catalogItems;
// common entity filter
// --------------------------------------------------------------------------
@@ -712,7 +726,6 @@ export class CatalogComponent {
_.reverse(filteredComponents);
}
}
-
return filteredComponents;
}
}