alsmanager_lib 1.0.76 → 1.0.78

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 (2) hide show
  1. package/lib/modules.js +191 -34
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -183,6 +183,41 @@ function getStorageByIdDevice(db_used, id_device) {
183
183
  return query;
184
184
  }
185
185
 
186
+
187
+ function getStorageComboByIdDeviceSQLite(id_device, id_exclude) {
188
+ var query = "select ds.id, concat(st.name, ' - ', ds.storage_manifacturer, ' - ', ds.storage_model) as descrizione from device_storages ds ";
189
+ query += "join storage_types st on st.id = ds.storage_type ";
190
+ query += "where id_device = " + id_device;
191
+ if (id_exclude && id_exclude > 0) {
192
+ query += "and ds.id <> " + id_exclude;
193
+ }
194
+ return query;
195
+ }
196
+
197
+ function getStorageComboByIdDeviceMySQL(id_device, id_exclude) {
198
+ var query = "select ds.id, concat(st.name, ' - ', ds.storage_manifacturer, ' - ', ds.storage_model) as descrizione from device_storages ds ";
199
+ query += "join storage_types st on st.id = ds.storage_type ";
200
+ query += "where id_device = :id_device";
201
+ if (id_exclude && id_exclude > 0) {
202
+ query += "and ds.id <> :id_exclude";
203
+ }
204
+ return query;
205
+ }
206
+ function getStorageComboByIdDevice(db_used, id_device, id_exclude) {
207
+ var query = "";
208
+ if (db_used) {
209
+ switch (db_used) {
210
+ case 'SQLITE':
211
+ query = getStorageComboByIdDeviceSQLite(id_device, id_exclude);
212
+ break;
213
+ case 'MYSQL':
214
+ query = getStorageComboByIdDeviceMySQL(id_device, id_exclude);
215
+ break;
216
+ }
217
+ }
218
+ return query;
219
+ }
220
+
186
221
  function getStorageByIdSQLite(id_storage) {
187
222
  var query = "select id, id_device, storage_type, storage_size_unit, storage_totsize, storage_available, storage_manifacturer, storage_model from device_storages ";
188
223
  query += "where id = " + id_storage;
@@ -333,8 +368,8 @@ function getStoragesByConfigSQLite(id_device, id_conf) {
333
368
  function getStoragesByConfigMySQL(id_device, id_conf) {
334
369
  var query = "select ds.id, st.name as Tipo, ds.storage_size_unit as Unit, ds.storage_totsize as Dimensione, ds.storage_available as Disponibile, ds.storage_manifacturer as Marca, ds.storage_model as Modello from device_storages ds ";
335
370
  query += "join storage_types st on st.id = ds.storage_type ";
336
- query += "where id_device = " + id_device + " ";
337
- query += "and ds.id in (select id_part from change_config where id_conf = " + id_conf + ")";
371
+ query += "where id_device = :id_device ";
372
+ query += "and ds.id in (select id_part from change_config where id_conf = :id_conf)";
338
373
  return query;
339
374
  }
340
375
  function getStoragesByConfig(db_used, id_device, id_conf) {
@@ -379,6 +414,37 @@ function getNetworkByIdDevice(db_used, id_device) {
379
414
  return query;
380
415
  }
381
416
 
417
+ function getNetworkComboByIdDeviceSQLite(id_device, id_exclude) {
418
+ var query = "select dn.id, concat(dn.net_type , ' - ', dn.mac_address, ' - ', dn.ipv4_static, ' - ', dn.ipv6_static) as descrizione from device_networks dn ";
419
+ query += "where dn.id_device = " + id_device + " ";
420
+ if (id_exclude && id_exclude > 0) {
421
+ query += "and dn.id <> " + id_exclude;
422
+ }
423
+ return query;
424
+ }
425
+ function getNetworkComboByIdDeviceMySQL(id_device, id_exclude) {
426
+ var query = "select dn.id, concat(dn.net_type , ' - ', dn.mac_address, ' - ', dn.ipv4_static, ' - ', dn.ipv6_static) as descrizione from device_networks dn ";
427
+ query += "where dn.id_device = :id_device ";
428
+ if (id_exclude && id_exclude > 0) {
429
+ query += "and dn.id <> :id_exclude";
430
+ }
431
+ return query;
432
+ }
433
+ function getNetworkComboByIdDevice(db_used, id_device, id_exclude) {
434
+ var query = "";
435
+ if (db_used) {
436
+ switch (db_used) {
437
+ case 'SQLITE':
438
+ query = getNetworkComboByIdDeviceSQLite(id_device, id_exclude);
439
+ break;
440
+ case 'MYSQL':
441
+ query = getNetworkComboByIdDeviceMySQL(id_device, id_exclude);
442
+ break;
443
+ }
444
+ }
445
+ return query;
446
+ }
447
+
382
448
  function getNetworkByIdSQLite(id_network) {
383
449
  var query = "select id, id_device, net_type, mac_address, ipv4_static, ipv6_static from device_networks ";
384
450
  query += "where id = " + id_network;
@@ -501,17 +567,15 @@ function removeNetwork(db_used, id_device, network_obj) {
501
567
  }
502
568
  //
503
569
  function getNetworksByConfigSQLite(id_device, id_conf) {
504
- var query = "select ds.id, st.name as Tipo, ds.storage_size_unit as Unit, ds.storage_totsize as Dimensione, ds.storage_available as Disponibile, ds.storage_manifacturer as Marca, ds.storage_model as Modello from device_storages ds ";
505
- query += "join storage_types st on st.id = ds.storage_type ";
506
- query += "where id_device = " + id_device + " ";
507
- query += "and ds.id in (select id_part from change_config where id_conf = " + id_conf + ")";
570
+ var query = "select dn.id, dn.net_type as Tipo, dn.mac_address as MAC, dn.ipv4_static as IP4, dn.ipv6_static as IP6 from device_networks dn ";
571
+ query += "where dn.id_device = " + id_device + " ";
572
+ query += "and dn.id in (select id_part from change_config where id_conf = " + id_conf + ")";
508
573
  return query;
509
574
  }
510
575
  function getNetworksByConfigMySQL(id_device, id_conf) {
511
- var query = "select ds.id, st.name as Tipo, ds.storage_size_unit as Unit, ds.storage_totsize as Dimensione, ds.storage_available as Disponibile, ds.storage_manifacturer as Marca, ds.storage_model as Modello from device_storages ds ";
512
- query += "join storage_types st on st.id = ds.storage_type ";
513
- query += "where id_device = " + id_device + " ";
514
- query += "and ds.id in (select id_part from change_config where id_conf = " + id_conf + ")";
576
+ var query = "select dn.id, dn.net_type as Tipo, dn.mac_address as MAC, dn.ipv4_static as IP4, dn.ipv6_static as IP6 from device_networks dn ";
577
+ query += "where dn.id_device = :id_device ";
578
+ query += "and dn.id in (select id_part from change_config where id_conf = :id_conf)";
515
579
  return query;
516
580
  }
517
581
  function getNetworksByConfig(db_used, id_device, id_conf) {
@@ -530,6 +594,32 @@ function getNetworksByConfig(db_used, id_device, id_conf) {
530
594
  }
531
595
  //End Manage Network
532
596
  // Manage AddOns
597
+ //get addon types
598
+ function getAddOnTypesSQLite() {
599
+ var query = "select id, name, description from addon_types";
600
+ return query;
601
+ }
602
+ function getAddOnTypesMySQL() {
603
+ var query = "select id, name, description from addon_types";
604
+ return query;
605
+ }
606
+ function getAddOnTypes(db_used) {
607
+ var query = "";
608
+ if (db_used) {
609
+ switch (db_used) {
610
+ case 'SQLITE':
611
+ query = getAddOnTypesSQLite();
612
+ break;
613
+ case 'MYSQL':
614
+ query = getAddOnTypesMySQL();
615
+ break;
616
+ }
617
+ }
618
+ return query;
619
+ }
620
+ //end get addon types
621
+
622
+
533
623
  function getAddOnByIdDeviceSQLite(id_device) {
534
624
  var query = "select da.id, a.name as Tipo, da.maker as Marca, da.model as Modello, da.description as Descrizione from device_addons da ";
535
625
  query += "join addon_types a on a.id = da.addon_type ";
@@ -556,6 +646,40 @@ function getAddOnByIdDevice(db_used, id_device) {
556
646
  }
557
647
  return query;
558
648
  }
649
+
650
+ function getAddOnComboByIdDeviceSQLite(id_device, id_exclude) {
651
+ var query = "select da.id, concat(a.name, ' - ', da.maker, ' - ', da.model) as descrizione from device_addons da ";
652
+ query += "join addon_types a on a.id = da.addon_type ";
653
+ query += "where da.id_device = " + id_device + " ";
654
+ if (id_exclude && id_exclude > 0) {
655
+ query += "and da.id <> " + id_exclude;
656
+ }
657
+ return query;
658
+ }
659
+ function getAddOnComboByIdDeviceMySQL(id_device, id_exclude) {
660
+ var query = "select da.id, concat(a.name, ' - ', da.maker, ' - ', da.model) as descrizione from device_addons da ";
661
+ query += "join addon_types a on a.id = da.addon_type ";
662
+ query += "where da.id_device = :id_device ";
663
+ if (id_exclude && id_exclude > 0) {
664
+ query += "and da.id <> :id_exclude";
665
+ }
666
+ return query;
667
+ }
668
+ function getAddOnComboByIdDevice(db_used, id_device, id_exclude) {
669
+ var query = "";
670
+ if (db_used) {
671
+ switch (db_used) {
672
+ case 'SQLITE':
673
+ query = getAddOnComboByIdDeviceSQLite(id_device, id_exclude);
674
+ break;
675
+ case 'MYSQL':
676
+ query = getAddOnComboByIdDeviceMySQL(id_device, id_exclude);
677
+ break;
678
+ }
679
+ }
680
+ return query;
681
+ }
682
+
559
683
  function getAddOnByIdSQLite(id_addon) {
560
684
  var query = "select id, id_device, addon_type, maker, model, description from device_addons ";
561
685
  query += "where id = " + id_addon;
@@ -657,7 +781,7 @@ function removeAddOnSQLite(id_device, addon_obj) {
657
781
  }
658
782
  function removeAddOnMySQL(id_device, addon_obj) {
659
783
  var query = "delete from device_addons ";
660
- query += "where id = id_addon";
784
+ query += "where id = :id_addon";
661
785
  }
662
786
 
663
787
  function removeAddOn(db_used, id_device, addon_obj) {
@@ -675,29 +799,29 @@ function removeAddOn(db_used, id_device, addon_obj) {
675
799
  return query;
676
800
  }
677
801
  //
678
- function getAddonsByConfigSQLite(id_device, id_conf) {
679
- var query = "select ds.id, st.name as Tipo, ds.storage_size_unit as Unit, ds.storage_totsize as Dimensione, ds.storage_available as Disponibile, ds.storage_manifacturer as Marca, ds.storage_model as Modello from device_storages ds ";
680
- query += "join storage_types st on st.id = ds.storage_type ";
681
- query += "where id_device = " + id_device + " ";
682
- query += "and ds.id in (select id_part from change_config where id_conf = " + id_conf + ")";
802
+ function getAddOnsByConfigSQLite(id_device, id_conf) {
803
+ var query = "select da.id, a.name as Tipo, da.maker as Marca, da.model as Modello, da.description as Descrizione from device_addons da ";
804
+ query += "join addon_types a on a.id = da.addon_type ";
805
+ query += "where da.id_device = " + id_device + " ";
806
+ query += "and da.id in (select id_part from change_config where id_conf = " + id_conf + ")";
683
807
  return query;
684
808
  }
685
- function getAddonsByConfigMySQL(id_device, id_conf) {
686
- var query = "select ds.id, st.name as Tipo, ds.storage_size_unit as Unit, ds.storage_totsize as Dimensione, ds.storage_available as Disponibile, ds.storage_manifacturer as Marca, ds.storage_model as Modello from device_storages ds ";
687
- query += "join storage_types st on st.id = ds.storage_type ";
688
- query += "where id_device = " + id_device + " ";
689
- query += "and ds.id in (select id_part from change_config where id_conf = " + id_conf + ")";
809
+ function getAddOnsByConfigMySQL(id_device, id_conf) {
810
+ var query = "select da.id, a.name as Tipo, da.maker as Marca, da.model as Modello, da.description as Descrizione from device_addons da ";
811
+ query += "join addon_types a on a.id = da.addon_type ";
812
+ query += "where da.id_device = :id_device ";
813
+ query += "and da.id in (select id_part from change_config where id_conf = :id_conf)";
690
814
  return query;
691
815
  }
692
- function getAddonsByConfig(db_used, id_device, id_conf) {
816
+ function getAddOnsByConfig(db_used, id_device, id_conf) {
693
817
  var query = "";
694
818
  if (db_used) {
695
819
  switch (db_used) {
696
820
  case 'SQLITE':
697
- query = getAddonsByConfigSQLite(id_device, id_conf);
821
+ query = getAddOnsByConfigSQLite(id_device, id_conf);
698
822
  break;
699
823
  case 'MYSQL':
700
- query = getAddonsByConfigMySQL(id_device, id_conf);
824
+ query = getAddOnsByConfigMySQL(id_device, id_conf);
701
825
  break;
702
826
  }
703
827
  }
@@ -892,35 +1016,63 @@ function insertPartChanged(db_used, id_conf, part_type, id_part, operation, id_p
892
1016
  return query;
893
1017
  }
894
1018
 
895
- function updatePartChangedSQLite(id_change, id_conf, part_type, id_part, operation, id_part_replaced) {
1019
+ function updatePartChangedSQLite(id_change, operation, id_part_replaced) {
896
1020
  var query = "update change_config set ";
897
- query += "id_conf = " + id_conf + ", ";
898
- query += "part_type = '" + part_type + "', ";
899
- query += "id_part = " + id_part + ", ";
900
1021
  query += "operation = '" + operation + "', ";
901
- query += "id_part_replaced = '" + id_part_replaced + "', ";
1022
+ query += "id_part_replaced = " + id_part_replaced + " ";
902
1023
  query += "where id = " + id_change;
903
1024
  return query;
904
1025
  }
905
1026
 
906
- function updatePartChangedMySQL(id_change, id_conf, part_type, id_part, operation) {
1027
+ function updatePartChangedMySQL(id_change, operation, id_part_replaced) {
1028
+ var query = "update change_config set ";
1029
+ query += "operation = :operation, ";
1030
+ query += "id_part_replaced = :id_part_replaced ";
1031
+ query += "where id = :id_change";
1032
+ return query;
907
1033
  }
908
1034
 
909
- function updatePartChanged(db_used, id_change, id_conf, part_type, id_part, operation, id_part_replaced) {
1035
+ function updatePartChanged(db_used, id_change, operation, id_part_replaced) {
910
1036
  var query = "";
911
1037
  if (db_used) {
912
1038
  switch (db_used) {
913
1039
  case 'SQLITE':
914
- query = updatePartChangedSQLite(id_change, id_conf, part_type, id_part, operation, id_part_replaced);
1040
+ query = updatePartChangedSQLite(id_change, operation, id_part_replaced);
915
1041
  break;
916
1042
  case 'MYSQL':
917
- query = updatePartChangedMySQL(id_change, id_conf, part_type, id_part, operation, id_part_replaced);
1043
+ query = updatePartChangedMySQL(id_change, operation, id_part_replaced);
918
1044
  break;
919
1045
  }
920
1046
  }
921
1047
  return query;
922
1048
  }
923
1049
 
1050
+ function removePartChangedSQLite(id_change, id_conf) {
1051
+ var query = "delete from change_config ";
1052
+ query += "where id = " + id_change + " and id_conf = " + id_conf;
1053
+ return query;
1054
+ }
1055
+
1056
+ function removePartChangedMySQL(id_change, id_conf) {
1057
+ var query = "delete from change_config ";
1058
+ query += "where id = :id_change and id_conf = :id_conf";
1059
+ return query;
1060
+ }
1061
+
1062
+ function removePartChanged(db_used, id_change, id_conf) {
1063
+ var query = "";
1064
+ if (db_used) {
1065
+ switch (db_used) {
1066
+ case 'SQLITE':
1067
+ query = removePartChangedSQLite(id_change, id_conf);
1068
+ break;
1069
+ case 'MYSQL':
1070
+ query = removePartChangedMySQL(id_change, id_conf);
1071
+ break;
1072
+ }
1073
+ }
1074
+ return query;
1075
+ }
924
1076
 
925
1077
  //End Device configurations
926
1078
 
@@ -8243,6 +8395,7 @@ module.exports = {
8243
8395
  updateConnector,
8244
8396
  removeConnector,
8245
8397
  getStorageByIdDevice,
8398
+ getStorageComboByIdDevice,
8246
8399
  getStorageById,
8247
8400
  createStorageObjMySQL,
8248
8401
  insertStorage,
@@ -8250,19 +8403,22 @@ module.exports = {
8250
8403
  removeStorage,
8251
8404
  getStoragesByConfig,
8252
8405
  getNetworkByIdDevice,
8406
+ getNetworkComboByIdDevice,
8253
8407
  getNetworkById,
8254
8408
  createNetworkObjMySQL,
8255
8409
  insertNetwork,
8256
8410
  updateNetwork,
8257
8411
  removeNetwork,
8258
8412
  getNetworksByConfig,
8413
+ getAddOnTypes,
8259
8414
  getAddOnByIdDevice,
8415
+ getAddOnComboByIdDevice,
8260
8416
  getAddOnById,
8261
8417
  createAddOnObjMySQL,
8262
8418
  insertAddOn,
8263
8419
  updateAddOn,
8264
8420
  removeAddOn,
8265
- getAddonsByConfig,
8421
+ getAddOnsByConfig,
8266
8422
  //
8267
8423
  getDeviceConfigurations,
8268
8424
  getLastDeviceConfiguration,
@@ -8272,6 +8428,7 @@ module.exports = {
8272
8428
  removeDeviceConfiguration,
8273
8429
  insertPartChanged,
8274
8430
  updatePartChanged,
8431
+ removePartChanged,
8275
8432
  //
8276
8433
  selectBeneDaInventario,
8277
8434
  getDevicesSelectForInventarioRaw,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "1.0.76",
3
+ "version": "1.0.78",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",