@c8y/ngx-components 1017.0.75 → 1017.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9999,12 +9999,28 @@ class DocsService {
9999
9999
  /**
10000
10000
  * Default documentation URL.
10001
10001
  */
10002
- this.DEFAULT_DOCS_BASE_URL = 'https://www.cumulocity.com/guides';
10002
+ this.DEFAULT_DOCS_BASE_URL = 'https://www.cumulocity.com/guides/{{ version }}';
10003
10003
  const supportUrlRefreshTrigger = this.app.map(({ supportUrl }) => supportUrl);
10004
10004
  this.items$ = fromTriggerOnce(router, [supportUrlRefreshTrigger, this.refreshTrigger], [getInjectedHooks(HOOK_DOCS, this.injectors), () => this.factories, this]).pipe(shareReplay(1), distinctUntilChanged());
10005
10005
  }
10006
- getBaseUrl() {
10007
- return this.options.get('docsBaseUrl', this.DEFAULT_DOCS_BASE_URL);
10006
+ getBaseUrl(uiVersion) {
10007
+ const docsBaseUrl = this.options.get('docsBaseUrl', this.DEFAULT_DOCS_BASE_URL);
10008
+ return this.getUrlWithDocsVersion(docsBaseUrl, uiVersion);
10009
+ }
10010
+ /**
10011
+ * Takes a URL and replaces all `{{ version }}` placeholders with the relevant docs version
10012
+ * (the version is derived from the app state or from the provided parameter).
10013
+ * @param url Any URL that contains `{{ version }}` placeholders.
10014
+ * @param uiVersion A version string or object, defaults to the app state version.
10015
+ * @returns The URL with replaced `{{ version }}` placeholders.
10016
+ */
10017
+ getUrlWithDocsVersion(url, uiVersion = this.app.uiVersion) {
10018
+ const version = typeof uiVersion === 'string' ? uiVersion : get(uiVersion, 'ngx');
10019
+ let docsVersion = '';
10020
+ if (!(isUndefined(version) || version === '')) {
10021
+ docsVersion = this.getDocsVersionForUiVersion(version);
10022
+ }
10023
+ return url.replace(/{{\s*version\s*}}/g, docsVersion).replace(/\/+$/g, '');
10008
10024
  }
10009
10025
  get templateStr() {
10010
10026
  return this.options.get('guideHrefTemplate', '${docsBaseUrl}${partialUrl}');
@@ -10068,6 +10084,22 @@ class DocsService {
10068
10084
  const prefix = shouldPrefix ? '/' : '';
10069
10085
  return `${prefix}${partialLink}`;
10070
10086
  }
10087
+ /**
10088
+ * Returns the most relevant version of documentation for the given version of UI.
10089
+ * For maintenance versions, it's the first version in the line, e.g. 1017.0.123 -> 10.17.0.
10090
+ * For develop versions, it's the next minor one, e.g. 1017.123.0-SNAPSHOT -> 10.18.0.
10091
+ *
10092
+ * @param uiVersion The version of UI.
10093
+ * @private
10094
+ */
10095
+ getDocsVersionForUiVersion(uiVersion) {
10096
+ const [majorMinorStr, patchStr] = uiVersion.split('.');
10097
+ const patchNumber = parseInt(patchStr, 10);
10098
+ const takeNextMinor = patchNumber > 0;
10099
+ const majorNumber = Math.floor(parseInt(majorMinorStr, 10) / 100);
10100
+ const minorNumber = parseInt(majorMinorStr, 10) - majorNumber * 100 + (takeNextMinor ? 1 : 0);
10101
+ return `${majorNumber}.${minorNumber}.0`;
10102
+ }
10071
10103
  }
10072
10104
  DocsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: DocsService, deps: [{ token: OptionsService }, { token: AppStateService }, { token: i0.Injector }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
10073
10105
  DocsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: DocsService, providedIn: 'root' });
@@ -25303,9 +25335,8 @@ class HelpComponent {
25303
25335
  /**
25304
25336
  * @ignore Only private DI
25305
25337
  */
25306
- constructor(docsService, appState, helpService) {
25338
+ constructor(docsService, helpService) {
25307
25339
  this.docsService = docsService;
25308
- this.appState = appState;
25309
25340
  this.helpService = helpService;
25310
25341
  /**
25311
25342
  * The source of the documentation. Used to link to the documentation as well as
@@ -25321,13 +25352,7 @@ class HelpComponent {
25321
25352
  */
25322
25353
  this.priority = Infinity;
25323
25354
  /**
25324
- * Currrent version of the UI which will be used to get the correct data from
25325
- * the docs. If the UI version is equal to the latest doc version, the value
25326
- * must be ''.
25327
- */
25328
- this.version = this.parseVersion(this.appState.uiVersion);
25329
- /**
25330
- * An title. Set in open by passing the source.
25355
+ * A title. Set in open by passing the source.
25331
25356
  */
25332
25357
  this.title = '';
25333
25358
  /**
@@ -25373,23 +25398,19 @@ class HelpComponent {
25373
25398
  try {
25374
25399
  docsUrl =
25375
25400
  typeof this.helpService.contextHelp.value === 'string'
25376
- ? new URL(this.helpService.contextHelp.value)
25401
+ ? new URL(this.docsService.getUrlWithDocsVersion(this.helpService.contextHelp.value))
25377
25402
  : new URL(this.docsService.getBaseUrl());
25378
25403
  }
25379
25404
  catch (error) {
25380
- docsUrl = new URL(this.docsService.DEFAULT_DOCS_BASE_URL);
25405
+ docsUrl = new URL(this.docsService.getBaseUrl());
25381
25406
  console.warn(error);
25382
25407
  }
25383
- const srcUrl = new URL(`${docsUrl}${src}`);
25384
25408
  const [url, hashFragment] = src.split('#');
25385
25409
  this.sectionHeading = hashFragment;
25386
25410
  if (index) {
25387
25411
  src = `${url}index.json`;
25388
25412
  }
25389
- if (this.version === '') {
25390
- return index ? `${docsUrl.href + src}` : srcUrl.href;
25391
- }
25392
- return `${docsUrl.href}/${this.version}${src}`;
25413
+ return `${docsUrl.href}${src}`;
25393
25414
  }
25394
25415
  /**
25395
25416
  * Toggles the visibility of the help dialog.
@@ -25433,19 +25454,6 @@ class HelpComponent {
25433
25454
  this.hasError = false;
25434
25455
  this.sectionContent = '';
25435
25456
  }
25436
- parseVersion(uiVersion) {
25437
- const version = typeof uiVersion === 'string' ? uiVersion : get(uiVersion, 'ngx');
25438
- if (isUndefined(version)) {
25439
- return undefined;
25440
- }
25441
- if (version === '') {
25442
- return '';
25443
- }
25444
- const versionToParse = version.split('.').shift();
25445
- const majorNumber = Math.floor(parseInt(versionToParse, 10) / 100);
25446
- const minorNumber = parseInt(versionToParse, 10) - majorNumber * 100;
25447
- return `${majorNumber}.${minorNumber}.0`;
25448
- }
25449
25457
  resolveIcon() {
25450
25458
  try {
25451
25459
  const icon = Array.from(document.querySelector('nav .active i').classList).find(classes => classes.startsWith('c8y-icon-') || classes.startsWith('dlt-c8y-icon-'));
@@ -25458,10 +25466,6 @@ class HelpComponent {
25458
25466
  render(req) {
25459
25467
  if (req.readyState === 4) {
25460
25468
  this.isLoading = false;
25461
- if (req.status === 404 && this.version !== '') {
25462
- this.version = '';
25463
- this.open();
25464
- }
25465
25469
  if (req.status === 200) {
25466
25470
  this.hasError = false;
25467
25471
  const sectionData = req.response[this.sectionHeading];
@@ -25476,12 +25480,12 @@ class HelpComponent {
25476
25480
  }
25477
25481
  }
25478
25482
  }
25479
- HelpComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: HelpComponent, deps: [{ token: DocsService }, { token: AppStateService }, { token: HelpService }], target: i0.ɵɵFactoryTarget.Component });
25483
+ HelpComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: HelpComponent, deps: [{ token: DocsService }, { token: HelpService }], target: i0.ɵɵFactoryTarget.Component });
25480
25484
  HelpComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.6", type: HelpComponent, selector: "c8y-help", inputs: { src: "src", isCollapsed: "isCollapsed", priority: "priority", icon: "icon" }, ngImport: i0, template: "<c8y-action-bar-item\n [placement]=\"'right'\"\n itemClass=\"pull-right m-l-8\"\n [priority]=\"priority\"\n *ngIf=\"!!(helpService.contextHelp | async)\"\n>\n <button\n class=\"btn-help\"\n type=\"button\"\n [attr.aria-label]=\"'About this page' | translate\"\n [attr.aria-expanded]=\"!isCollapsed\"\n aria-controls=\"collapseHelp\"\n tooltip=\"{{ 'About this page' | translate }}\"\n [delay]=\"750\"\n placement=\"left\"\n container=\"body\"\n (click)=\"toggle()\"\n c8yProductExperience\n [actionName]=\"isCollapsed ? 'helpOpened' : 'helpClosed'\"\n [actionData]=\"{ src: src }\"\n >\n </button>\n</c8y-action-bar-item>\n\n<div\n id=\"collapseHelp\"\n class=\"c8y-help-drawer\"\n [collapse]=\"isCollapsed\"\n [isAnimated]=\"true\"\n (collapsed)=\"onCollapsed()\"\n>\n <div\n [ngClass]=\"{ 'c8y-help-drawer-block': isInit }\"\n #docOutlet\n >\n <div *ngIf=\"isLoading\">\n <c8y-loading></c8y-loading>\n </div>\n\n <div *ngIf=\"!isLoading\">\n <div class=\"d-flex\">\n <i\n [c8yIcon]=\"!hasError ? icon : 'unlink'\"\n [ngClass]=\"{ 'text-warning': hasError, 'text-muted': !hasError }\"\n class=\"c8y-icon-duocolor icon-48\"\n ></i>\n <div\n class=\"p-l-16 flex-grow\"\n *ngIf=\"!hasError\"\n >\n <div\n class=\"alert alert-info m-b-16\"\n *ngIf=\"\n !helpService.isSupportedLanguage() &&\n !showLangWarning &&\n !helpService.isWarningAlertViewed\n \"\n >\n <button\n class=\"close\"\n type=\"button\"\n (click)=\"\n showLangWarning = !showLangWarning;\n helpService.isWarningAlertViewed = !helpService.isWarningAlertViewed\n \"\n [attr.aria-label]=\"'Close' | translate\"\n >\n <span aria-hidden=\"true\">\u00D7</span>\n <span class=\"sr-only\">Close</span>\n </button>\n <p>\n {{ 'Help content is only available in English.' | translate }}\n </p>\n </div>\n <h4 class=\"text-bold text-primary p-t-16 m-b-16\">\n {{ title }}\n </h4>\n <div\n id=\"helpContent\"\n class=\"help-content\"\n [innerHTML]=\"sectionContent\"\n ></div>\n </div>\n\n <div\n class=\"p-l-16 p-t-16 flex-grow\"\n *ngIf=\"hasError\"\n >\n <h4\n class=\"text-bold m-b-16\"\n translate\n >Sorry, that didn't work</h4>\n <div class=\"help-content\">\n <p translate>The content couldn't be loaded.</p>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div\n class=\"c8y-help-drawer-footer animated fadeIn\"\n style=\"animation-delay: 0.35s\"\n *ngIf=\"!isLoading && !hasError\"\n >\n <button\n class=\"btn btn-default\"\n (click)=\"toggle()\"\n [title]=\"'Close help' | translate\"\n type=\"button\"\n [attr.aria-expanded]=\"!isCollapsed\"\n aria-controls=\"collapseHelp\"\n translate\n >\n Close\n </button>\n <a\n href=\"{{ hasError ? getUrl() : getUrl(src) }}\"\n class=\"btn btn-primary\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n <span\n translate\n *ngIf=\"!hasError\"\n >\n Open the\n <span>User guide`KEEP_ORIGINAL`</span>\n </span>\n <span\n translate\n *ngIf=\"hasError\"\n >\n Check the\n <span>User guide`KEEP_ORIGINAL`</span>\n </span>\n </a>\n </div>\n</div>", dependencies: [{ kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i1$5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: LoadingComponent, selector: "c8y-loading" }, { kind: "directive", type: i1$a.CollapseDirective, selector: "[collapse]", inputs: ["display", "isAnimated", "collapse"], outputs: ["collapsed", "collapses", "expanded", "expands"], exportAs: ["bs-collapse"] }, { kind: "directive", type: i1$8.TooltipDirective, selector: "[tooltip], [tooltipHtml]", inputs: ["adaptivePosition", "tooltip", "placement", "triggers", "container", "containerClass", "boundariesElement", "isOpen", "isDisabled", "delay", "tooltipHtml", "tooltipPlacement", "tooltipIsOpen", "tooltipEnable", "tooltipAppendToBody", "tooltipAnimation", "tooltipClass", "tooltipContext", "tooltipPopupDelay", "tooltipFadeDuration", "tooltipTrigger"], outputs: ["tooltipChange", "onShown", "onHidden", "tooltipStateChanged"], exportAs: ["bs-tooltip"] }, { kind: "component", type: ActionBarItemComponent, selector: "c8y-action-bar-item", inputs: ["placement", "priority", "itemClass", "injector", "groupId"] }, { kind: "directive", type: ProductExperienceDirective, selector: "[c8yProductExperience]", inputs: ["actionName", "actionData", "inherit"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i1$5.AsyncPipe, name: "async" }] });
25481
25485
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: HelpComponent, decorators: [{
25482
25486
  type: Component,
25483
25487
  args: [{ selector: 'c8y-help', template: "<c8y-action-bar-item\n [placement]=\"'right'\"\n itemClass=\"pull-right m-l-8\"\n [priority]=\"priority\"\n *ngIf=\"!!(helpService.contextHelp | async)\"\n>\n <button\n class=\"btn-help\"\n type=\"button\"\n [attr.aria-label]=\"'About this page' | translate\"\n [attr.aria-expanded]=\"!isCollapsed\"\n aria-controls=\"collapseHelp\"\n tooltip=\"{{ 'About this page' | translate }}\"\n [delay]=\"750\"\n placement=\"left\"\n container=\"body\"\n (click)=\"toggle()\"\n c8yProductExperience\n [actionName]=\"isCollapsed ? 'helpOpened' : 'helpClosed'\"\n [actionData]=\"{ src: src }\"\n >\n </button>\n</c8y-action-bar-item>\n\n<div\n id=\"collapseHelp\"\n class=\"c8y-help-drawer\"\n [collapse]=\"isCollapsed\"\n [isAnimated]=\"true\"\n (collapsed)=\"onCollapsed()\"\n>\n <div\n [ngClass]=\"{ 'c8y-help-drawer-block': isInit }\"\n #docOutlet\n >\n <div *ngIf=\"isLoading\">\n <c8y-loading></c8y-loading>\n </div>\n\n <div *ngIf=\"!isLoading\">\n <div class=\"d-flex\">\n <i\n [c8yIcon]=\"!hasError ? icon : 'unlink'\"\n [ngClass]=\"{ 'text-warning': hasError, 'text-muted': !hasError }\"\n class=\"c8y-icon-duocolor icon-48\"\n ></i>\n <div\n class=\"p-l-16 flex-grow\"\n *ngIf=\"!hasError\"\n >\n <div\n class=\"alert alert-info m-b-16\"\n *ngIf=\"\n !helpService.isSupportedLanguage() &&\n !showLangWarning &&\n !helpService.isWarningAlertViewed\n \"\n >\n <button\n class=\"close\"\n type=\"button\"\n (click)=\"\n showLangWarning = !showLangWarning;\n helpService.isWarningAlertViewed = !helpService.isWarningAlertViewed\n \"\n [attr.aria-label]=\"'Close' | translate\"\n >\n <span aria-hidden=\"true\">\u00D7</span>\n <span class=\"sr-only\">Close</span>\n </button>\n <p>\n {{ 'Help content is only available in English.' | translate }}\n </p>\n </div>\n <h4 class=\"text-bold text-primary p-t-16 m-b-16\">\n {{ title }}\n </h4>\n <div\n id=\"helpContent\"\n class=\"help-content\"\n [innerHTML]=\"sectionContent\"\n ></div>\n </div>\n\n <div\n class=\"p-l-16 p-t-16 flex-grow\"\n *ngIf=\"hasError\"\n >\n <h4\n class=\"text-bold m-b-16\"\n translate\n >Sorry, that didn't work</h4>\n <div class=\"help-content\">\n <p translate>The content couldn't be loaded.</p>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div\n class=\"c8y-help-drawer-footer animated fadeIn\"\n style=\"animation-delay: 0.35s\"\n *ngIf=\"!isLoading && !hasError\"\n >\n <button\n class=\"btn btn-default\"\n (click)=\"toggle()\"\n [title]=\"'Close help' | translate\"\n type=\"button\"\n [attr.aria-expanded]=\"!isCollapsed\"\n aria-controls=\"collapseHelp\"\n translate\n >\n Close\n </button>\n <a\n href=\"{{ hasError ? getUrl() : getUrl(src) }}\"\n class=\"btn btn-primary\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n <span\n translate\n *ngIf=\"!hasError\"\n >\n Open the\n <span>User guide`KEEP_ORIGINAL`</span>\n </span>\n <span\n translate\n *ngIf=\"hasError\"\n >\n Check the\n <span>User guide`KEEP_ORIGINAL`</span>\n </span>\n </a>\n </div>\n</div>" }]
25484
- }], ctorParameters: function () { return [{ type: DocsService }, { type: AppStateService }, { type: HelpService }]; }, propDecorators: { src: [{
25488
+ }], ctorParameters: function () { return [{ type: DocsService }, { type: HelpService }]; }, propDecorators: { src: [{
25485
25489
  type: Input
25486
25490
  }], isCollapsed: [{
25487
25491
  type: Input