Skip to content

Commit

Permalink
Merge pull request #129 from iceljc/features/refine-chat-window
Browse files Browse the repository at this point in the history
refine plugin page
  • Loading branch information
Oceania2018 committed May 13, 2024
2 parents 0eda07e + 9230f72 commit b509134
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions src/routes/page/plugin/plugin-list.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,44 @@
Row,
} from '@sveltestrap/sveltestrap';
import { installPlugin, removePlugin } from '$lib/services/plugin-service';
import { goto } from '$app/navigation';
import Swal from 'sweetalert2/dist/sweetalert2.js';
import "sweetalert2/src/sweetalert2.scss";
/** @type {import('$types').PluginDefModel[]} */
export let plugins;
/**
/**
* @param {string} id
* @param {string} name
* @param {boolean} enable
*/
async function handlePluginStatus(id, enable) {
if (enable) {
await installPlugin(id);
} else {
await removePlugin(id);
}
// refresh page
const path = window.location.pathname;
goto('').then(() => goto(path));
*/
function handlePluginStatus(id, name, enable) {
// @ts-ignore
Swal.fire({
title: 'Are you sure?',
text: `We will ${enable ? 'install' : 'remove'} ${name}.`,
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes',
cancelButtonText: 'No'
// @ts-ignore
}).then((result) => {
if (result.value) {
if (enable) {
installPlugin(id).then(() => {
refresh();
});
} else {
removePlugin(id).then(() => {
refresh();
})
}
}
});
}
function refresh() {
window.location.reload();
}
</script>

Expand Down Expand Up @@ -68,7 +87,7 @@
<a href="page/setting#{item.settings_name}" class="btn btn-soft-success btn-sm">{$_('Settings')}</a>
{/if}
{#if !item.is_core}
<button class="btn btn-soft-warning btn-sm" on:click={() => handlePluginStatus(item.id, !item.enabled)}>{item.enabled ? $_("Remove") : $_("Install")}</button>
<button class="btn btn-soft-warning btn-sm" on:click={() => handlePluginStatus(item.id, item.name, !item.enabled)}>{item.enabled ? $_("Remove") : $_("Install")}</button>
{/if}
</div>
</CardBody>
Expand Down

0 comments on commit b509134

Please sign in to comment.