@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
113 lines (108 loc) • 8.16 kB
JavaScript
import * as i0 from '@angular/core';
import { Component, NgModule } from '@angular/core';
import * as i1 from '@angular/router';
import { RouterModule } from '@angular/router';
import * as i2 from '@c8y/ngx-components';
import { gettext, CoreModule, QuickLinkModule } from '@c8y/ngx-components';
import * as i3 from '@angular/common';
class WelcomeToDeviceManagementComponent {
constructor(router, navigator) {
this.router = router;
this.navigator = navigator;
this.quickLinks = [];
this.isLoading = true;
}
async ngOnInit() {
this.navSubscription = this.navigator.items$.subscribe(nodes => {
this.navNodes = nodes;
this.createAllDevicesQuickLink();
this.createQuicklinkRegisterDevice();
this.createQuicklinkAddGroup();
this.createAddDeviceProfileQuickLink();
this.createAddSoftwareQuickLink();
this.createAddFirmwareQuickLink();
this.isLoading = false;
});
}
ngOnDestroy() {
if (this.navSubscription && !this.navSubscription.closed) {
this.navSubscription.unsubscribe();
}
}
createAllDevicesQuickLink() {
this.createQuickLinkToNavNode(['Devices', 'All devices']);
}
createQuicklinkRegisterDevice() {
this.createQuickLinkToNavNode(['Devices', 'Registration'], {
label: gettext('Register device')
});
}
createQuicklinkAddGroup() {
this.createQuickLinkToNavNode(['Groups'], {
label: gettext('Add group'),
icon: 'c8y-group-add',
click: async () => await this.router.navigate(['group'], { queryParams: { showAddGroup: true } })
});
}
createAddDeviceProfileQuickLink() {
this.createQuickLinkToNavNode(['Management', 'Device profiles'], {
label: gettext('Add device profile')
});
}
createAddSoftwareQuickLink() {
this.createQuickLinkToNavNode(['Management', 'Software repository'], {
label: gettext('Add software')
});
}
createAddFirmwareQuickLink() {
this.createQuickLinkToNavNode(['Management', 'Firmware repository'], {
label: gettext('Add firmware')
});
}
createQuickLinkToNavNode(navNodePathLabels, quickLinkOverrides = {}) {
const navNode = this.findVisibleNavNode(navNodePathLabels);
if (!navNode) {
return;
}
const quickLink = {
icon: navNode.icon,
label: navNode.label,
click: async () => {
await this.router.navigateByUrl(navNode.path);
},
...quickLinkOverrides
};
this.quickLinks.push(quickLink);
}
findVisibleNavNode(navNodePathLabels, navNodes = this.navNodes) {
const currentLabel = navNodePathLabels.shift();
const navNode = navNodes.find(navNode => !navNode.hidden && navNode.label === currentLabel);
if (navNode && navNodePathLabels.length > 0) {
return this.findVisibleNavNode(navNodePathLabels, navNode.children);
}
return navNode;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: WelcomeToDeviceManagementComponent, deps: [{ token: i1.Router }, { token: i2.NavigatorService }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: WelcomeToDeviceManagementComponent, selector: "c8y-welcome-to-devicemanagement", ngImport: i0, template: "<div class=\"welcome-widget\" tabindex=\"0\">\n <div class=\"p-16 text-center\" *ngIf=\"isLoading\">\n <c8y-loading></c8y-loading>\n </div>\n <div class=\"d-flex fit-h\" *ngIf=\"!isLoading\">\n <div class=\"col-xs-12 a-s-stretch col-md-12\">\n <div class=\"card-group interact-grid fit-h\">\n <div *ngFor=\"let link of quickLinks\" class=\"col-xs-4 no-gutter\">\n <button\n class=\"btn-clean card text-pre-normal\"\n [ngClass]=\"{ 'm-b-0': true }\"\n type=\"button\"\n [title]=\"link.label | translate\"\n (click)=\"link.click ? link.click() : false\"\n c8yProductExperience\n [actionName]=\"'welcomeWidgetClicked'\"\n [actionData]=\"{ link: link.label }\"\n data-cy=\"devicemanagement-welcome--quick-link\"\n >\n <c8y-quick-link [icon]=\"link.icon\" [label]=\"link.label\"></c8y-quick-link>\n </button>\n </div>\n </div>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.LoadingComponent, selector: "c8y-loading", inputs: ["layout", "progress", "message"] }, { kind: "directive", type: i2.ProductExperienceDirective, selector: "[c8yProductExperience]", inputs: ["actionName", "actionData", "inherit", "suppressDataOverriding"] }, { kind: "component", type: i2.QuickLinkComponent, selector: "c8y-quick-link", inputs: ["icon", "label"] }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: WelcomeToDeviceManagementComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-welcome-to-devicemanagement', template: "<div class=\"welcome-widget\" tabindex=\"0\">\n <div class=\"p-16 text-center\" *ngIf=\"isLoading\">\n <c8y-loading></c8y-loading>\n </div>\n <div class=\"d-flex fit-h\" *ngIf=\"!isLoading\">\n <div class=\"col-xs-12 a-s-stretch col-md-12\">\n <div class=\"card-group interact-grid fit-h\">\n <div *ngFor=\"let link of quickLinks\" class=\"col-xs-4 no-gutter\">\n <button\n class=\"btn-clean card text-pre-normal\"\n [ngClass]=\"{ 'm-b-0': true }\"\n type=\"button\"\n [title]=\"link.label | translate\"\n (click)=\"link.click ? link.click() : false\"\n c8yProductExperience\n [actionName]=\"'welcomeWidgetClicked'\"\n [actionData]=\"{ link: link.label }\"\n data-cy=\"devicemanagement-welcome--quick-link\"\n >\n <c8y-quick-link [icon]=\"link.icon\" [label]=\"link.label\"></c8y-quick-link>\n </button>\n </div>\n </div>\n </div>\n </div>\n</div>\n" }]
}], ctorParameters: () => [{ type: i1.Router }, { type: i2.NavigatorService }] });
class DeviceManagementWelcomeWidgetModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DeviceManagementWelcomeWidgetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: DeviceManagementWelcomeWidgetModule, declarations: [WelcomeToDeviceManagementComponent], imports: [CoreModule, QuickLinkModule, RouterModule] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DeviceManagementWelcomeWidgetModule, imports: [CoreModule, QuickLinkModule, RouterModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DeviceManagementWelcomeWidgetModule, decorators: [{
type: NgModule,
args: [{
imports: [CoreModule, QuickLinkModule, RouterModule],
declarations: [WelcomeToDeviceManagementComponent]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { DeviceManagementWelcomeWidgetModule, WelcomeToDeviceManagementComponent };
//# sourceMappingURL=c8y-ngx-components-widgets-implementations-device-management-welcome.mjs.map