[CORD-2424] Adding Instances and Networks to the graph
Change-Id: Ib30081f4995930d979447af59124896f1308f54d
diff --git a/src/app/service-graph/services/graph.config.ts b/src/app/service-graph/services/graph.config.ts
index 7db2d97..e6ddfbd 100644
--- a/src/app/service-graph/services/graph.config.ts
+++ b/src/app/service-graph/services/graph.config.ts
@@ -34,6 +34,33 @@
'XosGraphStore'
];
+ private instanceEnabled = false;
+ private instanceBinding = {
+ key: 'i',
+ modifiers: ['shift'],
+ cb: () => {
+ // NOTE anytime the graph change the observable is updated,
+ // no need to manually retrigger here
+ this.XosGraphStore.toggleInstances();
+ this.toggleNetworkShortcuts();
+ },
+ label: 'i',
+ description: 'Toggle Instances'
+ };
+
+ private networkEnabled = false;
+ private networkBinding = {
+ key: 'n',
+ modifiers: ['shift'],
+ cb: () => {
+ // NOTE anytime the graph change the observable is updated,
+ // no need to manually retrigger here
+ this.XosGraphStore.toggleNetwork();
+ },
+ label: 'n',
+ description: 'Toggle Networks'
+ };
+
constructor (
private $log: ng.ILogService,
private $cookies: ng.cookies.ICookiesService,
@@ -64,13 +91,13 @@
key: 's',
modifiers: ['shift'],
cb: () => {
- // NOTE anytime the graph change the observable is updated,
- // no need to manually retrigger here
this.XosGraphStore.toggleServiceInstances();
+ this.toggleInstanceShortcuts();
},
label: 's',
description: 'Toggle ServiceInstances'
});
+
}
public toggleFullscreen() {
@@ -80,4 +107,26 @@
this.$rootScope.$broadcast('xos.sg.update');
}, 500);
}
+
+ private toggleInstanceShortcuts(): void {
+ if (!this.instanceEnabled) {
+ this.XosKeyboardShortcut.registerKeyBinding(this.instanceBinding);
+ }
+ else {
+ this.XosKeyboardShortcut.removeKeyBinding(this.instanceBinding);
+ this.XosKeyboardShortcut.removeKeyBinding(this.networkBinding);
+ }
+ this.instanceEnabled = !this.instanceEnabled;
+ }
+
+ private toggleNetworkShortcuts(): void {
+ if (!this.networkEnabled) {
+ this.XosKeyboardShortcut.registerKeyBinding(this.networkBinding);
+ }
+ else {
+ this.XosKeyboardShortcut.removeKeyBinding(this.networkBinding);
+ }
+
+ this.networkEnabled = !this.networkEnabled;
+ }
}