@tager/admin-banners 0.2.0 → 0.3.2
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/menu.d.ts +4 -1
- package/dist/constants/paths.d.ts +8 -15
- package/dist/constants/routes.d.ts +3 -4
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useFetchBanner.d.ts +8 -0
- package/dist/hooks/useFetchBanners.d.ts +6 -0
- package/dist/hooks/useFetchZones.d.ts +6 -0
- package/dist/index.esm.js +3202 -875
- package/dist/index.umd.js +3216 -886
- package/dist/locales/en.d.ts +39 -0
- package/dist/locales/ru.d.ts +3 -0
- package/dist/{index.d.ts → main.d.ts} +1 -0
- package/dist/router/index.d.ts +4 -0
- package/dist/services/requests.d.ts +22 -35
- package/dist/typings/banners.d.ts +40 -0
- package/dist/typings/common.d.ts +1 -0
- package/dist/typings/model.d.ts +103 -15
- package/dist/typings/zones.d.ts +5 -0
- package/dist/utils/common.d.ts +2 -0
- package/dist/views/Banners/BannerForm/BannerForm.helpers.d.ts +5 -0
- package/dist/views/Banners/BannerForm/BannerForm.vue.d.ts +81 -0
- package/dist/views/Banners/BannerForm/index.d.ts +1 -0
- package/dist/views/Banners/BannerList/BannerList.helpers.d.ts +5 -0
- package/dist/views/Banners/BannerList/BannerList.vue.d.ts +55 -0
- package/dist/views/Banners/BannerList/hooks/index.d.ts +1 -0
- package/dist/views/Banners/BannerList/hooks/useAdvancedSearch.d.ts +21 -0
- package/dist/views/Banners/BannerList/index.d.ts +1 -0
- package/dist/views/Zones/ZoneList/ZoneList.helpers.d.ts +5 -0
- package/dist/views/Zones/ZoneList/ZoneList.vue.d.ts +28 -0
- package/dist/views/Zones/ZoneList/index.d.ts +1 -0
- package/package.json +32 -23
- package/src/config/config.json +1 -1
- package/src/constants/menu.ts +24 -10
- package/src/constants/paths.ts +10 -27
- package/src/constants/routes.ts +27 -49
- package/src/dev.ts +22 -34
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useFetchBanner.ts +41 -0
- package/src/hooks/useFetchBanners.ts +23 -0
- package/src/hooks/useFetchZones.ts +23 -0
- package/src/locales/en.ts +43 -0
- package/src/locales/ru.ts +45 -0
- package/src/main.ts +12 -0
- package/src/router/index.ts +38 -0
- package/src/services/requests.ts +35 -86
- package/src/typings/banners.ts +44 -0
- package/src/typings/common.ts +1 -0
- package/src/typings/model.ts +119 -16
- package/src/typings/shims-vue.d.ts +1 -0
- package/src/typings/translate.d.ts +10 -0
- package/src/typings/zones.ts +5 -0
- package/src/utils/common.ts +13 -0
- package/src/views/App.vue +7 -7
- package/src/views/Banners/BannerForm/BannerForm.helpers.ts +38 -0
- package/src/views/Banners/BannerForm/BannerForm.vue +236 -0
- package/src/views/Banners/BannerForm/index.ts +1 -0
- package/src/views/Banners/BannerList/BannerList.helpers.ts +93 -0
- package/src/views/Banners/BannerList/BannerList.vue +233 -0
- package/src/views/Banners/BannerList/hooks/index.ts +1 -0
- package/src/views/Banners/BannerList/hooks/useAdvancedSearch.ts +152 -0
- package/src/views/Banners/BannerList/index.ts +1 -0
- package/src/views/Home.vue +37 -0
- package/src/views/Zones/ZoneList/ZoneList.helpers.ts +34 -0
- package/src/views/Zones/ZoneList/ZoneList.vue +75 -0
- package/src/views/Zones/ZoneList/index.ts +1 -0
- package/dist/views/BannerAreaForm.vue.d.ts +0 -22
- package/dist/views/BannerAreaList.vue.d.ts +0 -17
- package/dist/views/BannerItemForm.vue.d.ts +0 -27
- package/dist/views/BannerItemList.vue.d.ts +0 -22
- package/src/index.ts +0 -3
- package/src/locales/en.js +0 -3
- package/src/locales/ru.js +0 -3
- package/src/views/BannerAreaForm.vue +0 -173
- package/src/views/BannerAreaList.vue +0 -176
- package/src/views/BannerItemForm.vue +0 -231
- package/src/views/BannerItemList.vue +0 -221
- package/typings/index.d.ts +0 -15
package/src/constants/menu.ts
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { MenuItemType } from '@tager/admin-layout';
|
|
2
|
+
import { TranslateFunction } from '@tager/admin-services';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import {
|
|
5
|
+
getBannersZoneListUrl,
|
|
6
|
+
getBannersBannerListUrl,
|
|
7
|
+
getBannersBannerFormUrl,
|
|
8
|
+
} from './paths';
|
|
9
|
+
|
|
10
|
+
export function getBannersMenuItem(params: {
|
|
11
|
+
t: TranslateFunction;
|
|
12
|
+
}): MenuItemType {
|
|
13
|
+
return {
|
|
14
|
+
id: 'banners',
|
|
15
|
+
text: params.t('banners:banners'),
|
|
16
|
+
icon: 'viewList',
|
|
17
|
+
children: [
|
|
18
|
+
{ text: params.t('banners:zones'), url: getBannersZoneListUrl() },
|
|
19
|
+
{ text: params.t('banners:banners'), url: getBannersBannerListUrl() },
|
|
20
|
+
{
|
|
21
|
+
text: params.t('banners:createBanner'),
|
|
22
|
+
url: getBannersBannerFormUrl({ bannerId: 'create' }),
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
package/src/constants/paths.ts
CHANGED
|
@@ -1,36 +1,19 @@
|
|
|
1
1
|
import { compile } from 'path-to-regexp';
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ITEM_FORM: '/banners/:areaAlias/items/:itemId',
|
|
3
|
+
export const BANNERS_ROUTE_PATHS = {
|
|
4
|
+
ZONE_LIST: '/banners/zones',
|
|
5
|
+
BANNER_LIST: '/banners',
|
|
6
|
+
BANNER_FORM: '/banners/:bannerId',
|
|
8
7
|
} as const;
|
|
9
8
|
|
|
10
|
-
export function
|
|
11
|
-
return
|
|
9
|
+
export function getBannersZoneListUrl() {
|
|
10
|
+
return BANNERS_ROUTE_PATHS.ZONE_LIST;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export function
|
|
15
|
-
|
|
16
|
-
}): string {
|
|
17
|
-
return compile(BANNER_ROUTE_PATHS.AREA_FORM)({
|
|
18
|
-
areaId: params.areaId,
|
|
19
|
-
});
|
|
13
|
+
export function getBannersBannerListUrl() {
|
|
14
|
+
return BANNERS_ROUTE_PATHS.BANNER_LIST;
|
|
20
15
|
}
|
|
21
16
|
|
|
22
|
-
export function
|
|
23
|
-
return compile(
|
|
24
|
-
areaAlias: params.areaAlias,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function getBannerItemFormUrl(params: {
|
|
29
|
-
areaAlias: string;
|
|
30
|
-
itemId: string | number;
|
|
31
|
-
}): string {
|
|
32
|
-
return compile(BANNER_ROUTE_PATHS.ITEM_FORM)({
|
|
33
|
-
areaAlias: params.areaAlias,
|
|
34
|
-
itemId: params.itemId,
|
|
35
|
-
});
|
|
17
|
+
export function getBannersBannerFormUrl(params: { bannerId: number | string }) {
|
|
18
|
+
return compile(BANNERS_ROUTE_PATHS.BANNER_FORM)(params);
|
|
36
19
|
}
|
package/src/constants/routes.ts
CHANGED
|
@@ -1,66 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CustomRouteConfig } from '@tager/admin-layout';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import BannerItemForm from '../views/BannerItemForm.vue';
|
|
3
|
+
import ZoneList from '../views/Zones/ZoneList';
|
|
4
|
+
import BannerList from '../views/Banners/BannerList';
|
|
5
|
+
import BannerForm from '../views/Banners/BannerForm';
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { BANNERS_ROUTE_PATHS } from './paths';
|
|
9
8
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
component: BannerAreaList,
|
|
15
|
-
name: 'Banner Area List',
|
|
16
|
-
meta: {
|
|
17
|
-
getBreadcrumbs: (route) => [
|
|
18
|
-
HOME_BREADCRUMB,
|
|
19
|
-
{ path: route.path, label: route.name },
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const BANNER_AREA_FORM_ROUTE: CustomRouteConfig = {
|
|
25
|
-
path: BANNER_ROUTE_PATHS.AREA_FORM,
|
|
26
|
-
component: BannerAreaForm,
|
|
27
|
-
name: 'Banner Area Form',
|
|
9
|
+
export const BANNERS_ZONE_LIST_ROUTE: CustomRouteConfig = {
|
|
10
|
+
path: BANNERS_ROUTE_PATHS.ZONE_LIST,
|
|
11
|
+
component: ZoneList,
|
|
12
|
+
name: 'Zones',
|
|
28
13
|
meta: {
|
|
29
|
-
getBreadcrumbs: (route
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
path: BANNER_ROUTE_PATHS.AREA_LIST,
|
|
33
|
-
label: BANNER_AREA_LIST_ROUTE.name,
|
|
34
|
-
},
|
|
35
|
-
{ path: route.path, label: route.name },
|
|
14
|
+
getBreadcrumbs: (route, t) => [
|
|
15
|
+
{ url: '/', text: t('banners:home') },
|
|
16
|
+
{ url: BANNERS_ROUTE_PATHS.ZONE_LIST, text: t('banners:zones') },
|
|
36
17
|
],
|
|
37
18
|
},
|
|
38
19
|
};
|
|
39
20
|
|
|
40
|
-
export const
|
|
41
|
-
path:
|
|
42
|
-
component:
|
|
43
|
-
name: '
|
|
21
|
+
export const BANNERS_BANNER_LIST_ROUTE: CustomRouteConfig = {
|
|
22
|
+
path: BANNERS_ROUTE_PATHS.BANNER_LIST,
|
|
23
|
+
component: BannerList,
|
|
24
|
+
name: 'Banners',
|
|
44
25
|
meta: {
|
|
45
|
-
getBreadcrumbs: (route) => [
|
|
46
|
-
|
|
47
|
-
{
|
|
26
|
+
getBreadcrumbs: (route, t) => [
|
|
27
|
+
{ url: '/', text: t('banners:home') },
|
|
28
|
+
{ url: BANNERS_ROUTE_PATHS.BANNER_LIST, text: t('banners:banners') },
|
|
48
29
|
],
|
|
49
30
|
},
|
|
50
31
|
};
|
|
51
32
|
|
|
52
|
-
export const
|
|
53
|
-
path:
|
|
54
|
-
component:
|
|
55
|
-
name: 'Banner
|
|
33
|
+
export const BANNERS_BANNER_FORM_ROUTE: CustomRouteConfig = {
|
|
34
|
+
path: BANNERS_ROUTE_PATHS.BANNER_FORM,
|
|
35
|
+
component: BannerForm,
|
|
36
|
+
name: 'Banner Form',
|
|
56
37
|
meta: {
|
|
57
|
-
getBreadcrumbs: (route) => [
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
label: BANNER_ITEM_LIST_ROUTE.name,
|
|
62
|
-
},
|
|
63
|
-
{ path: route.path, label: route.name },
|
|
38
|
+
getBreadcrumbs: (route, t) => [
|
|
39
|
+
{ url: '/', text: t('banners:home') },
|
|
40
|
+
{ url: BANNERS_ROUTE_PATHS.BANNER_LIST, text: t('banners:banners') },
|
|
41
|
+
{ url: route.path, text: t('banners:bannerForm') },
|
|
64
42
|
],
|
|
65
43
|
},
|
|
66
44
|
};
|
package/src/dev.ts
CHANGED
|
@@ -1,46 +1,34 @@
|
|
|
1
|
-
import Vue from 'vue';
|
|
1
|
+
import Vue, { CreateElement } from 'vue';
|
|
2
|
+
import VueCompositionApi, { createApp } from '@vue/composition-api';
|
|
3
|
+
|
|
2
4
|
import { configStore, i18n } from '@tager/admin-services';
|
|
3
5
|
import { AdminUiPlugin } from '@tager/admin-ui';
|
|
4
|
-
import {
|
|
5
|
-
AdminLayoutPlugin,
|
|
6
|
-
createRouter,
|
|
7
|
-
CustomRoute,
|
|
8
|
-
CustomRouteConfig,
|
|
9
|
-
} from '@tager/admin-layout';
|
|
6
|
+
import { AdminLayoutPlugin } from '@tager/admin-layout';
|
|
10
7
|
|
|
11
8
|
import '@tager/admin-ui/dist/admin-ui.css';
|
|
12
9
|
|
|
13
|
-
import
|
|
14
|
-
BANNER_AREA_FORM_ROUTE,
|
|
15
|
-
BANNER_AREA_LIST_ROUTE,
|
|
16
|
-
BANNER_ITEM_FORM_ROUTE,
|
|
17
|
-
BANNER_ITEM_LIST_ROUTE,
|
|
18
|
-
} from './constants/routes';
|
|
10
|
+
import router from './router';
|
|
19
11
|
import config from './config/config.json';
|
|
20
12
|
import App from './views/App.vue';
|
|
13
|
+
import EN from './locales/en';
|
|
14
|
+
import RU from './locales/ru';
|
|
21
15
|
|
|
22
16
|
configStore.setConfig(config);
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
BANNER_AREA_FORM_ROUTE,
|
|
32
|
-
BANNER_ITEM_LIST_ROUTE,
|
|
33
|
-
BANNER_ITEM_FORM_ROUTE,
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
{ useTitleSync: false }
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
i18n.init().then(() => {
|
|
40
|
-
Vue.use(i18n.getPlugin());
|
|
41
|
-
|
|
42
|
-
new Vue({
|
|
18
|
+
i18n.addTranslations('en', 'banners', EN);
|
|
19
|
+
i18n.addTranslations('ru', 'banners', RU);
|
|
20
|
+
|
|
21
|
+
i18n.init({ debug: false }).then(() => {
|
|
22
|
+
Vue.use(VueCompositionApi);
|
|
23
|
+
|
|
24
|
+
const app = createApp({
|
|
43
25
|
router,
|
|
44
|
-
render: (h) => h(App),
|
|
45
|
-
})
|
|
26
|
+
render: (h: CreateElement) => h(App),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
app.use(i18n.getPlugin());
|
|
30
|
+
app.use(AdminUiPlugin);
|
|
31
|
+
app.use(AdminLayoutPlugin);
|
|
32
|
+
|
|
33
|
+
app.mount('#app');
|
|
46
34
|
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { onMounted, Ref, SetupContext, watch } from '@vue/composition-api';
|
|
2
|
+
|
|
3
|
+
import { Nullable, ResourceRef, useResource } from '@tager/admin-services';
|
|
4
|
+
|
|
5
|
+
import { getBanner } from '../services/requests';
|
|
6
|
+
import { Banner } from '../typings/banners';
|
|
7
|
+
|
|
8
|
+
export function useFetchBanner({
|
|
9
|
+
context,
|
|
10
|
+
bannerId,
|
|
11
|
+
isCreation,
|
|
12
|
+
}: {
|
|
13
|
+
context: SetupContext;
|
|
14
|
+
bannerId: Ref<string>;
|
|
15
|
+
isCreation: Ref<boolean>;
|
|
16
|
+
}): ResourceRef<Nullable<Banner>> {
|
|
17
|
+
const [fetchBanner, resource] = useResource<Nullable<Banner>>({
|
|
18
|
+
fetchResource: () => getBanner(bannerId.value),
|
|
19
|
+
initialValue: null,
|
|
20
|
+
context,
|
|
21
|
+
resourceName: 'Banner',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
onMounted(() => {
|
|
25
|
+
if (isCreation.value) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fetchBanner();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
watch(bannerId, () => {
|
|
33
|
+
if (isCreation.value) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fetchBanner();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return resource;
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { onMounted, SetupContext } from '@vue/composition-api';
|
|
2
|
+
|
|
3
|
+
import { ResourceRef, useResource } from '@tager/admin-services';
|
|
4
|
+
|
|
5
|
+
import { getBanners } from '../services/requests';
|
|
6
|
+
import { Banner } from '../typings/banners';
|
|
7
|
+
|
|
8
|
+
export function useFetchBanners(params: {
|
|
9
|
+
context: SetupContext;
|
|
10
|
+
}): ResourceRef<Banner[]> {
|
|
11
|
+
const [fetchBanners, resource] = useResource<Banner[]>({
|
|
12
|
+
fetchResource: getBanners,
|
|
13
|
+
initialValue: [],
|
|
14
|
+
context: params.context,
|
|
15
|
+
resourceName: 'Banners',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
onMounted(() => {
|
|
19
|
+
fetchBanners();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return resource;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { onMounted, SetupContext } from '@vue/composition-api';
|
|
2
|
+
|
|
3
|
+
import { ResourceRef, useResource } from '@tager/admin-services';
|
|
4
|
+
|
|
5
|
+
import { getZones } from '../services/requests';
|
|
6
|
+
import { Zone } from '../typings/zones';
|
|
7
|
+
|
|
8
|
+
export function useFetchZones(params: {
|
|
9
|
+
context: SetupContext;
|
|
10
|
+
}): ResourceRef<Zone[]> {
|
|
11
|
+
const [fetchZones, resource] = useResource<Zone[]>({
|
|
12
|
+
fetchResource: getZones,
|
|
13
|
+
initialValue: [],
|
|
14
|
+
context: params.context,
|
|
15
|
+
resourceName: 'Banner zones',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
onMounted(() => {
|
|
19
|
+
fetchZones();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return resource;
|
|
23
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const EN = {
|
|
2
|
+
home: 'Home',
|
|
3
|
+
zone: 'Banner zone',
|
|
4
|
+
zones: 'Banner zones',
|
|
5
|
+
banners: 'Banners',
|
|
6
|
+
bannerForm: 'Banner Form',
|
|
7
|
+
createBanner: 'Create Banner',
|
|
8
|
+
updateBanner: 'Update Banner',
|
|
9
|
+
link: 'Link',
|
|
10
|
+
image: 'Image',
|
|
11
|
+
openNewTab: 'Open new tab',
|
|
12
|
+
period: 'Period',
|
|
13
|
+
from: 'From',
|
|
14
|
+
to: 'To',
|
|
15
|
+
disabled: 'Disabled',
|
|
16
|
+
comment: 'Comment',
|
|
17
|
+
status: 'Status',
|
|
18
|
+
bannerZoneIsDeleted: 'Banner zone is deleted',
|
|
19
|
+
newTab: 'New Tab',
|
|
20
|
+
yes: 'Yes',
|
|
21
|
+
no: 'No',
|
|
22
|
+
edit: 'Edit',
|
|
23
|
+
remove: 'Remove',
|
|
24
|
+
actions: 'actions',
|
|
25
|
+
date: 'Date',
|
|
26
|
+
|
|
27
|
+
success: 'Success',
|
|
28
|
+
error: 'Error',
|
|
29
|
+
|
|
30
|
+
statuses: {
|
|
31
|
+
waiting: 'Waiting',
|
|
32
|
+
archived: 'Archived',
|
|
33
|
+
active: 'Active',
|
|
34
|
+
disabled: 'Disabled',
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
bannerWasSuccessfullyCreated: 'Banner was successfully created',
|
|
38
|
+
bannerWasSuccessfullyUpdated: 'Banner was successfully updated',
|
|
39
|
+
bannerCreationWasFailed: 'Banner creation was failed',
|
|
40
|
+
bannerUpdateWasFailed: 'Banner update was failed',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default EN;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import EN from './en';
|
|
2
|
+
|
|
3
|
+
const RU: typeof EN = {
|
|
4
|
+
home: 'Главная',
|
|
5
|
+
zone: 'Баннерная зона',
|
|
6
|
+
zones: 'Баннерные зоны',
|
|
7
|
+
banners: 'Баннеры',
|
|
8
|
+
bannerForm: 'Форма баннера',
|
|
9
|
+
createBanner: 'Добавить баннер',
|
|
10
|
+
updateBanner: 'Редактировать баннер',
|
|
11
|
+
link: 'Ссылка',
|
|
12
|
+
image: 'Картинка',
|
|
13
|
+
openNewTab: 'Открывать в новой вкладке',
|
|
14
|
+
period: 'Срок действия',
|
|
15
|
+
from: 'От',
|
|
16
|
+
to: 'До',
|
|
17
|
+
disabled: 'Выключен',
|
|
18
|
+
comment: 'Комментарий',
|
|
19
|
+
status: 'Статус',
|
|
20
|
+
bannerZoneIsDeleted: 'Баннерная зона удалена',
|
|
21
|
+
newTab: 'Новая вкладка',
|
|
22
|
+
yes: 'Да',
|
|
23
|
+
no: 'Нет',
|
|
24
|
+
edit: 'Редактировать',
|
|
25
|
+
remove: 'Удалить',
|
|
26
|
+
actions: 'Действия',
|
|
27
|
+
date: 'Дата',
|
|
28
|
+
|
|
29
|
+
success: 'Успех',
|
|
30
|
+
error: 'Ошибка',
|
|
31
|
+
|
|
32
|
+
statuses: {
|
|
33
|
+
waiting: 'В ожидании',
|
|
34
|
+
archived: 'Архивный',
|
|
35
|
+
active: 'Активный',
|
|
36
|
+
disabled: 'Отключен',
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
bannerWasSuccessfullyCreated: 'Баннер успешно создан',
|
|
40
|
+
bannerWasSuccessfullyUpdated: 'Баннер успешно обновлен',
|
|
41
|
+
bannerCreationWasFailed: 'Не удалось создать баннер',
|
|
42
|
+
bannerUpdateWasFailed: 'Не удалось обновить баннер',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default RU;
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { i18n } from '@tager/admin-services';
|
|
2
|
+
|
|
3
|
+
import EN from './locales/en';
|
|
4
|
+
import RU from './locales/ru';
|
|
5
|
+
|
|
6
|
+
i18n.addTranslations('en', 'blog', EN);
|
|
7
|
+
i18n.addTranslations('ru', 'blog', RU);
|
|
8
|
+
|
|
9
|
+
export * from './constants/routes';
|
|
10
|
+
export * from './constants/menu';
|
|
11
|
+
export * from './constants/paths';
|
|
12
|
+
export * from './services/requests';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRouter,
|
|
3
|
+
CustomRoute,
|
|
4
|
+
CustomRouteConfig,
|
|
5
|
+
} from '@tager/admin-layout';
|
|
6
|
+
|
|
7
|
+
import Home from '@/views/Home.vue';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
BANNERS_ZONE_LIST_ROUTE,
|
|
11
|
+
BANNERS_BANNER_LIST_ROUTE,
|
|
12
|
+
BANNERS_BANNER_FORM_ROUTE,
|
|
13
|
+
} from '../constants/routes';
|
|
14
|
+
|
|
15
|
+
export const HOME_ROUTE: CustomRouteConfig = {
|
|
16
|
+
path: '/',
|
|
17
|
+
component: Home,
|
|
18
|
+
name: 'Home',
|
|
19
|
+
meta: {
|
|
20
|
+
getBreadcrumbs: (route: CustomRoute) => [
|
|
21
|
+
{ url: '/', text: route.name ?? '' },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const router = createRouter(
|
|
27
|
+
{
|
|
28
|
+
routes: [
|
|
29
|
+
HOME_ROUTE,
|
|
30
|
+
BANNERS_ZONE_LIST_ROUTE,
|
|
31
|
+
BANNERS_BANNER_LIST_ROUTE,
|
|
32
|
+
BANNERS_BANNER_FORM_ROUTE,
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{ useTitleSync: false }
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export default router;
|
package/src/services/requests.ts
CHANGED
|
@@ -1,107 +1,56 @@
|
|
|
1
|
-
import { request,
|
|
2
|
-
import { BannerArea, BannerItem } from '../typings/model';
|
|
1
|
+
import { request, ResponseBody } from '@tager/admin-services';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import { Zone } from '../typings/zones';
|
|
4
|
+
import { Banner, BannerPayload } from '../typings/banners';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
return request.get({ path: '/admin/market-boards' });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function getBannerAreaById(
|
|
11
|
-
areaId: number | string
|
|
12
|
-
): Promise<ResponseBody<BannerArea>> {
|
|
13
|
-
return request.get({ path: `/admin/market-boards/${areaId}` });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function getBannerAreaByAlias(
|
|
17
|
-
areaAlias: number | string
|
|
18
|
-
): Promise<ResponseBody<BannerArea>> {
|
|
19
|
-
return request.get({ path: `/admin/market-boards/${areaAlias}` });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type BannerAreaCreatePayload = {
|
|
23
|
-
alias: string;
|
|
24
|
-
label: string;
|
|
25
|
-
scenario: string;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export function createBannerArea(
|
|
29
|
-
payload: BannerAreaCreatePayload
|
|
30
|
-
): Promise<ResponseBody<BannerArea>> {
|
|
31
|
-
return request.post({ path: '/admin/market-boards', body: payload });
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type BannerAreaUpdatePayload = BannerAreaCreatePayload;
|
|
6
|
+
/** Zones **/
|
|
35
7
|
|
|
36
|
-
export function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
8
|
+
export function getZones(params?: {
|
|
9
|
+
query?: string;
|
|
10
|
+
pageNumber?: number;
|
|
11
|
+
pageSize?: number;
|
|
12
|
+
}): Promise<ResponseBody<Zone[]>> {
|
|
13
|
+
return request.get({ path: '/admin/adv/zones', params });
|
|
41
14
|
}
|
|
42
15
|
|
|
43
|
-
|
|
44
|
-
areaId: number | string
|
|
45
|
-
): Promise<{ success: boolean }> {
|
|
46
|
-
return request.delete({ path: `/admin/market-boards/${areaId}` });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Banners */
|
|
16
|
+
/** Banners **/
|
|
50
17
|
|
|
51
|
-
export function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
18
|
+
export function getBanners(params?: {
|
|
19
|
+
query?: string;
|
|
20
|
+
pageNumber?: number;
|
|
21
|
+
pageSize?: number;
|
|
22
|
+
}): Promise<ResponseBody<Banner[]>> {
|
|
23
|
+
return request.get({ path: '/admin/adv', params });
|
|
55
24
|
}
|
|
56
25
|
|
|
57
|
-
export function
|
|
58
|
-
|
|
59
|
-
): Promise<ResponseBody<
|
|
60
|
-
return request.get({ path: `/admin/
|
|
26
|
+
export function getBanner(
|
|
27
|
+
bannerId: number | string
|
|
28
|
+
): Promise<ResponseBody<Banner>> {
|
|
29
|
+
return request.get({ path: `/admin/adv/${bannerId}` });
|
|
61
30
|
}
|
|
62
31
|
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
buttonLabel: string;
|
|
68
|
-
buttonIsNewTab: boolean;
|
|
69
|
-
image: Nullable<number>;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export function createBannerItem(
|
|
73
|
-
areaId: number | string,
|
|
74
|
-
payload: BannerItemCreatePayload
|
|
75
|
-
): Promise<ResponseBody<BannerItem>> {
|
|
76
|
-
return request.post({
|
|
77
|
-
path: `/admin/market-boards/${areaId}/items`,
|
|
78
|
-
body: payload,
|
|
79
|
-
});
|
|
32
|
+
export function createBanner(
|
|
33
|
+
payload: BannerPayload
|
|
34
|
+
): Promise<ResponseBody<Banner>> {
|
|
35
|
+
return request.post({ path: '/admin/adv', body: payload });
|
|
80
36
|
}
|
|
81
37
|
|
|
82
|
-
export
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
payload: BannerItemUpdatePayload
|
|
87
|
-
): Promise<ResponseBody<BannerItem>> {
|
|
38
|
+
export function updateBanner(
|
|
39
|
+
bannerId: number | string,
|
|
40
|
+
payload: BannerPayload
|
|
41
|
+
): Promise<ResponseBody<Banner>> {
|
|
88
42
|
return request.put({
|
|
89
|
-
path: `/admin/
|
|
43
|
+
path: `/admin/adv/${bannerId}`,
|
|
90
44
|
body: payload,
|
|
91
45
|
});
|
|
92
46
|
}
|
|
93
47
|
|
|
94
|
-
export function
|
|
95
|
-
|
|
48
|
+
export function deleteBanner(
|
|
49
|
+
bannerId: number | string
|
|
96
50
|
): Promise<{ success: boolean }> {
|
|
97
|
-
return request.delete({ path: `/admin/
|
|
51
|
+
return request.delete({ path: `/admin/adv/${bannerId}` });
|
|
98
52
|
}
|
|
99
53
|
|
|
100
|
-
export function
|
|
101
|
-
|
|
102
|
-
direction: 'up' | 'down'
|
|
103
|
-
): Promise<{ success: boolean }> {
|
|
104
|
-
return request.post({
|
|
105
|
-
path: `/admin/market-boards/items/${bannerItemId}/${direction}`,
|
|
106
|
-
});
|
|
54
|
+
export function getBannerCount(): Promise<ResponseBody<{ count: number }>> {
|
|
55
|
+
return request.get({ path: '/admin/adv/count' });
|
|
107
56
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { FileType, Nullable } from '@tager/admin-services';
|
|
2
|
+
import { OptionType, SingleFileInputValueType } from '@tager/admin-ui';
|
|
3
|
+
|
|
4
|
+
export enum Status {
|
|
5
|
+
Waiting = 'WAITING',
|
|
6
|
+
Archived = 'ARCHIVED',
|
|
7
|
+
Active = 'ACTIVE',
|
|
8
|
+
Disabled = 'DISABLED',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Banner {
|
|
12
|
+
id: number;
|
|
13
|
+
status: Status;
|
|
14
|
+
link: Nullable<string>;
|
|
15
|
+
image: Nullable<FileType>;
|
|
16
|
+
bannerZone: Nullable<string>;
|
|
17
|
+
openNewTab: boolean;
|
|
18
|
+
dateStart: Nullable<string>;
|
|
19
|
+
dateEnd: Nullable<string>;
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
comment: Nullable<string>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface BannerFormValues {
|
|
25
|
+
link: Nullable<string>;
|
|
26
|
+
image: Nullable<SingleFileInputValueType>;
|
|
27
|
+
bannerZone: Nullable<OptionType>;
|
|
28
|
+
openNewTab: boolean;
|
|
29
|
+
dateStart: string;
|
|
30
|
+
dateEnd: string;
|
|
31
|
+
disabled: boolean;
|
|
32
|
+
comment: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface BannerPayload {
|
|
36
|
+
link: Nullable<string>;
|
|
37
|
+
image: Nullable<string>;
|
|
38
|
+
bannerZone: string;
|
|
39
|
+
openNewTab: boolean;
|
|
40
|
+
dateStart: string;
|
|
41
|
+
dateEnd: string;
|
|
42
|
+
disabled: boolean;
|
|
43
|
+
comment: string;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Values<T> = T[keyof T];
|