alsmanager_lib 1.0.52 → 1.0.54
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.
- package/lib/modules.js +232 -9
- package/package.json +1 -1
package/lib/modules.js
CHANGED
|
@@ -56,6 +56,16 @@ function getConnectorById(db_used, id_conn) {
|
|
|
56
56
|
return query;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function createConnectorObjMySQL(id_device, conn_obj) {
|
|
60
|
+
var obj = {};
|
|
61
|
+
obj.id_device = id_device;
|
|
62
|
+
obj.id = conn_obj.id;
|
|
63
|
+
obj.tipo = conn_obj.tipo;
|
|
64
|
+
obj.protocollo = conn_obj.protocollo;
|
|
65
|
+
obj.numero = conn_obj.numero;
|
|
66
|
+
obj.verso = conn_obj.verso;
|
|
67
|
+
return obj;
|
|
68
|
+
}
|
|
59
69
|
|
|
60
70
|
function insertConnectorSQLite(id_device, conn_obj) {
|
|
61
71
|
//dc.id, ct.conn_type as Tipo, cp.name as Protocollo, dc.conn_number as Numero, dc.conn_verse as Verso from device_connectors
|
|
@@ -200,15 +210,31 @@ function getStorageById(db_used, id_storage) {
|
|
|
200
210
|
return query;
|
|
201
211
|
}
|
|
202
212
|
|
|
213
|
+
function createStorageObjMySQL(id_device, storage_obj) {
|
|
214
|
+
var obj = {};
|
|
215
|
+
obj.id_device = id_device;
|
|
216
|
+
obj.id = storage_obj.id;
|
|
217
|
+
obj.tipo = storage_obj.tipo;
|
|
218
|
+
obj.unita = storage_obj.unita;
|
|
219
|
+
obj.dimensione = storage_obj.dimensione;
|
|
220
|
+
obj.dim_disponibile = storage_obj.dim_disponibile;
|
|
221
|
+
obj.marca = storage_obj.marca;
|
|
222
|
+
obj.modello = storage_obj.modello;
|
|
223
|
+
obj.is_replaced = storage_obj.is_replaced;
|
|
224
|
+
obj.date_replaced = storage_obj.date_replaced;
|
|
225
|
+
return obj;
|
|
226
|
+
}
|
|
227
|
+
|
|
203
228
|
function insertStorageSQLite(id_device, storage_obj) {
|
|
204
|
-
var query = "insert into device_storages (id_device, storage_type, storage_size_unit, storage_totsize, storage_available) values ";
|
|
205
|
-
query += "(" + id_device + ", " + storage_obj.tipo + ", '" + storage_obj.unita + "'," + storage_obj.dimensione + ", " + storage_obj.dim_disponibile + "
|
|
229
|
+
var query = "insert into device_storages (id_device, storage_type, storage_size_unit, storage_totsize, storage_available, storage_manifacturer, storage_model, is_replaced, date_replaced) values ";
|
|
230
|
+
query += "(" + id_device + ", " + storage_obj.tipo + ", '" + storage_obj.unita + "'," + storage_obj.dimensione + ", " + storage_obj.dim_disponibile + ", ";
|
|
231
|
+
query += "'" + storage_obj.marca + "', '" + storage_obj.modello + "', " + storage_obj.is_replaced + ", '" + storage_obj.date_replaced + "')";
|
|
206
232
|
return query;
|
|
207
233
|
}
|
|
208
234
|
|
|
209
235
|
function insertStorageMySQL(id_device, storage_obj) {
|
|
210
|
-
var query = "insert into device_storages (id_device, storage_type, storage_size_unit, storage_totsize, storage_available) values ";
|
|
211
|
-
query += "(:id_device, :tipo, :unita, :dimensione, :dim_disponibile)";
|
|
236
|
+
var query = "insert into device_storages (id_device, storage_type, storage_size_unit, storage_totsize, storage_available, storage_manifacturer, storage_model, is_replaced, date_replaced) values ";
|
|
237
|
+
query += "(:id_device, :tipo, :unita, :dimensione, :dim_disponibile, :marca, :modello, :is_replaced, :date_replaced)";
|
|
212
238
|
return query;
|
|
213
239
|
}
|
|
214
240
|
|
|
@@ -233,7 +259,11 @@ function updateStorageSQLite(id_device, storage_obj) {
|
|
|
233
259
|
query += "storage_type = " + storage_obj.tipo + ", ";
|
|
234
260
|
query += "storage_size_unit = '" + storage_obj.unita + "', ";
|
|
235
261
|
query += "storage_totsize = " + storage_obj.dimensione + ", ";
|
|
236
|
-
query += "storage_available = " + storage_obj.dim_disponibile + " ";
|
|
262
|
+
query += "storage_available = " + storage_obj.dim_disponibile + ", ";
|
|
263
|
+
query += "storage_manifacturer = '" + storage_obj.marca + "', ";
|
|
264
|
+
query += "storage_model = '" + storage_obj.modello + "', ";
|
|
265
|
+
query += "is_replaced = " + storage_obj.is_replaced + ", ";
|
|
266
|
+
query += "date_replaced = '" + storage_obj.date_replaced + "' ";
|
|
237
267
|
query += "where id = " + storage_obj.id;
|
|
238
268
|
return query;
|
|
239
269
|
}
|
|
@@ -245,6 +275,10 @@ function updateStorageMySQL(id_device, storage_obj) {
|
|
|
245
275
|
query += "storage_size_unit = :unita, ";
|
|
246
276
|
query += "storage_totsize = :dimensione, ";
|
|
247
277
|
query += "storage_available = :dim_disponibile ";
|
|
278
|
+
query += "storage_manifacturer = :marca, ";
|
|
279
|
+
query += "storage_model = :modello, ";
|
|
280
|
+
query += "is_replaced = :is_replaced, ";
|
|
281
|
+
query += "date_replaced = :date_replaced ";
|
|
248
282
|
query += "where id = id_storage";
|
|
249
283
|
return query;
|
|
250
284
|
}
|
|
@@ -340,6 +374,18 @@ function getNetworkById(db_used, id_network) {
|
|
|
340
374
|
}
|
|
341
375
|
return query;
|
|
342
376
|
}
|
|
377
|
+
|
|
378
|
+
function createNetworkObjMySQL(id_device, network_obj) {
|
|
379
|
+
var obj = {};
|
|
380
|
+
obj.id_device = id_device;
|
|
381
|
+
obj.id = network_obj.id;
|
|
382
|
+
obj.tipo = network_obj.tipo;
|
|
383
|
+
obj.mac_address = network_obj.mac_address;
|
|
384
|
+
obj.ipv4_static = network_obj.ipv4_static;
|
|
385
|
+
obj.ipv6_static = network_obj.ipv6_static;
|
|
386
|
+
return obj;
|
|
387
|
+
}
|
|
388
|
+
|
|
343
389
|
function insertNetworkSQLite(id_device, network_obj) {
|
|
344
390
|
var query = "insert into device_networks (id_device, net_type, mac_address, ipv4_static, ipv6_static) values ";
|
|
345
391
|
query += "(" + id_device + ", '" + network_obj.tipo + "', '" + network_obj.mac_address + "', '" + network_obj.ipv4_static + "', '" + network_obj.ipv6_static + "')";
|
|
@@ -460,7 +506,7 @@ function getAddOnByIdMySQL() {
|
|
|
460
506
|
query += "where id = :id_addon";
|
|
461
507
|
return query;
|
|
462
508
|
}
|
|
463
|
-
function getAddOnById(id_addon) {
|
|
509
|
+
function getAddOnById(db_used, id_addon) {
|
|
464
510
|
var query = "";
|
|
465
511
|
if (db_used) {
|
|
466
512
|
switch (db_used) {
|
|
@@ -474,6 +520,19 @@ function getAddOnById(id_addon) {
|
|
|
474
520
|
}
|
|
475
521
|
return query;
|
|
476
522
|
}
|
|
523
|
+
|
|
524
|
+
function createAddOnObjMySQL(id_device, addon_obj) {
|
|
525
|
+
var obj = {};
|
|
526
|
+
obj.id_device = id_device;
|
|
527
|
+
obj.id = addon_obj.id;
|
|
528
|
+
obj.addon_type = addon_obj.addon_type;
|
|
529
|
+
obj.maker = addon_obj.maker;
|
|
530
|
+
obj.model = addon_obj.model;
|
|
531
|
+
obj.description = addon_obj.description;
|
|
532
|
+
return obj;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
|
|
477
536
|
function insertAddOnSQLite(id_device, addon_obj) {
|
|
478
537
|
var query = "insert into device_addons (id_device, addon_type, maker, model, description) values ";
|
|
479
538
|
query += "(" + id_device + ", " + addon_obj.addon_type + ", '" + addon_obj.maker + "', '" + addon_obj.model + "', '" + addon_obj.description + "')";
|
|
@@ -612,7 +671,7 @@ function getPCProperties(db_used, id_device) {
|
|
|
612
671
|
query = getPCPropertiesSQLite(id_device);
|
|
613
672
|
break;
|
|
614
673
|
case 'MYSQL':
|
|
615
|
-
query =
|
|
674
|
+
query = getPCPropertiesMySQL(id_device);
|
|
616
675
|
break;
|
|
617
676
|
}
|
|
618
677
|
}
|
|
@@ -1280,10 +1339,10 @@ function getDevicesCounterByPlace(db_used, id_place) {
|
|
|
1280
1339
|
if (db_used) {
|
|
1281
1340
|
switch (db_used) {
|
|
1282
1341
|
case 'SQLITE':
|
|
1283
|
-
query =
|
|
1342
|
+
query = getDevicesCounterByPlaceSQLite(id_place);
|
|
1284
1343
|
break;
|
|
1285
1344
|
case 'MYSQL':
|
|
1286
|
-
query =
|
|
1345
|
+
query = getDevicesCounterByPlaceMySQL(id_place);
|
|
1287
1346
|
break;
|
|
1288
1347
|
}
|
|
1289
1348
|
}
|
|
@@ -7038,6 +7097,158 @@ function queryStatisticInventary(db_used) {
|
|
|
7038
7097
|
return query;
|
|
7039
7098
|
}
|
|
7040
7099
|
//End Get Inventary for Statistics
|
|
7100
|
+
// Benchmarking
|
|
7101
|
+
function getBenchmarkByIdSQLite(id_device) {
|
|
7102
|
+
var query = "select id_device, total_ref, evaluation_perfs from device_bmark ";
|
|
7103
|
+
query += "where id_device = " + id_device;
|
|
7104
|
+
return query;
|
|
7105
|
+
}
|
|
7106
|
+
|
|
7107
|
+
function getBenchmarkByIdMySQL(id_device) {
|
|
7108
|
+
var query = "select id_device, total_ref, evaluation_perfs from device_bmark ";
|
|
7109
|
+
query += "where id_device = :id_device";
|
|
7110
|
+
return query;
|
|
7111
|
+
}
|
|
7112
|
+
|
|
7113
|
+
function getBenchmarkById(db_used, id_device) {
|
|
7114
|
+
var query = "";
|
|
7115
|
+
if (db_used) {
|
|
7116
|
+
switch (db_used) {
|
|
7117
|
+
case 'SQLITE':
|
|
7118
|
+
query = getBenchmarkByIdSQLite(id_device);
|
|
7119
|
+
break;
|
|
7120
|
+
case 'MYSQL':
|
|
7121
|
+
query = getBenchmarkByIdMySQL(id_device);
|
|
7122
|
+
break;
|
|
7123
|
+
}
|
|
7124
|
+
}
|
|
7125
|
+
return query;
|
|
7126
|
+
}
|
|
7127
|
+
|
|
7128
|
+
function getBenchmarkPercentageByIdSQLite(id_device) {
|
|
7129
|
+
var query = "select ";
|
|
7130
|
+
query += "case ";
|
|
7131
|
+
query += "when total_ref is not null and total_ref > 0 then (evaluation_perfs/total_ref) * 100 ";
|
|
7132
|
+
query += "else 0 ";
|
|
7133
|
+
query += "end as perc_prestazioni from device_bmark ";
|
|
7134
|
+
query += "where id_device = " + id_device;
|
|
7135
|
+
return query;
|
|
7136
|
+
}
|
|
7137
|
+
|
|
7138
|
+
function getBenchmarkPercentageByIdMySQL(id_device) {
|
|
7139
|
+
var query = "select ";
|
|
7140
|
+
query += "case ";
|
|
7141
|
+
query += "when total_ref is not null and total_ref > 0 then (evaluation_perfs/total_ref) * 100 ";
|
|
7142
|
+
query += "else 0 ";
|
|
7143
|
+
query += "end as perc_prestazioni from device_bmark ";
|
|
7144
|
+
query += "where id_device = :id_device";
|
|
7145
|
+
return query;
|
|
7146
|
+
}
|
|
7147
|
+
|
|
7148
|
+
function getBenchmarkPercentageById(db_used, id_device) {
|
|
7149
|
+
var query = "";
|
|
7150
|
+
if (db_used) {
|
|
7151
|
+
switch (db_used) {
|
|
7152
|
+
case 'SQLITE':
|
|
7153
|
+
query = getBenchmarkPercentageByIdSQLite(id_device);
|
|
7154
|
+
break;
|
|
7155
|
+
case 'MYSQL':
|
|
7156
|
+
query = getBenchmarkPercentageByIdMySQL(id_device);
|
|
7157
|
+
break;
|
|
7158
|
+
}
|
|
7159
|
+
}
|
|
7160
|
+
return query;
|
|
7161
|
+
}
|
|
7162
|
+
|
|
7163
|
+
|
|
7164
|
+
function insertBenchmarkSQLite(id_device, total_ref, eval_perfs) {
|
|
7165
|
+
var query = "insert into device_bmark (id_device, total_ref, evaluation_perfs) value ";
|
|
7166
|
+
query += "(" + id_device + ", " + total_ref + ", " + eval_perfs + ")";
|
|
7167
|
+
return query;
|
|
7168
|
+
}
|
|
7169
|
+
|
|
7170
|
+
function insertBenchmarkMySQL(id_device, total_ref, eval_perfs) {
|
|
7171
|
+
var query = "insert into device_bmark (id_device, total_ref, evaluation_perfs) value ";
|
|
7172
|
+
query += "(:id_device, :total_ref, :eval_perfs)";
|
|
7173
|
+
return query;
|
|
7174
|
+
}
|
|
7175
|
+
|
|
7176
|
+
function insertBenchmark(db_used, id_device, total_ref, eval_perfs) {
|
|
7177
|
+
var query = "";
|
|
7178
|
+
if (db_used) {
|
|
7179
|
+
switch (db_used) {
|
|
7180
|
+
case 'SQLITE':
|
|
7181
|
+
query = insertBenchmarkSQLite(id_device, total_ref, eval_perfs);
|
|
7182
|
+
break;
|
|
7183
|
+
case 'MYSQL':
|
|
7184
|
+
query = insertBenchmarkMySQL(id_device, total_ref, eval_perfs);
|
|
7185
|
+
break;
|
|
7186
|
+
}
|
|
7187
|
+
}
|
|
7188
|
+
return query;
|
|
7189
|
+
}
|
|
7190
|
+
|
|
7191
|
+
|
|
7192
|
+
function updateBenchmarkSQLite(id_device, total_ref, eval_perfs) {
|
|
7193
|
+
var query = "update device_bmark set ";
|
|
7194
|
+
query += "total_ref = " + total_ref + ", ";
|
|
7195
|
+
query += "evaluation_perfs = " + eval_perfs + " ";
|
|
7196
|
+
query += "where id_device = " + id_device;
|
|
7197
|
+
return query;
|
|
7198
|
+
}
|
|
7199
|
+
|
|
7200
|
+
function updateBenchmarkMySQL(id_device, total_ref, eval_perfs) {
|
|
7201
|
+
var query = "update device_bmark set ";
|
|
7202
|
+
query += "total_ref = " + total_ref + ", ";
|
|
7203
|
+
query += "evaluation_perfs = " + eval_perfs + " ";
|
|
7204
|
+
query += "where id_device = " + id_device;
|
|
7205
|
+
return query;
|
|
7206
|
+
}
|
|
7207
|
+
|
|
7208
|
+
function updateBenchmark(db_used, id_device, total_ref, eval_perfs) {
|
|
7209
|
+
var query = "";
|
|
7210
|
+
if (db_used) {
|
|
7211
|
+
switch (db_used) {
|
|
7212
|
+
case 'SQLITE':
|
|
7213
|
+
query = updateBenchmarkSQLite(id_device, total_ref, eval_perfs);
|
|
7214
|
+
break;
|
|
7215
|
+
case 'MYSQL':
|
|
7216
|
+
query = updateBenchmarkMySQL(id_device, total_ref, eval_perfs);
|
|
7217
|
+
break;
|
|
7218
|
+
}
|
|
7219
|
+
}
|
|
7220
|
+
return query;
|
|
7221
|
+
}
|
|
7222
|
+
|
|
7223
|
+
function removeBenchmarkByIdSQLite(id_device) {
|
|
7224
|
+
var query = "delete from device_bmark ";
|
|
7225
|
+
query += "where id_device = " + id_device;
|
|
7226
|
+
return query;
|
|
7227
|
+
}
|
|
7228
|
+
|
|
7229
|
+
function removeBenchmarkByIdMySQL(id_device) {
|
|
7230
|
+
var query = "delete from device_bmark ";
|
|
7231
|
+
query += "where id_device = " + id_device;
|
|
7232
|
+
return query;
|
|
7233
|
+
}
|
|
7234
|
+
|
|
7235
|
+
function removeBenchmarkById(db_used, id_device) {
|
|
7236
|
+
var query = "";
|
|
7237
|
+
if (db_used) {
|
|
7238
|
+
switch (db_used) {
|
|
7239
|
+
case 'SQLITE':
|
|
7240
|
+
query = removeBenchmarkByIdSQLite(id_device);
|
|
7241
|
+
break;
|
|
7242
|
+
case 'MYSQL':
|
|
7243
|
+
query = removeBenchmarkByIdMySQL(id_device);
|
|
7244
|
+
break;
|
|
7245
|
+
}
|
|
7246
|
+
}
|
|
7247
|
+
return query;
|
|
7248
|
+
}
|
|
7249
|
+
|
|
7250
|
+
//End benchmarking
|
|
7251
|
+
|
|
7041
7252
|
//Get Devices Statistics bt Status
|
|
7042
7253
|
function queryStatisticsDeviceStatusSQLite() {
|
|
7043
7254
|
var query = "select case when ds.status is null then 0 else ds.status end as Stato, sd.name as Descrizione, count(*) as Numero from devices d ";
|
|
@@ -7400,23 +7611,30 @@ module.exports = {
|
|
|
7400
7611
|
insertDisplayProperties,
|
|
7401
7612
|
updateDisplayProperties,
|
|
7402
7613
|
getDisplayPartProperties,
|
|
7614
|
+
existsDisplayPartProperties,
|
|
7615
|
+
insertDisplayPartProperties,
|
|
7616
|
+
updateDisplayPartProperties,
|
|
7403
7617
|
getConnectorsByIdDevice,
|
|
7404
7618
|
getConnectorById,
|
|
7619
|
+
createConnectorObjMySQL,
|
|
7405
7620
|
insertConnector,
|
|
7406
7621
|
updateConnector,
|
|
7407
7622
|
removeConnector,
|
|
7408
7623
|
getStorageByIdDevice,
|
|
7409
7624
|
getStorageById,
|
|
7625
|
+
createStorageObjMySQL,
|
|
7410
7626
|
insertStorage,
|
|
7411
7627
|
updateStorage,
|
|
7412
7628
|
removeStorage,
|
|
7413
7629
|
getNetworkByIdDevice,
|
|
7414
7630
|
getNetworkById,
|
|
7631
|
+
createNetworkObjMySQL,
|
|
7415
7632
|
insertNetwork,
|
|
7416
7633
|
updateNetwork,
|
|
7417
7634
|
removeNetwork,
|
|
7418
7635
|
getAddOnByIdDevice,
|
|
7419
7636
|
getAddOnById,
|
|
7637
|
+
createAddOnObjMySQL,
|
|
7420
7638
|
insertAddOn,
|
|
7421
7639
|
updateAddOn,
|
|
7422
7640
|
removeAddOn,
|
|
@@ -7551,6 +7769,11 @@ module.exports = {
|
|
|
7551
7769
|
queryStatistic,
|
|
7552
7770
|
queryStatisticInventary,
|
|
7553
7771
|
queryStatisticsDeviceStatus,
|
|
7772
|
+
getBenchmarkById,
|
|
7773
|
+
getBenchmarkPercentageById,
|
|
7774
|
+
insertBenchmark,
|
|
7775
|
+
updateBenchmark,
|
|
7776
|
+
removeBenchmarkById,
|
|
7554
7777
|
getPropertiesFromBLOB,
|
|
7555
7778
|
getOpSystemFromBLOB,
|
|
7556
7779
|
getAllPropertiesFromBLOB,
|