aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components/ui/sdc-element-icon/sdc-element-icon.component.ts
blob: fc81a5bfdb56579e163e0a7155a93772e78128ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import {Component, Input, OnInit} from "@angular/core";
import {ComponentType, SdcElementType, ResourceType} from "../../../../utils/constants";


export class ElementIcon {
    iconName: string;
    color: string;
    backgroundColor: string;
    type: string
    shape: string;
    size: string;

    constructor(name?: string, type?:string,  backgroundColor?:string, color?:string, shape?: string, size?:string) {
        this.iconName = name || 'default';
        this.type = type || 'resource_24';
        this.backgroundColor = backgroundColor || 'primary';
        this.color = color || "white";
        this.shape = shape || "circle";
        this.size = size || "x_large";
    }
}

@Component({
    selector: 'sdc-element-icon',
    templateUrl: './sdc-element-icon.component.html',
    styleUrls: ['./sdc-element-icon.component.less']
})
export class SdcElementIconComponent {

    @Input() iconName: string;
    @Input() elementType: string;
    @Input() uncertified: boolean = false;

    public elementIcon;

    private createIconForDisplay = () => {
        switch (this.elementType) {

            case ComponentType.SERVICE:
                this.elementIcon = new ElementIcon(this.iconName, "services_24", "lightBlue");
                break;
            case ComponentType.SERVICE_PROXY:
            case ComponentType.SERVICE_SUBSTITUTION:
                this.elementIcon = new ElementIcon(this.iconName, "services_24", "white", "primary");
                break;
            case ResourceType.CONFIGURATION:
                this.elementIcon = new ElementIcon(this.iconName, "resources_24", "purple", "white", 'circle', "medium");
                break;
            case SdcElementType.GROUP:
                this.elementIcon = new ElementIcon("group", "resources_24", "blue", 'white', 'rectangle');
                break;
            case SdcElementType.POLICY:
                this.elementIcon = new ElementIcon("policy", "resources_24", "darkBlue2", 'white', 'rectangle');
                break;
            case ResourceType.VFC:
            case ResourceType.CP:
            case ResourceType.VL:
                this.elementIcon = new ElementIcon(this.iconName, "resources_24", "purple", '', '', 'medium');
                break;
            default:
                this.elementIcon = new ElementIcon(this.iconName, "resources_24", "purple");
        }
    }

    ngOnChanges():void {
        this.createIconForDisplay();
    }
}