@niyamulahsan/create-deskapp 0.0.0-stage → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -2
- package/bin/create.js +136 -0
- package/package.json +14 -4
- package/template/.env +13 -0
- package/template/.env.example +13 -0
- package/template/.vscode/extensions.json +6 -0
- package/template/.vscode/settings.json +37 -0
- package/template/LICENSE +21 -0
- package/template/README.md +29 -0
- package/template/biome.json +99 -0
- package/template/drizzle.config.ts +32 -0
- package/template/gitignore-stub +19 -0
- package/template/package.json +111 -0
- package/template/scripts/build-electron.mjs +55 -0
- package/template/scripts/dev-electron.mjs +53 -0
- package/template/scripts/installer.nsh +14 -0
- package/template/src/config/app.ts +24 -0
- package/template/src/core/api/bindings.generated.ts +23 -0
- package/template/src/core/api/generate.manifest.ts +86 -0
- package/template/src/core/api/registry.ts +48 -0
- package/template/src/core/config.ts +99 -0
- package/template/src/core/database/aggregate.ts +85 -0
- package/template/src/core/database/config.ts +48 -0
- package/template/src/core/database/connection.ts +114 -0
- package/template/src/core/database/migrate-hooks.ts +84 -0
- package/template/src/core/database/paginate.ts +224 -0
- package/template/src/core/database/reset.ts +19 -0
- package/template/src/core/database/seed.ts +169 -0
- package/template/src/core/database/status.ts +32 -0
- package/template/src/core/env.ts +106 -0
- package/template/src/core/facade.ts +59 -0
- package/template/src/core/maker/db/fresh.ts +8 -0
- package/template/src/core/maker/db/generate.ts +11 -0
- package/template/src/core/maker/db/helpers.ts +96 -0
- package/template/src/core/maker/db/migrate.ts +36 -0
- package/template/src/core/maker/db/mod.ts +63 -0
- package/template/src/core/maker/db/module-migrate.ts +53 -0
- package/template/src/core/maker/db/push.ts +21 -0
- package/template/src/core/maker/db/reset.ts +6 -0
- package/template/src/core/maker/db/seed.ts +7 -0
- package/template/src/core/maker/db/status.ts +6 -0
- package/template/src/core/maker/help.ts +66 -0
- package/template/src/core/maker/make/controller.ts +27 -0
- package/template/src/core/maker/make/helpers.ts +93 -0
- package/template/src/core/maker/make/mod.ts +68 -0
- package/template/src/core/maker/make/model.ts +14 -0
- package/template/src/core/maker/make/module.ts +62 -0
- package/template/src/core/maker/make/seeder.ts +21 -0
- package/template/src/core/maker/make/test.ts +30 -0
- package/template/src/core/maker/mod.ts +83 -0
- package/template/src/core/maker/run/mod.ts +112 -0
- package/template/src/core/maker/stub.ts +24 -0
- package/template/src/core/maker/stubs/controller/controller.controller.stub +55 -0
- package/template/src/core/maker/stubs/controller/controller.schema.stub +13 -0
- package/template/src/core/maker/stubs/model/model.stub +8 -0
- package/template/src/core/maker/stubs/seeder/seeder.stub +16 -0
- package/template/src/core/maker/stubs/test/test.stub +7 -0
- package/template/src/core/maker/sync-config.ts +94 -0
- package/template/src/core/utils/password.ts +27 -0
- package/template/src/core/utils/playwright.ts +121 -0
- package/template/src/core/utils/queue.ts +59 -0
- package/template/src/core/utils/scheduler.ts +70 -0
- package/template/src/core/utils/storage.ts +599 -0
- package/template/src/core/utils/validation.ts +35 -0
- package/template/src/database/migrations/sqlite/meta/_journal.json +1 -0
- package/template/src/database/schema.ts +6 -0
- package/template/src/icons/apple-touch-icon.png +0 -0
- package/template/src/icons/deskapp.png +0 -0
- package/template/src/icons/favicon-96x96.png +0 -0
- package/template/src/icons/favicon.ico +0 -0
- package/template/src/icons/favicon.svg +1 -0
- package/template/src/icons/site.webmanifest +21 -0
- package/template/src/icons/tray.png +0 -0
- package/template/src/icons/web-app-manifest-192x192.png +0 -0
- package/template/src/icons/web-app-manifest-512x512.png +0 -0
- package/template/src/main.ts +116 -0
- package/template/src/modules/app/controllers/demo.controller.ts +118 -0
- package/template/src/modules/app/controllers/net.controller.ts +48 -0
- package/template/src/modules/app/controllers/playwright.controller.ts +140 -0
- package/template/src/modules/app/controllers/storage.controller.ts +229 -0
- package/template/src/modules/app/controllers/window.controller.ts +107 -0
- package/template/src/preload.ts +35 -0
- package/template/src/storage/.gitkeep +1 -0
- package/template/src/storage/app/private/.gitkeep +1 -0
- package/template/src/storage/app/private/samples/.gitkeep +1 -0
- package/template/src/storage/app/private/samples/state.json +5 -0
- package/template/src/storage/app/private/uploads/.gitkeep +1 -0
- package/template/src/storage/app/public/.gitkeep +1 -0
- package/template/src/storage/app/tmp/generated/.gitkeep +1 -0
- package/template/src/storage/logs/.gitkeep +0 -0
- package/template/src/storage/logs/app.log +0 -0
- package/template/src/storage/logs/fatal.log +0 -0
- package/template/src/ui/.vscode/extensions.json +3 -0
- package/template/src/ui/index.html +14 -0
- package/template/src/ui/public/icons.svg +24 -0
- package/template/src/ui/src/App.vue +3 -0
- package/template/src/ui/src/app.ts +23 -0
- package/template/src/ui/src/assets/fonts/public-sans/public-sans-latin-ext.woff2 +0 -0
- package/template/src/ui/src/assets/fonts/public-sans/public-sans-latin.woff2 +0 -0
- package/template/src/ui/src/assets/images/deskapp.png +0 -0
- package/template/src/ui/src/assets/images/favicon/favicon.ico +0 -0
- package/template/src/ui/src/assets/scss/custom.scss +186 -0
- package/template/src/ui/src/bindings.d.ts +16 -0
- package/template/src/ui/src/components/Button.vue +32 -0
- package/template/src/ui/src/components/Checkbox.vue +29 -0
- package/template/src/ui/src/components/Input.vue +227 -0
- package/template/src/ui/src/components/Modal.vue +55 -0
- package/template/src/ui/src/components/Spinner.vue +42 -0
- package/template/src/ui/src/components/Switch.vue +65 -0
- package/template/src/ui/src/components/TextArea.vue +121 -0
- package/template/src/ui/src/components/Toast.vue +56 -0
- package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +98 -0
- package/template/src/ui/src/components/datatable/Pagination.vue +125 -0
- package/template/src/ui/src/components/datatable/SelectOpption.vue +35 -0
- package/template/src/ui/src/components/datatable/index.vue +258 -0
- package/template/src/ui/src/env.d.ts +13 -0
- package/template/src/ui/src/global.d.ts +35 -0
- package/template/src/ui/src/helpers/nformatter.ts +10 -0
- package/template/src/ui/src/pages/dashboard/index.vue +687 -0
- package/template/src/ui/src/plugins/gum.ts +549 -0
- package/template/src/ui/src/plugins/gum.ts.bak +683 -0
- package/template/src/ui/src/plugins/pulse.ts +148 -0
- package/template/src/ui/src/router/index.ts +25 -0
- package/template/src/ui/src/stores/example.ts +27 -0
- package/template/src/ui/tsconfig.json +15 -0
- package/template/src/ui/vite.config.ts +38 -0
- package/template/src/window/config.ts +71 -0
- package/template/src/window/dialogs.ts +67 -0
- package/template/src/window/manager.ts +139 -0
- package/template/src/window/native.ts +215 -0
- package/template/tsconfig.json +22 -0
- package/template/vitest.config.ts +34 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="skeleton card border">
|
|
3
|
+
<div class="card-header border-bottom-0 pb-0 px-2 px-sm-3">
|
|
4
|
+
<div class="row align-items-center">
|
|
5
|
+
<div class="col-12 col-sm-6 col-lg-3 col-xl-3 mb-2 mb-lg-0 d-flex">
|
|
6
|
+
<div class="py-2 rounded-1 border bg-custom ps-3 me-2"></div>
|
|
7
|
+
<div class="form-control py-2 bg-custom"></div>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="col-12 col-sm-6 col-lg-4 col-xl-5 mb-2 mb-lg-0">
|
|
10
|
+
<slot name="extra-option"></slot>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="col-12 col-lg-5 col-xl-4">
|
|
13
|
+
<div class="row gx-1">
|
|
14
|
+
<div class="col-2 col-sm-4 col-md-6 col-lg-2 text-start text-lg-end">
|
|
15
|
+
<span class="form-control py-2 bg-custom"></span>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="mb-2 mb-sm-0 text-start col-6 col-sm-6 col-md-4 col-lg-7">
|
|
18
|
+
<span class="form-control py-2 bg-custom"></span>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="col-4 col-sm-2 col-md-2 col-lg-3 text-end">
|
|
21
|
+
<span class="bg-custom form-control py-2"></span>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="card-body py-3 px-2 px-sm-3">
|
|
28
|
+
<div class="table-responsive rounded-1">
|
|
29
|
+
<table class="table table-bordered table-striped table-sm align-middle m-0">
|
|
30
|
+
<thead>
|
|
31
|
+
<tr>
|
|
32
|
+
<th v-for="dt in colCount" :key="`h-${dt}`" class="bg-custom py-2"></th>
|
|
33
|
+
</tr>
|
|
34
|
+
</thead>
|
|
35
|
+
<tbody>
|
|
36
|
+
<tr v-for="r in rowCount" :key="`r-${r}`">
|
|
37
|
+
<td v-for="c in colCount" :key="`c-${r}-${c}`" class="bg-custom py-2"></td>
|
|
38
|
+
</tr>
|
|
39
|
+
</tbody>
|
|
40
|
+
</table>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
<div class="card-footer border-top-0 pt-0 px-2 px-sm-3">
|
|
44
|
+
<div class="row align-items-center">
|
|
45
|
+
<div class="col-12 col-md-5 mb-2 mb-md-0"></div>
|
|
46
|
+
<div class="col-12 col-md-7 text-center text-md-end">
|
|
47
|
+
<span class="form-control bg-custom py-2"></span>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script setup lang="ts">
|
|
55
|
+
import { computed, useAttrs } from "vue";
|
|
56
|
+
|
|
57
|
+
defineOptions({ inheritAttrs: false });
|
|
58
|
+
|
|
59
|
+
const $attrs = useAttrs();
|
|
60
|
+
const colCount = computed(() => Number($attrs.col ?? 1));
|
|
61
|
+
const rowCount = computed(() => Number($attrs.row ?? 1));
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<style lang="scss" scoped>
|
|
65
|
+
table,
|
|
66
|
+
tr,
|
|
67
|
+
th,
|
|
68
|
+
td {
|
|
69
|
+
border-color: #cccccc;
|
|
70
|
+
animation: anim 3s infinite;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.bg-custom {
|
|
74
|
+
animation: anim 3s infinite;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@keyframes anim {
|
|
78
|
+
0% {
|
|
79
|
+
background-color: #efefef;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
25% {
|
|
83
|
+
background-color: #f8f8f8;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
50% {
|
|
87
|
+
background-color: #efefef;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
75% {
|
|
91
|
+
background-color: #f8f8f8;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
100% {
|
|
95
|
+
background-color: #efefef;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="row">
|
|
3
|
+
<div class="col-12 col-md-6 mb-3 mb-md-0">
|
|
4
|
+
<div class="py-2 text-center text-md-start">
|
|
5
|
+
Showing {{ nFormatter(page.from) }} to {{ nFormatter(page.to) }} of {{ nFormatter(page.total) }} entries
|
|
6
|
+
</div>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="col-12 col-md-6">
|
|
9
|
+
<nav :class="['datatable-pagination', `pagination-${variant}`]" aria-label="Page navigation">
|
|
10
|
+
<ul class="pagination justify-content-center justify-content-md-end">
|
|
11
|
+
<!-- First -->
|
|
12
|
+
<li :class="['page-item', { disabled: noPreviousPage }]">
|
|
13
|
+
<button type="button" class="page-link" :aria-disabled="noPreviousPage ? 'true' : 'false'"
|
|
14
|
+
:tabindex="noPreviousPage ? -1 : 0" @click.prevent="!noPreviousPage && change(1)">
|
|
15
|
+
<i class="bi bi-chevron-double-left"></i>
|
|
16
|
+
</button>
|
|
17
|
+
</li>
|
|
18
|
+
|
|
19
|
+
<!-- Prev -->
|
|
20
|
+
<li :class="['page-item', { disabled: noPreviousPage }]">
|
|
21
|
+
<button type="button" class="page-link" :aria-disabled="noPreviousPage ? 'true' : 'false'"
|
|
22
|
+
:tabindex="noPreviousPage ? -1 : 0"
|
|
23
|
+
@click.prevent="!noPreviousPage && change(page.current_page - 1)">
|
|
24
|
+
<i class="bi bi-chevron-left"></i>
|
|
25
|
+
</button>
|
|
26
|
+
</li>
|
|
27
|
+
|
|
28
|
+
<li class="page-item">
|
|
29
|
+
<div class="input-group input-group-sm">
|
|
30
|
+
<Input v-model="page.page" type="text" category="number" topclass="m-0" class="text-center"
|
|
31
|
+
style="width: 100px" @keyup.enter="change(page.page)" />
|
|
32
|
+
</div>
|
|
33
|
+
</li>
|
|
34
|
+
|
|
35
|
+
<li class="page-item">
|
|
36
|
+
<span class="page-link text-nowrap"> of {{ nFormatter(page.last_page) }} </span>
|
|
37
|
+
</li>
|
|
38
|
+
|
|
39
|
+
<!-- Next -->
|
|
40
|
+
<li :class="['page-item', { disabled: noNextPage }]">
|
|
41
|
+
<button type="button" class="page-link" :aria-disabled="noNextPage ? 'true' : 'false'"
|
|
42
|
+
:tabindex="noNextPage ? -1 : 0" @click.prevent="!noNextPage && change(page.current_page + 1)">
|
|
43
|
+
<i class="bi bi-chevron-right"></i>
|
|
44
|
+
</button>
|
|
45
|
+
</li>
|
|
46
|
+
|
|
47
|
+
<!-- Last -->
|
|
48
|
+
<li :class="['page-item', { disabled: noNextPage }]">
|
|
49
|
+
<button type="button" class="page-link" :aria-disabled="noNextPage ? 'true' : 'false'"
|
|
50
|
+
:tabindex="noNextPage ? -1 : 0" @click.prevent="!noNextPage && change(page.last_page)">
|
|
51
|
+
<i class="bi bi-chevron-double-right"></i>
|
|
52
|
+
</button>
|
|
53
|
+
</li>
|
|
54
|
+
</ul>
|
|
55
|
+
</nav>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
|
|
60
|
+
<script setup lang="ts">
|
|
61
|
+
import Input from "@/ui/components/Input.vue";
|
|
62
|
+
import { computed, reactive, watchEffect } from "vue";
|
|
63
|
+
import { formatCompactNumber } from "@/ui/helpers/nformatter";
|
|
64
|
+
|
|
65
|
+
interface PaginationData {
|
|
66
|
+
current_page: number;
|
|
67
|
+
last_page: number;
|
|
68
|
+
per_page: number;
|
|
69
|
+
total: number;
|
|
70
|
+
from: number | null;
|
|
71
|
+
to: number | null;
|
|
72
|
+
path: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface PaginationProps {
|
|
76
|
+
data: PaginationData;
|
|
77
|
+
variant?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const props = withDefaults(defineProps<PaginationProps>(), {
|
|
81
|
+
variant: "dark"
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const emit = defineEmits<(event: "change", value: string | number) => void>();
|
|
85
|
+
|
|
86
|
+
const page = reactive({ page: 1, from: 0, to: 0, total: 0, last_page: 1, current_page: 1 });
|
|
87
|
+
|
|
88
|
+
const noPreviousPage = computed(() => page.current_page - 1 <= 0);
|
|
89
|
+
const noNextPage = computed(() => page.current_page + 1 > page.last_page);
|
|
90
|
+
|
|
91
|
+
const change = (pageNo: string | number) => emit("change", pageNo);
|
|
92
|
+
|
|
93
|
+
const nFormatter = formatCompactNumber;
|
|
94
|
+
|
|
95
|
+
watchEffect(() => {
|
|
96
|
+
page.page = props.data.current_page;
|
|
97
|
+
page.from = props.data.from ?? (props.data.current_page - 1) * props.data.per_page + 1;
|
|
98
|
+
page.to = props.data.to ?? Math.min(props.data.current_page * props.data.per_page, props.data.total);
|
|
99
|
+
page.total = props.data.total;
|
|
100
|
+
page.last_page = props.data.last_page;
|
|
101
|
+
page.current_page = props.data.current_page;
|
|
102
|
+
});
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<style lang="scss" scoped>
|
|
106
|
+
ul.pagination {
|
|
107
|
+
margin: 0;
|
|
108
|
+
|
|
109
|
+
:deep(.page-item.disabled .page-link),
|
|
110
|
+
:deep(.page-link:disabled),
|
|
111
|
+
:deep(.page-link[aria-disabled="true"]) {
|
|
112
|
+
pointer-events: none;
|
|
113
|
+
cursor: not-allowed;
|
|
114
|
+
opacity: 0.5;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.page-link {
|
|
118
|
+
border-radius: 5px !important;
|
|
119
|
+
margin-left: 0;
|
|
120
|
+
border-color: var(--bs-pagination-border-color, #cdcdcd) !important;
|
|
121
|
+
color: inherit;
|
|
122
|
+
box-shadow: none;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="d-flex align-items-center justify-content-center justify-content-md-start mb-2 mb-md-0"
|
|
3
|
+
:class="{ 'd-none': !props.isOptions }">
|
|
4
|
+
Show
|
|
5
|
+
<select
|
|
6
|
+
:value="selectedoption"
|
|
7
|
+
class="form-select shadow-none w-auto mx-2"
|
|
8
|
+
@change="onChange">
|
|
9
|
+
<option v-for="(val, i) in props.option" :key="i" :value="val">{{ val }}</option>
|
|
10
|
+
</select>
|
|
11
|
+
entries
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
interface SelectOptionProps {
|
|
17
|
+
isOptions?: boolean;
|
|
18
|
+
option?: Array<string | number>;
|
|
19
|
+
selectedoption?: string | number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const props = withDefaults(defineProps<SelectOptionProps>(), {
|
|
23
|
+
isOptions: true,
|
|
24
|
+
option: () => []
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits<{ (event: "change", value: string | number): void }>();
|
|
28
|
+
|
|
29
|
+
const onChange = (e: Event) => {
|
|
30
|
+
const target = e.target as HTMLSelectElement;
|
|
31
|
+
emit("change", target.value);
|
|
32
|
+
};
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<style lang="scss" scoped></style>
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="card border">
|
|
3
|
+
<div class="card-header" :class="{ 'd-none': !(props.removable || props.searchable || props.optionable) }">
|
|
4
|
+
<div class="row align-items-center gx-1">
|
|
5
|
+
<div class="col-12 col-md-3">
|
|
6
|
+
<SelectOption :is-options="props.optionable" :option="props.option" :selectedoption="selectedoption"
|
|
7
|
+
@change="handleSizeChange" />
|
|
8
|
+
</div>
|
|
9
|
+
<div class="col-12 col-md-9">
|
|
10
|
+
<slot name="extra-tools"></slot>
|
|
11
|
+
<div class="d-flex align-items-center justify-content-center justify-content-md-end">
|
|
12
|
+
<div v-if="checked.checkcolumn.length > 0" class="me-1" :class="{ 'd-none': !props.removable }">
|
|
13
|
+
<Button type="button" class="btn btn-outline-danger" @click.prevent="remove">
|
|
14
|
+
<i class="bi bi-trash"></i>
|
|
15
|
+
</Button>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="d-flex align-items-center" :class="{ 'd-none': !props.searchable }">
|
|
18
|
+
<Button class="btn btn-outline-secondary rounded-0 rounded-start" type="button" @click="searchMe">
|
|
19
|
+
<i class="bi bi-search"></i>
|
|
20
|
+
</Button>
|
|
21
|
+
<Input v-model="searchdata" type="text" class="w-auto shadow-none rounded-0 rounded-end" topclass="mb-0"
|
|
22
|
+
placeholder="Search..." @keyup.enter="searchMe" @keyup.delete="searchMe" />
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="card-body">
|
|
29
|
+
<slot name="extra"></slot>
|
|
30
|
+
<div class="table-responsive">
|
|
31
|
+
<table
|
|
32
|
+
class="table table-bordered table-striped border-custom table-sm align-middle m-0 datatable no-shrink-table">
|
|
33
|
+
<slot name="customhead"></slot>
|
|
34
|
+
<thead :class="{ 'd-none': slots.customhead }">
|
|
35
|
+
<tr>
|
|
36
|
+
<th class="align-middle" :class="{ 'd-none': !props.removable || !state.current_page }">
|
|
37
|
+
<Checkbox v-model="checked.check" topclass="ms-2" :value="checked.check" :disabled="props.disabled"
|
|
38
|
+
@click="checkAll" />
|
|
39
|
+
</th>
|
|
40
|
+
<th class="text-center align-middle" :class="{ 'd-none': !props.countable }">#</th>
|
|
41
|
+
<slot name="thead"></slot>
|
|
42
|
+
</tr>
|
|
43
|
+
</thead>
|
|
44
|
+
|
|
45
|
+
<slot name="custombody"></slot>
|
|
46
|
+
<tbody :class="{ 'd-none': slots.custombody }">
|
|
47
|
+
<tr v-for="(dt, i) in tableRows" :key="`${dt.id}-${i}`">
|
|
48
|
+
<td class="align-middle" :class="{ 'd-none': !props.removable || !state.current_page }">
|
|
49
|
+
<Checkbox v-model="checked.checkcolumn" topclass="ms-2" :value="dt.id" :disabled="props.disabled"
|
|
50
|
+
@change="updateChecked" />
|
|
51
|
+
</td>
|
|
52
|
+
<td class="text-center align-middle" :class="{ 'd-none': !props.countable }">
|
|
53
|
+
{{
|
|
54
|
+
state.current_page
|
|
55
|
+
? state.per_page * (state.current_page - 1) + (i + 1)
|
|
56
|
+
: i + 1
|
|
57
|
+
}}
|
|
58
|
+
</td>
|
|
59
|
+
<slot name="tbody" :td="dt"></slot>
|
|
60
|
+
</tr>
|
|
61
|
+
</tbody>
|
|
62
|
+
</table>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="card-footer" :class="{ 'd-none': state.total <= state.data.length }">
|
|
66
|
+
<Pagination :data="state" @change="handlePageChange" />
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script setup lang="ts">
|
|
72
|
+
import { debounce } from "lodash-es";
|
|
73
|
+
import SelectOption from "./SelectOpption.vue";
|
|
74
|
+
import Button from "@/ui/components/Button.vue";
|
|
75
|
+
import Input from "@/ui/components/Input.vue";
|
|
76
|
+
import Checkbox from "@/ui/components/Checkbox.vue";
|
|
77
|
+
import Pagination from "./Pagination.vue";
|
|
78
|
+
import { computed, reactive, ref, useSlots, watchEffect } from "vue";
|
|
79
|
+
import { useGum, type GumTransport } from "@/ui/plugins/gum";
|
|
80
|
+
|
|
81
|
+
interface DataRow {
|
|
82
|
+
id: string | number;
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface DataPageState {
|
|
87
|
+
data: DataRow[];
|
|
88
|
+
current_page: number;
|
|
89
|
+
last_page: number;
|
|
90
|
+
per_page: number;
|
|
91
|
+
total: number;
|
|
92
|
+
from: number | null;
|
|
93
|
+
to: number | null;
|
|
94
|
+
path: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface DataTableProps {
|
|
98
|
+
path: string;
|
|
99
|
+
search?: string;
|
|
100
|
+
loop?: DataRow[] | false;
|
|
101
|
+
option?: Array<string | number>;
|
|
102
|
+
removable?: boolean;
|
|
103
|
+
countable?: boolean;
|
|
104
|
+
searchable?: boolean;
|
|
105
|
+
optionable?: boolean;
|
|
106
|
+
disabled?: boolean;
|
|
107
|
+
/** Per-table transport override: "bindings" (SQLite, default from GumPlugin) or "http". */
|
|
108
|
+
transport?: GumTransport;
|
|
109
|
+
/** HTTP transport only: base URL prepended to `path`. */
|
|
110
|
+
baseURL?: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const props = withDefaults(defineProps<DataTableProps>(), {
|
|
114
|
+
search: "",
|
|
115
|
+
loop: false,
|
|
116
|
+
option: () => [10, 25, 50],
|
|
117
|
+
removable: true,
|
|
118
|
+
countable: true,
|
|
119
|
+
searchable: true,
|
|
120
|
+
optionable: true,
|
|
121
|
+
disabled: false
|
|
122
|
+
});
|
|
123
|
+
const gum = useGum();
|
|
124
|
+
|
|
125
|
+
const slots = useSlots();
|
|
126
|
+
|
|
127
|
+
const emit = defineEmits<{ (event: "remove", value: Array<string | number>): void; }>();
|
|
128
|
+
|
|
129
|
+
const state = reactive<DataPageState>({
|
|
130
|
+
data: [],
|
|
131
|
+
current_page: 1,
|
|
132
|
+
last_page: 1,
|
|
133
|
+
per_page: Number(props.option[0]) || 15,
|
|
134
|
+
total: 0,
|
|
135
|
+
from: null,
|
|
136
|
+
to: null,
|
|
137
|
+
path: props.path
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const loading = ref(false);
|
|
141
|
+
|
|
142
|
+
// checkbox select
|
|
143
|
+
let checked = reactive<{ check: boolean; checkcolumn: Array<string | number>; }>({
|
|
144
|
+
check: false,
|
|
145
|
+
checkcolumn: []
|
|
146
|
+
});
|
|
147
|
+
const checkAll = () => {
|
|
148
|
+
if (!checked.check) {
|
|
149
|
+
state.data.forEach((dt: DataRow) => {
|
|
150
|
+
if (!checked.checkcolumn.includes(dt.id)) {
|
|
151
|
+
checked.checkcolumn.push(dt.id);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
checked.checkcolumn = [];
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const updateChecked = () => checked.checkcolumn.length === state.data.length ? (checked.check = true) : (checked.check = false);
|
|
159
|
+
|
|
160
|
+
// remove from parent
|
|
161
|
+
const remove = () => {
|
|
162
|
+
emit("remove", checked.checkcolumn);
|
|
163
|
+
checked.check = false;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// for change data size show
|
|
167
|
+
const selectedoption = ref<string | number | undefined>(Number(props.option[0]));
|
|
168
|
+
const tableRows = computed<DataRow[]>(() => (props.loop ? props.loop : state.data));
|
|
169
|
+
|
|
170
|
+
// search data
|
|
171
|
+
const searchdata = ref(props.search || "");
|
|
172
|
+
const searchMe = debounce(() => {
|
|
173
|
+
load(1);
|
|
174
|
+
}, 500);
|
|
175
|
+
|
|
176
|
+
// fetch directly in-process; no router navigation/scroll restore (gum `navigate: false`)
|
|
177
|
+
const load = async (page?: number) => {
|
|
178
|
+
loading.value = true;
|
|
179
|
+
try {
|
|
180
|
+
const res = await gum.get(props.path, {
|
|
181
|
+
navigate: false,
|
|
182
|
+
transport: props.transport,
|
|
183
|
+
baseURL: props.baseURL,
|
|
184
|
+
query: {
|
|
185
|
+
page: page ?? state.current_page,
|
|
186
|
+
size: selectedoption.value,
|
|
187
|
+
search: searchdata.value
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const envelope = (res?.data ?? {}) as Partial<DataPageState>;
|
|
191
|
+
state.data = envelope.data ?? [];
|
|
192
|
+
state.current_page = Number(envelope.current_page) || 1;
|
|
193
|
+
state.last_page = Number(envelope.last_page) || 1;
|
|
194
|
+
state.per_page = Number(envelope.per_page) || Number(selectedoption.value) || 15;
|
|
195
|
+
state.total = Number(envelope.total) || 0;
|
|
196
|
+
state.from = envelope.from ?? null;
|
|
197
|
+
state.to = envelope.to ?? null;
|
|
198
|
+
if (envelope.path) state.path = envelope.path;
|
|
199
|
+
checked.checkcolumn = [];
|
|
200
|
+
checked.check = false;
|
|
201
|
+
} finally {
|
|
202
|
+
loading.value = false;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const handleSizeChange = (value: string | number) => {
|
|
207
|
+
selectedoption.value = value;
|
|
208
|
+
load(1);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const handlePageChange = (pageNo: string | number) => {
|
|
212
|
+
let p = parseInt(String(pageNo), 10);
|
|
213
|
+
if (Number.isNaN(p) || p < 1) p = 1;
|
|
214
|
+
if (p > state.last_page) p = state.last_page;
|
|
215
|
+
load(p);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// watch instance
|
|
219
|
+
watchEffect(() => {
|
|
220
|
+
if (props.option.length) {
|
|
221
|
+
const match = props.option.find((x) => Number(x) === Number(state.per_page)) ?? props.option[0];
|
|
222
|
+
selectedoption.value = match;
|
|
223
|
+
}
|
|
224
|
+
searchdata.value = props.search || "";
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// initial + subsequent loads when path changes
|
|
228
|
+
watchEffect(() => {
|
|
229
|
+
if (props.path) load();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
defineExpose({ load, state, loading });
|
|
233
|
+
</script>
|
|
234
|
+
|
|
235
|
+
<style lang="scss" scoped>
|
|
236
|
+
.border-custom {
|
|
237
|
+
border-color: var(--dk-table-border, #cccccc) !important;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.no-shrink-table th,
|
|
241
|
+
.no-shrink-table td {
|
|
242
|
+
white-space: nowrap;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* By default (large screens and up) do not force a min-width:
|
|
246
|
+
allow table to size normally so no horizontal scrollbar on large screens */
|
|
247
|
+
@media (min-width: 992px) {
|
|
248
|
+
.no-shrink-table {
|
|
249
|
+
min-width: 0;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@media (max-width: 991.98px) {
|
|
254
|
+
.no-shrink-table {
|
|
255
|
+
min-width: 1000px;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare const md: any & {
|
|
4
|
+
__invoke: (name: string, ...args: unknown[]) => Promise<unknown>;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
/** @deprecated alias for `md` (kept for compatibility) */
|
|
8
|
+
declare const bindings: typeof md;
|
|
9
|
+
|
|
10
|
+
interface Window {
|
|
11
|
+
md: typeof md;
|
|
12
|
+
bindings: typeof bindings;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Globals for untyped dependencies.
|
|
5
|
+
*
|
|
6
|
+
* - `*.vue`: single-file components resolved by @vitejs/plugin-vue; declare
|
|
7
|
+
* them here so arbitrary `.vue` imports type-check.
|
|
8
|
+
* - `lodash-es`: ships without types; only a few helpers are imported, so we
|
|
9
|
+
* declare just those.
|
|
10
|
+
*
|
|
11
|
+
* NOTE: keep this file a global *script* (no top-level import/export).
|
|
12
|
+
* Adding `export {}` turns `declare module` into module augmentation, which
|
|
13
|
+
* requires the target module to already have types and breaks these shims.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
declare module "*.vue" {
|
|
17
|
+
import type { DefineComponent } from "vue";
|
|
18
|
+
|
|
19
|
+
const component: DefineComponent<{}, {}, any>;
|
|
20
|
+
export default component;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare module "lodash-es" {
|
|
24
|
+
export function debounce<T extends (...args: any[]) => any>(fn: T, wait?: number): T;
|
|
25
|
+
export function throttle<T extends (...args: any[]) => any>(
|
|
26
|
+
fn: T,
|
|
27
|
+
wait?: number
|
|
28
|
+
): T & {
|
|
29
|
+
cancel: () => void;
|
|
30
|
+
flush: () => void;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module "luxon";
|
|
35
|
+
declare module "bootstrap/js/dist/toast.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const compactFormatter = new Intl.NumberFormat("en", {
|
|
2
|
+
notation: "compact",
|
|
3
|
+
maximumFractionDigits: 1
|
|
4
|
+
});
|
|
5
|
+
|
|
6
|
+
export function formatCompactNumber(value: number): string | number {
|
|
7
|
+
if (!Number.isFinite(value)) return String(value);
|
|
8
|
+
if (Math.abs(value) < 1000) return value;
|
|
9
|
+
return compactFormatter.format(value).replace(/\s/g, "");
|
|
10
|
+
}
|