@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.
@@ -9058,12 +9058,28 @@ class DocsService {
9058
9058
  /**
9059
9059
  * Default documentation URL.
9060
9060
  */
9061
- this.DEFAULT_DOCS_BASE_URL = 'https://www.cumulocity.com/guides';
9061
+ this.DEFAULT_DOCS_BASE_URL = 'https://www.cumulocity.com/guides/{{ version }}';
9062
9062
  const supportUrlRefreshTrigger = this.app.map(({ supportUrl }) => supportUrl);
9063
9063
  this.items$ = fromTriggerOnce(router, [supportUrlRefreshTrigger, this.refreshTrigger], [getInjectedHooks(HOOK_DOCS, this.injectors), () => this.factories, this]).pipe(shareReplay(1), distinctUntilChanged());
9064
9064
  }
9065
- getBaseUrl() {
9066
- return this.options.get('docsBaseUrl', this.DEFAULT_DOCS_BASE_URL);
9065
+ getBaseUrl(uiVersion) {
9066
+ const docsBaseUrl = this.options.get('docsBaseUrl', this.DEFAULT_DOCS_BASE_URL);
9067
+ return this.getUrlWithDocsVersion(docsBaseUrl, uiVersion);
9068
+ }
9069
+ /**
9070
+ * Takes a URL and replaces all `{{ version }}` placeholders with the relevant docs version
9071
+ * (the version is derived from the app state or from the provided parameter).
9072
+ * @param url Any URL that contains `{{ version }}` placeholders.
9073
+ * @param uiVersion A version string or object, defaults to the app state version.
9074
+ * @returns The URL with replaced `{{ version }}` placeholders.
9075
+ */
9076
+ getUrlWithDocsVersion(url, uiVersion = this.app.uiVersion) {
9077
+ const version = typeof uiVersion === 'string' ? uiVersion : get(uiVersion, 'ngx');
9078
+ let docsVersion = '';
9079
+ if (!(isUndefined(version) || version === '')) {
9080
+ docsVersion = this.getDocsVersionForUiVersion(version);
9081
+ }
9082
+ return url.replace(/{{\s*version\s*}}/g, docsVersion).replace(/\/+$/g, '');
9067
9083
  }
9068
9084
  get templateStr() {
9069
9085
  return this.options.get('guideHrefTemplate', '${docsBaseUrl}${partialUrl}');
@@ -9127,6 +9143,22 @@ class DocsService {
9127
9143
  const prefix = shouldPrefix ? '/' : '';
9128
9144
  return `${prefix}${partialLink}`;
9129
9145
  }
9146
+ /**
9147
+ * Returns the most relevant version of documentation for the given version of UI.
9148
+ * For maintenance versions, it's the first version in the line, e.g. 1017.0.123 -> 10.17.0.
9149
+ * For develop versions, it's the next minor one, e.g. 1017.123.0-SNAPSHOT -> 10.18.0.
9150
+ *
9151
+ * @param uiVersion The version of UI.
9152
+ * @private
9153
+ */
9154
+ getDocsVersionForUiVersion(uiVersion) {
9155
+ const [majorMinorStr, patchStr] = uiVersion.split('.');
9156
+ const patchNumber = parseInt(patchStr, 10);
9157
+ const takeNextMinor = patchNumber > 0;
9158
+ const majorNumber = Math.floor(parseInt(majorMinorStr, 10) / 100);
9159
+ const minorNumber = parseInt(majorMinorStr, 10) - majorNumber * 100 + (takeNextMinor ? 1 : 0);
9160
+ return `${majorNumber}.${minorNumber}.0`;
9161
+ }
9130
9162
  }
9131
9163
  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 });
9132
9164
  DocsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: DocsService, providedIn: 'root' });
@@ -25173,9 +25205,8 @@ class HelpComponent {
25173
25205
  /**
25174
25206
  * @ignore Only private DI
25175
25207
  */
25176
- constructor(docsService, appState, helpService) {
25208
+ constructor(docsService, helpService) {
25177
25209
  this.docsService = docsService;
25178
- this.appState = appState;
25179
25210
  this.helpService = helpService;
25180
25211
  /**
25181
25212
  * The source of the documentation. Used to link to the documentation as well as
@@ -25191,13 +25222,7 @@ class HelpComponent {
25191
25222
  */
25192
25223
  this.priority = Infinity;
25193
25224
  /**
25194
- * Currrent version of the UI which will be used to get the correct data from
25195
- * the docs. If the UI version is equal to the latest doc version, the value
25196
- * must be ''.
25197
- */
25198
- this.version = this.parseVersion(this.appState.uiVersion);
25199
- /**
25200
- * An title. Set in open by passing the source.
25225
+ * A title. Set in open by passing the source.
25201
25226
  */
25202
25227
  this.title = '';
25203
25228
  /**
@@ -25243,23 +25268,19 @@ class HelpComponent {
25243
25268
  try {
25244
25269
  docsUrl =
25245
25270
  typeof this.helpService.contextHelp.value === 'string'
25246
- ? new URL(this.helpService.contextHelp.value)
25271
+ ? new URL(this.docsService.getUrlWithDocsVersion(this.helpService.contextHelp.value))
25247
25272
  : new URL(this.docsService.getBaseUrl());
25248
25273
  }
25249
25274
  catch (error) {
25250
- docsUrl = new URL(this.docsService.DEFAULT_DOCS_BASE_URL);
25275
+ docsUrl = new URL(this.docsService.getBaseUrl());
25251
25276
  console.warn(error);
25252
25277
  }
25253
- const srcUrl = new URL(`${docsUrl}${src}`);
25254
25278
  const [url, hashFragment] = src.split('#');
25255
25279
  this.sectionHeading = hashFragment;
25256
25280
  if (index) {
25257
25281
  src = `${url}index.json`;
25258
25282
  }
25259
- if (this.version === '') {
25260
- return index ? `${docsUrl.href + src}` : srcUrl.href;
25261
- }
25262
- return `${docsUrl.href}/${this.version}${src}`;
25283
+ return `${docsUrl.href}${src}`;
25263
25284
  }
25264
25285
  /**
25265
25286
  * Toggles the visibility of the help dialog.
@@ -25303,19 +25324,6 @@ class HelpComponent {
25303
25324
  this.hasError = false;
25304
25325
  this.sectionContent = '';
25305
25326
  }
25306
- parseVersion(uiVersion) {
25307
- const version = typeof uiVersion === 'string' ? uiVersion : get(uiVersion, 'ngx');
25308
- if (isUndefined(version)) {
25309
- return undefined;
25310
- }
25311
- if (version === '') {
25312
- return '';
25313
- }
25314
- const versionToParse = version.split('.').shift();
25315
- const majorNumber = Math.floor(parseInt(versionToParse, 10) / 100);
25316
- const minorNumber = parseInt(versionToParse, 10) - majorNumber * 100;
25317
- return `${majorNumber}.${minorNumber}.0`;
25318
- }
25319
25327
  resolveIcon() {
25320
25328
  try {
25321
25329
  const icon = Array.from(document.querySelector('nav .active i').classList).find(classes => classes.startsWith('c8y-icon-') || classes.startsWith('dlt-c8y-icon-'));
@@ -25328,10 +25336,6 @@ class HelpComponent {
25328
25336
  render(req) {
25329
25337
  if (req.readyState === 4) {
25330
25338
  this.isLoading = false;
25331
- if (req.status === 404 && this.version !== '') {
25332
- this.version = '';
25333
- this.open();
25334
- }
25335
25339
  if (req.status === 200) {
25336
25340
  this.hasError = false;
25337
25341
  const sectionData = req.response[this.sectionHeading];
@@ -25346,12 +25350,12 @@ class HelpComponent {
25346
25350
  }
25347
25351
  }
25348
25352
  }
25349
- 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 });
25353
+ 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 });
25350
25354
  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" }] });
25351
25355
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: HelpComponent, decorators: [{
25352
25356
  type: Component,
25353
25357
  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>" }]
25354
- }], ctorParameters: function () { return [{ type: DocsService }, { type: AppStateService }, { type: HelpService }]; }, propDecorators: { src: [{
25358
+ }], ctorParameters: function () { return [{ type: DocsService }, { type: HelpService }]; }, propDecorators: { src: [{
25355
25359
  type: Input
25356
25360
  }], isCollapsed: [{
25357
25361
  type: Input