Merge branch 'dev' into feature/eslint

This commit is contained in:
Alex Ling 2022-08-19 12:11:00 +00:00
commit f8c569f204

View File

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