Skip to content

Commit

Permalink
use less jQuery, more JavaScript Web APIs
Browse files Browse the repository at this point in the history
Web APIs are the newer thing, and we might as well
use them instead of jQuery wherever possible.

unrelated, but also, make a logging statement more
useful, so that you can click on its link and go
straight to the web server
  • Loading branch information
srabraham committed Jan 17, 2025
1 parent 66c9c18 commit 5b56667
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
9 changes: 4 additions & 5 deletions src/ims/element/static/field_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,15 @@ function initFieldReportPage() {
// Set the user-visible error information on the page to the provided string.
function setErrorMessage(msg) {
msg = "Error: (Cause: " + msg + ")"
$("#error_info").removeClass("hidden");
$("#error_text").text(msg);
document.getElementById("error_info").classList.remove("hidden");
document.getElementById("error_text").textContent = msg;
}

function clearErrorMessage() {
$("#error_info").addClass("hidden");
$("#error_text").text("");
document.getElementById("error_info").classList.add("hidden");
document.getElementById("error_text").textContent = "";
}


//
// Load field report
//
Expand Down
19 changes: 11 additions & 8 deletions src/ims/element/static/field_reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ function initFieldReportsTable() {
// Set the user-visible error information on the page to the provided string.
function setErrorMessage(msg) {
msg = "Error: (Cause: " + msg + ")"
$("#error_info").removeClass("hidden");
$("#error_text").text(msg);
document.getElementById("error_info").classList.remove("hidden");
document.getElementById("error_text").textContent = msg;
}

function clearErrorMessage() {
$("#error_info").addClass("hidden");
$("#error_text").text("");
document.getElementById("error_info").classList.add("hidden");
document.getElementById("error_text").textContent = "";
}

//
Expand Down Expand Up @@ -204,15 +204,18 @@ function initDataTables() {
[1, "dsc"],
],
"createdRow": function (row, fieldReport, index) {
$(row).click(function () {
row.addEventListener("click", function (e) {
// Open new context with link
window.open(
urlReplace(url_viewFieldReports) + fieldReport.number,
"Field_Report:" + fieldReport.number,
);
});
$(row).find(".field_report_created")
.attr("title", fullDateTime.format(Date.parse(fieldReport.created)));
})
row.getElementsByClassName("field_report_created")[0]
.setAttribute(
"title",
fullDateTime.format(Date.parse(fieldReport.created)),
);
},
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/ims/element/static/incident.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ function loadIncident(success) {
// Set the user-visible error information on the page to the provided string.
function setErrorMessage(msg) {
msg = "Error: (Cause: " + msg + ")"
$("#error_info").removeClass("hidden");
$("#error_text").text(msg);
document.getElementById("error_info").classList.remove("hidden");
document.getElementById("error_text").textContent = msg;
}

function clearErrorMessage() {
$("#error_info").addClass("hidden");
$("#error_text").text("");
document.getElementById("error_info").classList.add("hidden");
document.getElementById("error_text").textContent = "";
}

function loadAndDisplayIncident(success) {
Expand Down
19 changes: 11 additions & 8 deletions src/ims/element/static/incidents.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ function loadEventFieldReports(success) {
// Set the user-visible error information on the page to the provided string.
function setErrorMessage(msg) {
msg = "Error: (Cause: " + msg + ")"
$("#error_info").removeClass("hidden");
$("#error_text").text(msg);
document.getElementById("error_info").classList.remove("hidden");
document.getElementById("error_text").textContent = msg;
}

function clearErrorMessage() {
$("#error_info").addClass("hidden");
$("#error_text").text("");
document.getElementById("error_info").classList.add("hidden");
document.getElementById("error_text").textContent = "";
}

//
Expand Down Expand Up @@ -299,15 +299,18 @@ function initDataTables() {
[2, "dsc"],
],
"createdRow": function (row, incident, index) {
$(row).click(function () {
row.addEventListener("click", function (e) {
// Open new context with link
window.open(
viewIncidentsURL + incident.number,
"Incident:" + eventID + "#" + incident.number,
);
});
$(row).find(".incident_created")
.attr("title", fullDateTime.format(Date.parse(incident.created)));
})
row.getElementsByClassName("incident_created")[0]
.setAttribute(
"title",
fullDateTime.format(Date.parse(incident.created)),
);
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/ims/run/_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def runServer(cls, config: Configuration, options: ServerOptions) -> None: # no
application = Application(config=config)

cls.log.info(
"Setting up web service at http://{host}:{port}/",
"Setting up web service at http://{host}:{port}/ims/app",
host=host,
port=port,
)
Expand Down

0 comments on commit 5b56667

Please sign in to comment.