Skip to content

Commit

Permalink
add client group
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed Jul 23, 2024
1 parent 869c518 commit 0bb3a67
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion backend/database/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/layouts/modals/Client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<v-col cols="12" sm="6" md="4">
<v-switch color="primary" v-model="client.enable" :label="$t('enable')" hide-details></v-switch>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-combobox v-model="client.group" :items="groups" :label="$t('client.group')" hide-details></v-combobox>
</v-col>
</v-row>
<v-row>
<v-col cols="12" sm="6" md="4">
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export default {
client: {
name: "Name",
desc: "Description",
group: "Group",
inboundTags: "Inbound Tags",
basics: "Basics",
config: "Config",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export default {
client: {
name: "نام",
desc: "شرح",
group: "گروه",
inboundTags: "برچسب‌های ورودی",
basics: "پایه",
config: "تنظیم",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/vi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/zhcn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export default {
client: {
name: "名称",
desc: "描述",
group: "组",
inboundTags: "入站标签",
basics: "基础",
config: "配置",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/zhtw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export default {
client: {
name: "名稱",
desc: "描述",
group: "組",
inboundTags: "入站標簽",
basics: "基礎",
config: "配置",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/types/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface Client {
up: number
down: number
desc: string
group: string
}

const defaultClient: Client = {
Expand All @@ -26,6 +27,7 @@ const defaultClient: Client = {
up: 0,
down: 0,
desc: "",
group: "",
}

type Config = {
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/views/Clients.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:visible="modal.visible"
:index="modal.index"
:data="modal.data"
:groups="groups"
:stats="modal.stats"
:inboundTags="inboundTags"
@close="closeModal"
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit 0bb3a67

Please sign in to comment.