Catalog alignment
[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                 this.elementIcon = new ElementIcon(this.iconName, "services_24", "white", "primary");
44                 break;
45             case ResourceType.CONFIGURATION:
46                 this.elementIcon = new ElementIcon(this.iconName, "resources_24", "purple", "white", 'circle', "medium");
47                 break;
48             case SdcElementType.GROUP:
49                 this.elementIcon = new ElementIcon("group", "resources_24", "blue", 'white', 'rectangle');
50                 break;
51             case SdcElementType.POLICY:
52                 this.elementIcon = new ElementIcon("policy", "resources_24", "darkBlue2", 'white', 'rectangle');
53                 break;
54             case ResourceType.CP:
55             case ResourceType.VL:
56                 this.elementIcon = new ElementIcon(this.iconName, "resources_24", "purple", '', '', 'medium');
57                 break;
58             default:
59                 this.elementIcon = new ElementIcon(this.iconName, "resources_24", "purple");
60         }
61     }
62
63     ngOnChanges():void {
64         this.createIconForDisplay();
65     }
66 }
67
68
69