Merge dev

This commit is contained in:
Alex Ling 2022-08-19 12:12:45 +00:00
parent f8c569f204
commit 5bdeca94fe

View File

@ -13,86 +13,78 @@ const component = () => {
if (!data.success) throw new Error(data.error); if (!data.success) throw new Error(data.error);
this.plugins = data.plugins; this.plugins = data.plugins;
let pid = localStorage.getItem("plugin"); let pid = localStorage.getItem('plugin');
if (!pid || !this.plugins.find((p) => p.id === pid)) { if (!pid || !this.plugins.find((p) => p.id === pid)) {
pid = this.plugins[0].id; pid = this.plugins[0].id;
} }
this.pid = pid; this.pid = pid;
this.list(pid); this.list(pid);
}) })
.catch((e) => { .catch((e) => {
alert( alert('danger', `Failed to list the available plugins. Error: ${e}`);
"danger", });
`Failed to list the available plugins. Error: ${e}` },
); pluginChanged() {
}); localStorage.setItem('plugin', this.pid);
}, this.list(this.pid);
pluginChanged() { },
localStorage.setItem("plugin", this.pid); list(pid) {
this.list(this.pid); if (!pid) return;
}, fetch(
list(pid) { `${base_url}api/admin/plugin/subscriptions?${new URLSearchParams({
if (!pid) return; plugin: pid,
fetch( })}`,
`${base_url}api/admin/plugin/subscriptions?${new URLSearchParams( {
{ method: 'GET',
plugin: pid, },
} )
)}`, .then((response) => response.json())
{ .then((data) => {
method: "GET", if (!data.success) throw new Error(data.error);
} this.subscriptions = data.subscriptions;
) })
.then((response) => response.json()) .catch((e) => {
.then((data) => { alert('danger', `Failed to list subscriptions. Error: ${e}`);
if (!data.success) throw new Error(data.error); });
this.subscriptions = data.subscriptions; },
}) renderStrCell(str) {
.catch((e) => { const maxLength = 40;
alert( if (str.length > maxLength)
"danger", return `<td><span>${str.substring(
`Failed to list subscriptions. Error: ${e}` 0,
); maxLength,
}); )}...</span><div uk-dropdown>${str}</div></td>`;
}, return `<td>${str}</td>`;
renderStrCell(str) { },
const maxLength = 40; renderDateCell(timestamp) {
if (str.length > maxLength) return `<td>${moment
return `<td><span>${str.substring( .duration(moment.unix(timestamp).diff(moment()))
0, .humanize(true)}</td>`;
maxLength },
)}...</span><div uk-dropdown>${str}</div></td>`; selected(event, modal) {
return `<td>${str}</td>`; const id = event.currentTarget.getAttribute('sid');
}, this.subscription = this.subscriptions.find((s) => s.id === id);
renderDateCell(timestamp) { UIkit.modal(modal).show();
return `<td>${moment },
.duration(moment.unix(timestamp).diff(moment())) renderFilterRow(ft) {
.humanize(true)}</td>`; const key = ft.key;
}, let type = ft.type;
selected(event, modal) { switch (type) {
const id = event.currentTarget.getAttribute("sid"); case 'number-min':
this.subscription = this.subscriptions.find((s) => s.id === id); type = 'number (minimum value)';
UIkit.modal(modal).show(); break;
}, case 'number-max':
renderFilterRow(ft) { type = 'number (maximum value)';
const key = ft.key; break;
let type = ft.type; case 'date-min':
switch (type) { type = 'minimum date';
case "number-min": break;
type = "number (minimum value)"; case 'date-max':
break; type = 'maximum date';
case "number-max": break;
type = "number (maximum value)"; }
break; let value = ft.value;
case "date-min":
type = "minimum date";
break;
case "date-max":
type = "maximum date";
break;
}
let value = ft.value;
if (ft.type.startsWith('number') && isNaN(value)) value = ''; if (ft.type.startsWith('number') && isNaN(value)) value = '';
else if (ft.type.startsWith('date') && value) else if (ft.type.startsWith('date') && value)