mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-08-29 04:49:57 +00:00
add cookies support
This commit is contained in:
@ -117,7 +117,6 @@
|
|||||||
data-sortable="true"
|
data-sortable="true"
|
||||||
data-sort-name="base"
|
data-sort-name="base"
|
||||||
data-sort-order="asc"
|
data-sort-order="asc"
|
||||||
data-toggle="table"
|
|
||||||
data-toolbar="#toolbar">
|
data-toolbar="#toolbar">
|
||||||
<thead class="table-primary">
|
<thead class="table-primary">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -539,5 +539,17 @@
|
|||||||
clearInterval(packageInfoAutoReloadTask);
|
clearInterval(packageInfoAutoReloadTask);
|
||||||
packageInfoAutoReloadTask = null; // not really required (?) but lets clear everything
|
packageInfoAutoReloadTask = null; // not really required (?) but lets clear everything
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// set refresh interval
|
||||||
|
for (let refreshEnabled = Cookies.get(`ahriman-${packageInfoAutoReloadButton.id}-refresh-enabled`);
|
||||||
|
!!refreshEnabled;
|
||||||
|
refreshEnabled = undefined) {
|
||||||
|
packageInfoAutoReloadButton.checked = refreshEnabled === "true";
|
||||||
|
}
|
||||||
|
for (let refreshInterval = Cookies.get(`ahriman-${packageInfoAutoReloadButton.id}-refresh-interval`);
|
||||||
|
!!refreshInterval;
|
||||||
|
refreshInterval = undefined) {
|
||||||
|
toggleActiveElement(packageInfoAutoReloadInput, "interval", refreshInterval);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -250,6 +250,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
ready(_ => {
|
ready(_ => {
|
||||||
|
const onCheckFunction = function () {
|
||||||
|
if (packageRemoveButton) {
|
||||||
|
packageRemoveButton.disabled = !getSelection().length;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
document.querySelectorAll("#repositories a").forEach(element => {
|
document.querySelectorAll("#repositories a").forEach(element => {
|
||||||
element.onclick = _ => {
|
element.onclick = _ => {
|
||||||
repository = {
|
repository = {
|
||||||
@ -264,18 +270,16 @@
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
table.on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table", _ => {
|
table.bootstrapTable({
|
||||||
if (packageRemoveButton) {
|
onCheck: onCheckFunction,
|
||||||
packageRemoveButton.disabled = !table.bootstrapTable("getSelections").length;
|
onCheckAll: onCheckFunction,
|
||||||
}
|
onClickRow: (data, row, cell) => {
|
||||||
});
|
|
||||||
table.on("click-row.bs.table", (self, data, row, cell) => {
|
|
||||||
if (0 === cell || "base" === cell) {
|
if (0 === cell || "base" === cell) {
|
||||||
const method = data[0] === true ? "uncheckBy" : "checkBy"; // fck javascript
|
const method = data[0] === true ? "uncheckBy" : "checkBy"; // fck javascript
|
||||||
table.bootstrapTable(method, {field: "id", values: [data.id]});
|
table.bootstrapTable(method, {field: "id", values: [data.id]});
|
||||||
} else showPackageInfo(data.id);
|
} else showPackageInfo(data.id);
|
||||||
});
|
},
|
||||||
table.on("created-controls.bs.table", _ => {
|
onCreatedControls: _ => {
|
||||||
new easepick.create({
|
new easepick.create({
|
||||||
element: document.querySelector(".bootstrap-table-filter-control-timestamp"),
|
element: document.querySelector(".bootstrap-table-filter-control-timestamp"),
|
||||||
css: [
|
css: [
|
||||||
@ -305,8 +309,24 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
onPageChange: (_, size) => { Cookies.set(`ahriman-${table.attr("id")}-page-size`, size); },
|
||||||
|
onUncheck: onCheckFunction,
|
||||||
|
onUncheckAll: onCheckFunction,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// set refresh interval
|
||||||
|
for (let refreshEnabled = Cookies.get(`ahriman-${tableAutoReloadButton.id}-refresh-enabled`);
|
||||||
|
!!refreshEnabled;
|
||||||
|
refreshEnabled = undefined) {
|
||||||
|
tableAutoReloadButton.checked = refreshEnabled === "true";
|
||||||
|
}
|
||||||
|
for (let refreshInterval = Cookies.get(`ahriman-${tableAutoReloadButton.id}-refresh-interval`);
|
||||||
|
!!refreshInterval;
|
||||||
|
refreshInterval = undefined) {
|
||||||
|
toggleActiveElement(tableAutoReloadInput, "interval", refreshInterval);
|
||||||
|
}
|
||||||
|
|
||||||
selectRepository();
|
selectRepository();
|
||||||
{% if autorefresh_intervals %}
|
{% if autorefresh_intervals %}
|
||||||
toggleTableAutoReload();
|
toggleTableAutoReload();
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.4/dist/chart.umd.min.js" crossorigin="anonymous" type="application/javascript"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.4/dist/chart.umd.min.js" crossorigin="anonymous" type="application/javascript"></script>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.5/dist/js.cookie.min.js" crossorigin="anonymous" type="application/javascript"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
async function copyToClipboard(text, button) {
|
async function copyToClipboard(text, button) {
|
||||||
await navigator.clipboard.writeText(text);
|
await navigator.clipboard.writeText(text);
|
||||||
@ -144,21 +146,28 @@
|
|||||||
interval = intervalSelector.querySelector(".active")?.dataset?.interval; // find active element
|
interval = intervalSelector.querySelector(".active")?.dataset?.interval; // find active element
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let intervalId = null;
|
||||||
if (interval) {
|
if (interval) {
|
||||||
if (toggle.checked) {
|
if (toggle.checked) {
|
||||||
// refresh UI
|
// refresh UI
|
||||||
Array.from(intervalSelector.children).forEach(il => {
|
toggleActiveElement(intervalSelector, "interval", interval);
|
||||||
Array.from(il.children).forEach(el => el.classList.remove("active"));
|
|
||||||
});
|
|
||||||
intervalSelector.querySelector(`a[data-interval="${interval}"]`)?.classList?.add("active");
|
|
||||||
// finally create timer task
|
// finally create timer task
|
||||||
return setInterval(callback, interval);
|
intervalId = setInterval(callback, interval);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toggle.checked = false; // no active interval found, disable toggle
|
toggle.checked = false; // no active interval found, disable toggle
|
||||||
}
|
}
|
||||||
|
|
||||||
return null; // return null to assign to keep method sane
|
Cookies.set(`ahriman-${toggle.id}-refresh-enabled`, toggle.checked);
|
||||||
|
Cookies.set(`ahriman-${toggle.id}-refresh-interval`, interval);
|
||||||
|
return intervalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleActiveElement(selector, dataType, value) {
|
||||||
|
Array.from(selector.children).forEach(il => {
|
||||||
|
Array.from(il.children).forEach(el => el.classList.remove("active"));
|
||||||
|
});
|
||||||
|
selector.querySelector(`a[data-${dataType}="${value}"]`)?.classList?.add("active");
|
||||||
}
|
}
|
||||||
|
|
||||||
Date.prototype.toISOStringShort = function() {
|
Date.prototype.toISOStringShort = function() {
|
||||||
|
Reference in New Issue
Block a user