wip: delete scans

This commit is contained in:
2023-04-12 20:54:09 +02:00
parent bd4952ee57
commit f105cc0a41
2 changed files with 146 additions and 3 deletions

View File

@@ -22,13 +22,14 @@
import { runnerFilter } from "../shared/tablefilters";
import CardRunner from "../cards/CardRunner.svelte";
import ScanValid from "./ScanValid.svelte";
import DeleteScansModal from "./DeleteScansModal.svelte";
$: selectedScans =
$table?.getSelectedRowModel().rows.map((row) => row.original) || [];
$: selected =
$table?.getSelectedRowModel().rows.map((row) => row.index) || [];
$: active_delete = undefined;
$: delete_active = false;
$: active_deletes = [];
export let current_scans = [];
const scans_promise = ScanService.scanControllerGetAll().then((val) => {
@@ -122,10 +123,12 @@
return renderComponent(TableActions, {
detailsLink: `./${info.row.original.id}`,
deleteAction: () => {
active_delete =
active_deletes = [
current_scans[
current_scans.findIndex((r) => r.id == info.row.original.id)
];
],
];
delete_active = true;
},
deleteEnabled:
store.state.jwtinfo.userdetails.permissions.includes("SCAN:DELETE"),
@@ -153,8 +156,44 @@
getSortedRowModel: getSortedRowModel(),
});
const table = createSvelteTable(options);
async function deleteScan(scan_id) {
// await ScanService.scanControllerRemove(scan_id, true);
current_scans = current_scans.filter((r) => r.id !== scan_id);
// options.update((options) => ({
// ...options,
// data: current_scans,
// }));
// Toastify({
// text: $_("scans-deleted"),
// duration: 3500,
// backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
// }).showToast();
}
async function deleteScans(scan_ids) {
scan_ids.forEach((scan_id) => {
deleteScan(scan_id);
});
// // await ScanService.scanControllerRemove(scan_id, true);
// current_scans = current_scans.filter((r) => r.id !== scan_id);
// options.update((options) => ({
// ...options,
// data: current_scans,
// }));
// Toastify({
// text: $_("scans-deleted"),
// duration: 3500,
// backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
// }).showToast();
}
</script>
<DeleteScansModal
delete_scans={active_deletes}
modal_open={delete_active}
on:delete={(event) => {
deleteScans(event.detail.scans);
}}
/>
{#if store.state.jwtinfo.userdetails.permissions.includes("SCAN:GET")}
{#await scans_promise}
<div