UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

123 lines (118 loc) 8.8 kB
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, LoadingComponent, ProductExperienceDirective, QuickLinkComponent, C8yTranslatePipe, CoreModule, QuickLinkModule } from '@c8y/ngx-components'; import { NgIf, NgFor, NgClass } 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: "19.2.14", 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: "19.2.14", type: WelcomeToDeviceManagementComponent, isStandalone: true, selector: "c8y-welcome-to-devicemanagement", ngImport: i0, template: "<div\n class=\"welcome-widget\"\n tabindex=\"0\"\n>\n <div\n class=\"p-16 text-center\"\n *ngIf=\"isLoading\"\n >\n <c8y-loading></c8y-loading>\n </div>\n <div\n class=\"d-flex fit-h\"\n *ngIf=\"!isLoading\"\n >\n <div class=\"col-xs-12 a-s-stretch col-md-12\">\n <div class=\"card-group interact-grid fit-h\">\n <div\n class=\"col-xs-4 no-gutter\"\n *ngFor=\"let link of quickLinks\"\n >\n <button\n class=\"btn-clean card text-pre-normal\"\n [title]=\"link.label | translate\"\n type=\"button\"\n [ngClass]=\"{ 'm-b-0': true }\"\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\n [icon]=\"link.icon\"\n [label]=\"link.label\"\n ></c8y-quick-link>\n </button>\n </div>\n </div>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: LoadingComponent, selector: "c8y-loading", inputs: ["layout", "progress", "message"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: ProductExperienceDirective, selector: "[c8yProductExperience]", inputs: ["actionName", "actionData", "inherit", "suppressDataOverriding"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: QuickLinkComponent, selector: "c8y-quick-link", inputs: ["icon", "label"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: WelcomeToDeviceManagementComponent, decorators: [{ type: Component, args: [{ selector: 'c8y-welcome-to-devicemanagement', imports: [ NgIf, LoadingComponent, NgFor, ProductExperienceDirective, NgClass, QuickLinkComponent, C8yTranslatePipe ], template: "<div\n class=\"welcome-widget\"\n tabindex=\"0\"\n>\n <div\n class=\"p-16 text-center\"\n *ngIf=\"isLoading\"\n >\n <c8y-loading></c8y-loading>\n </div>\n <div\n class=\"d-flex fit-h\"\n *ngIf=\"!isLoading\"\n >\n <div class=\"col-xs-12 a-s-stretch col-md-12\">\n <div class=\"card-group interact-grid fit-h\">\n <div\n class=\"col-xs-4 no-gutter\"\n *ngFor=\"let link of quickLinks\"\n >\n <button\n class=\"btn-clean card text-pre-normal\"\n [title]=\"link.label | translate\"\n type=\"button\"\n [ngClass]=\"{ 'm-b-0': true }\"\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\n [icon]=\"link.icon\"\n [label]=\"link.label\"\n ></c8y-quick-link>\n </button>\n </div>\n </div>\n </div>\n </div>\n</div>\n" }] }], ctorParameters: () => [{ type: i1.Router }, { type: i2.NavigatorService }] }); /** * @deprecated */ class DeviceManagementWelcomeWidgetModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceManagementWelcomeWidgetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: DeviceManagementWelcomeWidgetModule, imports: [CoreModule, QuickLinkModule, RouterModule, WelcomeToDeviceManagementComponent] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceManagementWelcomeWidgetModule, imports: [CoreModule, QuickLinkModule, RouterModule, WelcomeToDeviceManagementComponent] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceManagementWelcomeWidgetModule, decorators: [{ type: NgModule, args: [{ imports: [CoreModule, QuickLinkModule, RouterModule, WelcomeToDeviceManagementComponent] }] }] }); /** * Generated bundle index. Do not edit. */ export { DeviceManagementWelcomeWidgetModule, WelcomeToDeviceManagementComponent }; //# sourceMappingURL=c8y-ngx-components-widgets-implementations-device-management-welcome.mjs.map