@gudhub/core 1.1.65 → 1.1.67
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.
|
@@ -1228,6 +1228,13 @@ export default function generateModulesList(async_modules_path, file_server_url,
|
|
|
1228
1228
|
type: 'automation',
|
|
1229
1229
|
icon: 'automation_calculator',
|
|
1230
1230
|
private: true
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
data_type: 'DeleteItems',
|
|
1234
|
+
name: 'Delete Items',
|
|
1235
|
+
url: file_server_url + '/' + automation_modules_path + 'delete_items.js',
|
|
1236
|
+
type: 'automation',
|
|
1237
|
+
icon: 'rubbish'
|
|
1231
1238
|
}
|
|
1232
1239
|
]
|
|
1233
1240
|
}
|
|
@@ -9,7 +9,7 @@ export default class AppsTemplateService {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
createAppsFromTemplate(pack, maxNumberOfInsstalledItems, progressCallback) {
|
|
12
|
+
createAppsFromTemplate(pack, maxNumberOfInsstalledItems, progressCallback, installFromMaster) {
|
|
13
13
|
const self = this;
|
|
14
14
|
return new Promise(resolve => {
|
|
15
15
|
const stepsCount = pack.apps.length * 6;
|
|
@@ -21,7 +21,7 @@ export default class AppsTemplateService {
|
|
|
21
21
|
percent: currentStep * stepPercents,
|
|
22
22
|
status
|
|
23
23
|
}) : null;
|
|
24
|
-
}).then(success => {
|
|
24
|
+
}, installFromMaster).then(success => {
|
|
25
25
|
self.createItems(success, maxNumberOfInsstalledItems, (status) => {
|
|
26
26
|
if (typeof status === 'string') {
|
|
27
27
|
currentStep += 1;
|
|
@@ -36,41 +36,53 @@ export default class AppsTemplateService {
|
|
|
36
36
|
}) : null;
|
|
37
37
|
resolve();
|
|
38
38
|
}
|
|
39
|
-
})
|
|
39
|
+
}, installFromMaster)
|
|
40
40
|
})
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
createItems(create_apps, maxNumberOfInsstalledItems, callback) {
|
|
45
|
-
return new Promise(resolve => {
|
|
44
|
+
createItems(create_apps, maxNumberOfInsstalledItems, callback, installFromMaster) {
|
|
45
|
+
return new Promise(async (resolve) => {
|
|
46
46
|
const MAX_NUMBER_OF_INSTALLED_ITEMS = maxNumberOfInsstalledItems ? maxNumberOfInsstalledItems : 100000;
|
|
47
47
|
const self = this;
|
|
48
48
|
let createsItems = [];
|
|
49
49
|
let promises = [];
|
|
50
50
|
|
|
51
|
+
const { accesstoken } = await self.gudhub.req.axiosRequest({
|
|
52
|
+
method: 'POST',
|
|
53
|
+
url: 'https://gudhub.com/GudHub_Test/auth/login',
|
|
54
|
+
form: {
|
|
55
|
+
auth_key: '3HMOtCbC0M/1/1e4y4Uxo/Kh/aFN4V5LG2//5ixx7TZyiUfMb7IHAAHCj9PsLrOSDrZuuWkbX4BIX23f51H+eA=='
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
51
59
|
create_apps.forEach(app => {
|
|
52
|
-
promises.push(new Promise(app_resolve => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
promises.push(new Promise(async (app_resolve) => {
|
|
61
|
+
let result_app;
|
|
62
|
+
if(installFromMaster) {
|
|
63
|
+
result_app = await self.gudhub.req.axiosRequest({ url: `https://gudhub.com/GudHub_Test/api/app/get?token=${accesstoken}&app_id=${self._searchOldAppId(app.app_id, self.appsConnectingMap.apps)}`, method: 'GET' });
|
|
64
|
+
} else {
|
|
65
|
+
result_app = await self.gudhub.getApp(self._searchOldAppId(app.app_id, self.appsConnectingMap.apps));
|
|
66
|
+
}
|
|
67
|
+
callback ? callback.call(this, `GET APP: ${result_app.app_name} (Items steps)`) : null;
|
|
68
|
+
let source_app = JSON.parse(JSON.stringify(result_app));
|
|
69
|
+
let items = source_app.items_list.map(item => {
|
|
70
|
+
return {
|
|
71
|
+
index_number: item.index_number,
|
|
72
|
+
item_id: 0,
|
|
73
|
+
fields: []
|
|
74
|
+
}
|
|
75
|
+
}).filter((item, index) => index <= MAX_NUMBER_OF_INSTALLED_ITEMS);
|
|
76
|
+
self.gudhub.addNewItems(app.app_id, items).then(items => {
|
|
77
|
+
callback ? callback.call(this, `ADD NEW ITEMS: ${result_app.app_name} (Items steps)`) : null;
|
|
65
78
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
app.items_list = items;
|
|
80
|
+
self._updateMap(app.items_list, source_app.items_list);
|
|
81
|
+
self._addFieldValue(source_app.items_list, app.items_list, self.appsConnectingMap);
|
|
69
82
|
|
|
70
|
-
|
|
83
|
+
createsItems.push(app);
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
});
|
|
85
|
+
app_resolve();
|
|
74
86
|
});
|
|
75
87
|
}));
|
|
76
88
|
});
|
|
@@ -282,7 +294,7 @@ export default class AppsTemplateService {
|
|
|
282
294
|
return findId;
|
|
283
295
|
}
|
|
284
296
|
|
|
285
|
-
createApps(pack, callback) {
|
|
297
|
+
createApps(pack, callback, installFromMaster) {
|
|
286
298
|
const self = this;
|
|
287
299
|
|
|
288
300
|
let progress = {
|
|
@@ -290,53 +302,67 @@ export default class AppsTemplateService {
|
|
|
290
302
|
apps: []
|
|
291
303
|
}
|
|
292
304
|
|
|
293
|
-
return new Promise(resolve => {
|
|
305
|
+
return new Promise(async (resolve) => {
|
|
294
306
|
let source_apps = {};
|
|
295
307
|
let created_apps = [];
|
|
296
308
|
let updated_apps = [];
|
|
297
309
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
310
|
+
const { accesstoken } = await self.gudhub.req.axiosRequest({
|
|
311
|
+
method: 'POST',
|
|
312
|
+
url: 'https://gudhub.com/GudHub_Test/auth/login',
|
|
313
|
+
form: {
|
|
314
|
+
auth_key: '3HMOtCbC0M/1/1e4y4Uxo/Kh/aFN4V5LG2//5ixx7TZyiUfMb7IHAAHCj9PsLrOSDrZuuWkbX4BIX23f51H+eA=='
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
for(const app_id of pack.apps) {
|
|
319
|
+
let result_app;
|
|
320
|
+
|
|
321
|
+
if(installFromMaster) {
|
|
322
|
+
result_app = await self.gudhub.req.axiosRequest({ url: `https://gudhub.com/GudHub_Test/api/app/get?token=${accesstoken}&app_id=${app_id}`, method: 'GET' });
|
|
323
|
+
} else {
|
|
324
|
+
result_app = await self.gudhub.getApp(app_id);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
callback ? callback.call(this, `GET APP: ${result_app.app_name} (App steps)`) : null;
|
|
328
|
+
let source_app = JSON.parse(JSON.stringify(result_app));
|
|
329
|
+
source_apps[source_app.app_id] = source_app;
|
|
330
|
+
progress.apps.push(source_app.icon);
|
|
331
|
+
|
|
332
|
+
let appTemplate = self.prepareAppTemplate(source_app);
|
|
333
|
+
appTemplate.app_name = appTemplate.app_name + ' New';
|
|
334
|
+
appTemplate.privacy = 1;
|
|
335
|
+
if(pack.data_to_change) {
|
|
336
|
+
if(pack.data_to_change.name) {
|
|
337
|
+
appTemplate.app_name = pack.data_to_change.name;
|
|
338
|
+
}
|
|
339
|
+
if(pack.data_to_change.icon) {
|
|
340
|
+
appTemplate.icon = pack.data_to_change.icon;
|
|
315
341
|
}
|
|
316
|
-
|
|
342
|
+
}
|
|
343
|
+
self.resetViewsIds(appTemplate);
|
|
317
344
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
345
|
+
self.gudhub.createNewApp(appTemplate).then(created_app => {
|
|
346
|
+
callback ? callback.call(this, `CREATE NEW APP: ${result_app.app_name} (App steps)`) : null;
|
|
347
|
+
created_apps.push(created_app);
|
|
348
|
+
self.mapApp(source_app, created_app, self.appsConnectingMap);
|
|
322
349
|
|
|
323
|
-
|
|
324
|
-
|
|
350
|
+
if (pack.apps.length == created_apps.length) {
|
|
351
|
+
self.connectApps(created_apps, self.appsConnectingMap, source_apps);
|
|
325
352
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
353
|
+
created_apps.forEach(created_app => {
|
|
354
|
+
self.gudhub.updateApp(created_app).then(updated_app => {
|
|
355
|
+
callback ? callback.call(this, `UPDATE APP: ${result_app.app_name} (App steps)`) : null;
|
|
356
|
+
updated_apps.push(updated_app);
|
|
330
357
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
})
|
|
358
|
+
if (pack.apps.length == updated_apps.length) {
|
|
359
|
+
resolve(updated_apps);
|
|
360
|
+
}
|
|
335
361
|
})
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
})
|
|
339
|
-
}
|
|
362
|
+
})
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
340
366
|
});
|
|
341
367
|
}
|
|
342
368
|
|
package/GUDHUB/Utils/Utils.js
CHANGED
|
@@ -180,8 +180,8 @@ export class Utils {
|
|
|
180
180
|
return this.FileHelper.fileInstallerHelper(appId, items, elementId);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
createAppsFromTemplate(pack, maxNumberOfInsstalledItems, progressCallback) {
|
|
184
|
-
return this.AppsTemplateService.createAppsFromTemplate(pack, maxNumberOfInsstalledItems, progressCallback);
|
|
183
|
+
createAppsFromTemplate(pack, maxNumberOfInsstalledItems, progressCallback, installFromMaster) {
|
|
184
|
+
return this.AppsTemplateService.createAppsFromTemplate(pack, maxNumberOfInsstalledItems, progressCallback, installFromMaster);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
createApps(pack) {
|