Support for Nested/Hierarchical Services
[sdc.git] / catalog-ui / src / app / ng2 / components / ui / sdc-element-icon / sdc-element-icon.component.ts
1 import {Component, Input, OnInit} from "@angular/core";
2 import {ComponentType, SdcElementType, ResourceType} from "../../../../utils/constants";
3
4
5 export class ElementIcon {
6     iconName: string;
7     color: string;
8     backgroundColor: string;
9     type: string
10     shape: string;
11     size: string;
12
13     constructor(name?: string, type?:string,  backgroundColor?:string, color?:string, shape?: string, size?:string) {
14         this.iconName = name || 'default';
15         this.type = type || 'resource_24';
16         this.backgroundColor = backgroundColor || 'primary';
17         this.color = color || "white";
18         this.shape = shape || "circle";
19         this.size = size || "x_large";
20     }
21 }
22
23 @Component({
24     selector: 'sdc-element-icon',
25     templateUrl: './sdc-element-icon.component.html',
26     styleUrls: ['./sdc-element-icon.component.less']
27 })
28 export class SdcElementIconComponent {
29
30     @Input() iconName: string;
31     @Input() elementType: string;
32     @Input() uncertified: boolean = false;
33
34     public elementIcon;
35
36     private createIconForDisplay = () => {
37         switch (this.elementType) {
38
39             case ComponentType.SERVICE:
40                 this.elementIcon = new ElementIcon(this.iconName, "services_24", "lightBlue");
41                 break;
42             case ComponentType.SERVICE_PROXY:
43             case ComponentType.SERVICE_SUBSTITUTION:
44                 this.elementIcon = new ElementIcon(this.iconName, "services_24", "white", "primary");
45                 break;
46             case ResourceType.CONFIGURATION:
47                 this.elementIcon = new ElementIcon(this.iconName, "resources_24", "purple", "white", 'circle', "medium");
48                 break;
49             case SdcElementType.GROUP:
50                 this.elementIcon = new ElementIcon("group", "resources_24", "blue", 'white', 'rectangle');
51                 break;
52             case SdcElementType.POLICY:
53                 this.elementIcon = new ElementIcon("policy", "resources_24", "darkBlue2", 'white', 'rectangle');
54                 break;
55             case ResourceType.VFC:
56             case ResourceType.CP:
57             case ResourceType.VL:
58                 this.elementIcon = new ElementIcon(this.iconName, "resources_24", "purple", '', '', 'medium');
59                 break;
60             default:
61                 this.elementIcon = new ElementIcon(this.iconName, "resources_24", "purple");
62         }
63     }
64
65     ngOnChanges():void {
66         this.createIconForDisplay();
67     }
68 }
69
70
71