Skip to content

Commit 3064bcb

Browse files
committed
Add disable/enable all addons btns and fix InstallRes modal view
1 parent 675be6e commit 3064bcb

4 files changed

Lines changed: 90 additions & 7 deletions

File tree

lang/en-US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@
8585
"select-all": "Select All",
8686
"deselect-all": "Deselect All",
8787
"selected": "Selected",
88-
"disable-all-addons": "Disable all addons"
88+
"enable-all-addons": "Enable All Addons",
89+
"disable-all-addons": "Disable All Addons"
8990
},
9091
"pages": {
9192
"login": {
@@ -130,6 +131,7 @@
130131
"installed": "{amount} Installed Addon"
131132
},
132133
"update-available": "Update Available",
134+
"enable-all-confirm": "Are you sure you want to enable all addons?",
133135
"disable-all-confirm": "Are you sure you want to disable all addons?"
134136
},
135137
"addon-detail": {

lang/tr.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@
8484
"copy": "Kopyala",
8585
"select-all": "Tümünü Seç",
8686
"deselect-all": "Seçimi Kaldır",
87-
"disable-all-addons": "Tüm eklentileri devre dışı bırak",
87+
"enable-all-addons": "Tüm Eklentileri Etkinleştir",
88+
"disable-all-addons": "Tüm Eklentileri Devre Dışı Bırak",
8889
"selected": "Seçildi"
8990
},
9091
"pages": {
@@ -130,6 +131,7 @@
130131
"installed": "{amount} Yüklü Eklenti"
131132
},
132133
"update-available": "Güncelleme Mevcut",
134+
"enable-all-confirm": "Tüm eklentileri etkinleştirmek istediğinizden emin misiniz?",
133135
"disable-all-confirm": "Tüm eklentileri devre dışı bırakmak istediğinizden emin misiniz?"
134136
},
135137
"addon-detail": {

src/lib/components/modals/InstallResourceModal.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
on:click={hide}></button>
2121
</div>
2222
<div class="modal-body">
23-
<div class="list-group list-group-horizontal">
23+
<div class="list-group list-group-horizontal w-100" style="height: 250px;">
2424
<DragAndDropZone
25-
class="list-group-item list-group-item-action w-50 rounded-end-0"
26-
style="height: 250px; cursor: pointer;"
25+
class="list-group-item rounded-end-0 h-100"
26+
style="cursor: pointer; flex: 1;"
2727
icon="fas fa-upload fa-2x"
2828
title={$_('components.modals.install-resource.drag-here')}
2929
accept={$type === 'THEME'
@@ -33,8 +33,8 @@
3333

3434
<a
3535
href="{base}/{$type === 'PLUGIN' ? 'addons' : 'view'}/store"
36-
class="list-group-item list-group-item-action d-flex flex-column align-items-center justify-content-center w-50 text-center"
37-
style="height: 250px;"
36+
class="list-group-item d-flex flex-column align-items-center justify-content-center text-center h-100 text-decoration-none"
37+
style="flex: 1;"
3838
on:click={hide}>
3939
<i class="fas fa-store fa-2x mb-2"></i>
4040
{$_('components.modals.install-resource.install-from-pano-store')}

src/lib/pages/Addons.svelte

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<InstallResourceModal />
22
<AddonStartupErrorModal />
3+
<ConfirmActionModal />
34
<div class="container vstack gap-3">
45
{#if data.failedLogin}
56
<FailedLoginPanoStoreAlert />
@@ -10,6 +11,27 @@
1011
<!-- Action Menu -->
1112
<PageActions middleClasses="d-lg-flex d-none" leftClasses="d-lg-flex d-none">
1213
<div slot="right" class="hstack gap-2">
14+
<div class="btn-group">
15+
<button
16+
type="button"
17+
class="btn btn-link"
18+
aria-label={$_('buttons.enable-all-addons')}
19+
use:tooltip={[$_('buttons.enable-all-addons'), { placement: 'bottom' }]}
20+
on:click={enableAllAddons}
21+
disabled={data.plugins.every((p) => p.status === 'STARTED')}>
22+
<i class="fa-solid fa-play"></i>
23+
</button>
24+
<button
25+
type="button"
26+
class="btn btn-link"
27+
aria-label={$_('buttons.disable-all-addons')}
28+
use:tooltip={[$_('buttons.disable-all-addons'), { placement: 'bottom' }]}
29+
on:click={disableAllAddons}
30+
disabled={data.plugins.every((p) => p.status !== 'STARTED')}>
31+
<i class="fa-solid fa-power-off"></i>
32+
</button>
33+
</div>
34+
1335
<button
1436
type="button"
1537
class="btn btn-secondary"
@@ -220,6 +242,9 @@
220242
show as showConfirmEnablingAddonModal,
221243
setCallback as setCallbackConfirmEnablingAddonModal,
222244
} from '$lib/components/modals/ConfirmEnablingAddonWillCauseMoreEnableModal.svelte';
245+
import ConfirmActionModal, {
246+
show as showConfirmActionModal,
247+
} from '$lib/components/modals/ConfirmActionModal.svelte';
223248
224249
import NoContent from '$lib/components/NoContent.svelte';
225250
import VerifiedStatus from '$lib/components/VerifiedStatus.svelte';
@@ -357,4 +382,58 @@
357382
},
358383
});
359384
}
385+
386+
async function disableAllAddons() {
387+
const activePlugins = data.plugins.filter((p) => p.status === 'STARTED');
388+
if (activePlugins.length === 0) return;
389+
390+
showConfirmActionModal('pages.addons.disable-all-confirm', async () => {
391+
for (const plugin of activePlugins) {
392+
plugin.loading = true;
393+
}
394+
data.plugins = data.plugins;
395+
396+
await Promise.all(
397+
activePlugins.map(
398+
(plugin) =>
399+
new Promise((resolve) => {
400+
ApiUtil.put({
401+
path: `/api/panel/plugins/${plugin.id}`,
402+
body: { status: false },
403+
handler: (body) => resolve(body),
404+
});
405+
}),
406+
),
407+
);
408+
409+
await refreshData();
410+
});
411+
}
412+
413+
async function enableAllAddons() {
414+
const inactivePlugins = data.plugins.filter((p) => p.status !== 'STARTED');
415+
if (inactivePlugins.length === 0) return;
416+
417+
showConfirmActionModal('pages.addons.enable-all-confirm', async () => {
418+
for (const plugin of inactivePlugins) {
419+
plugin.loading = true;
420+
}
421+
data.plugins = data.plugins;
422+
423+
await Promise.all(
424+
inactivePlugins.map(
425+
(plugin) =>
426+
new Promise((resolve) => {
427+
ApiUtil.put({
428+
path: `/api/panel/plugins/${plugin.id}`,
429+
body: { status: true },
430+
handler: (body) => resolve(body),
431+
});
432+
}),
433+
),
434+
);
435+
436+
await refreshData();
437+
});
438+
}
360439
</script>

0 commit comments

Comments
 (0)