diff --git a/app/static/js/attributes.js b/app/static/js/attributes.js index fd397b67fa4f487996a6c1cc6b862a1a5e93e4f3..d21e0219e339d713f1d23b8beb195c5a0ab0dcde 100644 --- a/app/static/js/attributes.js +++ b/app/static/js/attributes.js @@ -1,10 +1,10 @@ -$(document).ready(function() { +$(document).ready(function () { var attributes_table = $("#attributes_table").DataTable({ - ajax: function(data, callback, settings) { + ajax: function (data, callback, settings) { var kind = $("li a.nav-link.active").text(); $.getJSON( $SCRIPT_ROOT + "/inventory/_retrieve_attributes/" + kind, - function(json) { + function (json) { callback(json); } ); @@ -15,49 +15,49 @@ $(document).ready(function() { targets: [0], orderable: false, className: "text-center align-middle", - render: function(data, type, row) { + render: function (data, type, row) { // render a checkbox to add/remove the attribute to the user's favorites var checked = data.favorite ? "checked" : ""; return ( '<input type="checkbox" value="' + data.id + '" ' + checked + ">" ); }, - width: "5%" + width: "5%", }, { targets: [1], orderable: false, - render: function(data, type, row) { + render: function (data, type, row) { // render QR code from base64 string return ( '<img class="img-fluid" src="data:image/png;base64,' + data + '">' ); }, - width: "10%" - } + width: "10%", + }, ], - paging: false + paging: false, }); // update the user favorites - $("#attributes_table").on("change", 'input[type="checkbox"]', function() { + $("#attributes_table").on("change", 'input[type="checkbox"]', function () { var kind = $("li a.nav-link.active").text(); $.ajax({ type: "POST", url: $SCRIPT_ROOT + "/inventory/_update_favorites/" + kind, data: JSON.stringify({ id: $(this).val(), - checked: this.checked + checked: this.checked, }), - contentType: "application/json" + contentType: "application/json", }); }); var attributes_favorites_table = $("#attributes_favorites_table").DataTable({ - ajax: function(data, callback, settings) { + ajax: function (data, callback, settings) { $.getJSON( $SCRIPT_ROOT + "/inventory/_retrieve_attributes_favorites", - function(json) { + function (json) { callback(json); } ); @@ -67,15 +67,15 @@ $(document).ready(function() { { targets: [0], orderable: false, - render: function(data, type, row) { + render: function (data, type, row) { // render QR code from base64 string return ( '<img class="img-fluid" src="data:image/png;base64,' + data + '">' ); }, - width: "10%" - } + width: "10%", + }, ], - paging: false + paging: false, }); }); diff --git a/app/static/js/create_item.js b/app/static/js/create_item.js index edb04e5d884a7cc9cbe9becb60efb2112393aeef..098e9130da118f85b9de8f57eb783b3aac59c4ea 100644 --- a/app/static/js/create_item.js +++ b/app/static/js/create_item.js @@ -1,5 +1,5 @@ -$(document).ready(function() { - $.fn.focusWithoutScrolling = function() { +$(document).ready(function () { + $.fn.focusWithoutScrolling = function () { var x = window.scrollX, y = window.scrollY; this.focus(); @@ -15,7 +15,7 @@ $(document).ready(function() { // Prevent enter key to submit the form when scanning a label // and remove the ICS:ics_id: prefix - $("#ics_id").keydown(function(event) { + $("#ics_id").keydown(function (event) { if (event.keyCode == 13) { event.preventDefault(); var value = $(this).val(); @@ -28,7 +28,7 @@ $(document).ready(function() { // Prevent enter key to submit the form when scanning serial number // Focus on the submit button so that scanning the Submit action // will submit the form (due to the CR sent by the scanner) - $("#serial_number").keydown(function(event) { + $("#serial_number").keydown(function (event) { if (event.keyCode == 13) { event.preventDefault(); $("#submit").focusWithoutScrolling(); @@ -36,13 +36,13 @@ $(document).ready(function() { } }); - $("#clear").click(function() { + $("#clear").click(function () { // clear all select fields $("select").val(""); }); // Update the stack member field linked to the host when changing it - $("#host_id").on("change", function() { + $("#host_id").on("change", function () { update_stack_member(); }); }); diff --git a/app/static/js/csentry.js b/app/static/js/csentry.js index 87ba457dd95b6a015c983ca5dbe459084b2797a0..b978aa4eba9a2c36fc9d76e818e0a721efb6a069 100644 --- a/app/static/js/csentry.js +++ b/app/static/js/csentry.js @@ -5,14 +5,11 @@ function flash_alert(message, category) { '<button type="button" class="close" data-dismiss="alert" aria-label="Close">'; htmlString += '<span aria-hidden="true">×</span></button>' + message + "</div>"; - $(htmlString) - .prependTo("#mainContent") - .hide() - .slideDown(); + $(htmlString).prependTo("#mainContent").hide().slideDown(); } function remove_alerts() { - $(".alert").slideUp("normal", function() { + $(".alert").slideUp("normal", function () { $(this).remove(); }); } @@ -33,7 +30,7 @@ function check_job_status(status_url, $modal) { dataType: "json", url: status_url, cache: false, - success: function(data, status, request) { + success: function (data, status, request) { switch (data.status) { case "unknown": $modal.modal("hide"); @@ -58,11 +55,11 @@ function check_job_status(status_url, $modal) { } default: // queued/started/deferred - setTimeout(function() { + setTimeout(function () { check_job_status(status_url, $modal); }, 500); } - } + }, }); } @@ -70,17 +67,13 @@ function check_job_status(status_url, $modal) { function update_selectfield(field_id, data, selected_value) { var $field = $(field_id); $field.empty(); - $.map(data, function(option, index) { + $.map(data, function (option, index) { if (option == "None") { var text = ""; } else { var text = option; } - $field.append( - $("<option></option>") - .attr("value", option) - .text(text) - ); + $field.append($("<option></option>").attr("value", option).text(text)); }); if (selected_value == "") { $field.prop("disabled", true); @@ -98,9 +91,9 @@ function update_stack_member() { $.getJSON( $SCRIPT_ROOT + "/inventory/_retrieve_free_stack_members/" + host_id, { - ics_id: $("#ics_id").val() + ics_id: $("#ics_id").val(), }, - function(json) { + function (json) { update_selectfield( "#stack_member", json.data.stack_members, @@ -111,13 +104,13 @@ function update_stack_member() { ); } -$(document).ready(function() { +$(document).ready(function () { // When an invalid input was submitted, the server // adds the "is-invalid" class to form fields to display // them in red with an error message // When starting to type again, we want to remove the error // message to not confuse the user - $('input[type="text"]').keyup(function(event) { + $('input[type="text"]').keyup(function (event) { $(this).removeClass("is-invalid"); }); diff --git a/app/static/js/domains.js b/app/static/js/domains.js index a8894630f4df9cdfd7fb71a97a129750c2f10304..00bfe8d99a84887a5f682f456f5b9aac81f0101d 100644 --- a/app/static/js/domains.js +++ b/app/static/js/domains.js @@ -1,5 +1,5 @@ -$(document).ready(function() { +$(document).ready(function () { var domains_table = $("#domains_table").DataTable({ - paging: false + paging: false, }); }); diff --git a/app/static/js/edit_item.js b/app/static/js/edit_item.js index 6dd458960d51c20a600f30a5ff87b8169cf3f4d5..5d5f27e163e11c4a90156d2f8bb4710054399965 100644 --- a/app/static/js/edit_item.js +++ b/app/static/js/edit_item.js @@ -1,9 +1,9 @@ -$(document).ready(function() { +$(document).ready(function () { // Populate the stack member field linked to the host on first page load update_stack_member(); // Update the stack member field linked to the host when changing it - $("#host_id").on("change", function() { + $("#host_id").on("change", function () { update_stack_member(); }); }); diff --git a/app/static/js/networks.js b/app/static/js/networks.js index 634c7a153c7a94a8178e72d5a856650af9b0dcfc..04b76376e2d3845718e29a203d002ced193b2adb 100644 --- a/app/static/js/networks.js +++ b/app/static/js/networks.js @@ -1,11 +1,11 @@ -$(document).ready(function() { +$(document).ready(function () { function update_scope_defaults() { // Retrieve available vlans, subnet prefixes and default domain // for the selected network scope and update the linked select fields var scope_id = $("#scope_id").val(); $.getJSON( $SCRIPT_ROOT + "/network/_retrieve_scope_defaults/" + scope_id, - function(json) { + function (json) { update_selectfield( "#vlan_id", json.data.vlans, @@ -29,7 +29,7 @@ $(document).ready(function() { var prefix = $("#prefix").val(); $.getJSON( $SCRIPT_ROOT + "/network/_retrieve_subnets/" + scope_id + "/" + prefix, - function(json) { + function (json) { update_selectfield( "#address", json.data.subnets, @@ -44,7 +44,7 @@ $(document).ready(function() { // Retrieve IPs for the selected subnet // and update the first and last ip select field var address = $("#address").val(); - $.getJSON($SCRIPT_ROOT + "/network/_retrieve_ips/" + address, function( + $.getJSON($SCRIPT_ROOT + "/network/_retrieve_ips/" + address, function ( json ) { update_selectfield("#first_ip", json.data.ips, json.data.selected_first); @@ -63,21 +63,21 @@ $(document).ready(function() { } // Update the default values linked to the scope when changing it - $("#scope_id").on("change", function() { + $("#scope_id").on("change", function () { update_scope_defaults(); }); // Update address select field when changing prefix - $("#prefix").on("change", function() { + $("#prefix").on("change", function () { update_address(); }); // Update first and last ip select field when changing address - $("#address").on("change", function() { + $("#address").on("change", function () { update_gateway_first_and_last_ip(); }); var networks_table = $("#networks_table").DataTable({ - paging: false + paging: false, }); }); diff --git a/app/static/js/profile.js b/app/static/js/profile.js index d358d8deae759b54098019688b6c91d920da3931..7f2e63a1c5b1d5b15b418a7086b753bf6c04ee8d 100644 --- a/app/static/js/profile.js +++ b/app/static/js/profile.js @@ -1,17 +1,17 @@ -$(document).ready(function() { +$(document).ready(function () { var $copyTokenBtn = $("#copyToken"); if ($copyTokenBtn.length) { // Instantiate the clipboard only if the copyToken button exists var clipboard = new Clipboard($copyTokenBtn[0]); // show tooltip "Copied!" on success - clipboard.on("success", function(e) { + clipboard.on("success", function (e) { $copyTokenBtn.tooltip("enable"); $copyTokenBtn.tooltip("show"); }); // disable tooltip when leaving button - $copyTokenBtn.on("mouseleave", function() { + $copyTokenBtn.on("mouseleave", function () { $copyTokenBtn.tooltip("disable"); }); } diff --git a/app/static/js/scopes.js b/app/static/js/scopes.js index 6a0c2519012b7fec5e23fcdd666cf7cc363a18ee..9f321700abb901750af1475ea965454be3fb44b4 100644 --- a/app/static/js/scopes.js +++ b/app/static/js/scopes.js @@ -1,5 +1,5 @@ -$(document).ready(function() { +$(document).ready(function () { var scopes_table = $("#scopes_table").DataTable({ - paging: false + paging: false, }); }); diff --git a/app/static/js/tasks.js b/app/static/js/tasks.js index 32291038ab37e51f15894dc090970a3e92bbb9c1..4f4fda3d43022c740c649a2ec80628d44ff46694 100644 --- a/app/static/js/tasks.js +++ b/app/static/js/tasks.js @@ -1,4 +1,4 @@ -$(document).ready(function() { +$(document).ready(function () { function render_task_link(data) { // render funtion to create link to Task view page if (data === null) { @@ -8,17 +8,17 @@ $(document).ready(function() { return '<a href="' + url + '">' + data + "</a>"; } - $("#allTasks").on("change", function() { + $("#allTasks").on("change", function () { // reload the data from the Ajax source tasks_table.ajax.reload(); }); var tasks_table = $("#tasks_table").DataTable({ - ajax: function(data, callback, settings) { + ajax: function (data, callback, settings) { var allTasks = $("#allTasks").prop("checked"); $.getJSON( $SCRIPT_ROOT + "/task/_retrieve_tasks?all=" + allTasks, - function(json) { + function (json) { callback(json); } ); @@ -27,15 +27,15 @@ $(document).ready(function() { pageLength: 20, lengthMenu: [ [20, 50, 100, -1], - [20, 50, 100, "All"] + [20, 50, 100, "All"], ], order: [[2, "desc"]], columns: [ { data: "id", - render: function(data, type, row) { + render: function (data, type, row) { return render_task_link(data); - } + }, }, { data: "name" }, { data: "created_at" }, @@ -43,22 +43,22 @@ $(document).ready(function() { { data: "status" }, { data: null, - render: function(data, type, row) { + render: function (data, type, row) { // render link to AWX job if (row.awx_job_id === null) { return null; } return '<a href="' + row.awx_job_url + '">' + row.awx_job_id + "</a>"; - } + }, }, { data: "depends_on", - render: function(data, type, row) { + render: function (data, type, row) { return render_task_link(data); - } + }, }, { data: "command" }, - { data: "user" } - ] + { data: "user" }, + ], }); });