diff options
author | Michael Lando <ml636r@att.com> | 2017-02-19 10:28:42 +0200 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2017-02-19 10:51:01 +0200 |
commit | 451a3400b76511393c62a444f588a4ed15f4a549 (patch) | |
tree | e4f5873a863d1d3e55618eab48b83262f874719d /catalog-ui/app/scripts/filters | |
parent | 5abfe4e1fb5fae4bbd5fbc340519f52075aff3ff (diff) |
Initial OpenECOMP SDC commit
Change-Id: I0924d5a6ae9cdc161ae17c68d3689a30d10f407b
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/app/scripts/filters')
18 files changed, 827 insertions, 0 deletions
diff --git a/catalog-ui/app/scripts/filters/_category-name-filter.ts b/catalog-ui/app/scripts/filters/_category-name-filter.ts new file mode 100644 index 0000000000..77bbf47684 --- /dev/null +++ b/catalog-ui/app/scripts/filters/_category-name-filter.ts @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class CategoryNameFilter{ + + constructor() { + let filter = <CategoryNameFilter>( (name:string) => { + if(name){ + let newName:string = _.last(name.split('/')); + if (newName){ + return newName; + } + return name; + } + }); + + return filter; + } + } + +} diff --git a/catalog-ui/app/scripts/filters/capitalize-filter.ts b/catalog-ui/app/scripts/filters/capitalize-filter.ts new file mode 100644 index 0000000000..ef0469aaa1 --- /dev/null +++ b/catalog-ui/app/scripts/filters/capitalize-filter.ts @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +module Sdc.Filters { + + export class CapitalizeFilter{ + + constructor() { + let filter = <CapitalizeFilter>( (sentence:string) => { + if (sentence != null) { + let newSentence:string = ""; + let words = sentence.split(' '); + for (let i=0; i < words.length; ++i){ + let word:string = words[i].toLowerCase(); + newSentence += word.substring(0,1).toUpperCase()+word.substring(1) + ' '; + } + return newSentence.trim(); + }else{ + return sentence; + } + }); + + return filter; + } + } + +} diff --git a/catalog-ui/app/scripts/filters/catalog-status-filter.ts b/catalog-ui/app/scripts/filters/catalog-status-filter.ts new file mode 100644 index 0000000000..5b382f6513 --- /dev/null +++ b/catalog-ui/app/scripts/filters/catalog-status-filter.ts @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +/** + * Created by obarda on 19/08/2015. + */ +module Sdc.Filters { + + export class CatalogStatusFilter{ + + constructor() { + let filter = <CatalogStatusFilter>( (statuses:any) => { + let filtered = []; + angular.forEach(statuses, function(status) { + filtered.push(status); + }); + return filtered; + }); + + return filter; + } + } + +} diff --git a/catalog-ui/app/scripts/filters/category-icon-filter.ts b/catalog-ui/app/scripts/filters/category-icon-filter.ts new file mode 100644 index 0000000000..6916a13399 --- /dev/null +++ b/catalog-ui/app/scripts/filters/category-icon-filter.ts @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class CategoryIconFilter{ + + constructor() { + let filter = <CategoryIconFilter>( (category:string) => { + let map = { + 'Application Layer 4+/Application Servers': ['applicationServer', 'server'], + 'Application Layer 4+/Media Servers': ['applicationServer', 'server'], + 'Application Layer 4+/Web Server': ['applicationServer', 'server'], + 'Network Layer 4+/Common Network Resources': ['network', 'loadBalancer'], + 'Generic/Infrastructure': ['objectStorage', 'compute'], + 'Generic/Network Elements': ['port', 'network', 'router'], + 'Application Layer 4+/Database': ['database'], + 'Generic/Database': ['database'], + 'Network Layer 2-3/Router': ['router'], + 'Network Layer 2-3/Gateway': ['gateway'], + 'Network Layer 2-3/LAN Connectors': ['connector'], + 'Network Layer 2-3/WAN Connectors': ['connector'], + 'Application Layer 4+/Border Elements': ['borderElement'], + 'Application Layer 4+/Load Balancer': ['loadBalancer'], + 'Application Layer 4+/Call Control': ['call_controll'], + 'VoIP Call Control': ['call_controll'], + 'Mobility': ['mobility'], + 'Network L1-3': ['network_l_1-3'], + 'Network L4': ['network_l_4'] + } + return map[category]; + + }); + return filter; + } + } +} diff --git a/catalog-ui/app/scripts/filters/category-type-filter.ts b/catalog-ui/app/scripts/filters/category-type-filter.ts new file mode 100644 index 0000000000..482e566e5a --- /dev/null +++ b/catalog-ui/app/scripts/filters/category-type-filter.ts @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class CategoryTypeFilter { + + static $inject = ['Sdc.Services.CacheService']; + + constructor(cacheService:Services.CacheService) { + let filter = <CategoryTypeFilter> (categories:any, selectedType:Array<string>) => { + + if (!selectedType.length) + return categories; + + let filteredCategories:any = []; + selectedType.forEach((type:string) => { + filteredCategories = filteredCategories.concat(cacheService.get(type.toLowerCase() + 'Categories')); + }); + + return _.filter(categories, function (category:any) { + return filteredCategories.indexOf(category) != -1; + }); + }; + return filter; + } + } +} diff --git a/catalog-ui/app/scripts/filters/clear-whitespaces-filter.ts b/catalog-ui/app/scripts/filters/clear-whitespaces-filter.ts new file mode 100644 index 0000000000..5c946e1715 --- /dev/null +++ b/catalog-ui/app/scripts/filters/clear-whitespaces-filter.ts @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class ClearWhiteSpacesFilter { + + constructor() { + let filter = <ClearWhiteSpacesFilter>( (text:string) => { + if (!angular.isString(text)) { + return text; + } + + return text.replace(/ /g,''); // remove also whitespaces inside + }); + + return filter; + } + } +} + + diff --git a/catalog-ui/app/scripts/filters/entity-filter.ts b/catalog-ui/app/scripts/filters/entity-filter.ts new file mode 100644 index 0000000000..ce60d69833 --- /dev/null +++ b/catalog-ui/app/scripts/filters/entity-filter.ts @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class EntityFilter{ + + constructor() { + + let filter = <EntityFilter>( (components:Array<Models.Components.Component>, filter:any) => { + + let filteredComponents:Array<Models.Components.Component> = components; + + // filter by type + // -------------------------------------------------------------------------- + if ((filter.selectedComponentTypes && filter.selectedComponentTypes.length>0) || (filter.selectedResourceSubTypes && filter.selectedResourceSubTypes.length>0)) { + let filteredTypes = []; + angular.forEach(components, (component:Models.Components.Component):void => { + // Filter by component type + let typeLower:string = component.componentType.toLowerCase(); + let typeFirstCapital:string = typeLower.charAt(0).toUpperCase() + typeLower.slice(1); + if (filter.selectedComponentTypes.indexOf(typeFirstCapital) !== -1) { + filteredTypes.push(component); + } + + // Filter by resource sub type, only in case the resource checkbox was not selected (because in this case we already added all the components in above section). + if (component.isResource() && filter.selectedComponentTypes.indexOf("Resource") === -1 && filter.selectedResourceSubTypes.length > 0) { + //filteredComponents.pop(); // Remove the last inserted component. + let resource:Sdc.Models.Components.Resource = <Sdc.Models.Components.Resource>component; + if (filter.selectedResourceSubTypes.indexOf(resource.getComponentSubType()) !== -1) { + filteredTypes.push(component); + } + } + }); + filteredComponents = filteredTypes; + } + + // filter by categories & subcategories & groupings + // -------------------------------------------------------------------------- + if (filter.selectedCategoriesModel && filter.selectedCategoriesModel.length>0) { + let filteredCategories = []; + angular.forEach(filteredComponents, (component:Models.Components.Component):void => { + if (component.categories && filter.selectedCategoriesModel.indexOf(component.categories[0].uniqueId) !== -1) { + filteredCategories.push(component); + } else if (component.categories && component.categories[0].subcategories && filter.selectedCategoriesModel.indexOf(component.categories[0].subcategories[0].uniqueId) !== -1) { + filteredCategories.push(component); + } else if (component.categories && component.categories[0].subcategories && component.categories[0].subcategories[0].groupings && filter.selectedCategoriesModel.indexOf(component.categories[0].subcategories[0].groupings[0].uniqueId) !== -1) { + filteredCategories.push(component); + } + }); + filteredComponents = filteredCategories; + } + + // filter by statuses + // -------------------------------------------------------------------------- + if (filter.selectedStatuses && filter.selectedStatuses.length > 0) { + //convert array of array to string array + let selectedStatuses:Array<string> = [].concat.apply([],filter.selectedStatuses); + + let filteredStatuses = []; + angular.forEach(filteredComponents, (component:Models.Components.Component):void => { + if (selectedStatuses.indexOf(component.lifecycleState) > -1) { + filteredStatuses.push(component); + } + //if status DISTRIBUTED && CERTIFIED are selected the component will added in CERTIFIED status , not need to add twice + if(selectedStatuses.indexOf('DISTRIBUTED') > -1 && !(selectedStatuses.indexOf('CERTIFIED') > -1)){ + if( component.distributionStatus && component.distributionStatus.indexOf('DISTRIBUTED') > -1 && component.lifecycleState.indexOf('CERTIFIED') > -1){ + filteredStatuses.push(component); + } + } + }); + filteredComponents = filteredStatuses; + } + + // filter by statuses and distributed + // -------------------------------------------------------------------------- + if (filter.distributed != undefined && filter.distributed.length > 0) { + let filterDistributed: Array<any> = filter.distributed; + let filteredDistributed = []; + angular.forEach(filteredComponents, (entity) => { + filterDistributed.forEach((distribute) => { + let distributeItem = distribute.split(','); + distributeItem.forEach((item) => { + if (item !== undefined && entity.distributionStatus === item){ + filteredDistributed.push(entity); + } + }) + }); + }); + filteredComponents = filteredDistributed; + } + + return filteredComponents; + }); + + return filter; + } + } + +} diff --git a/catalog-ui/app/scripts/filters/graph-resource-name-filter.ts b/catalog-ui/app/scripts/filters/graph-resource-name-filter.ts new file mode 100644 index 0000000000..63f0d780be --- /dev/null +++ b/catalog-ui/app/scripts/filters/graph-resource-name-filter.ts @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class GraphResourceNameFilter { + + + constructor() { + let filter = <GraphResourceNameFilter>( (name:string) => { + let context = document.createElement("canvas").getContext("2d"); + context.font = "13px Arial"; + + if(67 < context.measureText(name).width) { + let newLen = name.length - 3; + let newName = name.substring(0, newLen); + + while (59 < (context.measureText(newName).width)) { + newName = newName.substring(0, (--newLen)); + } + return newName + '...'; + } + + return name; + }); + return filter; + } + } + +} diff --git a/catalog-ui/app/scripts/filters/product-category-name-filter.ts b/catalog-ui/app/scripts/filters/product-category-name-filter.ts new file mode 100644 index 0000000000..afe8c7ef08 --- /dev/null +++ b/catalog-ui/app/scripts/filters/product-category-name-filter.ts @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +module Sdc.Filters { + + export class ProductCategoryNameFilter{ + + constructor() { + let filter = <CategoryNameFilter>( (name:string) => { + if(name){ + let newName:string = name.split('/')[1]; + if (newName){ + return newName; + } + return name; + } + }); + + return filter; + } + } + +} diff --git a/catalog-ui/app/scripts/filters/product-subcategory-name-filter.ts b/catalog-ui/app/scripts/filters/product-subcategory-name-filter.ts new file mode 100644 index 0000000000..66d7a76c28 --- /dev/null +++ b/catalog-ui/app/scripts/filters/product-subcategory-name-filter.ts @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +module Sdc.Filters { + + export class ProductSubCategoryNameFilter{ + + constructor() { + let filter = <CategoryNameFilter>( (name:string) => { + if(name){ + let newName:string = _.last(name.split('/')); + if (newName){ + return newName; + } + return name; + } + }); + + return filter; + } + } + +} diff --git a/catalog-ui/app/scripts/filters/relation-name-fllter.ts b/catalog-ui/app/scripts/filters/relation-name-fllter.ts new file mode 100644 index 0000000000..7d97eea372 --- /dev/null +++ b/catalog-ui/app/scripts/filters/relation-name-fllter.ts @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class RelationNameFilter{ + + constructor() { + let filter = <RelationNameFilter>( (relationshipType:string) => { + let icons: Array<string> = [ + 'AttachesTo', + 'BindsTo', + 'DependsOn', + 'HostedOn', + 'LinksTo', + 'RoutesTo' + ]; + + let result:string = 'ConnectedTo'; + + if (relationshipType) { + let arr = relationshipType.split('.'); // looks like tosca.relationships.AttachesTo + relationshipType = arr[arr.length - 1]; + if (icons.indexOf(relationshipType) > -1) { + result = relationshipType; + } + } + + return result; + }); + + return filter; + } + } + +} diff --git a/catalog-ui/app/scripts/filters/resource-name-filter.ts b/catalog-ui/app/scripts/filters/resource-name-filter.ts new file mode 100644 index 0000000000..a1f6162a4c --- /dev/null +++ b/catalog-ui/app/scripts/filters/resource-name-filter.ts @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class ResourceNameFilter{ + + + constructor() { + let filter = <ResourceNameFilter>( (name:string) => { + if(name){ + //let newName:string = _.last(name.split('.')); + let newName = + _.last(_.last(_.last(_.last(_.last(_.last(_.last(_.last(name.split('tosca.nodes.')) + .split('network.')).split('relationships.')).split('org.openecomp.')).split('resource.nfv.')) + .split('nodes.module.')).split('cp.')).split('vl.')); + if (newName){ + return newName; + } + return name; + } + }); + + return filter; + } + } + +} diff --git a/catalog-ui/app/scripts/filters/resource-type-filter.ts b/catalog-ui/app/scripts/filters/resource-type-filter.ts new file mode 100644 index 0000000000..6aa79dae76 --- /dev/null +++ b/catalog-ui/app/scripts/filters/resource-type-filter.ts @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class ResourceTypeFilter{ + static '$inject' = ['Sdc.Services.CacheService']; + constructor(cacheService:Services.CacheService) + { + let filter = <ResourceTypeFilter> (resourceType:string) => { + let uiConfiguration:any = cacheService.get('UIConfiguration'); + + if(uiConfiguration.resourceTypes && uiConfiguration.resourceTypes[resourceType]){ + return uiConfiguration.resourceTypes[resourceType]; + } + return resourceType; + } + return filter; + } + } +} diff --git a/catalog-ui/app/scripts/filters/string-to-date-filter.ts b/catalog-ui/app/scripts/filters/string-to-date-filter.ts new file mode 100644 index 0000000000..1c4919d419 --- /dev/null +++ b/catalog-ui/app/scripts/filters/string-to-date-filter.ts @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class StringToDateFilter{ + + constructor() { + let filter = <StringToDateFilter>( (date:string) => { + if(date){ + return new Date(date.replace(" UTC", '').replace(" ", 'T') + '+00:00'); + } + }); + return filter; + } + } +} diff --git a/catalog-ui/app/scripts/filters/tests-id-filter.ts b/catalog-ui/app/scripts/filters/tests-id-filter.ts new file mode 100644 index 0000000000..12c5e6fd79 --- /dev/null +++ b/catalog-ui/app/scripts/filters/tests-id-filter.ts @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +module Sdc.Filters { + + export class TestsIdFilter{ + + constructor() { + let filter = <TestsIdFilter>( (testId:string) => { + return testId.replace(/\s/g, '_').toLowerCase(); + }); + + return filter; + } + } + +} diff --git a/catalog-ui/app/scripts/filters/trim-filter.ts b/catalog-ui/app/scripts/filters/trim-filter.ts new file mode 100644 index 0000000000..fd231abc8d --- /dev/null +++ b/catalog-ui/app/scripts/filters/trim-filter.ts @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +/// <reference path="../references"/> +module Sdc.Filters { + + export class TrimFilter { + + constructor() { + let filter = <TrimFilter>( (text:string) => { + if (!angular.isString(text)) { + return text; + } + + return text.replace(/^\s+|\s+$/g, ''); // you could use .trim, but it's not going to work in IE<9 + }); + + return filter; + } + } +} + + diff --git a/catalog-ui/app/scripts/filters/truncate-filter.ts b/catalog-ui/app/scripts/filters/truncate-filter.ts new file mode 100644 index 0000000000..1470e5937d --- /dev/null +++ b/catalog-ui/app/scripts/filters/truncate-filter.ts @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +module Sdc.Filters { + + export class TruncateFilter { + constructor() { + let filter = <TruncateFilter> (str:string, length:number) => { + if (str.length <= length) { + return str; + } + + //if(str[length - 1] === ' '){ + // return str.substring(0, length - 1) + '...'; + //} + + let char; + let index = length; + while (char !== ' ' && index !== 0) { + index--; + char = str[index]; + } + if (index === 0) { + return (index === 0) ? str : str.substring(0, length - 3) + '...'; + } + return (index === 0) ? str : str.substring(0, index) + '...'; + }; + return filter; + } + + } +} diff --git a/catalog-ui/app/scripts/filters/underscoreless-filter.ts b/catalog-ui/app/scripts/filters/underscoreless-filter.ts new file mode 100644 index 0000000000..6849a36f04 --- /dev/null +++ b/catalog-ui/app/scripts/filters/underscoreless-filter.ts @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +module Sdc.Filters { + + export class UnderscoreLessFilter{ + + constructor() { + let filter = <UnderscoreLessFilter>( (sentence:string) => { + return sentence.replace(/_/g, ' '); + }); + + return filter; + } + } + +} |