un-cli 0.0.73 → 0.0.74

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 (4) hide show
  1. package/cmd.txt +1 -1
  2. package/index.html +33 -63
  3. package/index.mjs +14 -7
  4. package/package.json +1 -1
package/cmd.txt CHANGED
@@ -1,2 +1,2 @@
1
- update subnetworks --all --desc
1
+ export subnetworks --all
2
2
  exit
package/index.html CHANGED
@@ -87,12 +87,14 @@
87
87
 
88
88
  cmbService = document.getElementById("cmbService")
89
89
  while (cmbService.firstChild) cmbService.removeChild(cmbService.firstChild)
90
-
90
+
91
+ token = await getToken(parameters);
92
+
93
+ //if we logged in successfully
91
94
  const opt = document.createElement("option")
92
95
  opt.textContent = "(All Services)"
93
96
  cmbService.appendChild (opt)
94
97
 
95
- token = await getToken(parameters);
96
98
  const services = await portal.services()
97
99
  const featureServices = services.services.filter(s => s.type == "FeatureServer")
98
100
  featureServices.forEach(s=> {
@@ -390,16 +392,16 @@ async function loadAttributeRules () {
390
392
  }
391
393
  async function loadSQLLogs () {
392
394
 
393
- //build table
394
- const tblResult = document.getElementById("tblResult");
395
- //clear
396
- while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
397
-
395
+ //build table
396
+ const tblResult = document.getElementById("tblResult");
397
+ //clear
398
+ while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
399
+
398
400
 
399
- parameters.service = cmbService.options[cmbService.selectedIndex].text
400
-
401
-
402
- let mins = document.getElementById("txtAge").value //query logs for the last 30 minutes
401
+ parameters.service = cmbService.options[cmbService.selectedIndex].text
402
+
403
+
404
+ let mins = document.getElementById("txtAge").value //query logs for the last 30 minutes
403
405
 
404
406
 
405
407
  console.log(`Querying cursor sql logs for ${parameters.service} for the last ${mins} minutes ...`)
@@ -407,30 +409,7 @@ while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
407
409
  //startTime is the most recent
408
410
  //endTime is the oldest
409
411
 
410
-
411
-
412
- /*
413
- const topLogCount = 100;
414
- const startTime = Date.now()
415
- const endTime = Date.now() - mins*60*1000
416
- let services = [theService + ".MapServer"]
417
- if (theService == "(All Services)")
418
- services = "*"
419
- let result= await adminLog.query([code], services, topLogCount, startTime ,endTime , "DEBUG")
420
- let jsonRes = await result.json()
421
- let allMessages = [].concat(jsonRes.logMessages)
422
- allMessages = allMessages.filter(m => m.message.indexOf("EndCursor;") > -1)
423
- while (jsonRes.hasMore)
424
- {
425
- //start paging
426
- logger.info(`Aggregating messages... total so far ${allMessages.length} entries but more left, pulling logs between ${new Date(jsonRes.endTime)} and ${new Date(endTime)}`)
427
- result= await adminLog.query([102023], services, pageSize, jsonRes.endTime, endTime, "DEBUG")
428
- jsonRes = await result.json()
429
-
430
- allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("EndCursor;") > -1))
431
- }
432
- */
433
-
412
+
434
413
  //page query the admin log
435
414
  let allMessages = await adminLogQueryWithPaging(mins, parameters.service, [102023], "EndCursor;", "DEBUG")
436
415
 
@@ -472,6 +451,8 @@ while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
472
451
  let i =0;
473
452
 
474
453
  const header = document.createElement("tr");
454
+ const thead = docuemnt.createElement("thead")
455
+ thead.appendChild(header)
475
456
  const cService = document.createElement("th");
476
457
  cService.textContent = "Source"
477
458
  const cTime = document.createElement("th");
@@ -534,7 +515,7 @@ while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
534
515
  const cLog = document.createElement("td");
535
516
  const cLogText = document.createElement("input")
536
517
  cLogText.type = "text"
537
- cLogText.style = "width:500px"
518
+ cLogText.style = "width:800px"
538
519
  cLogText.value = m.message.substr( m.message.indexOf("SQL: ") + 5, m.message.length)
539
520
  cLogText.readOnly= true;
540
521
  cLog.appendChild(cLogText)
@@ -555,12 +536,6 @@ while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
555
536
 
556
537
  })
557
538
 
558
-
559
-
560
-
561
-
562
-
563
-
564
539
  //await populateMessages(allMessages)
565
540
 
566
541
 
@@ -718,27 +693,22 @@ function numberWithCommas(x) {
718
693
  }
719
694
 
720
695
 
721
- /*
722
- const topLogCount = 100;f
723
- const startTime = Date.now()
724
- const endTime = Date.now() - mins*60*1000
725
- let services = [theService + ".MapServer"]
726
- if (theService == "(All Services)")
727
- services = "*"
728
- let result= await adminLog.query([code], services, topLogCount, startTime ,endTime , "DEBUG")
729
- let jsonRes = await result.json()
730
- let allMessages = [].concat(jsonRes.logMessages)
731
- allMessages = allMessages.filter(m => m.message.indexOf("EndCursor;") > -1)
732
- while (jsonRes.hasMore)
733
- {
734
- //start paging
735
- logger.info(`Aggregating messages... total so far ${allMessages.length} entries but more left, pulling logs between ${new Date(jsonRes.endTime)} and ${new Date(endTime)}`)
736
- result= await adminLog.query([102023], services, pageSize, jsonRes.endTime, endTime, "DEBUG")
737
- jsonRes = await result.json()
738
-
739
- allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("EndCursor;") > -1))
740
- }
741
- */
696
+
697
+ function sortTable(table, col, reverse) {
698
+ var tb = table.tBodies[0], // use `<tbody>` to ignore `<thead>` and `<tfoot>` rows
699
+ tr = Array.prototype.slice.call(tb.rows, 0), // put rows into array
700
+ i;
701
+ reverse = -((+reverse) || -1);
702
+ tr = tr.sort(function (a, b) { // sort rows
703
+ return reverse // `-1 *` if want opposite order
704
+ * (a.cells[col].textContent.trim() // using `.textContent.trim()` for test
705
+ .localeCompare(b.cells[col].textContent.trim())
706
+ );
707
+ });
708
+ for(i = 0; i < tr.length; ++i) tb.appendChild(tr[i]); // append each row in order
709
+ }
710
+
711
+
742
712
  </script>
743
713
  </body>
744
714
  </html>
package/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { AdminLog } from "./adminlog.mjs"
7
7
  import logger from "./logger.mjs"
8
8
  import fetch from "node-fetch"
9
9
  //update version
10
- let version = "0.0.73";
10
+ let version = "0.0.74";
11
11
  const GENERATE_TOKEN_TIME_MIN = 30;
12
12
 
13
13
  let rl = null;
@@ -471,11 +471,17 @@ const inputs = {
471
471
  inputDir = file[0].replace("--folder ", "")
472
472
  //create directory if doesn't exists
473
473
  if (!fs.existsSync(inputDir)) fs.mkdirSync(inputDir)
474
-
474
+ let exportedSubnetworks = [];
475
+
475
476
  do {
476
477
 
478
+ let exportedSubnetworksWhereClause = ""
479
+
480
+ if (exportedSubnetworks.length > 0 )
481
+ exportedSubnetworksWhereClause = " AND SUBNETWORKNAME NOT IN (" + exportedSubnetworks.join(",") + ")"
482
+
477
483
  logger.info("Querying all subnetworks that are clean.");
478
- subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=0","domainnetworkname,tiername,subnetworkname");
484
+ subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=0 " + exportedSubnetworksWhereClause,"domainnetworkname,tiername,subnetworkname");
479
485
  logger.info(`Discovered ${subnetworks.features.length} subnetworks that can be exported.`);
480
486
  for (let i = 0; i < subnetworks.features.length; i++) {
481
487
  const f = subnetworks.features[i]
@@ -485,10 +491,10 @@ const inputs = {
485
491
  const fromDate = new Date();
486
492
 
487
493
  const subnetworkResult = await un.exportSubnetworks(v(f.attributes,"domainNetworkName"), v(f.attributes,"tierName"), v(f.attributes,"subnetworkName"),false);
488
-
489
-
494
+
490
495
  //code
491
-
496
+ exportedSubnetworks.push("'" + v(f.attributes,"subnetworkName") + "'")
497
+
492
498
  const toDate = new Date();
493
499
  const timeEnable = toDate.getTime() - fromDate.getTime();
494
500
  subnetworkResult.duration = numberWithCommas(timeEnable) + " ms"
@@ -498,6 +504,7 @@ const inputs = {
498
504
  logger.info("Export subnetwork failed " + JSON.stringify(subnetworkResult))
499
505
  continue;
500
506
  }
507
+
501
508
 
502
509
  //fetch the json and write it to disk
503
510
  const subContent = await fetch(subnetworkResult.url);
@@ -512,7 +519,7 @@ const inputs = {
512
519
 
513
520
  }
514
521
  }
515
- while (subnetworks.features.length > 0)
522
+ while (subnetworks?.features?.length > 0)
516
523
 
517
524
  },
518
525
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "un-cli",
3
- "version": "0.0.73",
3
+ "version": "0.0.74",
4
4
  "description": "Command line interface for working with ArcGIS Utility Network Extension",
5
5
  "main": "index.mjs",
6
6
  "bin": {