mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-08 21:05:54 +08:00
add color coding to tags
This commit is contained in:
parent
3bdb7fb5e3
commit
9cf2ad4fc5
3 changed files with 13 additions and 0 deletions
|
@ -88,6 +88,7 @@ func createTag(w http.ResponseWriter, r *http.Request) {
|
|||
TagName: req.TagName,
|
||||
Network: req.Network,
|
||||
CreatedBy: user.UserName,
|
||||
ColorCode: req.ColorCode,
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
_, err = logic.GetTag(tag.ID)
|
||||
|
@ -182,6 +183,14 @@ func updateTag(w http.ResponseWriter, r *http.Request) {
|
|||
// delete old Tag entry
|
||||
logic.DeleteTag(updateTag.ID, false)
|
||||
}
|
||||
if updateTag.ColorCode != "" && updateTag.ColorCode != tag.ColorCode {
|
||||
tag.ColorCode = updateTag.ColorCode
|
||||
err = logic.InsertTag(tag)
|
||||
if err != nil {
|
||||
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
|
||||
return
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
logic.UpdateTag(updateTag, newID)
|
||||
if updateTag.NewName != "" {
|
||||
|
|
|
@ -59,6 +59,7 @@ const (
|
|||
UserGroupAclID AclGroupType = "user-group"
|
||||
NodeTagID AclGroupType = "tag"
|
||||
NodeID AclGroupType = "device"
|
||||
EgressRange AclGroupType = "egress-range"
|
||||
NetmakerIPAclID AclGroupType = "ip"
|
||||
NetmakerSubNetRangeAClID AclGroupType = "ipset"
|
||||
)
|
||||
|
|
|
@ -23,6 +23,7 @@ type Tag struct {
|
|||
ID TagID `json:"id"`
|
||||
TagName string `json:"tag_name"`
|
||||
Network NetworkID `json:"network"`
|
||||
ColorCode string `json:"color_code"`
|
||||
CreatedBy string `json:"created_by"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
@ -30,6 +31,7 @@ type Tag struct {
|
|||
type CreateTagReq struct {
|
||||
TagName string `json:"tag_name"`
|
||||
Network NetworkID `json:"network"`
|
||||
ColorCode string `json:"color_code"`
|
||||
TaggedNodes []ApiNode `json:"tagged_nodes"`
|
||||
}
|
||||
|
||||
|
@ -48,5 +50,6 @@ type TagListRespNodes struct {
|
|||
type UpdateTagReq struct {
|
||||
Tag
|
||||
NewName string `json:"new_name"`
|
||||
ColorCode string `json:"color_code"`
|
||||
TaggedNodes []ApiNode `json:"tagged_nodes"`
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue