alsmanager_lib 1.0.82 → 1.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 +42 -14
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -156,14 +156,14 @@ function removeConnector(db_used, id_device, conn_obj) {
156
156
  //End Manage connectors
157
157
  // Manage Storage
158
158
  function getStorageByIdDeviceSQLite(id_device) {
159
- 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 ";
159
+ 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 ";
160
160
  query += "join storage_types st on st.id = ds.storage_type ";
161
161
  query += "where id_device = " + id_device;
162
162
  return query;
163
163
  }
164
164
 
165
165
  function getStorageByIdDeviceMySQL(id_device) {
166
- 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 ";
166
+ 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 ";
167
167
  query += "join storage_types st on st.id = ds.storage_type ";
168
168
  query += "where id_device = :id_device";
169
169
  return query;
@@ -252,13 +252,13 @@ function getStorageByIdPartAndIdConf(db_used, id_storage, id_conf) {
252
252
 
253
253
 
254
254
  function getStorageByIdSQLite(id_storage) {
255
- var query = "select id, id_device, storage_type, storage_size_unit, storage_totsize, storage_available, storage_manifacturer, storage_model from device_storages ";
255
+ var query = "select id, id_device, storage_type, storage_size_unit, storage_totsize, storage_manifacturer, storage_model from device_storages ";
256
256
  query += "where id = " + id_storage;
257
257
  return query;
258
258
  }
259
259
 
260
260
  function getStorageByIdMySQL() {
261
- var query = "select id, id_device, storage_type, storage_size_unit, storage_totsize, storage_available, storage_manifacturer, storage_model from device_storages ";
261
+ var query = "select id, id_device, storage_type, storage_size_unit, storage_totsize, storage_manifacturer, storage_model from device_storages ";
262
262
  query += "where id = :id_storage";
263
263
  return query;
264
264
  }
@@ -285,22 +285,21 @@ function createStorageObjMySQL(id_device, storage_obj) {
285
285
  obj.tipo = storage_obj.tipo;
286
286
  obj.unita = storage_obj.unita;
287
287
  obj.dimensione = storage_obj.dimensione;
288
- obj.dim_disponibile = storage_obj.dim_disponibile;
289
288
  obj.marca = storage_obj.marca;
290
289
  obj.modello = storage_obj.modello;
291
290
  return obj;
292
291
  }
293
292
 
294
293
  function insertStorageSQLite(id_device, storage_obj) {
295
- var query = "insert into device_storages (id_device, storage_type, storage_size_unit, storage_totsize, storage_available, storage_manifacturer, storage_model) values ";
296
- query += "(" + id_device + ", " + storage_obj.tipo + ", '" + storage_obj.unita + "'," + storage_obj.dimensione + ", " + storage_obj.dim_disponibile + ", ";
294
+ var query = "insert into device_storages (id_device, storage_type, storage_size_unit, storage_totsize, storage_manifacturer, storage_model) values ";
295
+ query += "(" + id_device + ", " + storage_obj.tipo + ", '" + storage_obj.unita + "'," + storage_obj.dimensione + ", ";
297
296
  query += "'" + storage_obj.marca + "', '" + storage_obj.modello + "')";
298
297
  return query;
299
298
  }
300
299
 
301
300
  function insertStorageMySQL(id_device, storage_obj) {
302
- var query = "insert into device_storages (id_device, storage_type, storage_size_unit, storage_totsize, storage_available, storage_manifacturer, storage_model) values ";
303
- query += "(:id_device, :tipo, :unita, :dimensione, :dim_disponibile, :marca, :modello)";
301
+ var query = "insert into device_storages (id_device, storage_type, storage_size_unit, storage_totsize, storage_manifacturer, storage_model) values ";
302
+ query += "(:id_device, :tipo, :unita, :dimensione, :marca, :modello)";
304
303
  return query;
305
304
  }
306
305
 
@@ -325,7 +324,6 @@ function updateStorageSQLite(id_device, storage_obj) {
325
324
  query += "storage_type = " + storage_obj.tipo + ", ";
326
325
  query += "storage_size_unit = '" + storage_obj.unita + "', ";
327
326
  query += "storage_totsize = " + storage_obj.dimensione + ", ";
328
- query += "storage_available = " + storage_obj.dim_disponibile + ", ";
329
327
  query += "storage_manifacturer = '" + storage_obj.marca + "', ";
330
328
  query += "storage_model = '" + storage_obj.modello + "' ";
331
329
  query += "where id = " + storage_obj.id;
@@ -338,7 +336,6 @@ function updateStorageMySQL(id_device, storage_obj) {
338
336
  query += "storage_type = :tipo, ";
339
337
  query += "storage_size_unit = :unita, ";
340
338
  query += "storage_totsize = :dimensione, ";
341
- query += "storage_available = :dim_disponibile ";
342
339
  query += "storage_manifacturer = :marca, ";
343
340
  query += "storage_model = :modello ";
344
341
  query += "where id = id_storage";
@@ -367,7 +364,7 @@ function removeStorageSQLite(id_device, storage_obj) {
367
364
 
368
365
  function removeStorageMySQL(id_device, storage_obj) {
369
366
  var query = "delete from device_storages ";
370
- query += "where id = id_storage";
367
+ query += "where id = :id_storage";
371
368
  return query;
372
369
  }
373
370
  function removeStorage(db_used, id_device, storage_obj) {
@@ -386,14 +383,14 @@ function removeStorage(db_used, id_device, storage_obj) {
386
383
  }
387
384
  //
388
385
  function getStoragesByConfigSQLite(id_device, id_conf) {
389
- 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 ";
386
+ 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 ";
390
387
  query += "join storage_types st on st.id = ds.storage_type ";
391
388
  query += "where id_device = " + id_device + " ";
392
389
  query += "and ds.id in (select id_part from change_config where id_conf = " + id_conf + ")";
393
390
  return query;
394
391
  }
395
392
  function getStoragesByConfigMySQL(id_device, id_conf) {
396
- 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 ";
393
+ 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 ";
397
394
  query += "join storage_types st on st.id = ds.storage_type ";
398
395
  query += "where id_device = :id_device ";
399
396
  query += "and ds.id in (select id_part from change_config where id_conf = :id_conf)";
@@ -1164,6 +1161,36 @@ function removePartChanged(db_used, id_change, id_conf) {
1164
1161
  return query;
1165
1162
  }
1166
1163
 
1164
+ function getLastPartInsertedSQLite(id_device, id_conf, part_type) {
1165
+ var query = "select id, id_conf, part_type, id_part, operation, id_part_replaced from change_config ";
1166
+ query += "where id_device = " + id_device + " ";
1167
+ query += "and id_conf = " + id_conf + " ";
1168
+ query += "and part_type = '" + part_type + "' ";
1169
+ query += "order by id desc LIMIT 1";
1170
+ return query;
1171
+ }
1172
+ function getLastPartInsertedMySQL(id_device, id_conf, part_type) {
1173
+ var query = "select id, id_conf, part_type, id_part, operation, id_part_replaced from change_config ";
1174
+ query += "where id_device = :id_device ";
1175
+ query += "and id_conf = :id_conf ";
1176
+ query += "and part_type = :part_type ";
1177
+ query += "order by id desc LIMIT 1";
1178
+ return query;
1179
+ }
1180
+ function getLastPartInserted(db_used, id_device, id_conf, part_type) {
1181
+ var query = "";
1182
+ if (db_used) {
1183
+ switch (db_used) {
1184
+ case 'SQLITE':
1185
+ query = getLastPartInsertedSQLite(id_device, id_conf, part_type);
1186
+ break;
1187
+ case 'MYSQL':
1188
+ query = getLastPartInsertedMySQL(id_device, id_conf, part_type);
1189
+ break;
1190
+ }
1191
+ }
1192
+ return query;
1193
+ }
1167
1194
  //End Device configurations
1168
1195
  // Disk usage
1169
1196
  function getDiskUsagesByIdStorageSQLite(id_storage) {
@@ -8719,6 +8746,7 @@ module.exports = {
8719
8746
  insertPartChanged,
8720
8747
  updatePartChanged,
8721
8748
  removePartChanged,
8749
+ getLastPartInserted,
8722
8750
  //
8723
8751
  selectBeneDaInventario,
8724
8752
  getDevicesSelectForInventarioRaw,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "1.0.82",
3
+ "version": "1.0.84",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",