@c8y/ngx-components 1024.0.0 → 1024.1.6

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.
Files changed (34) hide show
  1. package/fesm2022/c8y-ngx-components-datapoint-explorer-devicemanagement.mjs +0 -1
  2. package/fesm2022/c8y-ngx-components-datapoint-explorer-devicemanagement.mjs.map +1 -1
  3. package/fesm2022/c8y-ngx-components-operations-bulk-single-operations-list.mjs +4 -6
  4. package/fesm2022/c8y-ngx-components-operations-bulk-single-operations-list.mjs.map +1 -1
  5. package/fesm2022/c8y-ngx-components-repository-configuration.mjs +493 -417
  6. package/fesm2022/c8y-ngx-components-repository-configuration.mjs.map +1 -1
  7. package/fesm2022/c8y-ngx-components-repository-shared.mjs +69 -10
  8. package/fesm2022/c8y-ngx-components-repository-shared.mjs.map +1 -1
  9. package/fesm2022/c8y-ngx-components-widgets-implementations-quick-links.mjs +53 -24
  10. package/fesm2022/c8y-ngx-components-widgets-implementations-quick-links.mjs.map +1 -1
  11. package/fesm2022/c8y-ngx-components.mjs +51 -24
  12. package/fesm2022/c8y-ngx-components.mjs.map +1 -1
  13. package/locales/de.po +42 -39
  14. package/locales/es.po +32 -29
  15. package/locales/fr.po +24 -21
  16. package/locales/ja_JP.po +47 -44
  17. package/locales/ko.po +30 -27
  18. package/locales/locales.pot +3 -0
  19. package/locales/nl.po +27 -24
  20. package/locales/pl.po +42 -39
  21. package/locales/pt_BR.po +29 -26
  22. package/locales/zh_CN.po +28 -25
  23. package/locales/zh_TW.po +38 -35
  24. package/package.json +1 -1
  25. package/types/c8y-ngx-components-datapoint-explorer-devicemanagement.d.ts.map +1 -1
  26. package/types/c8y-ngx-components-operations-bulk-single-operations-list.d.ts.map +1 -1
  27. package/types/c8y-ngx-components-repository-configuration.d.ts +30 -11
  28. package/types/c8y-ngx-components-repository-configuration.d.ts.map +1 -1
  29. package/types/c8y-ngx-components-repository-shared.d.ts +26 -2
  30. package/types/c8y-ngx-components-repository-shared.d.ts.map +1 -1
  31. package/types/c8y-ngx-components-widgets-implementations-quick-links.d.ts +18 -5
  32. package/types/c8y-ngx-components-widgets-implementations-quick-links.d.ts.map +1 -1
  33. package/types/c8y-ngx-components.d.ts +16 -5
  34. package/types/c8y-ngx-components.d.ts.map +1 -1
@@ -192,6 +192,48 @@ const PRODUCT_EXPERIENCE_REPOSITORY_SHARED = {
192
192
  }
193
193
  };
194
194
 
195
+ /**
196
+ * Canonical mapping from a served MIME type to how we treat it — the single source of
197
+ * truth for both giving downloaded snapshots a meaningful filename (Cumulocity stores
198
+ * only the event id as the name) and picking the inline editor's syntax highlighting.
199
+ */
200
+ const MIME_TYPE_INFO = {
201
+ 'application/json': { ext: 'json', language: 'json' },
202
+ 'application/xml': { ext: 'xml', language: 'xml' },
203
+ 'text/xml': { ext: 'xml', language: 'xml' },
204
+ 'application/yaml': { ext: 'yaml', language: 'yaml' },
205
+ 'application/x-yaml': { ext: 'yaml', language: 'yaml' },
206
+ 'text/yaml': { ext: 'yaml', language: 'yaml' },
207
+ 'application/javascript': { ext: 'js', language: 'javascript' },
208
+ 'text/javascript': { ext: 'js', language: 'javascript' },
209
+ 'application/typescript': { ext: 'ts', language: 'typescript' },
210
+ 'text/html': { ext: 'html', language: 'html' },
211
+ 'text/css': { ext: 'css', language: 'css' },
212
+ 'text/markdown': { ext: 'md', language: 'markdown' },
213
+ 'text/csv': { ext: 'csv' },
214
+ 'application/csv': { ext: 'csv' },
215
+ 'application/x-sh': { ext: 'sh', language: 'shell' },
216
+ 'application/x-shellscript': { ext: 'sh', language: 'shell' },
217
+ 'application/toml': { ext: 'toml' },
218
+ 'text/plain': { ext: 'txt' }
219
+ };
220
+ /**
221
+ * Appends an extension derived from the MIME type when the filename lacks a useful one,
222
+ * so the inline editor can detect the language. Returns the name unchanged for unknown
223
+ * types (e.g. application/octet-stream) or when a matching extension is already present.
224
+ */
225
+ function appendExtensionFromMimeType(name, mimeType) {
226
+ const ext = MIME_TYPE_INFO[mimeType]?.ext;
227
+ if (!ext || name.toLowerCase().endsWith(`.${ext}`)) {
228
+ return name;
229
+ }
230
+ return `${name}.${ext}`;
231
+ }
232
+ /** Resolves a served MIME type to a Monaco editor language id, falling back to plain text. */
233
+ function mimeTypeToEditorLanguage(mimeType) {
234
+ return MIME_TYPE_INFO[mimeType]?.language ?? 'plaintext';
235
+ }
236
+
195
237
  class RepositoryService {
196
238
  constructor(inventory, inventoryBinary, operation, alert, event, operationRealtime, eventBinary, serviceRegistry, globalConfigService) {
197
239
  this.inventory = inventory;
@@ -382,7 +424,12 @@ class RepositoryService {
382
424
  cleanUp(mosToDelete) {
383
425
  mosToDelete.forEach(mo => {
384
426
  const { c8y_IsBinary } = mo;
385
- isUndefined(c8y_IsBinary) ? this.delete(mo) : this.inventoryBinary.delete(mo);
427
+ if (isUndefined(c8y_IsBinary)) {
428
+ this.delete(mo);
429
+ }
430
+ else {
431
+ this.inventoryBinary.delete(mo);
432
+ }
386
433
  });
387
434
  }
388
435
  delete(entity) {
@@ -964,12 +1011,24 @@ class RepositoryService {
964
1011
  configurationType
965
1012
  };
966
1013
  try {
967
- configSnapshot.binary = await (await this.eventBinary.download(event)).text();
968
- if (event.c8y_IsBinary) {
969
- configSnapshot.binaryType = event.c8y_IsBinary.type;
970
- }
1014
+ const blob = await (await this.eventBinary.download(event)).blob();
1015
+ const binaryInfo = event.c8y_IsBinary;
1016
+ // The served Content-Type (blob.type) is the most authoritative MIME available;
1017
+ // fall back to the stored fragment type. Both may be application/octet-stream, so
1018
+ // the actual text-vs-binary decision is left to a content scan (isBinaryFile).
1019
+ configSnapshot.binaryType = blob.type || binaryInfo?.type;
1020
+ // Preserve the original bytes so binary snapshots survive a save to the repository
1021
+ // intact; the string is kept only for the read-only text preview. Cumulocity stores
1022
+ // the event id (not a real filename) in c8y_IsBinary.name, so we use the event text
1023
+ // as before and derive an extension from the MIME type for inline-editor language
1024
+ // detection.
1025
+ const fileName = appendExtensionFromMimeType(event.text, configSnapshot.binaryType);
1026
+ configSnapshot.binaryFile = new File([blob], fileName, {
1027
+ type: configSnapshot.binaryType
1028
+ });
1029
+ configSnapshot.binary = await blob.text();
971
1030
  }
972
- catch (ex) {
1031
+ catch {
973
1032
  const msg = gettext('Could not get the binary.');
974
1033
  this.alert.danger(msg);
975
1034
  }
@@ -987,7 +1046,7 @@ class RepositoryService {
987
1046
  try {
988
1047
  mo = (await this.inventory.detail(snapshotId)).data;
989
1048
  }
990
- catch (ex) {
1049
+ catch {
991
1050
  // do nothing
992
1051
  }
993
1052
  if (mo) {
@@ -1090,7 +1149,7 @@ class RepositoryService {
1090
1149
  try {
1091
1150
  return await this.inventoryBinary.download(binaryId);
1092
1151
  }
1093
- catch (ex) {
1152
+ catch {
1094
1153
  const msg = gettext('Could not get the binary.');
1095
1154
  this.alert.danger(msg);
1096
1155
  }
@@ -1138,7 +1197,7 @@ class RepositoryService {
1138
1197
  try {
1139
1198
  res = await this.inventoryBinary.download(binaryId);
1140
1199
  }
1141
- catch (ex) {
1200
+ catch {
1142
1201
  if (!options.noAlerts) {
1143
1202
  const msg = gettext('Could not get the binary.');
1144
1203
  this.alert.danger(msg);
@@ -2093,5 +2152,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
2093
2152
  * Generated bundle index. Do not edit.
2094
2153
  */
2095
2154
 
2096
- export { DescriptionGridColumn, DeviceConfigurationOperation, DeviceTypeCellRendererComponent, DeviceTypeGridColumn, FileCellRendererComponent, FileDownloadComponent, FileGridColumn, LinkRenderType, PRODUCT_EXPERIENCE_REPOSITORY_SHARED, REPOSITORY_BINARY_TYPES, RepositoryItemNameCellRendererComponent, RepositoryItemNameGridColumn, RepositorySelectModalComponent, RepositoryService, RepositoryType, SharedRepositoryModule, SoftwareTypeComponent, TypeCellRendererComponent, TypeFilteringFormRendererComponent, TypeGridColumn, VersionsCellRendererComponent, VersionsGridColumn };
2155
+ export { DescriptionGridColumn, DeviceConfigurationOperation, DeviceTypeCellRendererComponent, DeviceTypeGridColumn, FileCellRendererComponent, FileDownloadComponent, FileGridColumn, LinkRenderType, MIME_TYPE_INFO, PRODUCT_EXPERIENCE_REPOSITORY_SHARED, REPOSITORY_BINARY_TYPES, RepositoryItemNameCellRendererComponent, RepositoryItemNameGridColumn, RepositorySelectModalComponent, RepositoryService, RepositoryType, SharedRepositoryModule, SoftwareTypeComponent, TypeCellRendererComponent, TypeFilteringFormRendererComponent, TypeGridColumn, VersionsCellRendererComponent, VersionsGridColumn, appendExtensionFromMimeType, mimeTypeToEditorLanguage };
2097
2156
  //# sourceMappingURL=c8y-ngx-components-repository-shared.mjs.map