Skip to content

Commit

Permalink
Improve node switching #477
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoudkooi committed Feb 22, 2024
1 parent 94d0ff0 commit 6816342
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG.md

## 7.3.2.2 (2024-02-22)
Fixes / changes:
- Improve cookie switching (Issue #477)
- Minor CSS adjustments for the popup window

## 7.3.2.0 (2024-02-22)
Features:
- Detect links in activity (Classic UI) and convert to hyperlinks. Works on page load, and on mouse over of activity label.
Expand Down
6 changes: 5 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ input {
accent-color: #5274FF;
}

a {
text-decoration: none;
}

div.info{
border:1pt solid #ff8234;
width:50%;
Expand Down Expand Up @@ -300,7 +304,7 @@ div.snucmdurl {

i.fas, i.far{
font-size:9pt;
padding-right: 3px;
margin-right: 3px;
text-align: center;
}

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"short_name": "SN Utils",
"description": "Productivity tools for ServiceNow. (Personal work, not affiliated to ServiceNow)",
"author": "Arnoud Kooi / arnoudkooi.com",
"version": "7.3.2.0",
"version": "7.3.2.2",
"manifest_version": 3,
"permissions": [
"activeTab",
Expand Down
18 changes: 16 additions & 2 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ function prepareJsonTable() {

//Query ServiceNow for nodes
function getNodes() {

let isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (isSafari) {
document.querySelector('#nodemessage').innerText = "Node switching may not work in Safari";
}

var myurl = url + '/api/now/table/sys_cluster_state?sysparm_query=ORDERBYsystem_id&sysparm_fields=system_id,node_id,status,node_type&sysparm_display_value=true&sysparm_exclude_reference_link=true';
snuFetch(g_ck, myurl, null, function (jsn) {
setNodes(jsn.result);
Expand All @@ -170,9 +176,10 @@ function getNodes() {
async function setActiveNode(node) {


await fetch(url + '/example_add_two_numbers.do'); // call a random leightweight page that returns not found, to make browser aware of new node

let response = await fetch(url + '/stats.do');
let statsDo = await response.text();

if (!statsDo.includes('Servlet statistics')) { //after a node switch, sometimes the first call fails. Try again
response = await fetch(url + '/stats.do');
statsDo = await response.text();
Expand Down Expand Up @@ -987,9 +994,16 @@ function setDataTableNodes(nme, node) {
dtNodes.search($(this).val(),true).draw();
}).focus().trigger('keyup');

$('a.setnode').click(function () {
$('a.setnode').click(function (ev) {

ev.currentTarget.innerHTML = "<i class='fas fa-spinner fa-spin' style='color:blue !important;'></i> Switching...";
ev.currentTarget.style.color = "blue";
console.log(ev);
var node = {"nodeId" : this.id, "nodeName" : $(this).attr('data-node') };
setActiveNode(node)



});

$('#waitingnodes').hide();
Expand Down

0 comments on commit 6816342

Please sign in to comment.