UNPKG

@c8y/apps

Version:

Cumulocity IoT applications

41 lines (38 loc) 1.12 kB
import { Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { IManagedObject } from '@c8y/client'; import { Widget } from '@c8y/ngx-components'; @Component({ selector: 'app-service-dashboard', templateUrl: './service-dashboard.component.html' }) export class ServiceDashboardComponent { context: any; name = 'myCustomDeviceDashboardName'; defaultWidgets: Widget[] = []; constructor(private route: ActivatedRoute) { this.context = this.route.parent.snapshot.data; if (this.context && this.context.contextData) { const device: IManagedObject = this.context.contextData; this.name = this.name + '-' + device.id; this.defaultWidgets = [ { _x: 3, _y: 0, _width: 6, _height: 6, componentId: 'angular.widget.demo', config: { device: { id: device.id, name: device.name }, text: 'Welcome to a context dashboard' }, title: 'Hello', id: 'some_unique_id' } ]; } } }