Adding keyboard shortcut to toggle notifications [S]
Change-Id: I5d69cb14141f4c484738920efee96f6c117527bc
(cherry picked from commit f37172583a9566708567e55a65f4426e7e5216d7)
diff --git a/src/app/core/debug/debug-summary.html b/src/app/core/debug/debug-summary.html
index 9807ac9..7e185da 100644
--- a/src/app/core/debug/debug-summary.html
+++ b/src/app/core/debug/debug-summary.html
@@ -41,5 +41,12 @@
<i class="fa fa-remove text-danger" ng-hide="vm.debugStatus.modelsTab"></i>
</td>
</tr>
+ <tr>
+ <td>Notifications</td>
+ <td class="text-right">
+ <i class="fa fa-check text-success" ng-show="vm.debugStatus.notifications"></i>
+ <i class="fa fa-remove text-danger" ng-hide="vm.debugStatus.notifications"></i>
+ </td>
+ </tr>
</tbody>
</table>
\ No newline at end of file
diff --git a/src/app/core/debug/debug.service.spec.ts b/src/app/core/debug/debug.service.spec.ts
index a26d8cc..99f9484 100644
--- a/src/app/core/debug/debug.service.spec.ts
+++ b/src/app/core/debug/debug.service.spec.ts
@@ -53,6 +53,13 @@
expect(service.status.events).toBeTruthy();
});
+ it('should read the notification status from localStorage', () => {
+ spyOn(window.localStorage, 'getItem')
+ .and.returnValue(null);
+ service = new XosDebugService($log, $scope, XosKeyboardShortcut);
+ expect(service.status.notifications).toBeTruthy();
+ });
+
it('should disable the global debug status', () => {
spyOn(window.localStorage, 'getItem')
.and.returnValue('true');
diff --git a/src/app/core/debug/debug.service.ts b/src/app/core/debug/debug.service.ts
index f23fa06..aee1064 100644
--- a/src/app/core/debug/debug.service.ts
+++ b/src/app/core/debug/debug.service.ts
@@ -20,12 +20,13 @@
global: boolean;
events: boolean;
modelsTab: boolean;
+ notifications: boolean;
}
export interface IXosDebugService {
status: IXosDebugStatus;
setupShortcuts(): void;
- toggleDebug(type: 'global' | 'events' | 'modelsTab'): void;
+ toggleDebug(type: 'global' | 'events' | 'modelsTab' | 'notifications'): void;
}
export class XosDebugService implements IXosDebugService {
@@ -35,7 +36,8 @@
public status: IXosDebugStatus = {
global: false,
events: false,
- modelsTab: false
+ modelsTab: false,
+ notifications: true
};
constructor (
@@ -51,6 +53,9 @@
const debugModelsTab = window.localStorage.getItem('debug-modelsTab');
this.status.modelsTab = (debugModelsTab === 'true');
+
+ const notifications = window.localStorage.getItem('debug-notifications');
+ this.status.notifications = (notifications !== null ? notifications === 'true' : true);
}
public setupShortcuts(): void {
@@ -65,9 +70,15 @@
cb: () => this.toggleDebug('events'),
description: 'Toggle debug messages for WS events in browser console'
}, 'global');
+
+ this.XosKeyboardShortcut.registerKeyBinding({
+ key: 'S',
+ cb: () => this.toggleDebug('notifications'),
+ description: 'Toggle notifications'
+ }, 'global');
}
- public toggleDebug(type: 'global' | 'events' | 'modelsTab'): void {
+ public toggleDebug(type: 'global' | 'events' | 'modelsTab' | 'notifications'): void {
if (window.localStorage.getItem(`debug-${type}`) === 'true') {
this.$log.info(`[XosDebug] Disabling ${type} debug`);
window.localStorage.setItem(`debug-${type}`, 'false');