alsmanager_lib 1.0.75 → 1.0.77

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 +92 -48
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -333,8 +333,8 @@ function getStoragesByConfigSQLite(id_device, id_conf) {
333
333
  function getStoragesByConfigMySQL(id_device, id_conf) {
334
334
  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
335
  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 + ")";
336
+ query += "where id_device = :id_device ";
337
+ query += "and ds.id in (select id_part from change_config where id_conf = :id_conf)";
338
338
  return query;
339
339
  }
340
340
  function getStoragesByConfig(db_used, id_device, id_conf) {
@@ -501,17 +501,15 @@ function removeNetwork(db_used, id_device, network_obj) {
501
501
  }
502
502
  //
503
503
  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 + ")";
504
+ 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 ";
505
+ query += "where dn.id_device = " + id_device + " ";
506
+ query += "and dn.id in (select id_part from change_config where id_conf = " + id_conf + ")";
508
507
  return query;
509
508
  }
510
509
  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 + ")";
510
+ 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 ";
511
+ query += "where dn.id_device = :id_device ";
512
+ query += "and dn.id in (select id_part from change_config where id_conf = :id_conf)";
515
513
  return query;
516
514
  }
517
515
  function getNetworksByConfig(db_used, id_device, id_conf) {
@@ -675,29 +673,29 @@ function removeAddOn(db_used, id_device, addon_obj) {
675
673
  return query;
676
674
  }
677
675
  //
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 + ")";
676
+ function getAddOnsByConfigSQLite(id_device, id_conf) {
677
+ 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 ";
678
+ query += "join addon_types a on a.id = da.addon_type ";
679
+ query += "where da.id_device = " + id_device + " ";
680
+ query += "and da.id in (select id_part from change_config where id_conf = " + id_conf + ")";
683
681
  return query;
684
682
  }
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 + ")";
683
+ function getAddOnsByConfigMySQL(id_device, id_conf) {
684
+ 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 ";
685
+ query += "join addon_types a on a.id = da.addon_type ";
686
+ query += "where da.id_device = :id_device ";
687
+ query += "and da.id in (select id_part from change_config where id_conf = :id_conf)";
690
688
  return query;
691
689
  }
692
- function getAddonsByConfig(db_used, id_device, id_conf) {
690
+ function getAddOnsByConfig(db_used, id_device, id_conf) {
693
691
  var query = "";
694
692
  if (db_used) {
695
693
  switch (db_used) {
696
694
  case 'SQLITE':
697
- query = getAddonsByConfigSQLite(id_device, id_conf);
695
+ query = getAddOnsByConfigSQLite(id_device, id_conf);
698
696
  break;
699
697
  case 'MYSQL':
700
- query = getAddonsByConfigMySQL(id_device, id_conf);
698
+ query = getAddOnsByConfigMySQL(id_device, id_conf);
701
699
  break;
702
700
  }
703
701
  }
@@ -707,12 +705,14 @@ function getAddonsByConfig(db_used, id_device, id_conf) {
707
705
  // Device configurations
708
706
  function getDeviceConfigurationsSQLite(id_device) {
709
707
  var query = "select id, date_conf, note from device_changes ";
710
- query += "where id_device = " + id_device;
708
+ query += "where id_device = " + id_device + " ";
709
+ query += "order by date_conf desc"
711
710
  return query;
712
711
  }
713
712
  function getDeviceConfigurationsMySQL(id_device) {
714
713
  var query = "select id, date_conf, note from device_changes ";
715
- query += "where id_device = :id_device";
714
+ query += "where id_device = :id_device ";
715
+ query += "order by date_conf desc"
716
716
  return query;
717
717
  }
718
718
  function getDeviceConfigurations(db_used, id_device) {
@@ -730,6 +730,33 @@ function getDeviceConfigurations(db_used, id_device) {
730
730
  return query;
731
731
  }
732
732
 
733
+ function getLastDeviceConfigurationSQLite(id_device) {
734
+ var query = "select id, date_conf, note from device_changes ";
735
+ query += "where id_device = " + id_device + " ";
736
+ query += "order by date_conf desc LIMIT 1";
737
+ return query;
738
+ }
739
+ function getLastDeviceConfigurationMySQL(id_device) {
740
+ var query = "select id, date_conf, note from device_changes ";
741
+ query += "where id_device = :id_device ";
742
+ query += "order by date_conf desc LIMIT 1";
743
+ return query;
744
+ }
745
+ function getLastDeviceConfiguration(db_used, id_device) {
746
+ var query = "";
747
+ if (db_used) {
748
+ switch (db_used) {
749
+ case 'SQLITE':
750
+ query = getLastDeviceConfigurationSQLite(id_device);
751
+ break;
752
+ case 'MYSQL':
753
+ query = getLastDeviceConfigurationMySQL(id_device);
754
+ break;
755
+ }
756
+ }
757
+ return query;
758
+ }
759
+
733
760
 
734
761
  function getDeviceConfigurationByIdSQLite(id_conf) {
735
762
  var query = "select id, id_device, date_conf, note from device_changes ";
@@ -738,7 +765,7 @@ function getDeviceConfigurationByIdSQLite(id_conf) {
738
765
  }
739
766
  function getDeviceConfigurationByIdMySQL(id_conf) {
740
767
  var query = "select id, id_device, date_conf, note from device_changes ";
741
- query += "where id = " + id_conf;
768
+ query += "where id = :id_conf";
742
769
  return query;
743
770
  }
744
771
  function getDeviceConfigurationById(db_used, id_conf) {
@@ -756,63 +783,79 @@ function getDeviceConfigurationById(db_used, id_conf) {
756
783
  return query;
757
784
  }
758
785
 
759
- function insertDeviceConfigurationSQLite(id_device, date_ref, note) {
760
-
786
+ function insertDeviceConfigurationSQLite(id_device, data, note) {
787
+ var query = "insert into device_changes (id_device, date_conf, note) values (";
788
+ query += id_device + ", '" + data + "', '" + note + "')";
789
+ return query;
761
790
  }
762
- function insertDeviceConfigurationMySQL(id_device, date_ref, note) {
763
-
791
+ function insertDeviceConfigurationMySQL(id_device, data, note) {
792
+ var query = "insert into device_changes (id_device, date_conf, note) values (";
793
+ query += ":id_device, :data, :note)";
794
+ return query;
764
795
  }
765
- function insertDeviceConfiguration(db_used, id_device, date_ref) {
796
+ function insertDeviceConfiguration(db_used, id_device, data, note) {
766
797
  var query = "";
767
798
  if (db_used) {
768
799
  switch (db_used) {
769
800
  case 'SQLITE':
770
- query = insertDeviceConfigurationSQLite(id_device, date_ref);
801
+ query = insertDeviceConfigurationSQLite(id_device, data, note);
771
802
  break;
772
803
  case 'MYSQL':
773
- query = insertDeviceConfigurationMySQL(id_device, date_ref);
804
+ query = insertDeviceConfigurationMySQL(id_device, data, note);
774
805
  break;
775
806
  }
776
807
  }
777
808
  return query;
778
809
  }
779
810
 
780
- function updateDeviceConfigurationSQLite(id_device, date_ref, note) {
781
-
811
+ function updateDeviceConfigurationSQLite(id_conf, data, note) {
812
+ var query = "update device_changes set ";
813
+ query += "date_conf = '" + data +"',";
814
+ query += "note = '" + note + "' ";
815
+ query += "where id = " + id_conf;
816
+ return query;
782
817
  }
783
- function updateDeviceConfigurationMySQL(id_device, date_ref, note) {
784
-
818
+ function updateDeviceConfigurationMySQL(id_conf, data, note) {
819
+ var query = "update device_changes set ";
820
+ query += "date_conf = :data,";
821
+ query += "note = :note ";
822
+ query += "where id = :id_conf";
823
+ return query;
785
824
  }
786
- function updateDeviceConfiguration(db_used, id_conf, id_device, date_ref) {
825
+ function updateDeviceConfiguration(db_used, id_conf, data, note) {
787
826
  var query = "";
788
827
  if (db_used) {
789
828
  switch (db_used) {
790
829
  case 'SQLITE':
791
- query = updateDeviceConfigurationSQLite(id_conf, id_device, date_ref);
830
+ query = updateDeviceConfigurationSQLite(id_conf, data, note);
792
831
  break;
793
832
  case 'MYSQL':
794
- query = updateDeviceConfigurationMySQL(id_conf, id_device, date_ref);
833
+ query = updateDeviceConfigurationMySQL(id_conf, data, note);
795
834
  break;
796
835
  }
797
836
  }
798
837
  return query;
799
838
  }
800
839
 
801
- function removeDeviceConfigurationSQLite(id_conf, id_device, date_ref) {
802
-
840
+ function removeDeviceConfigurationSQLite(id_conf) {
841
+ var query = "delete from device_changes ";
842
+ query += "where id = " + id_conf;
843
+ return query;
803
844
  }
804
- function removeDeviceConfigurationMySQL(id_conf, id_device, date_ref) {
805
-
845
+ function removeDeviceConfigurationMySQL(id_conf) {
846
+ var query = "delete from device_changes ";
847
+ query += "where id = :id_conf";
848
+ return query;
806
849
  }
807
- function removeDeviceConfiguration(db_used, id_conf, id_device, date_ref) {
850
+ function removeDeviceConfiguration(db_used, id_conf) {
808
851
  var query = "";
809
852
  if (db_used) {
810
853
  switch (db_used) {
811
854
  case 'SQLITE':
812
- query = removeDeviceConfigurationSQLite(id_conf, id_device, date_ref);
855
+ query = removeDeviceConfigurationSQLite(id_conf);
813
856
  break;
814
857
  case 'MYSQL':
815
- query = removeDeviceConfigurationMySQL(id_conf, id_device, date_ref);
858
+ query = removeDeviceConfigurationMySQL(id_conf);
816
859
  break;
817
860
  }
818
861
  }
@@ -8217,9 +8260,10 @@ module.exports = {
8217
8260
  insertAddOn,
8218
8261
  updateAddOn,
8219
8262
  removeAddOn,
8220
- getAddonsByConfig,
8263
+ getAddOnsByConfig,
8221
8264
  //
8222
8265
  getDeviceConfigurations,
8266
+ getLastDeviceConfiguration,
8223
8267
  getDeviceConfigurationById,
8224
8268
  insertDeviceConfiguration,
8225
8269
  updateDeviceConfiguration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "1.0.75",
3
+ "version": "1.0.77",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",