|
1 | 1 | <InstallResourceModal /> |
2 | 2 | <AddonStartupErrorModal /> |
| 3 | +<ConfirmActionModal /> |
3 | 4 | <div class="container vstack gap-3"> |
4 | 5 | {#if data.failedLogin} |
5 | 6 | <FailedLoginPanoStoreAlert /> |
|
10 | 11 | <!-- Action Menu --> |
11 | 12 | <PageActions middleClasses="d-lg-flex d-none" leftClasses="d-lg-flex d-none"> |
12 | 13 | <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 | + |
13 | 35 | <button |
14 | 36 | type="button" |
15 | 37 | class="btn btn-secondary" |
|
220 | 242 | show as showConfirmEnablingAddonModal, |
221 | 243 | setCallback as setCallbackConfirmEnablingAddonModal, |
222 | 244 | } from '$lib/components/modals/ConfirmEnablingAddonWillCauseMoreEnableModal.svelte'; |
| 245 | + import ConfirmActionModal, { |
| 246 | + show as showConfirmActionModal, |
| 247 | + } from '$lib/components/modals/ConfirmActionModal.svelte'; |
223 | 248 |
|
224 | 249 | import NoContent from '$lib/components/NoContent.svelte'; |
225 | 250 | import VerifiedStatus from '$lib/components/VerifiedStatus.svelte'; |
|
357 | 382 | }, |
358 | 383 | }); |
359 | 384 | } |
| 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 | + } |
360 | 439 | </script> |
0 commit comments