Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit a275d17

Browse files
authored
Merge pull request #32 from humpback/develop-0.0.1
Develop 0.0.1
2 parents e8f241a + a585bb3 commit a275d17

File tree

8 files changed

+105
-96
lines changed

8 files changed

+105
-96
lines changed

backend/api/handle/models/base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func ParseMapToStructConvert(m map[string]any, obj interface{}) error {
2323
}
2424

2525
func removeEmptyStrings(arr []string) []string {
26-
var result []string
26+
result := make([]string, 0)
2727
for _, str := range arr {
2828
if str != "" {
2929
result = append(result, str)

backend/api/handle/models/group.go

Lines changed: 84 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,118 @@
11
package models
22

33
import (
4-
"slices"
5-
"strings"
6-
7-
"humpback/common/enum"
8-
"humpback/common/locales"
9-
"humpback/common/response"
10-
"humpback/common/verify"
11-
"humpback/pkg/utils"
12-
"humpback/types"
4+
"slices"
5+
"strings"
6+
7+
"humpback/common/enum"
8+
"humpback/common/locales"
9+
"humpback/common/response"
10+
"humpback/common/verify"
11+
"humpback/pkg/utils"
12+
"humpback/types"
1313
)
1414

1515
type GroupCreateReqInfo struct {
16-
GroupName string `json:"groupName"`
17-
Description string `json:"description"`
18-
Users []string `json:"users"`
19-
Teams []string `json:"teams"`
16+
GroupName string `json:"groupName"`
17+
Description string `json:"description"`
18+
Users []string `json:"users"`
19+
Teams []string `json:"teams"`
2020
}
2121

2222
func (g *GroupCreateReqInfo) Check() error {
23-
if err := verify.CheckRequiredAndLengthLimit(g.GroupName, enum.LimitGroupName.Min, enum.LimitGroupName.Max, locales.CodeGroupNameNotEmpty, locales.CodeGroupNameLimitLength); err != nil {
24-
return err
25-
}
26-
if err := verify.CheckLengthLimit(g.Description, enum.LimitDescription.Min, enum.LimitDescription.Max, locales.CodeDescriptionLimitLength); err != nil {
27-
return err
28-
}
29-
return nil
23+
if err := verify.CheckRequiredAndLengthLimit(g.GroupName, enum.LimitGroupName.Min, enum.LimitGroupName.Max, locales.CodeGroupNameNotEmpty, locales.CodeGroupNameLimitLength); err != nil {
24+
return err
25+
}
26+
if err := verify.CheckLengthLimit(g.Description, enum.LimitDescription.Min, enum.LimitDescription.Max, locales.CodeDescriptionLimitLength); err != nil {
27+
return err
28+
}
29+
if g.Users == nil {
30+
g.Users = make([]string, 0)
31+
}
32+
if g.Teams == nil {
33+
g.Teams = make([]string, 0)
34+
}
35+
return nil
3036
}
3137

3238
func (g *GroupCreateReqInfo) NewGroupInfo() *types.NodesGroups {
33-
nowT := utils.NewActionTimestamp()
34-
return &types.NodesGroups{
35-
GroupId: utils.NewGroupId(),
36-
GroupName: g.GroupName,
37-
Description: g.Description,
38-
Users: g.Users,
39-
Teams: g.Teams,
40-
Nodes: make([]string, 0),
41-
CreatedAt: nowT,
42-
UpdatedAt: nowT,
43-
}
39+
nowT := utils.NewActionTimestamp()
40+
return &types.NodesGroups{
41+
GroupId: utils.NewGroupId(),
42+
GroupName: g.GroupName,
43+
Description: g.Description,
44+
Users: g.Users,
45+
Teams: g.Teams,
46+
Nodes: make([]string, 0),
47+
CreatedAt: nowT,
48+
UpdatedAt: nowT,
49+
}
4450
}
4551

4652
type GroupUpdateReqInfo struct {
47-
GroupId string `json:"groupId"`
48-
GroupCreateReqInfo
53+
GroupId string `json:"groupId"`
54+
GroupCreateReqInfo
4955
}
5056

5157
func (g *GroupUpdateReqInfo) Check() error {
52-
if err := verify.CheckIsEmpty(g.GroupId, locales.CodeGroupIdNotEmpty); err != nil {
53-
return err
54-
}
55-
return g.GroupCreateReqInfo.Check()
58+
if err := verify.CheckIsEmpty(g.GroupId, locales.CodeGroupIdNotEmpty); err != nil {
59+
return err
60+
}
61+
return g.GroupCreateReqInfo.Check()
5662
}
5763

5864
func (g *GroupUpdateReqInfo) NewGroupInfo(oldInfo *types.NodesGroups) *types.NodesGroups {
59-
return &types.NodesGroups{
60-
GroupId: oldInfo.GroupId,
61-
GroupName: g.GroupName,
62-
Description: g.Description,
63-
Users: g.Users,
64-
Teams: g.Teams,
65-
Nodes: oldInfo.Nodes,
66-
CreatedAt: oldInfo.CreatedAt,
67-
UpdatedAt: utils.NewActionTimestamp(),
68-
}
65+
return &types.NodesGroups{
66+
GroupId: oldInfo.GroupId,
67+
GroupName: g.GroupName,
68+
Description: g.Description,
69+
Users: g.Users,
70+
Teams: g.Teams,
71+
Nodes: oldInfo.Nodes,
72+
CreatedAt: oldInfo.CreatedAt,
73+
UpdatedAt: utils.NewActionTimestamp(),
74+
}
6975
}
7076

7177
type GroupQueryReqInfo struct {
72-
UserInfo *types.User `json:"-"`
73-
types.QueryInfo
78+
UserInfo *types.User `json:"-"`
79+
types.QueryInfo
7480
}
7581

7682
func (g *GroupQueryReqInfo) Check() error {
77-
g.QueryInfo.CheckBase()
78-
if g.Keywords != "" && g.Mode != "groupName" {
79-
return response.NewBadRequestErr(locales.CodeRequestParamsInvalid)
80-
}
81-
return nil
83+
g.QueryInfo.CheckBase()
84+
if g.Keywords != "" && g.Mode != "groupName" {
85+
return response.NewBadRequestErr(locales.CodeRequestParamsInvalid)
86+
}
87+
return nil
8288
}
8389

8490
func (g *GroupQueryReqInfo) QueryFilter(groups []*types.NodesGroups) []*types.NodesGroups {
85-
result := make([]*types.NodesGroups, 0)
86-
for _, group := range groups {
87-
if g.UserInfo.InGroup(group) && strings.Contains(strings.ToLower(group.GroupName), strings.ToLower(g.Keywords)) {
88-
result = append(result, group)
89-
}
90-
}
91-
g.sort(result)
92-
return result
91+
result := make([]*types.NodesGroups, 0)
92+
for _, group := range groups {
93+
if g.UserInfo.InGroup(group) && strings.Contains(strings.ToLower(group.GroupName), strings.ToLower(g.Keywords)) {
94+
result = append(result, group)
95+
}
96+
}
97+
g.sort(result)
98+
return result
9399
}
94100

95101
func (g *GroupQueryReqInfo) sort(list []*types.NodesGroups) []*types.NodesGroups {
96-
var sortField = []string{"groupName", "updatedAt", "createdAt"}
97-
if g.SortInfo == nil || g.SortInfo.Field == "" || slices.Index(sortField, g.SortInfo.Field) == -1 {
98-
return list
99-
}
100-
slices.SortFunc(list, func(a, b *types.NodesGroups) int {
101-
switch g.SortInfo.Field {
102-
case "groupName":
103-
return types.QuerySortOrder(g.SortInfo.Order, strings.ToLower(a.GroupName), strings.ToLower(b.GroupName))
104-
case "updatedAt":
105-
return types.QuerySortOrder(g.SortInfo.Order, a.UpdatedAt, b.UpdatedAt)
106-
case "createdAt":
107-
return types.QuerySortOrder(g.SortInfo.Order, a.CreatedAt, b.CreatedAt)
108-
}
109-
return 1
110-
})
111-
return list
102+
var sortField = []string{"groupName", "updatedAt", "createdAt"}
103+
if g.SortInfo == nil || g.SortInfo.Field == "" || slices.Index(sortField, g.SortInfo.Field) == -1 {
104+
return list
105+
}
106+
slices.SortFunc(list, func(a, b *types.NodesGroups) int {
107+
switch g.SortInfo.Field {
108+
case "groupName":
109+
return types.QuerySortOrder(g.SortInfo.Order, strings.ToLower(a.GroupName), strings.ToLower(b.GroupName))
110+
case "updatedAt":
111+
return types.QuerySortOrder(g.SortInfo.Order, a.UpdatedAt, b.UpdatedAt)
112+
case "createdAt":
113+
return types.QuerySortOrder(g.SortInfo.Order, a.CreatedAt, b.CreatedAt)
114+
}
115+
return 1
116+
})
117+
return list
112118
}

backend/api/handle/models/nodes.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ func (n *NodeUpdateLabelReqInfo) Check() error {
6161
if err := verify.CheckIsEmpty(n.NodeId, locales.CodeNodesIdNotEmpty); err != nil {
6262
return err
6363
}
64+
if n.Labels == nil {
65+
n.Labels = make(map[string]string)
66+
}
6467
return nil
6568
}
6669

backend/api/handle/models/service.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,7 @@ func (s *ServiceUpdateReqInfo) checkMetaInfo() error {
227227
if err := verify.CheckRequiredAndLengthLimit(info.Image, enum.LimitImageName.Min, enum.LimitImageName.Max, locales.CodeServiceImageNotEmpty, locales.CodeServiceImageLimitLength); err != nil {
228228
return err
229229
}
230-
if len(info.EnvConfig) == 0 {
231-
info.EnvConfig = make([]string, 0)
232-
}
230+
info.EnvConfig = removeEmptyStrings(info.EnvConfig)
233231
if len(info.Labels) == 0 {
234232
info.Labels = make(map[string]string)
235233
}
@@ -247,12 +245,6 @@ func (s *ServiceUpdateReqInfo) checkMetaInfo() error {
247245
CapDrop: make([]string, 0),
248246
}
249247
}
250-
if info.Capabilities.CapAdd == nil {
251-
info.Capabilities.CapAdd = make([]string, 0)
252-
}
253-
if info.Capabilities.CapDrop == nil {
254-
info.Capabilities.CapDrop = make([]string, 0)
255-
}
256248
info.Capabilities.CapAdd = removeEmptyStrings(info.Capabilities.CapAdd)
257249
info.Capabilities.CapDrop = removeEmptyStrings(info.Capabilities.CapDrop)
258250
if info.LogConfig == nil {
@@ -354,6 +346,10 @@ func (s *ServiceUpdateReqInfo) checkMetaInfo() error {
354346
info.RestartPolicy.Mode != types.RestartPolicyModeUnlessStopped {
355347
return response.NewBadRequestErr(locales.CodeServiceRestartPolicyInvalid)
356348
}
349+
if info.RestartPolicy.Mode != types.RestartPolicyModeOnFail {
350+
info.RestartPolicy.MaxRetryCount = 0
351+
}
352+
s.MetaInfo = info
357353
return nil
358354
}
359355

@@ -407,6 +403,7 @@ func (s *ServiceUpdateReqInfo) checkDeployment() error {
407403
} else {
408404
info.Schedule.Timeout = ""
409405
}
406+
s.DeploymentInfo = info
410407
return nil
411408
}
412409

front/projects/web/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<meta charset="UTF-8" />
55
<link href="/src/assets/logo.png" rel="icon" type="image/svg+xml" />
66
<link as="font" crossorigin href="./src/assets/fonts/Roboto/Roboto-Regular.ttf" rel="preload" type="font/ttf">
7-
<link as="font" crossorigin href="./src/assets/fonts/Roboto/Roboto-Medium.ttf" rel="preload" type="font/ttf">
7+
<!-- <link as="font" crossorigin href="./src/assets/fonts/Roboto/Roboto-Medium.ttf" rel="preload" type="font/ttf">-->
88
<link as="font" crossorigin href="./src/assets/fonts/Roboto/Roboto-SemiBold.ttf" rel="preload" type="font/ttf">
99
<link as="font" crossorigin href="./src/assets/fonts/Roboto/Roboto-Bold.ttf" rel="preload" type="font/ttf">
1010
<link as="font" crossorigin href="./src/assets/fonts/Roboto/Roboto-Italic.ttf" rel="preload" type="font/ttf">
11-
<link as="font" crossorigin href="./src/assets/fonts/Roboto/Roboto-MediumItalic.ttf" rel="preload" type="font/ttf">
11+
<!-- <link as="font" crossorigin href="./src/assets/fonts/Roboto/Roboto-MediumItalic.ttf" rel="preload" type="font/ttf">-->
1212
<link as="font" crossorigin href="./src/assets/fonts/Roboto/Roboto-SemiBoldItalic.ttf" rel="preload" type="font/ttf">
1313
<link as="font" crossorigin href="./src/assets/fonts/Roboto/Roboto-BoldItalic.ttf" rel="preload" type="font/ttf">
1414
<link as="font" crossorigin href="./src/assets/fonts/Noto-Sans-SC/NotoSansSC-Regular.ttf" rel="preload" type="font/ttf">
15-
<link as="font" crossorigin href="./src/assets/fonts/Noto-Sans-SC/NotoSansSC-Medium.ttf" rel="preload" type="font/ttf">
15+
<!-- <link as="font" crossorigin href="./src/assets/fonts/Noto-Sans-SC/NotoSansSC-Medium.ttf" rel="preload" type="font/ttf">-->
1616
<link as="font" crossorigin href="./src/assets/fonts/Noto-Sans-SC/NotoSansSC-SemiBold.ttf" rel="preload" type="font/ttf">
1717
<link as="font" crossorigin href="./src/assets/fonts/Noto-Sans-SC/NotoSansSC-Bold.ttf" rel="preload" type="font/ttf">
1818
<meta content="width=device-width, initial-scale=1.0" name="viewport" />

front/projects/web/src/views/service-management/service/application/application.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ServiceVolumeType } from "@/models"
1+
import { ServiceRestartPolicyMode, ServiceVolumeType } from "@/models"
22
import { NewServiceMetaDockerEmptyInfo, RegistryInfo, ServiceMetaDockerInfo } from "@/types"
33
import { filter, find, map, omit, omitBy, startsWith } from "lodash-es"
44
import { GenerateUUID } from "@/utils"
@@ -115,7 +115,10 @@ export function ParseMetaInfo(info: ServiceApplicationInfo): ServiceMetaDockerIn
115115
protocol: x.protocol
116116
})) || []
117117
},
118-
restartPolicy: info.restartPolicy
118+
restartPolicy: {
119+
mode: info.restartPolicy!.mode,
120+
maxRetryCount: info.restartPolicy!.mode === ServiceRestartPolicyMode.RestartPolicyModeOnFailure ? info.restartPolicy!.maxRetryCount : 0
121+
}
119122
}
120123
}
121124

front/projects/web/src/views/service-management/service/deployment/deployment.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ onMounted(async () => {
268268
<v-tips>{{ t("tips.scheduleTips") }}</v-tips>
269269
</div>
270270
<div v-for="(corn, index) in deploymentInfo.schedule.rules" :key="index" class="mb-3 cron-line">
271-
<div class="d-flex gap-3" style="background-color: #9cb4c5">
271+
<div class="d-flex gap-3">
272272
<strong>
273273
<el-text> {{ t("label.cron") }}</el-text>
274274
</strong>

front/projects/web/src/views/service-management/service/log/log.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { SetWebTitle } from "@/utils"
33
import { refreshData } from "@/views/service-management/service/common.ts"
44
import { RuleLength } from "@/models"
5-
import { find, toLower } from "lodash-es"
5+
import { filter, find, toLower } from "lodash-es"
66
77
const { t } = useI18n()
88
const route = useRoute()
@@ -14,7 +14,7 @@ const isAction = ref(false)
1414
1515
const groupId = ref(route.params.groupId as string)
1616
const serviceId = ref(route.params.serviceId as string)
17-
const containers = computed<ServiceContainerStatusInfo[]>(() => stateStore.getService(serviceId.value)?.containers || [])
17+
const containers = computed<ServiceContainerStatusInfo[]>(() => filter(stateStore.getService(serviceId.value)?.containers || [], x => !!x.containerId))
1818
1919
const searchInfo = ref({
2020
instance: "",

0 commit comments

Comments
 (0)