@tager/admin-files 0.0.7 → 1.0.1
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/dist/constants/paths.d.ts +4 -4
- package/dist/constants/routes.d.ts +3 -3
- package/dist/dev/App.vue.d.ts +6 -0
- package/dist/dev/config.d.ts +2 -0
- package/dist/dev/env.d.ts +1 -0
- package/dist/dev/main.d.ts +3 -0
- package/dist/index.mjs +315 -0
- package/dist/locales/apply.d.ts +1 -0
- package/dist/locales/en.d.ts +18 -19
- package/dist/locales/ru.d.ts +2 -3
- package/dist/main.d.ts +3 -3
- package/dist/services/requests.d.ts +16 -16
- package/dist/typings/model.d.ts +14 -14
- package/dist/utils/paths.d.ts +4 -4
- package/dist/views/FilesForm/FilesForm.helpers.d.ts +2 -2
- package/dist/views/FilesForm/FilesForm.vue.d.ts +23 -50
- package/dist/views/FilesForm/index.d.ts +1 -1
- package/dist/views/FilesList/FilesList.vue.d.ts +19 -37
- package/dist/views/FilesList/index.d.ts +1 -1
- package/package.json +47 -49
- package/src/constants/routes.ts +10 -10
- package/src/dev/App.vue +38 -0
- package/src/dev/config.ts +23 -0
- package/src/dev/env.ts +17 -0
- package/src/dev/main.ts +36 -0
- package/src/locales/apply.ts +9 -0
- package/src/locales/en.ts +1 -3
- package/src/locales/ru.ts +2 -4
- package/src/main.ts +2 -6
- package/src/services/requests.ts +2 -2
- package/src/typings/model.ts +1 -1
- package/src/views/FilesForm/FilesForm.helpers.ts +1 -1
- package/src/views/FilesForm/FilesForm.vue +32 -26
- package/src/views/FilesList/FilesList.vue +51 -49
- package/README.md +0 -1
- package/dist/dev.d.ts +0 -1
- package/dist/index.esm.js +0 -738
- package/dist/index.umd.js +0 -750
- package/src/dev.ts +0 -41
- package/src/typings/sfc.d.ts +0 -12
- package/src/typings/shims-tsx.d.ts +0 -13
- package/src/typings/shims-vue.d.ts +0 -11
- package/src/views/App.vue +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tager/admin-files",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -10,63 +10,61 @@
|
|
|
10
10
|
"typings",
|
|
11
11
|
"src"
|
|
12
12
|
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./dist/index.mjs"
|
|
15
|
+
},
|
|
13
16
|
"scripts": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
17
|
+
"build:js": "vite build",
|
|
18
|
+
"build:package": "yarn build:js && (yarn emit-declarations || echo 'vue-tsc: type errors found, declarations emitted anyway')",
|
|
19
|
+
"emit-declarations": "vue-tsc --project tsconfig.json --emitDeclarationOnly",
|
|
20
|
+
"start": "vite",
|
|
21
|
+
"prepare": "yarn build:package",
|
|
22
|
+
"tager:update": "yarn upgrade --latest --scope @tager",
|
|
23
|
+
"lint": "eslint .",
|
|
24
|
+
"format": "prettier --write src"
|
|
20
25
|
},
|
|
21
26
|
"dependencies": {
|
|
22
|
-
"filesize": "^
|
|
27
|
+
"filesize": "^9.0.11",
|
|
28
|
+
"lodash.isequal": "^4.5.0",
|
|
23
29
|
"lodash.kebabcase": "^4.1.1",
|
|
30
|
+
"lodash.pick": "^4.4.0",
|
|
24
31
|
"path-to-regexp": "^6.1.0"
|
|
25
32
|
},
|
|
26
33
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"@tager/admin-layout": "^0.
|
|
30
|
-
"@tager/admin-services": "^0.
|
|
31
|
-
"@tager/admin-ui": "^0.
|
|
32
|
-
"@types/
|
|
33
|
-
"@types/
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@vue/
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"sass-loader": "^9.0.3",
|
|
55
|
-
"typescript": "~3.9.6",
|
|
56
|
-
"vue": "2.6.x",
|
|
57
|
-
"vue-docgen-web-types": "^0.1.6",
|
|
58
|
-
"vue-router": "^3.5.1",
|
|
59
|
-
"vue-template-compiler": "^2.6.11"
|
|
34
|
+
"@eslint/js": "^9.39.5",
|
|
35
|
+
"@tager/admin-dynamic-field": "^1.0.0",
|
|
36
|
+
"@tager/admin-layout": "^1.0.0",
|
|
37
|
+
"@tager/admin-services": "^1.0.0",
|
|
38
|
+
"@tager/admin-ui": "^1.0.1",
|
|
39
|
+
"@types/filesize": "^5.0.0",
|
|
40
|
+
"@types/lodash.isequal": "^4.5.6",
|
|
41
|
+
"@types/lodash.pick": "^4.4.7",
|
|
42
|
+
"@types/node": "16.x",
|
|
43
|
+
"@vitejs/plugin-vue": "^5.2.4",
|
|
44
|
+
"@vue/eslint-config-typescript": "^14.9.0",
|
|
45
|
+
"core-js": "^3.22.3",
|
|
46
|
+
"eslint": "^9.39.5",
|
|
47
|
+
"eslint-config-prettier": "^10.1.8",
|
|
48
|
+
"eslint-import-resolver-typescript": "^4.4.5",
|
|
49
|
+
"eslint-plugin-import": "^2.32.0",
|
|
50
|
+
"eslint-plugin-vue": "^10.12.0",
|
|
51
|
+
"globals": "^16.5.0",
|
|
52
|
+
"prettier": "^3.9.10",
|
|
53
|
+
"sass": "^1.51.0",
|
|
54
|
+
"sass-loader": "^12.6.0",
|
|
55
|
+
"typescript": "^5.9.3",
|
|
56
|
+
"vite": "^6.4.5",
|
|
57
|
+
"vue": "^3.2.31",
|
|
58
|
+
"vue-eslint-parser": "^10.4.1",
|
|
59
|
+
"vue-router": "^4.0.14",
|
|
60
|
+
"vue-tsc": "^3.3.14"
|
|
60
61
|
},
|
|
61
62
|
"peerDependencies": {
|
|
62
|
-
"@tager/admin-layout": "
|
|
63
|
-
"@tager/admin-services": "
|
|
64
|
-
"@tager/admin-ui": "
|
|
65
|
-
"
|
|
66
|
-
"vue": "
|
|
67
|
-
},
|
|
68
|
-
"resolutions": {
|
|
69
|
-
"prettier": "2.x"
|
|
63
|
+
"@tager/admin-layout": "^1.0.0",
|
|
64
|
+
"@tager/admin-services": "^1.0.0",
|
|
65
|
+
"@tager/admin-ui": "^1.0.1",
|
|
66
|
+
"vue": "^3.2.31",
|
|
67
|
+
"vue-router": "^4.0.14"
|
|
70
68
|
},
|
|
71
69
|
"publishConfig": {
|
|
72
70
|
"access": "public"
|
package/src/constants/routes.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RouteRecordRaw } from 'vue-router';
|
|
2
2
|
|
|
3
3
|
import FilesList from '../views/FilesList';
|
|
4
4
|
import FilesForm from '../views/FilesForm';
|
|
5
5
|
|
|
6
6
|
import { FILES_ROUTE_PATHS } from './paths';
|
|
7
7
|
|
|
8
|
-
export const FILES_LIST_ROUTE:
|
|
8
|
+
export const FILES_LIST_ROUTE: RouteRecordRaw = {
|
|
9
9
|
path: FILES_ROUTE_PATHS.FILES_LIST,
|
|
10
10
|
component: FilesList,
|
|
11
11
|
name: 'Files List',
|
|
12
12
|
meta: {
|
|
13
|
-
getBreadcrumbs: (route,
|
|
14
|
-
{ url: '/', text: t('files:home') },
|
|
15
|
-
{ url: route.path, text: t('files:filesList') },
|
|
13
|
+
getBreadcrumbs: (route, i18n) => [
|
|
14
|
+
{ url: '/', text: i18n.t('files:home') },
|
|
15
|
+
{ url: route.path, text: i18n.t('files:filesList') },
|
|
16
16
|
],
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const FILES_FORM_ROUTE:
|
|
20
|
+
export const FILES_FORM_ROUTE: RouteRecordRaw = {
|
|
21
21
|
path: FILES_ROUTE_PATHS.FILES_FORM,
|
|
22
22
|
component: FilesForm,
|
|
23
23
|
name: 'Files Form',
|
|
24
24
|
meta: {
|
|
25
|
-
getBreadcrumbs: (route,
|
|
26
|
-
{ url: '/', text: t('files:home') },
|
|
27
|
-
{ url: FILES_LIST_ROUTE.path, text: t('files:filesList') },
|
|
28
|
-
{ url: route.path, text: t('files:filesForm') },
|
|
25
|
+
getBreadcrumbs: (route, i18n) => [
|
|
26
|
+
{ url: '/', text: i18n.t('files:home') },
|
|
27
|
+
{ url: FILES_LIST_ROUTE.path, text: i18n.t('files:filesList') },
|
|
28
|
+
{ url: route.path, text: i18n.t('files:filesForm') },
|
|
29
29
|
],
|
|
30
30
|
},
|
|
31
31
|
};
|
package/src/dev/App.vue
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PageLayout :sidebar-menu-list="sidebarMenuList">
|
|
3
|
+
<router-view/>
|
|
4
|
+
</PageLayout>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import {defineComponent} from 'vue';
|
|
9
|
+
|
|
10
|
+
import {type MenuItemType, PageLayout} from "@tager/admin-layout";
|
|
11
|
+
import {ViewListIcon} from "@tager/admin-ui";
|
|
12
|
+
import {useI18n} from "@tager/admin-services";
|
|
13
|
+
|
|
14
|
+
import {getFilesListUrl} from '../utils/paths';
|
|
15
|
+
|
|
16
|
+
export default defineComponent({
|
|
17
|
+
name: 'App',
|
|
18
|
+
components: {
|
|
19
|
+
PageLayout,
|
|
20
|
+
},
|
|
21
|
+
setup() {
|
|
22
|
+
const i18n = useI18n();
|
|
23
|
+
|
|
24
|
+
const sidebarMenuList: Array<MenuItemType> = [
|
|
25
|
+
{
|
|
26
|
+
id: 'files',
|
|
27
|
+
text: i18n.t('files:files'),
|
|
28
|
+
icon: ViewListIcon,
|
|
29
|
+
children: [{text: i18n.t('files:files'), url: getFilesListUrl()}],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
sidebarMenuList,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AppConfigType } from '@tager/admin-services';
|
|
2
|
+
|
|
3
|
+
export const OZITAG_CONFIG: AppConfigType = {
|
|
4
|
+
APP_NAME: 'OZiTAG_ADMIN',
|
|
5
|
+
TITLE_TEMPLATE: 'OZiTAG Admin - {{title}}',
|
|
6
|
+
LANGUAGE: 'EN',
|
|
7
|
+
BRAND: {
|
|
8
|
+
small: {
|
|
9
|
+
logo: 'logo-small.svg',
|
|
10
|
+
},
|
|
11
|
+
large: {
|
|
12
|
+
logo: 'logo.svg',
|
|
13
|
+
label: 'OZiTAG',
|
|
14
|
+
'label-color': '#DD6900',
|
|
15
|
+
},
|
|
16
|
+
subtitle: '',
|
|
17
|
+
},
|
|
18
|
+
SPLASH_SCREEN: {
|
|
19
|
+
enabled: true,
|
|
20
|
+
logo: 'logo-white.svg',
|
|
21
|
+
background: '#1e1e1e',
|
|
22
|
+
},
|
|
23
|
+
};
|
package/src/dev/env.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { initializeEnvironment } from '@tager/admin-services';
|
|
2
|
+
|
|
3
|
+
export function populateEnvironment() {
|
|
4
|
+
initializeEnvironment({
|
|
5
|
+
publicPath: import.meta.env.VUE_APP_PUBLIC_PATH,
|
|
6
|
+
appEnv: import.meta.env.VUE_APP_ENV,
|
|
7
|
+
apiUrl: import.meta.env.VUE_APP_API_URL,
|
|
8
|
+
accessToken: import.meta.env.VUE_APP_ACCESS_TOKEN,
|
|
9
|
+
websiteUrl: import.meta.env.VUE_APP_WEBSITE_URL,
|
|
10
|
+
websiteButtonUrl: import.meta.env.VUE_APP_WEBSITE_BUTTON_URL,
|
|
11
|
+
sentryDsn: import.meta.env.VUE_APP_SENTRY_DSN,
|
|
12
|
+
sentryEnv: import.meta.env.VUE_APP_SENTRY_ENVIRONMENT,
|
|
13
|
+
baseUrl: import.meta.env.BASE_URL,
|
|
14
|
+
nodeEnv: import.meta.env.MODE,
|
|
15
|
+
version: import.meta.env.VUE_APP_VERSION,
|
|
16
|
+
});
|
|
17
|
+
}
|
package/src/dev/main.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {createApp} from 'vue';
|
|
2
|
+
|
|
3
|
+
import {configStore, i18n, i18nPlugin} from '@tager/admin-services';
|
|
4
|
+
import {createRouter} from '@tager/admin-layout';
|
|
5
|
+
import '@tager/admin-ui/css';
|
|
6
|
+
import '@tager/admin-layout/css';
|
|
7
|
+
import '@tager/admin-dynamic-field/css';
|
|
8
|
+
|
|
9
|
+
import {applyTranslations} from '../locales/apply';
|
|
10
|
+
import {FILES_LIST_ROUTE, FILES_FORM_ROUTE} from '../constants/routes';
|
|
11
|
+
|
|
12
|
+
import {OZITAG_CONFIG} from './config';
|
|
13
|
+
import App from './App.vue';
|
|
14
|
+
import {populateEnvironment} from './env';
|
|
15
|
+
|
|
16
|
+
populateEnvironment();
|
|
17
|
+
|
|
18
|
+
configStore.setConfig(OZITAG_CONFIG);
|
|
19
|
+
|
|
20
|
+
const router = createRouter(
|
|
21
|
+
{
|
|
22
|
+
routes: [FILES_LIST_ROUTE, FILES_FORM_ROUTE],
|
|
23
|
+
},
|
|
24
|
+
{useTitleSync: false}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const app = createApp(App);
|
|
28
|
+
|
|
29
|
+
app.use(router);
|
|
30
|
+
app.use(i18nPlugin);
|
|
31
|
+
|
|
32
|
+
applyTranslations();
|
|
33
|
+
|
|
34
|
+
i18n.init({debug: true, lng: 'ru'}).then(() => {
|
|
35
|
+
app.mount('#app');
|
|
36
|
+
});
|
package/src/locales/en.ts
CHANGED
package/src/locales/ru.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import EN from './en';
|
|
1
|
+
import {EN} from './en';
|
|
2
2
|
|
|
3
|
-
const RU: typeof EN = {
|
|
3
|
+
export const RU: typeof EN = {
|
|
4
4
|
home: 'Главная',
|
|
5
5
|
success: 'Успех',
|
|
6
6
|
error: 'Ошибка',
|
|
@@ -19,5 +19,3 @@ const RU: typeof EN = {
|
|
|
19
19
|
delete: 'Удалить',
|
|
20
20
|
add: 'Добавить',
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
export default RU;
|
package/src/main.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { applyTranslations } from './locales/apply';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import RU from './locales/ru';
|
|
5
|
-
|
|
6
|
-
i18n.addTranslations('en', 'files', EN);
|
|
7
|
-
i18n.addTranslations('ru', 'files', RU);
|
|
3
|
+
applyTranslations();
|
|
8
4
|
|
|
9
5
|
export * from './constants/routes';
|
|
10
6
|
export * from './utils/paths';
|
package/src/services/requests.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { request, ResponseBody } from '@tager/admin-services';
|
|
1
|
+
import { request, type ResponseBody } from '@tager/admin-services';
|
|
2
2
|
|
|
3
|
-
import { FileModel } from '../typings/model';
|
|
3
|
+
import { type FileModel } from '../typings/model';
|
|
4
4
|
|
|
5
5
|
export function getFilesList(params?: {
|
|
6
6
|
query?: string;
|
package/src/typings/model.ts
CHANGED
|
@@ -1,50 +1,58 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<Page :title="$i18n.t('files:fileCreation')">
|
|
3
3
|
<form novalidate @submit.prevent>
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/>
|
|
11
|
-
</template>
|
|
4
|
+
<FormFieldFileInput
|
|
5
|
+
v-model:value="values.file"
|
|
6
|
+
:error="errors.file"
|
|
7
|
+
:label="$i18n.t('files:file')"
|
|
8
|
+
name="file"
|
|
9
|
+
/>
|
|
12
10
|
</form>
|
|
13
11
|
|
|
14
|
-
<template
|
|
12
|
+
<template #footer>
|
|
15
13
|
<FormFooter
|
|
16
14
|
:back-href="getFilesListUrl()"
|
|
17
|
-
:on-submit="submitForm"
|
|
18
15
|
:is-submitting="isSubmitting"
|
|
19
16
|
:is-creation="true"
|
|
20
17
|
submit-label="Добавить"
|
|
18
|
+
@submit="submitForm"
|
|
21
19
|
/>
|
|
22
20
|
</template>
|
|
23
|
-
</
|
|
21
|
+
</Page>
|
|
24
22
|
</template>
|
|
25
23
|
|
|
26
24
|
<script lang="ts">
|
|
27
|
-
import { defineComponent } from '
|
|
28
|
-
import {
|
|
25
|
+
import { defineComponent, ref } from 'vue';
|
|
26
|
+
import { useRouter } from 'vue-router';
|
|
29
27
|
|
|
30
|
-
import { convertRequestErrorToMap } from '@tager/admin-services';
|
|
31
28
|
import {
|
|
32
|
-
TagerFormSubmitEvent,
|
|
29
|
+
type TagerFormSubmitEvent,
|
|
33
30
|
FormFooter,
|
|
34
|
-
|
|
31
|
+
FormField,
|
|
32
|
+
FormFieldFileInput,
|
|
35
33
|
} from '@tager/admin-ui';
|
|
34
|
+
import {
|
|
35
|
+
convertRequestErrorToMap,
|
|
36
|
+
navigateBack,
|
|
37
|
+
useI18n,
|
|
38
|
+
useResource,
|
|
39
|
+
useToast,
|
|
40
|
+
} from '@tager/admin-services';
|
|
41
|
+
import { Page } from '@tager/admin-layout';
|
|
36
42
|
|
|
37
43
|
import { addFile } from '../../services/requests';
|
|
38
44
|
import { getFilesListUrl } from '../../utils/paths';
|
|
39
|
-
import { FormValues } from '../../typings/model';
|
|
45
|
+
import { type FormValues } from '../../typings/model';
|
|
40
46
|
|
|
41
47
|
import { convertFilesFormValuesToCreationPayload } from './FilesForm.helpers';
|
|
42
48
|
|
|
43
49
|
export default defineComponent({
|
|
44
50
|
name: 'FilesForm',
|
|
45
|
-
components: { FormFooter },
|
|
46
|
-
setup(
|
|
47
|
-
const { t } =
|
|
51
|
+
components: { Page, FormFieldFileInput, FormFooter },
|
|
52
|
+
setup() {
|
|
53
|
+
const { t } = useI18n();
|
|
54
|
+
const toast = useToast();
|
|
55
|
+
const router = useRouter();
|
|
48
56
|
|
|
49
57
|
/** Form state */
|
|
50
58
|
|
|
@@ -69,10 +77,10 @@ export default defineComponent({
|
|
|
69
77
|
event.type === 'create_exit' ||
|
|
70
78
|
event.type === 'save_exit'
|
|
71
79
|
) {
|
|
72
|
-
|
|
80
|
+
navigateBack(router, getFilesListUrl());
|
|
73
81
|
}
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
toast.show({
|
|
76
84
|
variant: 'success',
|
|
77
85
|
title: t('files:success'),
|
|
78
86
|
body: t('files:createdSuccessMessage'),
|
|
@@ -81,7 +89,7 @@ export default defineComponent({
|
|
|
81
89
|
.catch((error) => {
|
|
82
90
|
console.error(error);
|
|
83
91
|
errors.value = convertRequestErrorToMap(error);
|
|
84
|
-
|
|
92
|
+
toast.show({
|
|
85
93
|
variant: 'danger',
|
|
86
94
|
title: t('files:error'),
|
|
87
95
|
body: t('files:createdErrorMessage'),
|
|
@@ -102,5 +110,3 @@ export default defineComponent({
|
|
|
102
110
|
},
|
|
103
111
|
});
|
|
104
112
|
</script>
|
|
105
|
-
|
|
106
|
-
<style lang="scss" scoped></style>
|
|
@@ -1,61 +1,65 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
<Page
|
|
3
|
+
:title="$i18n.t('files:filesList')"
|
|
4
|
+
:header-buttons="[
|
|
5
5
|
{
|
|
6
|
-
text: $t('files:createFile'),
|
|
6
|
+
text: $i18n.t('files:createFile'),
|
|
7
7
|
href: getFilesFormUrl({ fileId: 'create' }),
|
|
8
8
|
},
|
|
9
9
|
]"
|
|
10
10
|
>
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
<DataTable
|
|
12
|
+
:column-defs="columnDefs"
|
|
13
|
+
:row-data="rowData"
|
|
14
|
+
:loading="isRowDataLoading"
|
|
15
|
+
:error-message="errorMessage"
|
|
16
|
+
:search-query="searchQuery"
|
|
17
|
+
:pagination="{
|
|
18
18
|
pageSize,
|
|
19
19
|
pageCount,
|
|
20
20
|
pageNumber,
|
|
21
21
|
disabled: isRowDataLoading,
|
|
22
22
|
}"
|
|
23
|
-
|
|
23
|
+
@change="handleChange"
|
|
24
24
|
>
|
|
25
|
-
<template
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
<template #cell(delete)="{ row }">
|
|
26
|
+
<BaseButton
|
|
27
|
+
variant="icon"
|
|
28
|
+
:title="$i18n.t('files:delete')"
|
|
29
|
+
:disabled="isDeleting(row.id)"
|
|
30
|
+
@click="handleResourceDelete(row.id)"
|
|
31
31
|
>
|
|
32
|
-
<
|
|
33
|
-
</
|
|
32
|
+
<DeleteIcon />
|
|
33
|
+
</BaseButton>
|
|
34
34
|
</template>
|
|
35
|
-
</
|
|
36
|
-
</
|
|
35
|
+
</DataTable>
|
|
36
|
+
</Page>
|
|
37
37
|
</template>
|
|
38
38
|
|
|
39
39
|
<script lang="ts">
|
|
40
|
-
import {defineComponent, onMounted} from '
|
|
40
|
+
import { defineComponent, onMounted } from 'vue';
|
|
41
41
|
import filesize from 'filesize';
|
|
42
42
|
|
|
43
43
|
import {
|
|
44
|
-
ColumnDefinition,
|
|
44
|
+
type ColumnDefinition,
|
|
45
45
|
useDataTable,
|
|
46
|
-
|
|
46
|
+
DataTable,
|
|
47
|
+
BaseButton,
|
|
48
|
+
DeleteIcon,
|
|
49
|
+
cutUrlOrigin,
|
|
47
50
|
} from '@tager/admin-ui';
|
|
48
|
-
import {useResourceDelete} from '@tager/admin-services';
|
|
51
|
+
import { useI18n, useResourceDelete } from '@tager/admin-services';
|
|
52
|
+
import { Page } from '@tager/admin-layout';
|
|
49
53
|
|
|
50
|
-
import {deleteFile, getFilesList} from '../../services/requests';
|
|
51
|
-
import {FileModel} from '../../typings/model';
|
|
52
|
-
import {getFilesFormUrl} from '../../utils/paths';
|
|
54
|
+
import { deleteFile, getFilesList } from '../../services/requests';
|
|
55
|
+
import { type FileModel } from '../../typings/model';
|
|
56
|
+
import { getFilesFormUrl } from '../../utils/paths';
|
|
53
57
|
|
|
54
58
|
export default defineComponent({
|
|
55
59
|
name: 'FilesList',
|
|
56
|
-
components: {},
|
|
57
|
-
setup(
|
|
58
|
-
const {t} =
|
|
60
|
+
components: { DataTable, BaseButton, DeleteIcon, Page },
|
|
61
|
+
setup() {
|
|
62
|
+
const { t } = useI18n();
|
|
59
63
|
|
|
60
64
|
const {
|
|
61
65
|
fetchEntityList: fetchFilesList,
|
|
@@ -69,13 +73,12 @@ export default defineComponent({
|
|
|
69
73
|
pageNumber,
|
|
70
74
|
} = useDataTable<FileModel>({
|
|
71
75
|
fetchEntityList: (params) =>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
getFilesList({
|
|
77
|
+
query: params.searchQuery,
|
|
78
|
+
pageNumber: params.pageNumber,
|
|
79
|
+
pageSize: params.pageSize,
|
|
80
|
+
}),
|
|
77
81
|
initialValue: [],
|
|
78
|
-
context,
|
|
79
82
|
resourceName: 'Files list',
|
|
80
83
|
pageSize: 100,
|
|
81
84
|
});
|
|
@@ -84,11 +87,10 @@ export default defineComponent({
|
|
|
84
87
|
fetchFilesList();
|
|
85
88
|
});
|
|
86
89
|
|
|
87
|
-
const {handleResourceDelete, isDeleting} = useResourceDelete({
|
|
90
|
+
const { handleResourceDelete, isDeleting } = useResourceDelete({
|
|
88
91
|
deleteResource: deleteFile,
|
|
89
92
|
resourceName: 'File',
|
|
90
93
|
onSuccess: fetchFilesList,
|
|
91
|
-
context,
|
|
92
94
|
});
|
|
93
95
|
|
|
94
96
|
const columnDefs: Array<ColumnDefinition<FileModel>> = [
|
|
@@ -96,8 +98,8 @@ export default defineComponent({
|
|
|
96
98
|
id: 1,
|
|
97
99
|
name: 'ID',
|
|
98
100
|
field: 'id',
|
|
99
|
-
style: {width: '50px', textAlign: 'center'},
|
|
100
|
-
headStyle: {width: '50px', textAlign: 'center'},
|
|
101
|
+
style: { width: '50px', textAlign: 'center' },
|
|
102
|
+
headStyle: { width: '50px', textAlign: 'center' },
|
|
101
103
|
},
|
|
102
104
|
{
|
|
103
105
|
id: 2,
|
|
@@ -113,26 +115,26 @@ export default defineComponent({
|
|
|
113
115
|
id: 4,
|
|
114
116
|
name: t('files:fileSize'),
|
|
115
117
|
field: 'size',
|
|
116
|
-
format: ({row}) => filesize(row.size),
|
|
117
|
-
style: {whiteSpace: 'nowrap'},
|
|
118
|
-
headStyle: {whiteSpace: 'nowrap'},
|
|
118
|
+
format: ({ row }) => filesize(row.size),
|
|
119
|
+
style: { whiteSpace: 'nowrap' },
|
|
120
|
+
headStyle: { whiteSpace: 'nowrap' },
|
|
119
121
|
},
|
|
120
122
|
{
|
|
121
123
|
id: 5,
|
|
122
124
|
name: 'URL',
|
|
123
125
|
type: 'link',
|
|
124
126
|
field: 'url',
|
|
125
|
-
format: ({row}) => ({
|
|
127
|
+
format: ({ row }) => ({
|
|
126
128
|
url: row.url,
|
|
127
|
-
text: cutUrlOrigin(row.url)
|
|
129
|
+
text: cutUrlOrigin(row.url),
|
|
128
130
|
}),
|
|
129
131
|
},
|
|
130
132
|
{
|
|
131
133
|
id: 6,
|
|
132
134
|
name: t('files:delete'),
|
|
133
135
|
field: 'delete',
|
|
134
|
-
style: {textAlign: 'center'},
|
|
135
|
-
headStyle: {textAlign: 'center'},
|
|
136
|
+
style: { textAlign: 'center' },
|
|
137
|
+
headStyle: { textAlign: 'center' },
|
|
136
138
|
},
|
|
137
139
|
];
|
|
138
140
|
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# tager-admin-files
|
package/dist/dev.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@tager/admin-ui/dist/admin-ui.css';
|