aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components/ui/canvas-zone
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/components/ui/canvas-zone')
-rw-r--r--catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.html6
-rw-r--r--catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.less2
-rw-r--r--catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.ts32
-rw-r--r--catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.html14
-rw-r--r--catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.less100
-rw-r--r--catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.ts100
6 files changed, 186 insertions, 68 deletions
diff --git a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.html b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.html
index e279e3f704..981efbb58e 100644
--- a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.html
+++ b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.html
@@ -1,11 +1,11 @@
-<div class="sdc-canvas-zone {{class}}-zone" [class.minimized]="minifyZone" [class.hidden]="!showZone">
- <div class="sdc-canvas-zone__header" (click)="unminifyZone()" >
+<div class="sdc-canvas-zone {{class}}-zone" [class.minimized]="minimized" [class.hidden]="!visible" (click)="backgroundClicked()">
+ <div class="sdc-canvas-zone__header" (click)="unminifyZone(); $event.stopPropagation();" >
<div class="sdc-canvas-zone__title">{{title}}
<span class="sdc-canvas-zone__counter">{{count}}</span>
</div>
<span class="sdc-canvas-zone__state-button">&ndash;</span>
</div>
- <div class="sdc-canvas-zone__container">
+ <div class="sdc-canvas-zone__container" #scrollDiv >
<ng-content></ng-content>
</div>
</div> \ No newline at end of file
diff --git a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.less b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.less
index 3e77c5ca3b..02880a9202 100644
--- a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.less
+++ b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.less
@@ -1,5 +1,5 @@
.sdc-canvas-zone {
- width: 280px;
+ width: 285px;
max-height:186px;
display:flex;
flex-direction:column;
diff --git a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.ts b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.ts
index 7e60cb37a6..4059ad6cae 100644
--- a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.ts
+++ b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-container.component.ts
@@ -1,6 +1,5 @@
-import { Component, Input, Output, ViewEncapsulation, EventEmitter } from '@angular/core';
-import { EventListenerService } from 'app/services';
-import { GRAPH_EVENTS } from 'app/utils';
+import { Component, Input, Output, ViewEncapsulation, EventEmitter, OnInit } from '@angular/core';
+import { ZoneInstanceType } from '../../../../models/graph/zones/zone-instance';
@Component({
selector: 'zone-container',
@@ -9,17 +8,28 @@ import { GRAPH_EVENTS } from 'app/utils';
encapsulation: ViewEncapsulation.None
})
-export class ZoneContainerComponent {
+export class ZoneContainerComponent implements OnInit {
@Input() title:string;
- @Input() class:string;
- @Input() count:number;
- @Input() showZone:boolean;
- @Input() minifyZone:boolean;
- constructor(private eventListenerService:EventListenerService) {}
+ @Input() type:ZoneInstanceType;
+ @Input() count:number;
+ @Input() visible:boolean;
+ @Input() minimized:boolean;
+ @Output() minimize: EventEmitter<any> = new EventEmitter<any>();
+ @Output() backgroundClick: EventEmitter<void> = new EventEmitter<void>();
+ private class:string;
+
+ constructor() {}
+
+ ngOnInit() {
+ this.class = ZoneInstanceType[this.type].toLowerCase();
+ }
private unminifyZone = () => {
- this.minifyZone = !this.minifyZone;
- this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_ZONE_SIZE_CHANGE);
+ this.minimize.emit();
+ }
+
+ private backgroundClicked = () => {
+ this.backgroundClick.emit();
}
} \ No newline at end of file
diff --git a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.html b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.html
index d36b7aec6f..031b081323 100644
--- a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.html
+++ b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.html
@@ -1,8 +1,10 @@
-<div class="zone-child mode-{{config.mode}}" [class.locked]="activeInstanceMode > MODE.HOVER"
- (mouseenter)="setMode(MODE.HOVER)" (mouseleave)="setMode(MODE.NONE)" (click)="setMode(MODE.SELECTED)">
- <div class="zone-child__handle" (click)="setMode(MODE.TAG, $event)">+</div>
- <div class="zone-child__body">
- <div class="zone-child__body-content">{{config.count || defaultIconText}}</div>
+<div tooltip="{{zoneInstance.instanceData.name}}" #currentComponent
+ class="zone-instance mode-{{zoneInstance.mode}}" [class.locked]="activeInstanceMode > MODE.HOVER" [class.hiding]="hidden"
+ (mouseenter)="setMode(MODE.HOVER)" (mouseleave)="setMode(MODE.NONE)" (click)="setMode(MODE.SELECTED, $event)">
+ <div *ngIf="zoneInstance.handle" class="target-handle {{zoneInstance.handle}}" (click)="tagHandleClicked($event)"></div>
+ <div *ngIf="!isViewOnly" class="zone-instance__handle" (click)="setMode(MODE.TAG, $event)">+</div>
+ <div class="zone-instance__body">
+ <div class="zone-instance__body-content">{{zoneInstance.assignments.length || defaultIconText}}</div>
</div>
- <div class="zone-child__name">{{config.name}}</div>
+ <div class="zone-instance__name">{{zoneInstance.instanceData.name}}</div>
</div> \ No newline at end of file
diff --git a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.less b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.less
index a1d56df96e..b562c08514 100644
--- a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.less
+++ b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.less
@@ -1,9 +1,12 @@
-.zone-child {
+@import '../../../../../../assets/styles/variables';
+
+.zone-instance {
position:relative;
width:76px;
margin:5px;
+ opacity:1;
- .zone-child__handle {
+ .zone-instance__handle {
display:none;
position:absolute;
right:4px;
@@ -11,33 +14,34 @@
width:22px;
height:22px;
cursor:pointer;
- border: solid white 1px;
+ border: solid @main_color_p 1px;
border-radius: 2px;
text-align: center;
font-weight:bold;
}
- .zone-child__body {
+ .zone-instance__body {
margin:0 auto;
width:43px;
height:43px;
display:flex;
padding:3px;
-
}
- .zone-child__body-content {
+ .zone-instance__body-content {
border-radius: 2px;
flex:1;
- color:white;
- font-size:18px;
+ color:@main_color_p;
+ font-size:16px;
text-align:center;
display:flex;
align-items: center;
justify-content: center;
+ box-shadow:none;
+ transition:box-shadow 5s;
}
- .zone-child__name {
+ .zone-instance__name {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
@@ -45,66 +49,86 @@
}
/* Dynamic classes below */
+ .target-handle {
+ position:absolute;
+ width:18px;
+ height:18px;
+ display:block;
+ top: -4px;
+ right: 10px;
+ background-size: 100% 100%;
+ cursor: url("../../../../../../assets/styles/images/canvas-tagging-icons/policy_2.svg"), pointer;
+
+ &.tagged-policy {
+ background-image: url('../../../../../../assets/styles/images/canvas-tagging-icons/policy_added.svg');
+ }
+
+ &.tag-available {
+ background-image: url('../../../../../../assets/styles/images/canvas-tagging-icons/indication.svg');
+ }
+ }
+
+
&.mode-1, &.mode-2, &.mode-3 { //hover, selected, tag
- .zone-child__body {
+ .zone-instance__body {
border:solid 2px;
border-radius: 2px;
padding:2px;
cursor:pointer;
}
- .zone-child__handle{
+ }
+
+ &.mode-1, &.mode-2:hover{
+ .zone-instance__handle{
display:block;
- cursor:pointer;
}
}
&.locked {
- cursor: default;
+ cursor: inherit;
}
-
- // &:not(.locked):hover .zone-child__handle{
- // display:block;
- // }
- .zone-child__body {
- cursor: default;
+
+ &.hiding {
+ opacity:0;
+ .zone-instance__body-content {
+ box-shadow: #CCC 0px 0px 15px;
+ }
}
- &.mode-3 .zone-child__handle {
+
+
+ &.mode-3 .zone-instance__handle {
width:24px;
height:24px;
right:3px;
top:9px;
display:block;
background-image: linear-gradient(-140deg, #009E98 0%, #97D648 100%);
- border: 2px solid #FFFFFF;
+ border: 2px solid @main_color_p;
border-radius: 2px;
box-shadow: inset 2px -2px 3px 0 #007A3E;
- cursor: pointer;
}
}
.sdc-canvas-zone.group-zone {
- .zone-child__handle {
- background-color:#009FDB;
- }
- .zone-child__body {
- border-color:#009FDB;
+ .zone-instance__handle {
+ background-color:@main_color_a;
}
- .zone-child__body-content {
- background: #009FDB;
+ .zone-instance__body {
+ border-color:@main_color_a;
+ .zone-instance__body-content {
+ background: @main_color_a;
+ }
}
}
.sdc-canvas-zone.policy-zone {
- .zone-child__handle {
- background-color:#0568AE;
+ .zone-instance__handle {
+ background-color:@main_color_r;
}
- .zone-child__body {
- border-color:#1287D9;
- .zone-child__body-content {
- background: #1287D9;
+ .zone-instance__body {
+ border-color:@main_color_r;
+ .zone-instance__body-content {
+ background: @main_color_r;
}
}
- .zone-child__body-content {
- background: #0568AE;
- }
} \ No newline at end of file
diff --git a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.ts b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.ts
index 8057ae908a..3c2dd45db5 100644
--- a/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.ts
+++ b/catalog-ui/src/app/ng2/components/ui/canvas-zone/zone-instance/zone-instance.component.ts
@@ -1,5 +1,14 @@
-import { Component, Input, Output, EventEmitter, ViewEncapsulation } from '@angular/core';
-import { ZoneInstanceConfig, ZoneInstanceMode } from 'app/models/graph/zones/zone-child';
+import { Component, Input, Output, EventEmitter, ViewEncapsulation, OnInit, SimpleChange, ElementRef, ViewChild, SimpleChanges } from '@angular/core';
+import {
+ ZoneInstance, ZoneInstanceMode, ZoneInstanceType,
+ IZoneInstanceAssignment
+} from 'app/models/graph/zones/zone-instance';
+import { PoliciesService } from '../../../../services/policies.service';
+import { GroupsService } from '../../../../services/groups.service';
+import { IZoneService } from "../../../../../models/graph/zones/zone";
+import { EventListenerService } from 'app/services';
+import { GRAPH_EVENTS } from '../../../../../utils';
+import { Subject, Observable } from 'rxjs';
@Component({
selector: 'zone-instance',
@@ -7,22 +16,95 @@ import { ZoneInstanceConfig, ZoneInstanceMode } from 'app/models/graph/zones/zon
styleUrls: ['./zone-instance.component.less'],
encapsulation: ViewEncapsulation.None
})
-export class ZoneInstanceComponent {
+export class ZoneInstanceComponent implements OnInit {
- @Input() config:ZoneInstanceConfig;
+ @Input() zoneInstance:ZoneInstance;
@Input() defaultIconText:string;
@Input() isActive:boolean;
+ @Input() isViewOnly:boolean;
@Input() activeInstanceMode: ZoneInstanceMode;
+ @Input() hidden:boolean;
+ @Input() forceSave:Subject<Function>;
@Output() modeChange: EventEmitter<any> = new EventEmitter<any>();
+ @Output() assignmentSaveStart: EventEmitter<void> = new EventEmitter<void>();
+ @Output() assignmentSaveComplete: EventEmitter<boolean> = new EventEmitter<boolean>();
+ @Output() tagHandleClick: EventEmitter<ZoneInstance> = new EventEmitter<ZoneInstance>();
+ @ViewChild('currentComponent') currentComponent: ElementRef;
private MODE = ZoneInstanceMode;
+ private zoneService:IZoneService;
- private setMode = (mode:ZoneInstanceMode, event?:any):void => {
- if(!this.isActive || this.isActive && mode == ZoneInstanceMode.TAG){ //when active, do not allow hover/select mode toggling
- this.modeChange.emit({newMode: mode, instance: this.config});
+ constructor(private policiesService:PoliciesService, private groupsService:GroupsService, private eventListenerService:EventListenerService){}
+
+ ngOnInit(){
+ if(this.zoneInstance.type == ZoneInstanceType.POLICY){
+ this.zoneService = this.policiesService;
+ } else {
+ this.zoneService = this.groupsService;
}
- if(event){
- event.stopPropagation();
+ this.forceSave.subscribe((afterSaveFunction:Function) => {
+ this.setMode(ZoneInstanceMode.TAG, null, afterSaveFunction);
+ })
+ }
+
+ ngOnChanges(changes:SimpleChanges) {
+ if(changes.hidden){
+ this.currentComponent.nativeElement.scrollIntoView({behavior: "smooth", block: "nearest", inline:"end"});
}
}
+ ngOnDestroy() {
+ this.forceSave.unsubscribe();
+ }
+
+ private setMode = (mode:ZoneInstanceMode, event?:any, afterSaveCallback?:Function):void => {
+
+ if(event){ //prevent event from handle and then repeat event from zone instance
+ event.stopPropagation();
+ }
+
+ if(!this.isActive && this.activeInstanceMode === ZoneInstanceMode.TAG) {
+ return; //someone else is tagging. No events allowed
+ }
+
+ if(this.isActive && this.zoneInstance.mode === ZoneInstanceMode.TAG){
+ if(mode !== ZoneInstanceMode.TAG) {
+ return; //ignore all other events. The only valid option is saving changes.
+ }
+
+ let oldAssignments:Array<IZoneInstanceAssignment> = this.zoneInstance.instanceData.getSavedAssignments();
+ if(this.zoneInstance.isZoneAssignmentChanged(oldAssignments, this.zoneInstance.assignments)) {
+
+ this.assignmentSaveStart.emit();
+
+ this.zoneService.updateZoneInstanceAssignments(this.zoneInstance.parentComponentType, this.zoneInstance.parentComponentID, this.zoneInstance.instanceData.uniqueId, this.zoneInstance.assignments).subscribe(
+ (success) => {
+ this.zoneInstance.instanceData.setSavedAssignments(this.zoneInstance.assignments);
+ if(this.zoneInstance.type === ZoneInstanceType.POLICY){
+ this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_POLICY_INSTANCE_UPDATE, this.zoneInstance.instanceData);
+ } else {
+ this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_GROUP_INSTANCE_UPDATE, this.zoneInstance.instanceData);
+ }
+ this.assignmentSaveComplete.emit(true);
+ if(afterSaveCallback) afterSaveCallback();
+ }, (error) => {
+ this.zoneInstance.assignments = oldAssignments;
+ this.assignmentSaveComplete.emit(false);
+ });
+ } else {
+ if(afterSaveCallback) afterSaveCallback();
+ }
+ this.modeChange.emit({newMode: ZoneInstanceMode.NONE, instance: this.zoneInstance});
+
+ } else {
+ this.modeChange.emit({newMode: mode, instance: this.zoneInstance});
+ }
+
+
+ }
+
+ private tagHandleClicked = (event:Event) => {
+ this.tagHandleClick.emit(this.zoneInstance);
+ event.stopPropagation();
+ };
+
} \ No newline at end of file