alsmanager_lib 1.0.86 → 1.0.87

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 +47 -13
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -413,14 +413,24 @@ function getStoragesByConfigSQLite(id_device, id_conf) {
413
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 ";
414
414
  query += "join storage_types st on st.id = ds.storage_type ";
415
415
  query += "where id_device = " + id_device + " ";
416
- query += "and ds.id in (select id_part from change_config where id_conf = " + id_conf + ")";
416
+ if (id_conf > 0) {
417
+ query += "and ds.id in (select id_part from change_config where id_conf = " + id_conf + ")";
418
+ }
419
+ else {
420
+ query += "and ds.id in (select id_part from change_config where id_device = " + id_device + " and part_type = 'STORAGE' order by id desc LIMIT 1)"
421
+ }
417
422
  return query;
418
423
  }
419
424
  function getStoragesByConfigMySQL(id_device, id_conf) {
420
425
  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 ";
421
426
  query += "join storage_types st on st.id = ds.storage_type ";
422
427
  query += "where id_device = :id_device ";
423
- query += "and ds.id in (select id_part from change_config where id_conf = :id_conf)";
428
+ if (id_conf > 0) {
429
+ query += "and ds.id in (select id_part from change_config where id_conf = :id_conf)";
430
+ }
431
+ else {
432
+ query += "and ds.id in (select id_part from change_config where id_device = :id_device and part_type = 'STORAGE' order by id desc LIMIT 1)"
433
+ }
424
434
  return query;
425
435
  }
426
436
  function getStoragesByConfig(db_used, id_device, id_conf) {
@@ -679,13 +689,23 @@ function getLastNetworkInserted(db_used, id_device) {
679
689
  function getNetworksByConfigSQLite(id_device, id_conf) {
680
690
  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 ";
681
691
  query += "where dn.id_device = " + id_device + " ";
682
- query += "and dn.id in (select id_part from change_config where id_conf = " + id_conf + ")";
692
+ if (id_conf > 0) {
693
+ query += "and dn.id in (select id_part from change_config where id_conf = " + id_conf + ")";
694
+ }
695
+ else {
696
+ query += "and dn.id in (select id_part from change_config where id_device = " + id_device + " and part_type = 'NETWORK' order by id desc LIMIT 1)"
697
+ }
683
698
  return query;
684
699
  }
685
700
  function getNetworksByConfigMySQL(id_device, id_conf) {
686
701
  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 ";
687
702
  query += "where dn.id_device = :id_device ";
688
- query += "and dn.id in (select id_part from change_config where id_conf = :id_conf)";
703
+ if (id_conf > 0) {
704
+ query += "and dn.id in (select id_part from change_config where id_conf = :id_conf)";
705
+ }
706
+ else {
707
+ query += "and dn.id in (select id_part from change_config where id_device = :id_device and part_type = 'NETWORK' order by id desc LIMIT 1)"
708
+ }
689
709
  return query;
690
710
  }
691
711
  function getNetworksByConfig(db_used, id_device, id_conf) {
@@ -971,14 +991,24 @@ function getAddOnsByConfigSQLite(id_device, id_conf) {
971
991
  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 ";
972
992
  query += "join addon_types a on a.id = da.addon_type ";
973
993
  query += "where da.id_device = " + id_device + " ";
974
- query += "and da.id in (select id_part from change_config where id_conf = " + id_conf + ")";
994
+ if (id_conf > 0) {
995
+ query += "and da.id in (select id_part from change_config where id_conf = " + id_conf + ")";
996
+ }
997
+ else {
998
+ query += "and da.id in (select id_part from change_config where id_device = " + id_device + " and part_type = 'ADDON' order by id desc LIMIT 1)"
999
+ }
975
1000
  return query;
976
1001
  }
977
1002
  function getAddOnsByConfigMySQL(id_device, id_conf) {
978
1003
  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 ";
979
1004
  query += "join addon_types a on a.id = da.addon_type ";
980
1005
  query += "where da.id_device = :id_device ";
981
- query += "and da.id in (select id_part from change_config where id_conf = :id_conf)";
1006
+ if (id_conf > 0) {
1007
+ query += "and da.id in (select id_part from change_config where id_conf = :id_conf)";
1008
+ }
1009
+ else {
1010
+ query += "and da.id in (select id_part from change_config where id_device = :id_device and part_type = 'ADDON' order by id desc LIMIT 1)"
1011
+ }
982
1012
  return query;
983
1013
  }
984
1014
  function getAddOnsByConfig(db_used, id_device, id_conf) {
@@ -1222,27 +1252,31 @@ function updatePartChanged(db_used, id_change, operation, id_part_replaced) {
1222
1252
  return query;
1223
1253
  }
1224
1254
 
1225
- function removePartChangedSQLite(id_change, id_conf) {
1255
+ function removePartChangedSQLite(id_conf, id_part, part_type) {
1226
1256
  var query = "delete from change_config ";
1227
- query += "where id = " + id_change + " and id_conf = " + id_conf;
1257
+ query += "where id_device = " + id_part + " ";
1258
+ query += "and id_conf = " + id_conf + " ";
1259
+ query += "and part_type = '" + part_type + "'";
1228
1260
  return query;
1229
1261
  }
1230
1262
 
1231
- function removePartChangedMySQL(id_change, id_conf) {
1263
+ function removePartChangedMySQL(id_conf, id_part) {
1232
1264
  var query = "delete from change_config ";
1233
- query += "where id = :id_change and id_conf = :id_conf";
1265
+ query += "where id_device = :id_part ";
1266
+ query += "and id_conf = :id_conf ";
1267
+ query += "and part_type = :part_type";
1234
1268
  return query;
1235
1269
  }
1236
1270
 
1237
- function removePartChanged(db_used, id_change, id_conf) {
1271
+ function removePartChanged(db_used, id_conf, id_part, part_type) {
1238
1272
  var query = "";
1239
1273
  if (db_used) {
1240
1274
  switch (db_used) {
1241
1275
  case 'SQLITE':
1242
- query = removePartChangedSQLite(id_change, id_conf);
1276
+ query = removePartChangedSQLite(id_conf, id_part, part_type);
1243
1277
  break;
1244
1278
  case 'MYSQL':
1245
- query = removePartChangedMySQL(id_change, id_conf);
1279
+ query = removePartChangedMySQL(id_conf, id_part, part_type);
1246
1280
  break;
1247
1281
  }
1248
1282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "1.0.86",
3
+ "version": "1.0.87",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",