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,30 +13,36 @@ 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.pid = pid;
this.list(pid); this.list(pid);
}) })
.catch((e) => { .catch((e) => {
alert('danger', `Failed to list the available plugins. Error: ${e}`); alert(
"danger",
`Failed to list the available plugins. Error: ${e}`
);
}); });
}, },
pluginChanged() { pluginChanged() {
localStorage.setItem('plugin', this.pid); localStorage.setItem("plugin", this.pid);
this.list(this.pid); this.list(this.pid);
}, },
list(pid) { list(pid) {
if (!pid) return; if (!pid) return;
fetch( fetch(
`${base_url}api/admin/plugin/subscriptions?${new URLSearchParams({ `${base_url}api/admin/plugin/subscriptions?${new URLSearchParams(
plugin: pid,
})}`,
{ {
method: 'GET', plugin: pid,
}, }
)}`,
{
method: "GET",
}
) )
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
@ -44,7 +50,10 @@ const component = () => {
this.subscriptions = data.subscriptions; this.subscriptions = data.subscriptions;
}) })
.catch((e) => { .catch((e) => {
alert('danger', `Failed to list subscriptions. Error: ${e}`); alert(
"danger",
`Failed to list subscriptions. Error: ${e}`
);
}); });
}, },
renderStrCell(str) { renderStrCell(str) {
@ -52,7 +61,7 @@ const component = () => {
if (str.length > maxLength) if (str.length > maxLength)
return `<td><span>${str.substring( return `<td><span>${str.substring(
0, 0,
maxLength, maxLength
)}...</span><div uk-dropdown>${str}</div></td>`; )}...</span><div uk-dropdown>${str}</div></td>`;
return `<td>${str}</td>`; return `<td>${str}</td>`;
}, },
@ -62,7 +71,7 @@ const component = () => {
.humanize(true)}</td>`; .humanize(true)}</td>`;
}, },
selected(event, modal) { selected(event, modal) {
const id = event.currentTarget.getAttribute('sid'); const id = event.currentTarget.getAttribute("sid");
this.subscription = this.subscriptions.find((s) => s.id === id); this.subscription = this.subscriptions.find((s) => s.id === id);
UIkit.modal(modal).show(); UIkit.modal(modal).show();
}, },
@ -70,17 +79,17 @@ const component = () => {
const key = ft.key; const key = ft.key;
let type = ft.type; let type = ft.type;
switch (type) { switch (type) {
case 'number-min': case "number-min":
type = 'number (minimum value)'; type = "number (minimum value)";
break; break;
case 'number-max': case "number-max":
type = 'number (maximum value)'; type = "number (maximum value)";
break; break;
case 'date-min': case "date-min":
type = 'minimum date'; type = "minimum date";
break; break;
case 'date-max': case "date-max":
type = 'maximum date'; type = "maximum date";
break; break;
} }
let value = ft.value; let value = ft.value;