alsmanager_lib 3.0.82 → 3.0.84

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 +54 -4
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -4288,13 +4288,15 @@ function writeDeviceProperties(db_used, id_device, raw_data) {
4288
4288
  //Read Device properties
4289
4289
  function readDevicePropertiesSQLite(id_device) {
4290
4290
  var query = "select raw_properties from device_properties ";
4291
- query += "where id_device = " + id_device;
4291
+ query += "where id_device = " + id_device + " ";
4292
+ query += "and (is_imported is null or is_imported = 0)"
4292
4293
  return query;
4293
4294
  }
4294
4295
 
4295
4296
  function readDevicePropertiesMySQL() {
4296
4297
  var query = "select raw_properties from device_properties ";
4297
- query += "where id_device = :id_device";
4298
+ query += "where id_device = :id_device ";
4299
+ query += "and (is_imported is null or is_imported = 0)"
4298
4300
  return query;
4299
4301
  }
4300
4302
  function readDeviceProperties(db_used, id_device) {
@@ -4315,7 +4317,44 @@ function readDeviceProperties(db_used, id_device) {
4315
4317
  return query;
4316
4318
  }
4317
4319
  //End Read Device properties
4320
+ //Update Device Properties after import
4321
+ function updateDevicePropertiesSQLite(id_prop, is_imported, id_config) {
4322
+ var query = "update device_properties set ";
4323
+ query += "is_imported " + is_imported + " ";
4324
+ if (id_config) {
4325
+ query += ", id_config = " + id_config + " ";
4326
+ }
4327
+ query += "where id = " + id_prop;
4328
+ return query;
4329
+ }
4318
4330
 
4331
+ function updateDevicePropertiesMySQL(id_prop, is_imported, id_config) {
4332
+ var query = "update device_properties set ";
4333
+ query += "is_imported :is_imported ";
4334
+ if (id_config) {
4335
+ query += ", id_config = :id_config ";
4336
+ }
4337
+ query += "where id = :id_prop";
4338
+ return query;
4339
+ }
4340
+ function updateDeviceProperties(db_used, id_prop, is_imported, id_config) {
4341
+ var query = "";
4342
+ if (db_used) {
4343
+ switch (db_used) {
4344
+ case 'SQLITE':
4345
+ query = updateDevicePropertiesSQLite(id_prop, is_imported, id_config);
4346
+ break;
4347
+ case 'MYSQL':
4348
+ query = updateDevicePropertiesMySQL(id_prop, is_imported, id_config);
4349
+ break;
4350
+ case 'MYSQL2':
4351
+ query = updateDevicePropertiesSQLite(id_prop, is_imported, id_config);
4352
+ break;
4353
+ }
4354
+ }
4355
+ return query;
4356
+ }
4357
+ //End Update Device Properties after import
4319
4358
  // Get Devices with properties
4320
4359
  function getDevicesWithPropertiesSQLite(id_device) {
4321
4360
  var query = "select ";
@@ -5751,12 +5790,22 @@ function getFreeLanPortsCombo(db_used, id_place, id_site, port_type){
5751
5790
  //end Get Network on device
5752
5791
  //
5753
5792
  function getImportedPropertiesByIdDeviceSQLite(id_device) {
5754
- var query = "select raw_properties as Dati from device_properties dp ";
5793
+ var query = "select dp.raw_properties as Dati, ";
5794
+ query += "case ";
5795
+ query += "when dp.is_imported = 1 then 'Importato' ";
5796
+ query += "else ''";
5797
+ query += "end as Stato ";
5798
+ query += "from device_properties dp ";
5755
5799
  query += "where dp.id_device = " + id_device;
5756
5800
  return query;
5757
5801
  }
5758
5802
  function getImportedPropertiesByIdDeviceMySQL(id_device) {
5759
- var query = "select raw_properties as Dati from device_properties dp ";
5803
+ var query = "select dp.raw_properties as Dati, ";
5804
+ query += "case ";
5805
+ query += "when dp.is_imported = 1 then 'Importato' ";
5806
+ query += "else ''";
5807
+ query += "end as Stato ";
5808
+ query += "from device_properties dp ";
5760
5809
  query += "where dp.id_device = :id_device";
5761
5810
  return query;
5762
5811
  }
@@ -14344,6 +14393,7 @@ module.exports = {
14344
14393
  getDeviceMySQLPayload,
14345
14394
  writeDeviceProperties,
14346
14395
  readDeviceProperties,
14396
+ updateDeviceProperties,
14347
14397
  //
14348
14398
  getDiskUsagesByIdStorage,
14349
14399
  getLastDiskUsagesByIdStorage,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  ".": "./lib/modules.js",
5
5
  "./dbconn": "./lib/dbconn.js"
6
6
  },
7
- "version": "3.0.82",
7
+ "version": "3.0.84",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",