alsmanager_lib 1.0.83 → 1.0.85

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 +115 -0
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -381,6 +381,33 @@ function removeStorage(db_used, id_device, storage_obj) {
381
381
  }
382
382
  return query;
383
383
  }
384
+
385
+ function getLastStorageInsertedSQLite(id_device) {
386
+ var query = "select id, id_device, storage_type, storage_size_unit, storage_totsize, storage_manifacturer, storage_model from device_storages ";
387
+ query += "where id_device = " + id_device + " ";
388
+ query += "order by id desc LIMIT 1";
389
+ return query;
390
+ }
391
+ function getLastStorageInsertedMySQL(id_device) {
392
+ var query = "select id, id_device, storage_type, storage_size_unit, storage_totsize, storage_manifacturer, storage_model from device_storages ";
393
+ query += "where id_device = :id_device ";
394
+ query += "order by id desc LIMIT 1";
395
+ return query;
396
+ }
397
+ function getLastStorageInserted(db_used, id_device) {
398
+ var query = "";
399
+ if (db_used) {
400
+ switch (db_used) {
401
+ case 'SQLITE':
402
+ query = getLastStorageInsertedSQLite(id_device);
403
+ break;
404
+ case 'MYSQL':
405
+ query = getLastStorageInsertedMySQL(id_device);
406
+ break;
407
+ }
408
+ }
409
+ return query;
410
+ }
384
411
  //
385
412
  function getStoragesByConfigSQLite(id_device, id_conf) {
386
413
  var query = "select ds.id, st.name as Tipo, ds.storage_size_unit as Unit, ds.storage_totsize as Dimensione, ds.storage_manifacturer as Marca, ds.storage_model as Modello from device_storages ds ";
@@ -621,6 +648,33 @@ function removeNetwork(db_used, id_device, network_obj) {
621
648
  }
622
649
  return query;
623
650
  }
651
+
652
+ function getLastNetworkInsertedSQLite(id_device) {
653
+ var query = "select id, id_device, net_type, mac_address, ipv4_static, ipv6_static from device_networks ";
654
+ query += "where id_device = " + id_device + " ";
655
+ query += "order by id desc LIMIT 1";
656
+ return query;
657
+ }
658
+ function getLastNetworkInsertedMySQL(id_device) {
659
+ var query = "select id, id_device, net_type, mac_address, ipv4_static, ipv6_static from device_networks ";
660
+ query += "where id_device = :id_device ";
661
+ query += "order by id desc LIMIT 1";
662
+ return query;
663
+ }
664
+ function getLastNetworkInserted(db_used, id_device) {
665
+ var query = "";
666
+ if (db_used) {
667
+ switch (db_used) {
668
+ case 'SQLITE':
669
+ query = getLastNetworkInsertedSQLite(id_device);
670
+ break;
671
+ case 'MYSQL':
672
+ query = getLastNetworkInsertedMySQL(id_device);
673
+ break;
674
+ }
675
+ }
676
+ return query;
677
+ }
624
678
  //
625
679
  function getNetworksByConfigSQLite(id_device, id_conf) {
626
680
  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 ";
@@ -885,6 +939,33 @@ function removeAddOn(db_used, id_device, addon_obj) {
885
939
  }
886
940
  return query;
887
941
  }
942
+
943
+ function getLastAddOnInsertedSQLite(id_device) {
944
+ var query = "select id, id_device, addon_type, maker, model, description from device_addons ";
945
+ query += "where id_device = " + id_device + " ";
946
+ query += "order by id desc LIMIT 1";
947
+ return query;
948
+ }
949
+ function getLastAddOnInsertedMySQL(id_device) {
950
+ var query = "select id, id_device, addon_type, maker, model, description from device_addons ";
951
+ query += "where id_device = :id_device ";
952
+ query += "order by id desc LIMIT 1";
953
+ return query;
954
+ }
955
+ function getLastAddOnInserted(db_used, id_device) {
956
+ var query = "";
957
+ if (db_used) {
958
+ switch (db_used) {
959
+ case 'SQLITE':
960
+ query = getLastAddOnInsertedSQLite(id_device);
961
+ break;
962
+ case 'MYSQL':
963
+ query = getLastAddOnInsertedMySQL(id_device);
964
+ break;
965
+ }
966
+ }
967
+ return query;
968
+ }
888
969
  //
889
970
  function getAddOnsByConfigSQLite(id_device, id_conf) {
890
971
  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 ";
@@ -1161,6 +1242,36 @@ function removePartChanged(db_used, id_change, id_conf) {
1161
1242
  return query;
1162
1243
  }
1163
1244
 
1245
+ function getLastPartInsertedSQLite(id_device, id_conf, part_type) {
1246
+ var query = "select id, id_conf, part_type, id_part, operation, id_part_replaced from change_config ";
1247
+ query += "where id_device = " + id_device + " ";
1248
+ query += "and id_conf = " + id_conf + " ";
1249
+ query += "and part_type = '" + part_type + "' ";
1250
+ query += "order by id desc LIMIT 1";
1251
+ return query;
1252
+ }
1253
+ function getLastPartInsertedMySQL(id_device, id_conf, part_type) {
1254
+ var query = "select id, id_conf, part_type, id_part, operation, id_part_replaced from change_config ";
1255
+ query += "where id_device = :id_device ";
1256
+ query += "and id_conf = :id_conf ";
1257
+ query += "and part_type = :part_type ";
1258
+ query += "order by id desc LIMIT 1";
1259
+ return query;
1260
+ }
1261
+ function getLastPartInserted(db_used, id_device, id_conf, part_type) {
1262
+ var query = "";
1263
+ if (db_used) {
1264
+ switch (db_used) {
1265
+ case 'SQLITE':
1266
+ query = getLastPartInsertedSQLite(id_device, id_conf, part_type);
1267
+ break;
1268
+ case 'MYSQL':
1269
+ query = getLastPartInsertedMySQL(id_device, id_conf, part_type);
1270
+ break;
1271
+ }
1272
+ }
1273
+ return query;
1274
+ }
1164
1275
  //End Device configurations
1165
1276
  // Disk usage
1166
1277
  function getDiskUsagesByIdStorageSQLite(id_storage) {
@@ -8686,6 +8797,7 @@ module.exports = {
8686
8797
  insertStorage,
8687
8798
  updateStorage,
8688
8799
  removeStorage,
8800
+ getLastStorageInserted,
8689
8801
  getStoragesByConfig,
8690
8802
  getNetworkByIdDevice,
8691
8803
  getNetworkComboByIdDevice,
@@ -8695,6 +8807,7 @@ module.exports = {
8695
8807
  insertNetwork,
8696
8808
  updateNetwork,
8697
8809
  removeNetwork,
8810
+ getLastNetworkInserted,
8698
8811
  getNetworksByConfig,
8699
8812
  getAddOnTypes,
8700
8813
  getAddOnByIdDevice,
@@ -8705,6 +8818,7 @@ module.exports = {
8705
8818
  insertAddOn,
8706
8819
  updateAddOn,
8707
8820
  removeAddOn,
8821
+ getLastAddOnInserted,
8708
8822
  getAddOnsByConfig,
8709
8823
  //
8710
8824
  getDeviceConfigurations,
@@ -8716,6 +8830,7 @@ module.exports = {
8716
8830
  insertPartChanged,
8717
8831
  updatePartChanged,
8718
8832
  removePartChanged,
8833
+ getLastPartInserted,
8719
8834
  //
8720
8835
  selectBeneDaInventario,
8721
8836
  getDevicesSelectForInventarioRaw,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "1.0.83",
3
+ "version": "1.0.85",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",