Skip to content
Snippets Groups Projects
Commit c4395f11 authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Update bootstrap to 4.4.1

Remove btn-secondary class on datatables button
btn-outline-secondary shouldn't be added with btn-secondary anymore with
4.4.1

JIRA INFRA-2021 #action In Progress
parent 0b4a061d
No related branches found
No related tags found
No related merge requests found
source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
$(document).ready(function() { $(document).ready(function () {
function group_type_update() { function group_type_update() {
var hosts_selectize = $("#hosts")[0].selectize; var hosts_selectize = $("#hosts")[0].selectize;
if ($("#type option:selected").text() == "STATIC") { if ($("#type option:selected").text() == "STATIC") {
...@@ -10,7 +10,7 @@ $(document).ready(function() { ...@@ -10,7 +10,7 @@ $(document).ready(function() {
} }
// Disable or enable hosts on group type update // Disable or enable hosts on group type update
$("#type").on("change", function() { $("#type").on("change", function () {
group_type_update(); group_type_update();
}); });
...@@ -22,13 +22,13 @@ $(document).ready(function() { ...@@ -22,13 +22,13 @@ $(document).ready(function() {
if ($("#groupForm").length || $("#editGroupForm").length) { if ($("#groupForm").length || $("#editGroupForm").length) {
var groupVarsEditor = CodeMirror.fromTextArea(vars, { var groupVarsEditor = CodeMirror.fromTextArea(vars, {
lineNumbers: true, lineNumbers: true,
mode: "yaml" mode: "yaml",
}); });
groupVarsEditor.setSize(null, 120); groupVarsEditor.setSize(null, 120);
var handle = cmResize(groupVarsEditor, { var handle = cmResize(groupVarsEditor, {
minHeight: 120, minHeight: 120,
resizableWidth: false, resizableWidth: false,
resizableHeight: true resizableHeight: true,
}); });
} }
...@@ -39,7 +39,7 @@ $(document).ready(function() { ...@@ -39,7 +39,7 @@ $(document).ready(function() {
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>", "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
ajax: { ajax: {
url: $SCRIPT_ROOT + "/network/_retrieve_groups", url: $SCRIPT_ROOT + "/network/_retrieve_groups",
type: "POST" type: "POST",
}, },
processing: true, processing: true,
serverSide: true, serverSide: true,
...@@ -52,19 +52,19 @@ $(document).ready(function() { ...@@ -52,19 +52,19 @@ $(document).ready(function() {
columns: [ columns: [
{ {
data: "name", data: "name",
render: function(data, type, row) { render: function (data, type, row) {
// render funtion to create link to group view page // render funtion to create link to group view page
if (data === null) { if (data === null) {
return data; return data;
} }
var url = $SCRIPT_ROOT + "/network/groups/view/" + data; var url = $SCRIPT_ROOT + "/network/groups/view/" + data;
return '<a href="' + url + '">' + data + "</a>"; return '<a href="' + url + '">' + data + "</a>";
} },
}, },
{ {
data: "vars", data: "vars",
orderable: false, orderable: false,
render: function(data, type, row) { render: function (data, type, row) {
if (data === null) { if (data === null) {
return ""; return "";
} }
...@@ -73,24 +73,24 @@ $(document).ready(function() { ...@@ -73,24 +73,24 @@ $(document).ready(function() {
JSON.stringify(data, null, 2) + JSON.stringify(data, null, 2) +
"</pre>" "</pre>"
); );
} },
}, },
{ data: "type" }, { data: "type" },
{ {
data: "children", data: "children",
orderable: false, orderable: false,
render: function(data, type, row) { render: function (data, type, row) {
return data.join(", "); return data.join(", ");
} },
}, },
{ {
data: "hosts", data: "hosts",
orderable: false, orderable: false,
render: function(data, type, row) { render: function (data, type, row) {
return data.join(", "); return data.join(", ");
} },
} },
] ],
}); });
if ($("#groups_table").length) { if ($("#groups_table").length) {
...@@ -99,14 +99,15 @@ $(document).ready(function() { ...@@ -99,14 +99,15 @@ $(document).ready(function() {
{ {
text: "Reset", text: "Reset",
className: "btn-outline-secondary", className: "btn-outline-secondary",
action: function(e, dt, node, conf) { action: function (e, dt, node, conf) {
dt.state.clear(); dt.state.clear();
dt.search("") dt.search("").order([]).draw();
.order([]) },
.draw(); init: function (api, node, config) {
} $(node).removeClass("btn-secondary");
} },
] },
],
}); });
groups_table groups_table
......
$(document).ready(function() { $(document).ready(function () {
function render_host_link(data) { function render_host_link(data) {
// render funtion to create link to Host view page // render funtion to create link to Host view page
if (data === null) { if (data === null) {
...@@ -20,13 +20,13 @@ $(document).ready(function() { ...@@ -20,13 +20,13 @@ $(document).ready(function() {
if ($("#hostForm").length || $("#editHostForm").length) { if ($("#hostForm").length || $("#editHostForm").length) {
var hostVarsEditor = CodeMirror.fromTextArea(ansible_vars, { var hostVarsEditor = CodeMirror.fromTextArea(ansible_vars, {
lineNumbers: true, lineNumbers: true,
mode: "yaml" mode: "yaml",
}); });
hostVarsEditor.setSize(null, 120); hostVarsEditor.setSize(null, 120);
var handle = cmResize(hostVarsEditor, { var handle = cmResize(hostVarsEditor, {
minHeight: 120, minHeight: 120,
resizableWidth: false, resizableWidth: false,
resizableHeight: true resizableHeight: true,
}); });
} }
...@@ -38,7 +38,7 @@ $(document).ready(function() { ...@@ -38,7 +38,7 @@ $(document).ready(function() {
$("#ip").removeClass("is-invalid"); $("#ip").removeClass("is-invalid");
$.getJSON( $.getJSON(
$SCRIPT_ROOT + "/network/_retrieve_first_available_ip/" + network_id, $SCRIPT_ROOT + "/network/_retrieve_first_available_ip/" + network_id,
function(json) { function (json) {
$("#ip").val(json.data); $("#ip").val(json.data);
} }
); );
...@@ -49,13 +49,9 @@ $(document).ready(function() { ...@@ -49,13 +49,9 @@ $(document).ready(function() {
function update_device_type_attributes() { function update_device_type_attributes() {
var device_type = $("#device_type_id option:selected").text(); var device_type = $("#device_type_id option:selected").text();
if (device_type.startsWith("Virtual")) { if (device_type.startsWith("Virtual")) {
$("#random_mac") $("#random_mac").prop("checked", true).change();
.prop("checked", true)
.change();
} else { } else {
$("#random_mac") $("#random_mac").prop("checked", false).change();
.prop("checked", false)
.change();
} }
} }
...@@ -63,7 +59,9 @@ $(document).ready(function() { ...@@ -63,7 +59,9 @@ $(document).ready(function() {
// Empty the field otherwise // Empty the field otherwise
function fill_mac_address() { function fill_mac_address() {
if ($("#random_mac").prop("checked")) { if ($("#random_mac").prop("checked")) {
$.getJSON($SCRIPT_ROOT + "/network/_generate_random_mac", function(json) { $.getJSON($SCRIPT_ROOT + "/network/_generate_random_mac", function (
json
) {
$("#mac").val(json.data.mac); $("#mac").val(json.data.mac);
$("#mac").prop("readonly", true); $("#mac").prop("readonly", true);
}); });
...@@ -101,17 +99,15 @@ $(document).ready(function() { ...@@ -101,17 +99,15 @@ $(document).ready(function() {
// or click a dropdown item // or click a dropdown item
$("#network_id") $("#network_id")
.next(".selectize-control") .next(".selectize-control")
.on("click", function() { .on("click", function () {
var network_id_selectize = $("#network_id")[0].selectize; var network_id_selectize = $("#network_id")[0].selectize;
network_id_selectize.clear(true); network_id_selectize.clear(true);
}); });
// Set the default IP when changing network // Set the default IP when changing network
$("#network_id").on("change", function() { $("#network_id").on("change", function () {
$(this).removeClass("is-invalid"); $(this).removeClass("is-invalid");
$(this) $(this).next(".selectize-control").removeClass("is-invalid");
.next(".selectize-control")
.removeClass("is-invalid");
set_default_ip(); set_default_ip();
}); });
...@@ -121,7 +117,7 @@ $(document).ready(function() { ...@@ -121,7 +117,7 @@ $(document).ready(function() {
update_device_type_attributes(); update_device_type_attributes();
// And change // And change
$("#device_type_id").on("change", function() { $("#device_type_id").on("change", function () {
update_device_type_attributes(); update_device_type_attributes();
}); });
} }
...@@ -132,7 +128,7 @@ $(document).ready(function() { ...@@ -132,7 +128,7 @@ $(document).ready(function() {
} }
// Fill or clear MAC address depending on random_mac checkbox // Fill or clear MAC address depending on random_mac checkbox
$("#random_mac").on("change", function() { $("#random_mac").on("change", function () {
fill_mac_address(); fill_mac_address();
}); });
...@@ -143,7 +139,7 @@ $(document).ready(function() { ...@@ -143,7 +139,7 @@ $(document).ready(function() {
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>", "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
ajax: { ajax: {
url: $SCRIPT_ROOT + "/network/_retrieve_hosts", url: $SCRIPT_ROOT + "/network/_retrieve_hosts",
type: "POST" type: "POST",
}, },
processing: true, processing: true,
serverSide: true, serverSide: true,
...@@ -155,14 +151,14 @@ $(document).ready(function() { ...@@ -155,14 +151,14 @@ $(document).ready(function() {
pageLength: 20, pageLength: 20,
lengthMenu: [ lengthMenu: [
[20, 50, 100], [20, 50, 100],
[20, 50, 100] [20, 50, 100],
], ],
columns: [ columns: [
{ {
data: "name", data: "name",
render: function(data, type, row) { render: function (data, type, row) {
return render_host_link(data); return render_host_link(data);
} },
}, },
{ data: "device_type" }, { data: "device_type" },
{ data: "description", orderable: false }, { data: "description", orderable: false },
...@@ -170,13 +166,13 @@ $(document).ready(function() { ...@@ -170,13 +166,13 @@ $(document).ready(function() {
{ data: "interfaces.0.mac", defaultContent: "", orderable: false }, { data: "interfaces.0.mac", defaultContent: "", orderable: false },
{ {
data: "interfaces.0.network", data: "interfaces.0.network",
render: function(data, type, row) { render: function (data, type, row) {
return render_network_link(data); return render_network_link(data);
}, },
defaultContent: "", defaultContent: "",
orderable: false orderable: false,
} },
] ],
}); });
if ($("#hosts_table").length) { if ($("#hosts_table").length) {
...@@ -185,14 +181,15 @@ $(document).ready(function() { ...@@ -185,14 +181,15 @@ $(document).ready(function() {
{ {
text: "Reset", text: "Reset",
className: "btn-outline-secondary", className: "btn-outline-secondary",
action: function(e, dt, node, conf) { action: function (e, dt, node, conf) {
dt.state.clear(); dt.state.clear();
dt.search("") dt.search("").order([]).draw();
.order([]) },
.draw(); init: function (api, node, config) {
} $(node).removeClass("btn-secondary");
} },
] },
],
}); });
hosts_table hosts_table
......
$(document).ready(function() { $(document).ready(function () {
function render_item_link(data) { function render_item_link(data) {
// render funtion to create link to Item view page // render funtion to create link to Item view page
if (data === null) { if (data === null) {
...@@ -18,14 +18,14 @@ $(document).ready(function() { ...@@ -18,14 +18,14 @@ $(document).ready(function() {
var jira_tag = { var jira_tag = {
type: "lang", type: "lang",
regex: /(TAG-\d+)/g, regex: /(TAG-\d+)/g,
replace: "[$1](https://jira.esss.lu.se/browse/$1)" replace: "[$1](https://jira.esss.lu.se/browse/$1)",
}; };
// Register the extension // Register the extension
showdown.extension("jira_tag", jira_tag); showdown.extension("jira_tag", jira_tag);
var converter = new showdown.Converter({ var converter = new showdown.Converter({
extensions: ["jira_tag"], extensions: ["jira_tag"],
simplifiedAutoLink: true simplifiedAutoLink: true,
}); });
if ($("#commentLivePreview").length) { if ($("#commentLivePreview").length) {
...@@ -33,14 +33,14 @@ $(document).ready(function() { ...@@ -33,14 +33,14 @@ $(document).ready(function() {
$("#commentLivePreview").html(converter.makeHtml($("#body").val())); $("#commentLivePreview").html(converter.makeHtml($("#body").val()));
// Live rendering of markdown comment to HTML // Live rendering of markdown comment to HTML
$("#body").keyup(function(event) { $("#body").keyup(function (event) {
var comment = $(this).val(); var comment = $(this).val();
$("#commentLivePreview").html(converter.makeHtml(comment)); $("#commentLivePreview").html(converter.makeHtml(comment));
}); });
} }
// render existing comments to HTML // render existing comments to HTML
$(".item-comment").each(function() { $(".item-comment").each(function () {
var raw = $(this).html(); var raw = $(this).html();
$(this).html(converter.makeHtml(raw)); $(this).html(converter.makeHtml(raw));
}); });
...@@ -51,18 +51,18 @@ $(document).ready(function() { ...@@ -51,18 +51,18 @@ $(document).ready(function() {
$.ajax({ $.ajax({
url: $SCRIPT_ROOT + "/inventory/items/_generate_excel_file", url: $SCRIPT_ROOT + "/inventory/items/_generate_excel_file",
method: "GET", method: "GET",
success: function(data, status, request) { success: function (data, status, request) {
$modal.modal({ $modal.modal({
backdrop: "static", backdrop: "static",
keyboard: false keyboard: false,
}); });
status_url = request.getResponseHeader("Location"); status_url = request.getResponseHeader("Location");
check_job_status(status_url, $modal); check_job_status(status_url, $modal);
}, },
error: function(jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
$modal.modal("hide"); $modal.modal("hide");
flash_alert(JSON.parse(jqXHR.responseText).message, "danger", false); flash_alert(JSON.parse(jqXHR.responseText).message, "danger", false);
} },
}); });
} }
...@@ -73,7 +73,7 @@ $(document).ready(function() { ...@@ -73,7 +73,7 @@ $(document).ready(function() {
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>", "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
ajax: { ajax: {
url: $SCRIPT_ROOT + "/inventory/_retrieve_items", url: $SCRIPT_ROOT + "/inventory/_retrieve_items",
type: "POST" type: "POST",
}, },
processing: true, processing: true,
serverSide: true, serverSide: true,
...@@ -85,14 +85,14 @@ $(document).ready(function() { ...@@ -85,14 +85,14 @@ $(document).ready(function() {
pageLength: 20, pageLength: 20,
lengthMenu: [ lengthMenu: [
[20, 50, 100], [20, 50, 100],
[20, 50, 100] [20, 50, 100],
], ],
columns: [ columns: [
{ {
data: "ics_id", data: "ics_id",
render: function(data, type, row) { render: function (data, type, row) {
return render_item_link(data); return render_item_link(data);
} },
}, },
{ data: "created_at" }, { data: "created_at" },
{ data: "updated_at" }, { data: "updated_at" },
...@@ -104,11 +104,11 @@ $(document).ready(function() { ...@@ -104,11 +104,11 @@ $(document).ready(function() {
{ data: "status" }, { data: "status" },
{ {
data: "parent", data: "parent",
render: function(data, type, row) { render: function (data, type, row) {
return render_item_link(data); return render_item_link(data);
} },
} },
] ],
}); });
if ($("#items_table").length) { if ($("#items_table").length) {
...@@ -118,21 +118,25 @@ $(document).ready(function() { ...@@ -118,21 +118,25 @@ $(document).ready(function() {
text: text:
'<span class="oi oi-data-transfer-download" title="Export to excel file" aria-hidden="true"></span> Excel', '<span class="oi oi-data-transfer-download" title="Export to excel file" aria-hidden="true"></span> Excel',
className: "btn-outline-secondary", className: "btn-outline-secondary",
action: function(e, dt, node, conf) { action: function (e, dt, node, conf) {
download_excel(); download_excel();
} },
init: function (api, node, config) {
$(node).removeClass("btn-secondary");
},
}, },
{ {
text: "Reset", text: "Reset",
className: "btn-outline-secondary", className: "btn-outline-secondary",
action: function(e, dt, node, conf) { action: function (e, dt, node, conf) {
dt.state.clear(); dt.state.clear();
dt.search("") dt.search("").order([]).draw();
.order([]) },
.draw(); init: function (api, node, config) {
} $(node).removeClass("btn-secondary");
} },
] },
],
}); });
items_table items_table
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment