@c8y/ngx-components 1023.14.201 → 1023.14.203

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.
@@ -117,7 +117,7 @@ class ServiceCommandService {
117
117
  * @returns Icon string for the command.
118
118
  */
119
119
  getCommandIcon(command) {
120
- return SERVICE_COMMANDS_MAP[command]?.icon || 'console';
120
+ return SERVICE_COMMANDS_MAP[command.toUpperCase()]?.icon || 'console';
121
121
  }
122
122
  /**
123
123
  * Get the icon class for a specific command.
@@ -125,7 +125,7 @@ class ServiceCommandService {
125
125
  * @returns Icon class string for the command.
126
126
  */
127
127
  getCommandIconClass(command) {
128
- return SERVICE_COMMANDS_MAP[command]?.styleClass;
128
+ return SERVICE_COMMANDS_MAP[command.toUpperCase()]?.styleClass;
129
129
  }
130
130
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: ServiceCommandService, deps: [{ token: i1.OperationService }, { token: i2.AlertService }], target: i0.ɵɵFactoryTarget.Injectable }); }
131
131
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: ServiceCommandService, providedIn: 'root' }); }
@@ -1 +1 @@
1
- {"version":3,"file":"c8y-ngx-components-services-shared.mjs","sources":["../../services/shared/services.model.ts","../../services/shared/service-command.service.ts","../../services/shared/c8y-ngx-components-services-shared.ts"],"sourcesContent":["import { gettext } from '@c8y/ngx-components/gettext';\n\nexport const SERVICE_FRAGMENT = 'c8y_Service';\n\nexport const SERVICE_COMMANDS_MAP = {\n START: {\n label: gettext('Start'),\n command: 'START',\n icon: 'play-circle',\n styleClass: 'text-success'\n },\n STOP: {\n label: gettext('Stop'),\n command: 'STOP',\n icon: 'stop-circle',\n styleClass: 'text-danger'\n },\n RESTART: {\n label: gettext('Restart'),\n command: 'RESTART',\n icon: 'refresh',\n styleClass: 'text-info'\n }\n};\n\nexport interface Service {\n id: string;\n name: string;\n serviceType: string;\n status: string;\n c8y_SupportedOperations?: string[];\n c8y_SupportedServiceCommands?: string[];\n [key: string]: unknown;\n}\n","import { Injectable } from '@angular/core';\nimport { IOperation, IResult, OperationService } from '@c8y/client';\nimport { gettext } from '@c8y/ngx-components/gettext';\nimport { ActionControl, AlertService } from '@c8y/ngx-components';\nimport { map } from 'lodash-es';\nimport { Service, SERVICE_COMMANDS_MAP } from './services.model';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ServiceCommandService {\n constructor(\n private operationService: OperationService,\n private alertService: AlertService\n ) {}\n\n /**\n * Check if the service supports service commands.\n * @param service The service object containing supported operations.\n * @returns boolean indicating if the service supports service commands.\n */\n isServiceCommandSupported(service: Service): boolean {\n return service.c8y_SupportedOperations?.includes('c8y_ServiceCommand');\n }\n\n /**\n * Get the list of supported service commands for the given service object.\n * @param service The service object containing the c8y_SupportedServiceCommands fragment.\n * @returns Array of supported commands.\n */\n getSupportedCommands(service: Service): string[] {\n return service.c8y_SupportedServiceCommands || map(SERVICE_COMMANDS_MAP, 'command');\n }\n\n /**\n * Check if a specific command is supported for the given service.\n * @param service The service object.\n * @param command The command to check (e.g., START, STOP).\n * @returns boolean indicating if the command is supported.\n */\n isCommandSupported(service: Service, command: string): boolean {\n const supportedCommands = this.getSupportedCommands(service);\n return supportedCommands.includes(command);\n }\n\n /**\n * Get all supported commands for a list of services.\n * @param services The list of service objects to evaluate.\n * @returns Array of all unique supported commands.\n */\n getAllSupportedCommands(services: Service[]): string[] {\n const allCommands = services\n .filter(service => this.isServiceCommandSupported(service))\n .flatMap(service => this.getSupportedCommands(service));\n\n return Array.from(new Set(allCommands));\n }\n\n /**\n * Create an operation for the selected service command.\n * @param service The service object the operation should target.\n * @param command The command to execute (e.g., START, STOP).\n * @returns Promise of the created operation.\n */\n createOperation(\n { id, name, serviceType }: Service,\n command: string\n ): Promise<IResult<IOperation>> {\n const operation: IOperation = {\n deviceId: id,\n description: `${command} ${name}`,\n c8y_ServiceCommand: {\n command,\n serviceName: name,\n serviceType: serviceType\n }\n };\n\n return this.operationService.create(operation);\n }\n\n /**\n * Generate a static list of action controls.\n * The specific logic for each service is handled dynamically in showIf and callback.\n * @returns Array of ActionControl objects.\n */\n generateActionControls(commands: string[]): ActionControl[] {\n return commands.map(command => ({\n type: command.toLowerCase(),\n icon: this.getCommandIcon(command),\n iconClasses: this.getCommandIconClass(command),\n text: command,\n showIf: (service: Service) =>\n this.isServiceCommandSupported(service) && this.isCommandSupported(service, command),\n callback: async (service: Service) => {\n try {\n await this.createOperation(service, command);\n this.alertService.success(gettext('Operation created.'));\n } catch (error) {\n const alertMessage = gettext('Could not create operation.');\n this.alertService.danger(alertMessage, error);\n }\n }\n }));\n }\n\n /**\n * Get the icon for a specific command.\n * @param command The command name.\n * @returns Icon string for the command.\n */\n private getCommandIcon(command: string): string {\n return SERVICE_COMMANDS_MAP[command]?.icon || 'console';\n }\n\n /**\n * Get the icon class for a specific command.\n * @param command The command name.\n * @returns Icon class string for the command.\n */\n private getCommandIconClass(command: string): string {\n return SERVICE_COMMANDS_MAP[command]?.styleClass;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,gBAAgB,GAAG;AAEzB,MAAM,oBAAoB,GAAG;AAClC,IAAA,KAAK,EAAE;AACL,QAAA,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;AACvB,QAAA,OAAO,EAAE,OAAO;AAChB,QAAA,IAAI,EAAE,aAAa;AACnB,QAAA,UAAU,EAAE;AACb,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;AACtB,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,IAAI,EAAE,aAAa;AACnB,QAAA,UAAU,EAAE;AACb,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC;AACzB,QAAA,OAAO,EAAE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AhHW,qBAAqB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,gBAAA,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,YAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAArB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,cAFpB,MAAM,EAAA,CAAA,CAAA;;4FAEP,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAHjC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACTD;;AAEG;;;;"}
1
+ {"version":3,"file":"c8y-ngx-components-services-shared.mjs","sources":["../../services/shared/services.model.ts","../../services/shared/service-command.service.ts","../../services/shared/c8y-ngx-components-services-shared.ts"],"sourcesContent":["import { gettext } from '@c8y/ngx-components/gettext';\n\nexport const SERVICE_FRAGMENT = 'c8y_Service';\n\nexport const SERVICE_COMMANDS_MAP = {\n START: {\n label: gettext('Start'),\n command: 'START',\n icon: 'play-circle',\n styleClass: 'text-success'\n },\n STOP: {\n label: gettext('Stop'),\n command: 'STOP',\n icon: 'stop-circle',\n styleClass: 'text-danger'\n },\n RESTART: {\n label: gettext('Restart'),\n command: 'RESTART',\n icon: 'refresh',\n styleClass: 'text-info'\n }\n};\n\nexport interface Service {\n id: string;\n name: string;\n serviceType: string;\n status: string;\n c8y_SupportedOperations?: string[];\n c8y_SupportedServiceCommands?: string[];\n [key: string]: unknown;\n}\n","import { Injectable } from '@angular/core';\nimport { IOperation, IResult, OperationService } from '@c8y/client';\nimport { gettext } from '@c8y/ngx-components/gettext';\nimport { ActionControl, AlertService } from '@c8y/ngx-components';\nimport { map } from 'lodash-es';\nimport { Service, SERVICE_COMMANDS_MAP } from './services.model';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ServiceCommandService {\n constructor(\n private operationService: OperationService,\n private alertService: AlertService\n ) {}\n\n /**\n * Check if the service supports service commands.\n * @param service The service object containing supported operations.\n * @returns boolean indicating if the service supports service commands.\n */\n isServiceCommandSupported(service: Service): boolean {\n return service.c8y_SupportedOperations?.includes('c8y_ServiceCommand');\n }\n\n /**\n * Get the list of supported service commands for the given service object.\n * @param service The service object containing the c8y_SupportedServiceCommands fragment.\n * @returns Array of supported commands.\n */\n getSupportedCommands(service: Service): string[] {\n return service.c8y_SupportedServiceCommands || map(SERVICE_COMMANDS_MAP, 'command');\n }\n\n /**\n * Check if a specific command is supported for the given service.\n * @param service The service object.\n * @param command The command to check (e.g., START, STOP).\n * @returns boolean indicating if the command is supported.\n */\n isCommandSupported(service: Service, command: string): boolean {\n const supportedCommands = this.getSupportedCommands(service);\n return supportedCommands.includes(command);\n }\n\n /**\n * Get all supported commands for a list of services.\n * @param services The list of service objects to evaluate.\n * @returns Array of all unique supported commands.\n */\n getAllSupportedCommands(services: Service[]): string[] {\n const allCommands = services\n .filter(service => this.isServiceCommandSupported(service))\n .flatMap(service => this.getSupportedCommands(service));\n\n return Array.from(new Set(allCommands));\n }\n\n /**\n * Create an operation for the selected service command.\n * @param service The service object the operation should target.\n * @param command The command to execute (e.g., START, STOP).\n * @returns Promise of the created operation.\n */\n createOperation(\n { id, name, serviceType }: Service,\n command: string\n ): Promise<IResult<IOperation>> {\n const operation: IOperation = {\n deviceId: id,\n description: `${command} ${name}`,\n c8y_ServiceCommand: {\n command,\n serviceName: name,\n serviceType: serviceType\n }\n };\n\n return this.operationService.create(operation);\n }\n\n /**\n * Generate a static list of action controls.\n * The specific logic for each service is handled dynamically in showIf and callback.\n * @returns Array of ActionControl objects.\n */\n generateActionControls(commands: string[]): ActionControl[] {\n return commands.map(command => ({\n type: command.toLowerCase(),\n icon: this.getCommandIcon(command),\n iconClasses: this.getCommandIconClass(command),\n text: command,\n showIf: (service: Service) =>\n this.isServiceCommandSupported(service) && this.isCommandSupported(service, command),\n callback: async (service: Service) => {\n try {\n await this.createOperation(service, command);\n this.alertService.success(gettext('Operation created.'));\n } catch (error) {\n const alertMessage = gettext('Could not create operation.');\n this.alertService.danger(alertMessage, error);\n }\n }\n }));\n }\n\n /**\n * Get the icon for a specific command.\n * @param command The command name.\n * @returns Icon string for the command.\n */\n private getCommandIcon(command: string): string {\n return SERVICE_COMMANDS_MAP[command.toUpperCase()]?.icon || 'console';\n }\n\n /**\n * Get the icon class for a specific command.\n * @param command The command name.\n * @returns Icon class string for the command.\n */\n private getCommandIconClass(command: string): string {\n return SERVICE_COMMANDS_MAP[command.toUpperCase()]?.styleClass;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,gBAAgB,GAAG;AAEzB,MAAM,oBAAoB,GAAG;AAClC,IAAA,KAAK,EAAE;AACL,QAAA,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;AACvB,QAAA,OAAO,EAAE,OAAO;AAChB,QAAA,IAAI,EAAE,aAAa;AACnB,QAAA,UAAU,EAAE;AACb,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;AACtB,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,IAAI,EAAE,aAAa;AACnB,QAAA,UAAU,EAAE;AACb,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC;AACzB,QAAA,OAAO,EAAE,SAAS;AAClB,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,UAAU,EAAE;AACb;;;MCZU,qBAAqB,CAAA;IAChC,WAAA,CACU,gBAAkC,EAClC,YAA0B,EAAA;QAD1B,IAAA,CAAA,gBAAgB,GAAhB,gBAAgB;QAChB,IAAA,CAAA,YAAY,GAAZ,YAAY;IACnB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A,CAAA,CAAA;AAArB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,cAFpB,MAAM,EAAA,CAAA,CAAA;;4FAEP,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAHjC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACTD;;AAEG;;;;"}
@@ -946,20 +946,37 @@ function gettextCatalogDecorator($delegate, $interpolate, c8yTranslate) {
946
946
  'ngInject';
947
947
  const gettextCatalog = $delegate;
948
948
  const originalGetString = angular.bind(gettextCatalog, gettextCatalog.getString);
949
+ const originalGetPlural = angular.bind(gettextCatalog, gettextCatalog.getPlural);
949
950
  function newGetString(input, scope, context) {
950
951
  if (typeof input === 'string') {
951
952
  const translatedString = originalGetString(input, scope, context);
952
953
  const interpolatedString = scope ? $interpolate(input)(scope) : input;
953
- let stringToReturn = translatedString;
954
- if (translatedString && translatedString === interpolatedString) {
955
- const translatedServerMessage = c8yTranslate.instant(interpolatedString);
956
- stringToReturn = translatedServerMessage;
957
- }
958
- return stringToReturn;
954
+ return fallBackToC8yTranslate(translatedString, interpolatedString);
959
955
  }
960
956
  return input;
961
957
  }
958
+ function newGetPlural(count, input, inputPlural, scope, context) {
959
+ const sourceString = count === 1 ? input : inputPlural;
960
+ if (typeof sourceString === 'string') {
961
+ const translatedString = originalGetPlural(count, input, inputPlural, scope, context);
962
+ const interpolatedString = scope ? $interpolate(sourceString)(scope) : sourceString;
963
+ return fallBackToC8yTranslate(translatedString, interpolatedString);
964
+ }
965
+ return sourceString;
966
+ }
967
+ /**
968
+ * If angular-gettext could not translate the string on its own, it returns the source string.
969
+ * In that case we let the Angular translate service handle it, so that server message patterns
970
+ * are resolved and context indicators (text in backticks) are removed in runtime.
971
+ */
972
+ function fallBackToC8yTranslate(translatedString, interpolatedString) {
973
+ if (translatedString && translatedString === interpolatedString) {
974
+ return c8yTranslate.instant(interpolatedString);
975
+ }
976
+ return translatedString;
977
+ }
962
978
  gettextCatalog.getString = newGetString;
979
+ gettextCatalog.getPlural = newGetPlural;
963
980
  return gettextCatalog;
964
981
  }
965
982