in source/console/src/app/secure/child-views/systems/default-system/default-system.component.ts [39:89]
ngOnInit() {
const self = this;
function defaultErrorCallback(err) {
console.error('Error:', err);
}
self.appSyncService
.getSystemBlueprint(self.system.systemBlueprintId)
.then((systemBlueprint: SystemBlueprint) => {
if (systemBlueprint && systemBlueprint.spec.hasOwnProperty('View')) {
self.parent = self;
const widgetSubscriptions = [];
const view = JSON.parse(
JSON.stringify(systemBlueprint.spec.View)
.split('[SYSTEM_NAME]')
.join(self.system.name)
);
if (view.hasOwnProperty('subscriptions')) {
const subs = view.subscriptions;
for (let ref in subs) {
if (subs.hasOwnProperty(ref)) {
const topic = subs[ref];
// console.log('Subscription:', ref, topic);
self.widgetSubscriptionSubjects[ref] = new Subject<any>();
self.widgetSubscriptionObservable$[
ref
] = self.widgetSubscriptionSubjects[ref].asObservable();
widgetSubscriptions.push({
topic: topic,
onMessage: message => {
// console.log('onMessage:', topic, message);
self.widgetSubscriptionSubjects[ref].next(message.value);
},
onError: defaultErrorCallback
});
}
}
}
self.subscribe(widgetSubscriptions);
if (view.hasOwnProperty('widgets')) {
self.widgets = view.widgets;
}
}
})
.catch(defaultErrorCallback);
}