Fix bugs in attribute outputs page
[sdc.git] / catalog-ui / src / app / models / data-type-catalog-component.ts
1 /*
2  * -
3  *  ============LICENSE_START=======================================================
4  *  Copyright (C) 2022 Nordix Foundation.
5  *  ================================================================================
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *       http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21
22 'use strict';
23
24 import {DataTypeModel} from "./data-types";
25 import {Icon, ToscaType} from "../utils/constants";
26 import {Service} from "./components/service";
27 import {Resource} from "./components/resource";
28 import {Model} from "./model";
29
30 export class DataTypeCatalogComponent {
31
32     public name:string;
33     public uniqueId:string;
34     public uuid:string;
35     public version:string;
36     public model:Model;
37     public componentType:string;
38     public icon:string;
39     public iconSprite:string;
40     public lastUpdateDate:string;
41     public filterTerm:string;
42
43     constructor(dataTypeCatalogComponent?: DataTypeModel) {
44         this.name = dataTypeCatalogComponent.name;
45         this.uniqueId = dataTypeCatalogComponent.uniqueId;
46         if (dataTypeCatalogComponent.model) {
47             this.model = dataTypeCatalogComponent.model;
48         } else {
49             this.model = undefined;
50         }
51         this.componentType = ToscaType.DATATYPE;
52         this.icon = Icon.DATATYPE_ICON;
53         this.iconSprite = 'sprite-resource-icons';
54         this.lastUpdateDate = dataTypeCatalogComponent.creationTime;
55         this.filterTerm = dataTypeCatalogComponent.name;
56     }
57
58     public isService = ():boolean => {
59         return this instanceof Service;
60     }
61
62     public isResource = ():boolean => {
63         return this instanceof Resource;
64     }
65
66     public getComponentSubType= ():string => {
67         return this.componentType;
68     }
69 }
70