mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-10 22:05:58 +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,
|
TagName: req.TagName,
|
||||||
Network: req.Network,
|
Network: req.Network,
|
||||||
CreatedBy: user.UserName,
|
CreatedBy: user.UserName,
|
||||||
|
ColorCode: req.ColorCode,
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
}
|
}
|
||||||
_, err = logic.GetTag(tag.ID)
|
_, err = logic.GetTag(tag.ID)
|
||||||
|
@ -182,6 +183,14 @@ func updateTag(w http.ResponseWriter, r *http.Request) {
|
||||||
// delete old Tag entry
|
// delete old Tag entry
|
||||||
logic.DeleteTag(updateTag.ID, false)
|
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() {
|
go func() {
|
||||||
logic.UpdateTag(updateTag, newID)
|
logic.UpdateTag(updateTag, newID)
|
||||||
if updateTag.NewName != "" {
|
if updateTag.NewName != "" {
|
||||||
|
|
|
@ -59,6 +59,7 @@ const (
|
||||||
UserGroupAclID AclGroupType = "user-group"
|
UserGroupAclID AclGroupType = "user-group"
|
||||||
NodeTagID AclGroupType = "tag"
|
NodeTagID AclGroupType = "tag"
|
||||||
NodeID AclGroupType = "device"
|
NodeID AclGroupType = "device"
|
||||||
|
EgressRange AclGroupType = "egress-range"
|
||||||
NetmakerIPAclID AclGroupType = "ip"
|
NetmakerIPAclID AclGroupType = "ip"
|
||||||
NetmakerSubNetRangeAClID AclGroupType = "ipset"
|
NetmakerSubNetRangeAClID AclGroupType = "ipset"
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,6 +23,7 @@ type Tag struct {
|
||||||
ID TagID `json:"id"`
|
ID TagID `json:"id"`
|
||||||
TagName string `json:"tag_name"`
|
TagName string `json:"tag_name"`
|
||||||
Network NetworkID `json:"network"`
|
Network NetworkID `json:"network"`
|
||||||
|
ColorCode string `json:"color_code"`
|
||||||
CreatedBy string `json:"created_by"`
|
CreatedBy string `json:"created_by"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
@ -30,6 +31,7 @@ type Tag struct {
|
||||||
type CreateTagReq struct {
|
type CreateTagReq struct {
|
||||||
TagName string `json:"tag_name"`
|
TagName string `json:"tag_name"`
|
||||||
Network NetworkID `json:"network"`
|
Network NetworkID `json:"network"`
|
||||||
|
ColorCode string `json:"color_code"`
|
||||||
TaggedNodes []ApiNode `json:"tagged_nodes"`
|
TaggedNodes []ApiNode `json:"tagged_nodes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,5 +50,6 @@ type TagListRespNodes struct {
|
||||||
type UpdateTagReq struct {
|
type UpdateTagReq struct {
|
||||||
Tag
|
Tag
|
||||||
NewName string `json:"new_name"`
|
NewName string `json:"new_name"`
|
||||||
|
ColorCode string `json:"color_code"`
|
||||||
TaggedNodes []ApiNode `json:"tagged_nodes"`
|
TaggedNodes []ApiNode `json:"tagged_nodes"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue