alsmanager_lib 3.0.7 → 3.0.9

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 +108 -0
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -2088,6 +2088,110 @@ function getPCPropertiesByConfig(db_used, id_device, id_conf) {
2088
2088
  return query;
2089
2089
  }
2090
2090
  //End Manage PC Properties
2091
+ // Switch/Patch Properties
2092
+ function getSwitchPatchPropertiesSQLite(id_device) {
2093
+ var query = "select d.id as Id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello,";
2094
+ query += "ds.num_ports as NumeroPorte ";
2095
+ query += "from devices d ";
2096
+ query += "left join device_switch ds on d.id = ds.id_device ";
2097
+ query += "where d.id = " + id_device;
2098
+ return query;
2099
+ }
2100
+ function getSwitchPatchPropertiesMySQL(id_device) {
2101
+ var query = "select d.id as Id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello,";
2102
+ query += "ds.num_ports as NumeroPorte ";
2103
+ query += "from devices d ";
2104
+ query += "left join device_switch ds on d.id = ds.id_device ";
2105
+ query += "where d.id = :id_device";
2106
+ return query;
2107
+ }
2108
+ function getSwitchPatchProperties(db_used, id_device) {
2109
+ var query = "";
2110
+ if (db_used) {
2111
+ switch (db_used) {
2112
+ case 'SQLITE':
2113
+ query = getSwitchPatchPropertiesSQLite(id_device);
2114
+ break;
2115
+ case 'MYSQL':
2116
+ query = getSwitchPatchPropertiesMySQL(id_device);
2117
+ break;
2118
+ case 'MYSQL2':
2119
+ query = getSwitchPatchPropertiesSQLite(id_device);
2120
+ break;
2121
+ }
2122
+ }
2123
+ return query;
2124
+ }
2125
+ function createSwitchPatchPropertiesMySQLObj(id_device, dev_prop) {
2126
+ var obj = {};
2127
+ obj.id_prop = dev_prop.id_prop;
2128
+ obj.id_device = id_device;
2129
+ obj.num_ports = dev_prop.num_porte;
2130
+ return obj;
2131
+ }
2132
+ function insertSwitchPatchPropertiesSQLite(id_device, dev_prop) {
2133
+ var query = "insert into device_switch (id_device, num_ports) values ";
2134
+ query += "(" + id_device + ", '" + dev_prop.num_ports + ")";
2135
+ return query;
2136
+ }
2137
+ function insertSwitchPatchPropertiesMySQL() {
2138
+ var query = "insert into device_switch (id_device, num_ports) values ";
2139
+ query += "(:id_device, :num_ports)";
2140
+ }
2141
+ function insertSwitchPatchProperties(db_used, id_device, dev_prop) {
2142
+ var query = "";
2143
+ if (db_used) {
2144
+ switch (db_used) {
2145
+ case 'SQLITE':
2146
+ query = insertSwitchPatchPropertiesSQLite(id_device, dev_prop);
2147
+ break;
2148
+ case 'MYSQL':
2149
+ query = insertSwitchPatchPropertiesMySQL();
2150
+ break;
2151
+ case 'MYSQL2':
2152
+ query = insertSwitchPatchPropertiesSQLite(id_device, dev_prop);
2153
+ break;
2154
+ }
2155
+ }
2156
+ return query;
2157
+ }
2158
+
2159
+ function updateSwitchPatchPropertiesSQLite(id_device, dev_prop) {
2160
+ var query = "update device_pc set ";
2161
+ query += "id_device = " + id_device + ", ";
2162
+ query += "num_ports = " + dev_prop.num_ports + " ";
2163
+ query += "where id_device = " + id_device + " ";
2164
+ query += "and id = " + dev_prop.id_prop;
2165
+ return query;
2166
+ }
2167
+
2168
+ function updateSwitchPatchPropertiesMySQL() {
2169
+ var query = "update device_pc set ";
2170
+ query += "id_device = :id_device, ";
2171
+ query += "num_ports = :num_ports ";
2172
+ query += "where id_device = :id_device ";
2173
+ query += "and id = :id_prop";
2174
+ return query;
2175
+ }
2176
+ function updateSwitchPatchProperties(db_used, id_device, dev_prop) {
2177
+ var query = "";
2178
+ if (db_used) {
2179
+ switch (db_used) {
2180
+ case 'SQLITE':
2181
+ query = updateSwitchPatchPropertiesSQLite(id_device, dev_prop);
2182
+ break;
2183
+ case 'MYSQL':
2184
+ query = updateSwitchPatchPropertiesMySQL();
2185
+ break;
2186
+ case 'MYSQL2':
2187
+ query = updateSwitchPatchPropertiesSQLite(id_device, dev_prop);
2188
+ break;
2189
+ }
2190
+ }
2191
+ return query;
2192
+ }
2193
+ //End Switch/Patch Properties
2194
+
2091
2195
  // Manage Display Part Properties
2092
2196
  function getDisplayPartPropertiesSQLite(id_device) {
2093
2197
  var query = "select d.id as Id, ";
@@ -12990,6 +13094,10 @@ module.exports = {
12990
13094
  updatePCProperties,
12991
13095
  getLastPCPropertiesInserted,
12992
13096
  getPCPropertiesByConfig,
13097
+ getSwitchPatchProperties,
13098
+ createSwitchPatchPropertiesMySQLObj,
13099
+ insertSwitchPatchProperties,
13100
+ updateSwitchPatchProperties,
12993
13101
  existsDisplayProperties,
12994
13102
  getDisplayProperties,
12995
13103
  createDisplayPropertiesMySQLObj,
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.7",
7
+ "version": "3.0.9",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",