UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

126 lines (120 loc) 23 kB
import * as i0 from '@angular/core'; import { Input, Component, ViewChild, NgModule } from '@angular/core'; import * as i2 from '@angular/forms'; import { Validators } from '@angular/forms'; import * as i1$1 from '@c8y/ngx-components'; import { gettext, C8yStepper, CoreModule, FormsModule, hookWizard } from '@c8y/ngx-components'; import { uniqBy } from 'lodash-es'; import * as i3 from '@ngx-translate/core'; import * as i4 from '@angular/common'; import * as i5 from '@angular/cdk/stepper'; import * as i1 from '@c8y/client'; import { SharedEcosystemModule, EcosystemWizards } from '@c8y/ngx-components/ecosystem/shared'; class LicenseViewComponent { constructor(fetchClient) { this.fetchClient = fetchClient; this.content = gettext('Loading license content'); this.FALL_BACK_URL = 'https://spdx.org/licenses/'; } async ngOnInit() { const response = await this.fetchClient.fetch(this.url); if (response.status === 200) { this.content = await response.text(); return; } this.content = ''; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: LicenseViewComponent, deps: [{ token: i1.FetchClient }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: LicenseViewComponent, isStandalone: false, selector: "c8y-license-view", inputs: { url: "url", name: "name" }, ngImport: i0, template: "<ng-container *ngIf=\"content\">\n <a [href]=\"url\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"small pull-right\">\n <i c8yIcon=\"external-link\" class=\"m-r-4\"></i>\n <span translate>Open in new window</span>\n </a>\n <textarea\n [attr.aria-label]=\"'License' | translate\"\n class=\"form-control bg-level-1 text-monospace small m-b-16\"\n readonly\n style=\"height: 170px\"\n [textContent]=\"content\"\n ></textarea>\n</ng-container>\n\n<div class=\"alert alert-warning\" role=\"alert\" *ngIf=\"!content && name\">\n <strong translate>No license attached</strong>\n <p translate>\n The author of the package hasn't included a license file in a format that can be displayed.\n Verify the license online, for example, with a website like:\n </p>\n <a [href]=\"FALL_BACK_URL + name\" target=\"_blank\" rel=\"noopener noreferrer\">\n {{ FALL_BACK_URL }}{{ name }}\n </a>\n</div>\n\n<div class=\"alert alert-danger\" role=\"alert\" *ngIf=\"!content && !name\">\n <strong translate>No license found</strong>\n <p translate>\n There is no license attached to this package. You can continue installing it at your own risk.\n </p>\n</div>\n", dependencies: [{ kind: "directive", type: i1$1.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i1$1.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1$1.C8yTranslatePipe, name: "translate" }] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: LicenseViewComponent, decorators: [{ type: Component, args: [{ selector: 'c8y-license-view', standalone: false, template: "<ng-container *ngIf=\"content\">\n <a [href]=\"url\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"small pull-right\">\n <i c8yIcon=\"external-link\" class=\"m-r-4\"></i>\n <span translate>Open in new window</span>\n </a>\n <textarea\n [attr.aria-label]=\"'License' | translate\"\n class=\"form-control bg-level-1 text-monospace small m-b-16\"\n readonly\n style=\"height: 170px\"\n [textContent]=\"content\"\n ></textarea>\n</ng-container>\n\n<div class=\"alert alert-warning\" role=\"alert\" *ngIf=\"!content && name\">\n <strong translate>No license attached</strong>\n <p translate>\n The author of the package hasn't included a license file in a format that can be displayed.\n Verify the license online, for example, with a website like:\n </p>\n <a [href]=\"FALL_BACK_URL + name\" target=\"_blank\" rel=\"noopener noreferrer\">\n {{ FALL_BACK_URL }}{{ name }}\n </a>\n</div>\n\n<div class=\"alert alert-danger\" role=\"alert\" *ngIf=\"!content && !name\">\n <strong translate>No license found</strong>\n <p translate>\n There is no license attached to this package. You can continue installing it at your own risk.\n </p>\n</div>\n" }] }], ctorParameters: () => [{ type: i1.FetchClient }], propDecorators: { url: [{ type: Input }], name: [{ type: Input }] } }); class LicenseConfirmModalComponent { constructor(wizardComponent, fb, optionsService, translateService) { this.wizardComponent = wizardComponent; this.fb = fb; this.optionsService = optionsService; this.translateService = translateService; this.licenses = []; } ngOnInit() { const { pluginsToInstall } = this.wizardComponent.componentInitialState; this.formGroupAccept = this.fb.group({ confirmed: [false, Validators.required] }); this.formGroupLicenses = this.fb.group({ acceptAll: [false, Validators.required] }); const allLicenses = pluginsToInstall.map(app => ({ appName: app.name, url: `/apps/${app.contextPath}@${app.version}/LICENSE.txt`, licenseName: app.license })); const uniqByUrl = uniqBy(allLicenses, 'url').map(license => ({ ...license, pluginName: allLicenses .filter(({ url }) => url === license.url) .map(({ appName: pluginName }) => pluginName) .join(', ') })); const companyName = this.optionsService.get('companyName', 'Cumulocity'); const disclaimerHtmlWithCompany = gettext('These plugins and/or blueprints are provided <strong>as-is and without warranty or support</strong>, and they do not constitute part of the {{ companyName }} product suite. Users are free to use subject to the license agreement.'); const disclaimerHtmlWithoutCompany = gettext('These plugins and/or blueprints are provided <strong>as-is and without warranty or support</strong>, and they do not constitute part of the product suite. Users are free to use subject to the license agreement.'); this.disclaimerHtml = this.translateService.instant(companyName ? disclaimerHtmlWithCompany : disclaimerHtmlWithoutCompany, { companyName }); this.licenses = uniqByUrl; } cancel() { this.wizardComponent.close(false); } done() { this.wizardComponent.close(true); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: LicenseConfirmModalComponent, deps: [{ token: i1$1.WizardComponent }, { token: i2.FormBuilder }, { token: i1$1.OptionsService }, { token: i3.TranslateService }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: LicenseConfirmModalComponent, isStandalone: false, selector: "c8y-license-confirm-modal", viewQueries: [{ propertyName: "stepper", first: true, predicate: C8yStepper, descendants: true, static: true }], ngImport: i0, template: "<c8y-wizard-header>\n <i c8yIcon=\"privacy-policy\"></i>\n <div\n class=\"modal-title h4\"\n id=\"modal-title\"\n translate\n >\n Accept license(s)`dialog title`\n </div>\n</c8y-wizard-header>\n<c8y-wizard-body>\n <div class=\"m-t-16 m-l-32 m-r-32\">\n <c8y-stepper>\n <cdk-step\n [stepControl]=\"formGroupAccept\"\n [label]=\"'Disclaimer' | translate\"\n >\n <div class=\"m-t-8\">\n <div class=\"text-center m-b-16 h4\">\n <i\n class=\"text-info d-block icon-40 m-b-8\"\n c8yIcon=\"info-circle\"\n ></i>\n {{ 'About community packages' | translate }}\n </div>\n <p\n class=\"m-b-16\"\n [innerHTML]=\"disclaimerHtml\"\n ></p>\n <hr style=\"margin: 16px -24px 16px\" />\n <div class=\"text-center\">\n <c8y-form-group class=\"d-inline-block\">\n <div\n class=\"d-flex d-col a-i-center\"\n [formGroup]=\"formGroupAccept\"\n >\n <label class=\"c8y-checkbox\">\n <input\n class=\"form-control\"\n type=\"checkbox\"\n required\n formControlName=\"confirmed\"\n />\n <span></span>\n <span translate>Understood and agreed.</span>\n </label>\n <c8y-messages class=\"d-inline-block\">\n <c8y-message\n [name]=\"'required'\"\n [text]=\"'Accept the maintenance disclaimer.' | translate\"\n ></c8y-message>\n </c8y-messages>\n </div>\n </c8y-form-group>\n </div>\n </div>\n\n <c8y-wizard-footer *ngIf=\"stepper.selectedIndex === 0\">\n <c8y-stepper-buttons\n [title]=\"'Confirm agreement' | translate\"\n [showButtons]=\"{ next: true, cancel: true, back: false, custom: false }\"\n (onCancel)=\"cancel()\"\n ></c8y-stepper-buttons>\n </c8y-wizard-footer>\n </cdk-step>\n <cdk-step\n state=\"final\"\n [stepControl]=\"formGroupLicenses\"\n [label]=\"'Licenses' | translate\"\n >\n <div\n class=\"p-t-24\"\n *ngFor=\"let license of licenses\"\n >\n <label\n class=\"text-normal\"\n *ngIf=\"license.licenseName\"\n translate\n [translateParams]=\"{ appName: license.appName, licenseName: license.licenseName }\"\n ngNonBindable\n >\n <b>{{ appName }}</b>\n uses\n <b>{{ licenseName }}</b>\n license\n </label>\n <label\n class=\"text-normal\"\n *ngIf=\"!license.licenseName\"\n translate\n [translateParams]=\"{ appName: license.appName, licenseName: license.licenseName }\"\n ngNonBindable\n >\n <b>{{ appName }}</b>\n uses\n <b>no license</b>\n </label>\n <c8y-license-view\n [url]=\"license.url\"\n [name]=\"license.licenseName\"\n ></c8y-license-view>\n </div>\n <c8y-wizard-footer *ngIf=\"stepper.selectedIndex === 1\">\n <c8y-form-group class=\"text-center d-inline-block\">\n <div\n class=\"d-flex d-col a-i-center\"\n [formGroup]=\"formGroupLicenses\"\n >\n <label class=\"c8y-checkbox\">\n <input\n class=\"form-control\"\n type=\"checkbox\"\n required\n formControlName=\"acceptAll\"\n />\n <span></span>\n <span\n *ngIf=\"licenses.length === 1\"\n translate\n >\n Accept license.`formal agreement`\n </span>\n <span\n *ngIf=\"licenses.length > 1\"\n translate\n >\n Accept all licenses.`formal agreement`\n </span>\n </label>\n <c8y-messages class=\"d-inline-block\">\n <c8y-message\n [name]=\"'required'\"\n [text]=\"'You need to accept the license agreement(s)' | translate\"\n ></c8y-message>\n </c8y-messages>\n </div>\n </c8y-form-group>\n <hr style=\"margin: 0 -24px 16px\" />\n <c8y-stepper-buttons\n [showButtons]=\"{ next: true, cancel: true, back: false, custom: false }\"\n (onCancel)=\"cancel()\"\n (onNext)=\"done()\"\n ></c8y-stepper-buttons>\n </c8y-wizard-footer>\n </cdk-step>\n </c8y-stepper>\n </div>\n</c8y-wizard-body>\n", dependencies: [{ kind: "directive", type: i1$1.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i1$1.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.CheckboxRequiredValidator, selector: "input[type=checkbox][required][formControlName],input[type=checkbox][required][formControl],input[type=checkbox][required][ngModel]" }, { kind: "component", type: i1$1.FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: i1$1.MessageDirective, selector: "c8y-message", inputs: ["name", "text"] }, { kind: "component", type: i1$1.MessagesComponent, selector: "c8y-messages", inputs: ["show", "defaults", "helpMessage"] }, { kind: "directive", type: i1$1.RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "component", type: i1$1.C8yStepper, selector: "c8y-stepper", inputs: ["disableDefaultIcons", "disableProgressButtons", "customClasses", "hideStepProgress", "useStepLabelsAsTitlesOnly"], outputs: ["onStepChange"] }, { kind: "component", type: i5.CdkStep, selector: "cdk-step", inputs: ["stepControl", "label", "errorMessage", "aria-label", "aria-labelledby", "state", "editable", "optional", "completed", "hasError"], outputs: ["interacted"], exportAs: ["cdkStep"] }, { kind: "component", type: i1$1.C8yStepperButtons, selector: "c8y-stepper-buttons", inputs: ["labels", "pending", "disabled", "showButtons"], outputs: ["onCancel", "onNext", "onBack", "onCustom"] }, { kind: "component", type: i1$1.WizardHeaderComponent, selector: "c8y-wizard-header" }, { kind: "component", type: i1$1.WizardBodyComponent, selector: "c8y-wizard-body" }, { kind: "component", type: i1$1.WizardFooterComponent, selector: "c8y-wizard-footer" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: LicenseViewComponent, selector: "c8y-license-view", inputs: ["url", "name"] }, { kind: "pipe", type: i1$1.C8yTranslatePipe, name: "translate" }] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: LicenseConfirmModalComponent, decorators: [{ type: Component, args: [{ selector: 'c8y-license-confirm-modal', standalone: false, template: "<c8y-wizard-header>\n <i c8yIcon=\"privacy-policy\"></i>\n <div\n class=\"modal-title h4\"\n id=\"modal-title\"\n translate\n >\n Accept license(s)`dialog title`\n </div>\n</c8y-wizard-header>\n<c8y-wizard-body>\n <div class=\"m-t-16 m-l-32 m-r-32\">\n <c8y-stepper>\n <cdk-step\n [stepControl]=\"formGroupAccept\"\n [label]=\"'Disclaimer' | translate\"\n >\n <div class=\"m-t-8\">\n <div class=\"text-center m-b-16 h4\">\n <i\n class=\"text-info d-block icon-40 m-b-8\"\n c8yIcon=\"info-circle\"\n ></i>\n {{ 'About community packages' | translate }}\n </div>\n <p\n class=\"m-b-16\"\n [innerHTML]=\"disclaimerHtml\"\n ></p>\n <hr style=\"margin: 16px -24px 16px\" />\n <div class=\"text-center\">\n <c8y-form-group class=\"d-inline-block\">\n <div\n class=\"d-flex d-col a-i-center\"\n [formGroup]=\"formGroupAccept\"\n >\n <label class=\"c8y-checkbox\">\n <input\n class=\"form-control\"\n type=\"checkbox\"\n required\n formControlName=\"confirmed\"\n />\n <span></span>\n <span translate>Understood and agreed.</span>\n </label>\n <c8y-messages class=\"d-inline-block\">\n <c8y-message\n [name]=\"'required'\"\n [text]=\"'Accept the maintenance disclaimer.' | translate\"\n ></c8y-message>\n </c8y-messages>\n </div>\n </c8y-form-group>\n </div>\n </div>\n\n <c8y-wizard-footer *ngIf=\"stepper.selectedIndex === 0\">\n <c8y-stepper-buttons\n [title]=\"'Confirm agreement' | translate\"\n [showButtons]=\"{ next: true, cancel: true, back: false, custom: false }\"\n (onCancel)=\"cancel()\"\n ></c8y-stepper-buttons>\n </c8y-wizard-footer>\n </cdk-step>\n <cdk-step\n state=\"final\"\n [stepControl]=\"formGroupLicenses\"\n [label]=\"'Licenses' | translate\"\n >\n <div\n class=\"p-t-24\"\n *ngFor=\"let license of licenses\"\n >\n <label\n class=\"text-normal\"\n *ngIf=\"license.licenseName\"\n translate\n [translateParams]=\"{ appName: license.appName, licenseName: license.licenseName }\"\n ngNonBindable\n >\n <b>{{ appName }}</b>\n uses\n <b>{{ licenseName }}</b>\n license\n </label>\n <label\n class=\"text-normal\"\n *ngIf=\"!license.licenseName\"\n translate\n [translateParams]=\"{ appName: license.appName, licenseName: license.licenseName }\"\n ngNonBindable\n >\n <b>{{ appName }}</b>\n uses\n <b>no license</b>\n </label>\n <c8y-license-view\n [url]=\"license.url\"\n [name]=\"license.licenseName\"\n ></c8y-license-view>\n </div>\n <c8y-wizard-footer *ngIf=\"stepper.selectedIndex === 1\">\n <c8y-form-group class=\"text-center d-inline-block\">\n <div\n class=\"d-flex d-col a-i-center\"\n [formGroup]=\"formGroupLicenses\"\n >\n <label class=\"c8y-checkbox\">\n <input\n class=\"form-control\"\n type=\"checkbox\"\n required\n formControlName=\"acceptAll\"\n />\n <span></span>\n <span\n *ngIf=\"licenses.length === 1\"\n translate\n >\n Accept license.`formal agreement`\n </span>\n <span\n *ngIf=\"licenses.length > 1\"\n translate\n >\n Accept all licenses.`formal agreement`\n </span>\n </label>\n <c8y-messages class=\"d-inline-block\">\n <c8y-message\n [name]=\"'required'\"\n [text]=\"'You need to accept the license agreement(s)' | translate\"\n ></c8y-message>\n </c8y-messages>\n </div>\n </c8y-form-group>\n <hr style=\"margin: 0 -24px 16px\" />\n <c8y-stepper-buttons\n [showButtons]=\"{ next: true, cancel: true, back: false, custom: false }\"\n (onCancel)=\"cancel()\"\n (onNext)=\"done()\"\n ></c8y-stepper-buttons>\n </c8y-wizard-footer>\n </cdk-step>\n </c8y-stepper>\n </div>\n</c8y-wizard-body>\n" }] }], ctorParameters: () => [{ type: i1$1.WizardComponent }, { type: i2.FormBuilder }, { type: i1$1.OptionsService }, { type: i3.TranslateService }], propDecorators: { stepper: [{ type: ViewChild, args: [C8yStepper, { static: true }] }] } }); class LicenseConfirmModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: LicenseConfirmModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: LicenseConfirmModule, declarations: [LicenseConfirmModalComponent, LicenseViewComponent], imports: [CoreModule, FormsModule, SharedEcosystemModule], exports: [LicenseConfirmModalComponent, LicenseViewComponent] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: LicenseConfirmModule, providers: [ hookWizard({ wizardId: EcosystemWizards.LICENSE_CONFIRM, component: LicenseConfirmModalComponent, name: undefined }) ], imports: [CoreModule, FormsModule, SharedEcosystemModule] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: LicenseConfirmModule, decorators: [{ type: NgModule, args: [{ declarations: [LicenseConfirmModalComponent, LicenseViewComponent], imports: [CoreModule, FormsModule, SharedEcosystemModule], exports: [LicenseConfirmModalComponent, LicenseViewComponent], providers: [ hookWizard({ wizardId: EcosystemWizards.LICENSE_CONFIRM, component: LicenseConfirmModalComponent, name: undefined }) ] }] }] }); /** * Generated bundle index. Do not edit. */ export { LicenseConfirmModalComponent, LicenseConfirmModule, LicenseViewComponent }; //# sourceMappingURL=c8y-ngx-components-ecosystem-license-confirm.mjs.map