From 0bb3a67f79be878b6e1eb0f12ff62f9f767b3f58 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Tue, 23 Jul 2024 22:57:19 +0200 Subject: [PATCH] add client group --- backend/database/model/model.go | 3 ++- frontend/src/layouts/modals/Client.vue | 5 ++++- frontend/src/locales/en.ts | 1 + frontend/src/locales/fa.ts | 1 + frontend/src/locales/vi.ts | 1 + frontend/src/locales/zhcn.ts | 1 + frontend/src/locales/zhtw.ts | 1 + frontend/src/types/clients.ts | 2 ++ frontend/src/views/Clients.vue | 5 +++++ 9 files changed, 18 insertions(+), 2 deletions(-) diff --git a/backend/database/model/model.go b/backend/database/model/model.go index 0004dcc..d027aa3 100644 --- a/backend/database/model/model.go +++ b/backend/database/model/model.go @@ -41,7 +41,8 @@ type Client struct { Expiry int64 `json:"expiry" form:"expiry"` Down int64 `json:"down" form:"down"` Up int64 `json:"up" form:"up"` - Desc string `json:"desc" from:"desc"` + Desc string `json:"desc" form:"desc"` + Group string `json:"group" form:"group"` } type Stats struct { diff --git a/frontend/src/layouts/modals/Client.vue b/frontend/src/layouts/modals/Client.vue index 35db483..cae827a 100644 --- a/frontend/src/layouts/modals/Client.vue +++ b/frontend/src/layouts/modals/Client.vue @@ -21,6 +21,9 @@ + + + @@ -186,7 +189,7 @@ import DatePick from '@/components/DateTime.vue' import { HumanReadable } from '@/plugins/utils' export default { - props: ['visible', 'data', 'index', 'inboundTags', 'stats'], + props: ['visible', 'data', 'index', 'inboundTags', 'groups', 'stats'], emits: ['close', 'save'], data() { return { diff --git a/frontend/src/locales/en.ts b/frontend/src/locales/en.ts index 4e5ce42..a4d3271 100644 --- a/frontend/src/locales/en.ts +++ b/frontend/src/locales/en.ts @@ -157,6 +157,7 @@ export default { client: { name: "Name", desc: "Description", + group: "Group", inboundTags: "Inbound Tags", basics: "Basics", config: "Config", diff --git a/frontend/src/locales/fa.ts b/frontend/src/locales/fa.ts index 7e70a81..389309f 100644 --- a/frontend/src/locales/fa.ts +++ b/frontend/src/locales/fa.ts @@ -156,6 +156,7 @@ export default { client: { name: "نام", desc: "شرح", + group: "گروه", inboundTags: "برچسب‌های ورودی", basics: "پایه", config: "تنظیم", diff --git a/frontend/src/locales/vi.ts b/frontend/src/locales/vi.ts index f2e8fe2..04d2bff 100644 --- a/frontend/src/locales/vi.ts +++ b/frontend/src/locales/vi.ts @@ -157,6 +157,7 @@ export default { client: { name: "Tên", desc: "Mô tả", + group: "Nhóm", inboundTags: "Thẻ đầu vào", basics: "Cơ bản", config: "Cấu hình", diff --git a/frontend/src/locales/zhcn.ts b/frontend/src/locales/zhcn.ts index 0584947..58913ee 100644 --- a/frontend/src/locales/zhcn.ts +++ b/frontend/src/locales/zhcn.ts @@ -157,6 +157,7 @@ export default { client: { name: "名称", desc: "描述", + group: "组", inboundTags: "入站标签", basics: "基础", config: "配置", diff --git a/frontend/src/locales/zhtw.ts b/frontend/src/locales/zhtw.ts index 08d47dc..1bb89ea 100644 --- a/frontend/src/locales/zhtw.ts +++ b/frontend/src/locales/zhtw.ts @@ -158,6 +158,7 @@ export default { client: { name: "名稱", desc: "描述", + group: "組", inboundTags: "入站標簽", basics: "基礎", config: "配置", diff --git a/frontend/src/types/clients.ts b/frontend/src/types/clients.ts index 02fca3e..671ed6e 100644 --- a/frontend/src/types/clients.ts +++ b/frontend/src/types/clients.ts @@ -13,6 +13,7 @@ export interface Client { up: number down: number desc: string + group: string } const defaultClient: Client = { @@ -26,6 +27,7 @@ const defaultClient: Client = { up: 0, down: 0, desc: "", + group: "", } type Config = { diff --git a/frontend/src/views/Clients.vue b/frontend/src/views/Clients.vue index 089f652..8ce6588 100644 --- a/frontend/src/views/Clients.vue +++ b/frontend/src/views/Clients.vue @@ -5,6 +5,7 @@ :visible="modal.visible" :index="modal.index" :data="modal.data" + :groups="groups" :stats="modal.stats" :inboundTags="inboundTags" @close="closeModal" @@ -181,6 +182,10 @@ const inboundTags = computed((): string[] => { return inbounds.value?.filter(i => i.tag != "" && Object.hasOwn(i,'users')).map(i => i.tag) }) +const groups = computed((): string[] => { + if (!clients.value) return [] + return Array.from(new Set(clients.value?.map(c => c.group))) +}) const filter = ref("") const filterItems = [