Catalog alignment
[sdc.git] / catalog-ui / src / app / ng2 / components / ui / tile / tile.component.ts
1 import {Component, Input, Output, Inject, EventEmitter} from '@angular/core';
2 import {Component as ComponentModel} from 'app/models';
3 import {SdcMenuToken, IAppMenu} from "../../../config/sdc-menu.config";
4 import {ElementIcon} from "../sdc-element-icon/sdc-element-icon.component";
5 import {ComponentType, ResourceType, SdcElementType} from "../../../../utils/constants";
6
7 @Component({
8     selector: 'ui-tile',
9     templateUrl: './tile.component.html',
10     styleUrls: ['./tile.component.less']
11 })
12 export class TileComponent {
13     @Input() public component: ComponentModel;
14     @Output() public onTileClick: EventEmitter<ComponentModel>;
15     public catalogIcon: ElementIcon;
16     public hasEllipsis: boolean;
17
18     constructor(@Inject(SdcMenuToken) public sdcMenu: IAppMenu) {
19         this.onTileClick = new EventEmitter<ComponentModel>();
20         this.hasEllipsis = false;
21     }
22
23     ngOnInit(): void {
24         switch (this.component.componentType) {
25
26             case ComponentType.SERVICE:
27                 if (this.component.icon === 'defaulticon') {
28                     this.catalogIcon = new ElementIcon(this.component.icon, "services_60", 'lightBlue', 'white');
29                 } else {
30                     this.catalogIcon = new ElementIcon(this.component.icon, "services_60", '', 'lightBlue');
31                 }
32                 break;
33             case ComponentType.RESOURCE:
34                 switch (this.component.getComponentSubType()) {
35                     case ResourceType.CP:
36                     case ResourceType.VL:
37                         this.catalogIcon = new ElementIcon(this.component.icon, "resources_24", "purple", "white", "circle", 'medium');
38                         break;
39                     default:
40                         if (this.component.icon === 'defaulticon') {
41                             this.catalogIcon = new ElementIcon(this.component.icon, "resources_60", "purple", "white", "circle", 'x_large');
42                         } else {
43                             this.catalogIcon = new ElementIcon(this.component.icon, "resources_60", '', "error");
44                         }
45
46                 }
47
48         }
49     }
50
51     public tileClicked() {
52         this.onTileClick.emit(this.component);
53     }
54 }