@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
- self.gudhub.getApp(self._searchOldAppId(app.app_id, self.appsConnectingMap.apps)).then(result_app => {
54
- callback ? callback.call(this, `GET APP: ${result_app.app_name} (Items steps)`) : null;
55
- let source_app = JSON.parse(JSON.stringify(result_app));
56
- let items = source_app.items_list.map(item => {
57
- return {
58
- index_number: item.index_number,
59
- item_id: 0,
60
- fields: []
61
- }
62
- }).filter((item, index) => index <= MAX_NUMBER_OF_INSTALLED_ITEMS);
63
- self.gudhub.addNewItems(app.app_id, items).then(items => {
64
- callback ? callback.call(this, `ADD NEW ITEMS: ${result_app.app_name} (Items steps)`) : null;
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
- app.items_list = items;
67
- self._updateMap(app.items_list, source_app.items_list);
68
- self._addFieldValue(source_app.items_list, app.items_list, self.appsConnectingMap);
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
- createsItems.push(app);
83
+ createsItems.push(app);
71
84
 
72
- app_resolve();
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
- pack.apps.forEach(app_id => {
299
- self.gudhub.getApp(app_id).then(result_app => {
300
- callback ? callback.call(this, `GET APP: ${result_app.app_name} (App steps)`) : null;
301
- let source_app = JSON.parse(JSON.stringify(result_app));
302
- source_apps[source_app.app_id] = source_app;
303
- progress.apps.push(source_app.icon);
304
-
305
- let appTemplate = self.prepareAppTemplate(source_app);
306
- appTemplate.app_name = appTemplate.app_name + ' New';
307
- appTemplate.privacy = 1;
308
- if(pack.data_to_change) {
309
- if(pack.data_to_change.name) {
310
- appTemplate.app_name = pack.data_to_change.name;
311
- }
312
- if(pack.data_to_change.icon) {
313
- appTemplate.icon = pack.data_to_change.icon;
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
- self.resetViewsIds(appTemplate);
342
+ }
343
+ self.resetViewsIds(appTemplate);
317
344
 
318
- self.gudhub.createNewApp(appTemplate).then(created_app => {
319
- callback ? callback.call(this, `CREATE NEW APP: ${result_app.app_name} (App steps)`) : null;
320
- created_apps.push(created_app);
321
- self.mapApp(source_app, created_app, self.appsConnectingMap);
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
- if (pack.apps.length == created_apps.length) {
324
- self.connectApps(created_apps, self.appsConnectingMap, source_apps);
350
+ if (pack.apps.length == created_apps.length) {
351
+ self.connectApps(created_apps, self.appsConnectingMap, source_apps);
325
352
 
326
- created_apps.forEach(created_app => {
327
- self.gudhub.updateApp(created_app).then(updated_app => {
328
- callback ? callback.call(this, `UPDATE APP: ${result_app.app_name} (App steps)`) : null;
329
- updated_apps.push(updated_app);
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
- if (pack.apps.length == updated_apps.length) {
332
- resolve(updated_apps);
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
 
@@ -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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.1.65",
3
+ "version": "1.1.67",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {