@c8y/ngx-components 1018.0.191 → 1018.0.194
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.
- package/esm2020/repository/configuration/device-tab/save-to-repository.component.mjs +4 -4
- package/esm2020/repository/configuration/list/configuration-detail.component.mjs +5 -5
- package/esm2020/repository/shared/repository.model.mjs +1 -1
- package/esm2020/repository/shared/repository.service.mjs +80 -85
- package/fesm2015/c8y-ngx-components-repository-configuration.mjs +2 -2
- package/fesm2015/c8y-ngx-components-repository-configuration.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components-repository-shared.mjs +94 -98
- package/fesm2015/c8y-ngx-components-repository-shared.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-repository-configuration.mjs +2 -2
- package/fesm2020/c8y-ngx-components-repository-configuration.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-repository-shared.mjs +76 -81
- package/fesm2020/c8y-ngx-components-repository-shared.mjs.map +1 -1
- package/package.json +1 -1
- package/repository/configuration/device-tab/save-to-repository.component.d.ts +2 -2
- package/repository/configuration/list/configuration-detail.component.d.ts +3 -4
- package/repository/shared/repository.model.d.ts +2 -0
- package/repository/shared/repository.service.d.ts +11 -15
- package/repository/shared/select-modal/repository-select-modal.component.d.ts +4 -1
|
@@ -124,7 +124,7 @@ const PRODUCT_EXPERIENCE = {
|
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
class RepositoryService {
|
|
127
|
-
constructor(inventory, inventoryBinary, operation, alert, event, operationRealtime, eventBinary, advancedSoftwareService) {
|
|
127
|
+
constructor(inventory, inventoryBinary, operation, alert, event, operationRealtime, eventBinary, advancedSoftwareService, globalConfigService) {
|
|
128
128
|
this.inventory = inventory;
|
|
129
129
|
this.inventoryBinary = inventoryBinary;
|
|
130
130
|
this.operation = operation;
|
|
@@ -133,6 +133,7 @@ class RepositoryService {
|
|
|
133
133
|
this.operationRealtime = operationRealtime;
|
|
134
134
|
this.eventBinary = eventBinary;
|
|
135
135
|
this.advancedSoftwareService = advancedSoftwareService;
|
|
136
|
+
this.globalConfigService = globalConfigService;
|
|
136
137
|
this.dateFrom = new Date(0);
|
|
137
138
|
this.dateTo = new Date(Date.now() + 86400000); // 1 day in the future
|
|
138
139
|
this.queriesUtil = new QueriesUtil();
|
|
@@ -167,54 +168,38 @@ class RepositoryService {
|
|
|
167
168
|
filters = Object.assign({ query: this.queriesUtil.buildQuery(fullQuery), pageSize: 50, withTotalPages: true }, ((options && options.params) || {}));
|
|
168
169
|
return this.inventory.list(filters);
|
|
169
170
|
}
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
create(modal, type, mo = {}) {
|
|
172
|
+
var _a, _b;
|
|
172
173
|
return __awaiter(this, void 0, void 0, function* () {
|
|
173
174
|
switch (type) {
|
|
174
|
-
case RepositoryType.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
175
|
+
case RepositoryType.FIRMWARE:
|
|
176
|
+
case RepositoryType.SOFTWARE:
|
|
177
|
+
return this.createRepositoryObject(modal, type);
|
|
178
|
+
case RepositoryType.CONFIGURATION:
|
|
179
|
+
Object.assign(modal, {
|
|
180
|
+
selected: {
|
|
181
|
+
id: ((_a = modal.selected) === null || _a === void 0 ? void 0 : _a.id) || mo.id,
|
|
182
|
+
name: modal.version || ((_b = modal.selected) === null || _b === void 0 ? void 0 : _b.name)
|
|
183
|
+
},
|
|
184
|
+
configurationType: modal.selected ? modal.selected.configurationType : undefined,
|
|
185
|
+
name: modal.version
|
|
182
186
|
});
|
|
183
|
-
if (!
|
|
184
|
-
|
|
187
|
+
if (!modal.deviceType && mo.id) {
|
|
188
|
+
modal.deviceType = null;
|
|
185
189
|
}
|
|
186
|
-
if (!
|
|
187
|
-
|
|
190
|
+
if (!modal.selected && mo.id) {
|
|
191
|
+
modal.configurationType = null;
|
|
188
192
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
else if (data.binary.file) {
|
|
197
|
-
const response = yield this.inventoryBinary.create(data.binary.file, {
|
|
198
|
-
c8y_Global: {}
|
|
199
|
-
});
|
|
200
|
-
mo.url = response.data.self;
|
|
201
|
-
}
|
|
202
|
-
if (mo.id) {
|
|
203
|
-
return this.updateEntry(mo, existingUrl);
|
|
204
|
-
}
|
|
205
|
-
return this.createEntry(mo);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
create(modal, type) {
|
|
209
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
-
switch (type) {
|
|
211
|
-
case RepositoryType.FIRMWARE:
|
|
212
|
-
case RepositoryType.SOFTWARE:
|
|
213
|
-
return this.createFirmwareOrSoftware(modal, type);
|
|
193
|
+
const repositoryObject = this.createRepositoryObject(modal, type);
|
|
194
|
+
if (mo.url) {
|
|
195
|
+
const newBinaryUrl = (yield repositoryObject).url;
|
|
196
|
+
this.removeOutdatedBinary(newBinaryUrl, mo.url);
|
|
197
|
+
}
|
|
198
|
+
return repositoryObject;
|
|
214
199
|
}
|
|
215
200
|
});
|
|
216
201
|
}
|
|
217
|
-
|
|
202
|
+
createRepositoryObject(modal, type) {
|
|
218
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
219
204
|
let binary;
|
|
220
205
|
let binaryURL;
|
|
@@ -223,22 +208,28 @@ class RepositoryService {
|
|
|
223
208
|
const mos = [];
|
|
224
209
|
const { selected: { id: selectedId }, binary: { file, url } } = modal;
|
|
225
210
|
try {
|
|
211
|
+
const globalParam = yield this.getGlobalFragment(type);
|
|
226
212
|
if (file) {
|
|
227
|
-
({ data: binary } = yield this.saveBinary(file));
|
|
213
|
+
({ data: binary } = yield this.saveBinary(file, globalParam));
|
|
228
214
|
({ self: binaryURL } = binary);
|
|
215
|
+
if (type === RepositoryType.CONFIGURATION) {
|
|
216
|
+
modal.binary.url = binaryURL;
|
|
217
|
+
}
|
|
229
218
|
mos.push(binary);
|
|
230
219
|
}
|
|
231
220
|
else {
|
|
232
221
|
binaryURL = url;
|
|
233
222
|
}
|
|
234
|
-
({ data: repositoryEntry } = yield this.createOrUpdateRepositoryEntry(modal, type));
|
|
223
|
+
({ data: repositoryEntry } = yield this.createOrUpdateRepositoryEntry(Object.assign(Object.assign({}, modal), globalParam), type));
|
|
235
224
|
if (isNil(selectedId)) {
|
|
236
225
|
mos.push(repositoryEntry);
|
|
237
226
|
}
|
|
238
|
-
(
|
|
239
|
-
|
|
227
|
+
if (type !== RepositoryType.CONFIGURATION) {
|
|
228
|
+
({ data: repositoryBinary } = yield this.createRepositoryBinary(Object.assign(Object.assign({}, modal), globalParam), binaryURL, type, repositoryEntry));
|
|
229
|
+
mos.push(repositoryBinary);
|
|
230
|
+
}
|
|
240
231
|
if (file) {
|
|
241
|
-
yield this.linkBinary(repositoryBinary, binary);
|
|
232
|
+
yield this.linkBinary(repositoryBinary, binary, repositoryEntry);
|
|
242
233
|
}
|
|
243
234
|
return repositoryEntry;
|
|
244
235
|
}
|
|
@@ -250,40 +241,51 @@ class RepositoryService {
|
|
|
250
241
|
}
|
|
251
242
|
});
|
|
252
243
|
}
|
|
253
|
-
saveBinary(file) {
|
|
254
|
-
return this.inventoryBinary.create(file,
|
|
244
|
+
saveBinary(file, global) {
|
|
245
|
+
return this.inventoryBinary.create(file, global);
|
|
255
246
|
}
|
|
256
247
|
createOrUpdateRepositoryEntry(modal, type) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
248
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
249
|
+
const { selected: { id, name }, description, deviceType, c8y_Global, binary } = modal;
|
|
250
|
+
const mo = {
|
|
251
|
+
id,
|
|
252
|
+
name,
|
|
253
|
+
description,
|
|
254
|
+
type,
|
|
255
|
+
c8y_Global
|
|
256
|
+
};
|
|
257
|
+
if (deviceType && type !== RepositoryType.CONFIGURATION) {
|
|
258
|
+
set(mo, 'c8y_Filter.type', deviceType);
|
|
259
|
+
}
|
|
260
|
+
if (deviceType && type === RepositoryType.CONFIGURATION) {
|
|
261
|
+
set(mo, 'deviceType', deviceType);
|
|
262
|
+
}
|
|
263
|
+
if (modal.softwareType) {
|
|
264
|
+
set(mo, 'softwareType', modal.softwareType.softwareType);
|
|
265
|
+
}
|
|
266
|
+
if (modal.configurationType) {
|
|
267
|
+
set(mo, 'configurationType', modal.configurationType);
|
|
268
|
+
}
|
|
269
|
+
if (type === RepositoryType.CONFIGURATION) {
|
|
270
|
+
set(mo, 'url', binary === null || binary === void 0 ? void 0 : binary.url);
|
|
271
|
+
}
|
|
272
|
+
return id
|
|
273
|
+
? this.inventory.update(mo)
|
|
274
|
+
: this.inventory.create(mo);
|
|
275
|
+
});
|
|
274
276
|
}
|
|
275
277
|
createRepositoryBinary(modal, binaryURL, type, parent) {
|
|
276
278
|
const mo = this.prepareRepositoryBinaryMO(modal, binaryURL, type);
|
|
277
279
|
return this.inventory.childAdditionsCreate(mo, parent);
|
|
278
280
|
}
|
|
279
281
|
prepareRepositoryBinaryMO(modal, binaryURL, type) {
|
|
280
|
-
const { version, patchVersion, dependency } = modal;
|
|
282
|
+
const { version, patchVersion, dependency, c8y_Global } = modal;
|
|
281
283
|
const result = {
|
|
282
284
|
type: REPOSITORY_BINARY_TYPES[type],
|
|
283
285
|
[type]: {
|
|
284
286
|
url: binaryURL
|
|
285
287
|
},
|
|
286
|
-
c8y_Global
|
|
288
|
+
c8y_Global
|
|
287
289
|
};
|
|
288
290
|
if (dependency) {
|
|
289
291
|
set(result, [type, 'version'], patchVersion);
|
|
@@ -298,13 +300,17 @@ class RepositoryService {
|
|
|
298
300
|
}
|
|
299
301
|
return result;
|
|
300
302
|
}
|
|
301
|
-
linkBinary(repositoryBinary, binary) {
|
|
303
|
+
linkBinary(repositoryBinary, binary, repositoryEntry) {
|
|
302
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
if (repositoryBinary) {
|
|
306
|
+
const { id: repositoryBinaryId } = repositoryBinary;
|
|
307
|
+
if (binary) {
|
|
308
|
+
const { id: binaryId } = binary;
|
|
309
|
+
return this.inventory.childAdditionsAdd(binaryId, repositoryBinaryId);
|
|
310
|
+
}
|
|
307
311
|
}
|
|
312
|
+
else
|
|
313
|
+
return this.inventory.childAdditionsAdd(binary, repositoryEntry);
|
|
308
314
|
});
|
|
309
315
|
}
|
|
310
316
|
cleanUp(mosToDelete) {
|
|
@@ -1131,30 +1137,6 @@ class RepositoryService {
|
|
|
1131
1137
|
return res;
|
|
1132
1138
|
});
|
|
1133
1139
|
}
|
|
1134
|
-
createEntry(mo) {
|
|
1135
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1136
|
-
const binaryId = yield this.inventoryBinary.getIdFromUrl(mo.url);
|
|
1137
|
-
const newMo = yield this.inventory.create(mo);
|
|
1138
|
-
if (binaryId) {
|
|
1139
|
-
yield this.inventory.childAdditionsAdd(binaryId, newMo.data);
|
|
1140
|
-
}
|
|
1141
|
-
return newMo;
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
updateEntry(mo, url) {
|
|
1145
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1146
|
-
const existingBinaryId = yield this.inventoryBinary.getIdFromUrl(url);
|
|
1147
|
-
const newBinaryId = yield this.inventoryBinary.getIdFromUrl(mo.url);
|
|
1148
|
-
if (existingBinaryId && existingBinaryId !== newBinaryId) {
|
|
1149
|
-
const id = this.inventoryBinary.getIdFromUrl(url);
|
|
1150
|
-
yield this.inventoryBinary.delete(id);
|
|
1151
|
-
}
|
|
1152
|
-
if (newBinaryId) {
|
|
1153
|
-
yield this.inventory.childAdditionsAdd(newBinaryId, mo);
|
|
1154
|
-
}
|
|
1155
|
-
return this.inventory.update(mo);
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
1140
|
getBaseVersionResultListForLegacyEntry(entry) {
|
|
1159
1141
|
return Promise.resolve({
|
|
1160
1142
|
res: {},
|
|
@@ -1244,12 +1226,26 @@ class RepositoryService {
|
|
|
1244
1226
|
softwareListToLegacy(list) {
|
|
1245
1227
|
return (list || []).reduce((prev, curr) => (Object.assign(Object.assign({}, prev), { [curr.name]: curr.version })), {});
|
|
1246
1228
|
}
|
|
1229
|
+
getGlobalFragment(type) {
|
|
1230
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1231
|
+
return (yield this.globalConfigService.getGlobalParam(type)) ? { c8y_Global: {} } : undefined;
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
removeOutdatedBinary(newBinaryURL, oldBinaryURL) {
|
|
1235
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1236
|
+
const existingBinaryId = yield this.inventoryBinary.getIdFromUrl(oldBinaryURL);
|
|
1237
|
+
const newBinaryId = yield this.inventoryBinary.getIdFromUrl(newBinaryURL);
|
|
1238
|
+
if (existingBinaryId && existingBinaryId !== newBinaryId) {
|
|
1239
|
+
yield this.inventoryBinary.delete(existingBinaryId);
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1247
1243
|
}
|
|
1248
|
-
RepositoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: RepositoryService, deps: [{ token: i1.InventoryService }, { token: i1.InventoryBinaryService }, { token: i1.OperationService }, { token: i2.AlertService }, { token: i1.EventService }, { token: i2.OperationRealtimeService }, { token: i1.EventBinaryService }, { token: AdvancedSoftwareService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1244
|
+
RepositoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: RepositoryService, deps: [{ token: i1.InventoryService }, { token: i1.InventoryBinaryService }, { token: i1.OperationService }, { token: i2.AlertService }, { token: i1.EventService }, { token: i2.OperationRealtimeService }, { token: i1.EventBinaryService }, { token: AdvancedSoftwareService }, { token: i2.GlobalConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1249
1245
|
RepositoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: RepositoryService });
|
|
1250
1246
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: RepositoryService, decorators: [{
|
|
1251
1247
|
type: Injectable
|
|
1252
|
-
}], ctorParameters: function () { return [{ type: i1.InventoryService }, { type: i1.InventoryBinaryService }, { type: i1.OperationService }, { type: i2.AlertService }, { type: i1.EventService }, { type: i2.OperationRealtimeService }, { type: i1.EventBinaryService }, { type: AdvancedSoftwareService }]; } });
|
|
1248
|
+
}], ctorParameters: function () { return [{ type: i1.InventoryService }, { type: i1.InventoryBinaryService }, { type: i1.OperationService }, { type: i2.AlertService }, { type: i1.EventService }, { type: i2.OperationRealtimeService }, { type: i1.EventBinaryService }, { type: AdvancedSoftwareService }, { type: i2.GlobalConfigService }]; } });
|
|
1253
1249
|
|
|
1254
1250
|
class FileDownloadComponent {
|
|
1255
1251
|
constructor(repositoryService, inventoryBinaryService, alertService) {
|