Showing synchronizer notification
Change-Id: Ibc0ef77471026b48fa2e0a577adde9e43dde2a10
diff --git a/src/app/datasources/helpers/store.helpers.ts b/src/app/datasources/helpers/store.helpers.ts
index dfb1e7a..1a2b0ab 100644
--- a/src/app/datasources/helpers/store.helpers.ts
+++ b/src/app/datasources/helpers/store.helpers.ts
@@ -10,6 +10,7 @@
public updateCollection(event: IWSEvent, subject: BehaviorSubject<any>): BehaviorSubject<any> {
const collection: any[] = subject.value;
const index: number = _.findIndex(collection, (i) => {
+ // NOTE evaluate to use event.msg.pk
return i.id === event.msg.object.id;
});
const exist: boolean = index > -1;
diff --git a/src/app/datasources/index.ts b/src/app/datasources/index.ts
index 4473541..535937b 100644
--- a/src/app/datasources/index.ts
+++ b/src/app/datasources/index.ts
@@ -4,6 +4,7 @@
import {WebSocketEvent} from './websocket/global';
import {SliceStore} from './stores/slices.store';
import {StoreHelpers} from './helpers/store.helpers';
+import {SynchronizerStore} from './stores/synchronizer.store';
export const xosRest = 'xosDataSources';
@@ -17,4 +18,5 @@
angular
.module('xosDataSources')
.service('StoreHelpers', StoreHelpers)
+ .service('SynchronizerStore', SynchronizerStore)
.service('SlicesStore', SliceStore);
diff --git a/src/app/datasources/stores/synchronizer.store.ts b/src/app/datasources/stores/synchronizer.store.ts
new file mode 100644
index 0000000..598d23c
--- /dev/null
+++ b/src/app/datasources/stores/synchronizer.store.ts
@@ -0,0 +1,26 @@
+/// <reference path="../../../../typings/index.d.ts"/>
+
+import {Subject} from 'rxjs/Rx';
+import {IWSEvent, IWSEventService} from '../websocket/global';
+
+export class SynchronizerStore {
+ static $inject = ['WebSocket'];
+ private _notifications: Subject<IWSEvent> = new Subject();
+ constructor(
+ private webSocket: IWSEventService
+ ) {
+ this.webSocket.list()
+ .filter((e: IWSEvent) => {
+ return e.msg.changed_fields.indexOf('backend_status') > -1;
+ })
+ .subscribe(
+ (event: IWSEvent) => {
+ this._notifications.next(event);
+ }
+ );
+ }
+
+ query() {
+ return this._notifications.asObservable();
+ }
+}