NewShare
This commit is contained in:
parent
4b090ed825
commit
4820e87db5
@ -1,8 +1,9 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"slices"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"slices"
|
||||||
|
|
||||||
oclib "cloud.o-forge.io/core/oc-lib"
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
@ -56,6 +57,7 @@ func (o *SharedWorkspaceController) Put() {
|
|||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||||
caller := tools.NewHTTPCaller(paths)
|
caller := tools.NewHTTPCaller(paths)
|
||||||
|
fmt.Println("UPDATE", res)
|
||||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, caller)
|
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, caller)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
@ -83,9 +85,10 @@ func (o *SharedWorkspaceController) Post() {
|
|||||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
caller := tools.NewHTTPCaller(paths)
|
||||||
var res map[string]interface{}
|
var res map[string]interface{}
|
||||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||||
caller := tools.NewHTTPCaller(paths)
|
|
||||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, caller)
|
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, caller)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
@ -117,7 +120,24 @@ func (o *SharedWorkspaceController) Get() {
|
|||||||
// @Success 200 {shared workspace} models.shared_workspace
|
// @Success 200 {shared workspace} models.shared_workspace
|
||||||
// @router /:id/workspace/:id2 [delete]
|
// @router /:id/workspace/:id2 [delete]
|
||||||
func (o *SharedWorkspaceController) RemoveWorkspace() {
|
func (o *SharedWorkspaceController) RemoveWorkspace() {
|
||||||
var res map[string]interface{}
|
var paths = map[string]map[tools.METHOD]string{
|
||||||
|
utils.SHARED_WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKFLOW.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||||
|
},
|
||||||
|
utils.PEER.String(): {
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
caller := tools.NewHTTPCaller(paths)
|
||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
id2 := o.Ctx.Input.Param(":id2")
|
id2 := o.Ctx.Input.Param(":id2")
|
||||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||||
@ -131,7 +151,7 @@ func (o *SharedWorkspaceController) RemoveWorkspace() {
|
|||||||
}
|
}
|
||||||
shared.Workspaces = newWorkspace
|
shared.Workspaces = newWorkspace
|
||||||
}
|
}
|
||||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +162,24 @@ func (o *SharedWorkspaceController) RemoveWorkspace() {
|
|||||||
// @Success 200 {shared workspace} models.shared_workspace
|
// @Success 200 {shared workspace} models.shared_workspace
|
||||||
// @router /:id/workflow/:id2 [delete]
|
// @router /:id/workflow/:id2 [delete]
|
||||||
func (o *SharedWorkspaceController) RemoveWorkflow() {
|
func (o *SharedWorkspaceController) RemoveWorkflow() {
|
||||||
var res map[string]interface{}
|
var paths = map[string]map[tools.METHOD]string{
|
||||||
|
utils.SHARED_WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKFLOW.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||||
|
},
|
||||||
|
utils.PEER.String(): {
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
caller := tools.NewHTTPCaller(paths)
|
||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
id2 := o.Ctx.Input.Param(":id2")
|
id2 := o.Ctx.Input.Param(":id2")
|
||||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||||
@ -156,7 +193,7 @@ func (o *SharedWorkspaceController) RemoveWorkflow() {
|
|||||||
}
|
}
|
||||||
shared.Workflows = newWorkflows
|
shared.Workflows = newWorkflows
|
||||||
}
|
}
|
||||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +204,24 @@ func (o *SharedWorkspaceController) RemoveWorkflow() {
|
|||||||
// @Success 200 {shared workspace} models.shared_workspace
|
// @Success 200 {shared workspace} models.shared_workspace
|
||||||
// @router /:id/peer/:id2 [delete]
|
// @router /:id/peer/:id2 [delete]
|
||||||
func (o *SharedWorkspaceController) RemovePeer() {
|
func (o *SharedWorkspaceController) RemovePeer() {
|
||||||
var res map[string]interface{}
|
var paths = map[string]map[tools.METHOD]string{
|
||||||
|
utils.SHARED_WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKFLOW.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||||
|
},
|
||||||
|
utils.PEER.String(): {
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
caller := tools.NewHTTPCaller(paths)
|
||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
id2 := o.Ctx.Input.Param(":id2")
|
id2 := o.Ctx.Input.Param(":id2")
|
||||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||||
@ -190,7 +244,7 @@ func (o *SharedWorkspaceController) RemovePeer() {
|
|||||||
}
|
}
|
||||||
shared.Peers = newPeers
|
shared.Peers = newPeers
|
||||||
}
|
}
|
||||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,13 +255,30 @@ func (o *SharedWorkspaceController) RemovePeer() {
|
|||||||
// @Success 200 {shared workspace} models.shared_workspace
|
// @Success 200 {shared workspace} models.shared_workspace
|
||||||
// @router /:id/rule/:id2 [delete]
|
// @router /:id/rule/:id2 [delete]
|
||||||
func (o *SharedWorkspaceController) RemoveRule() {
|
func (o *SharedWorkspaceController) RemoveRule() {
|
||||||
var res map[string]interface{}
|
var paths = map[string]map[tools.METHOD]string{
|
||||||
|
utils.SHARED_WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKFLOW.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||||
|
},
|
||||||
|
utils.PEER.String(): {
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
caller := tools.NewHTTPCaller(paths)
|
||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
id2 := o.Ctx.Input.Param(":id2")
|
id2 := o.Ctx.Input.Param(":id2")
|
||||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||||
shared := r.ToSharedWorkspace()
|
shared := r.ToSharedWorkspace()
|
||||||
newRules := []string{}
|
newRules := []string{}
|
||||||
if slices.Contains(shared.Rules, id) {
|
if shared != nil && slices.Contains(shared.Rules, id) {
|
||||||
for _, rule := range shared.Rules {
|
for _, rule := range shared.Rules {
|
||||||
if rule != id2 {
|
if rule != id2 {
|
||||||
newRules = append(newRules, rule)
|
newRules = append(newRules, rule)
|
||||||
@ -215,7 +286,7 @@ func (o *SharedWorkspaceController) RemoveRule() {
|
|||||||
}
|
}
|
||||||
shared.Rules = newRules
|
shared.Rules = newRules
|
||||||
}
|
}
|
||||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,15 +297,37 @@ func (o *SharedWorkspaceController) RemoveRule() {
|
|||||||
// @Success 200 {shared workspace} models.shared_workspace
|
// @Success 200 {shared workspace} models.shared_workspace
|
||||||
// @router /:id/workspace/:id2 [post]
|
// @router /:id/workspace/:id2 [post]
|
||||||
func (o *SharedWorkspaceController) AddWorkspace() {
|
func (o *SharedWorkspaceController) AddWorkspace() {
|
||||||
var res map[string]interface{}
|
var paths = map[string]map[tools.METHOD]string{
|
||||||
|
utils.SHARED_WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKFLOW.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||||
|
},
|
||||||
|
utils.PEER.String(): {
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
caller := tools.NewHTTPCaller(paths)
|
||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
id2 := o.Ctx.Input.Param(":id2")
|
id2 := o.Ctx.Input.Param(":id2")
|
||||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||||
|
if r.Code != 200 {
|
||||||
|
o.Data["json"] = r
|
||||||
|
o.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
shared := r.ToSharedWorkspace()
|
shared := r.ToSharedWorkspace()
|
||||||
if !slices.Contains(shared.Workspaces, id) {
|
if shared != nil && !slices.Contains(shared.Workspaces, id) {
|
||||||
shared.Workspaces = append(shared.Workspaces, id2)
|
shared.Workspaces = append(shared.Workspaces, id2)
|
||||||
}
|
}
|
||||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,15 +338,35 @@ func (o *SharedWorkspaceController) AddWorkspace() {
|
|||||||
// @Success 200 {shared workspace} models.shared_workspace
|
// @Success 200 {shared workspace} models.shared_workspace
|
||||||
// @router /:id/workflow/:id2 [post]
|
// @router /:id/workflow/:id2 [post]
|
||||||
func (o *SharedWorkspaceController) AddWorkflow() {
|
func (o *SharedWorkspaceController) AddWorkflow() {
|
||||||
var res map[string]interface{}
|
var paths = map[string]map[tools.METHOD]string{
|
||||||
|
utils.SHARED_WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKFLOW.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||||
|
},
|
||||||
|
utils.PEER.String(): {
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
caller := tools.NewHTTPCaller(paths)
|
||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
id2 := o.Ctx.Input.Param(":id2")
|
id2 := o.Ctx.Input.Param(":id2")
|
||||||
|
fmt.Println("AddWorkflow", id, id2)
|
||||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||||
shared := r.ToSharedWorkspace()
|
shared := r.ToSharedWorkspace()
|
||||||
if !slices.Contains(shared.Workflows, id) {
|
if shared != nil && !slices.Contains(shared.Workflows, id) {
|
||||||
shared.Workflows = append(shared.Workflows, id2)
|
shared.Workflows = append(shared.Workflows, id2)
|
||||||
}
|
}
|
||||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
fmt.Println("AddWorkflow", shared.Workflows)
|
||||||
|
|
||||||
|
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,15 +377,32 @@ func (o *SharedWorkspaceController) AddWorkflow() {
|
|||||||
// @Success 200 {shared workspace} models.shared_workspace
|
// @Success 200 {shared workspace} models.shared_workspace
|
||||||
// @router /:id/peer/:id2 [post]
|
// @router /:id/peer/:id2 [post]
|
||||||
func (o *SharedWorkspaceController) AddPeer() {
|
func (o *SharedWorkspaceController) AddPeer() {
|
||||||
var res map[string]interface{}
|
var paths = map[string]map[tools.METHOD]string{
|
||||||
|
utils.SHARED_WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKFLOW.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||||
|
},
|
||||||
|
utils.PEER.String(): {
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
caller := tools.NewHTTPCaller(paths)
|
||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
id2 := o.Ctx.Input.Param(":id2")
|
id2 := o.Ctx.Input.Param(":id2")
|
||||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||||
shared := r.ToSharedWorkspace()
|
shared := r.ToSharedWorkspace()
|
||||||
if !slices.Contains(shared.Peers, id) {
|
if shared != nil && !slices.Contains(shared.Peers, id) {
|
||||||
shared.Peers = append(shared.Peers, id2)
|
shared.Peers = append(shared.Peers, id2)
|
||||||
}
|
}
|
||||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,15 +413,32 @@ func (o *SharedWorkspaceController) AddPeer() {
|
|||||||
// @Success 200 {shared workspace} models.shared_workspace
|
// @Success 200 {shared workspace} models.shared_workspace
|
||||||
// @router /:id/rule/:id2 [post]
|
// @router /:id/rule/:id2 [post]
|
||||||
func (o *SharedWorkspaceController) AddRule() {
|
func (o *SharedWorkspaceController) AddRule() {
|
||||||
var res map[string]interface{}
|
var paths = map[string]map[tools.METHOD]string{
|
||||||
|
utils.SHARED_WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKSPACE.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||||
|
},
|
||||||
|
utils.WORKFLOW.String(): {
|
||||||
|
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||||
|
},
|
||||||
|
utils.PEER.String(): {
|
||||||
|
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc/peer",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
caller := tools.NewHTTPCaller(paths)
|
||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
id2 := o.Ctx.Input.Param(":id2")
|
id2 := o.Ctx.Input.Param(":id2")
|
||||||
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||||||
shared := r.ToSharedWorkspace()
|
shared := r.ToSharedWorkspace()
|
||||||
if !slices.Contains(shared.Rules, id) {
|
if shared != nil && !slices.Contains(shared.Rules, id) {
|
||||||
shared.Rules = append(shared.Rules, id2)
|
shared.Rules = append(shared.Rules, id2)
|
||||||
}
|
}
|
||||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, nil)
|
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -11,7 +11,7 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826125854-050e6022cb8d // indirect
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240827121739-3c5c065b8d24 // indirect
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
github.com/beego/bee/v2 v2.1.0 // indirect
|
github.com/beego/bee/v2 v2.1.0 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
|
16
go.sum
16
go.sum
@ -124,6 +124,22 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240826103423-aff9304b1a71 h1:GodGMXVFgSdd5
|
|||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826103423-aff9304b1a71/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826103423-aff9304b1a71/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826125854-050e6022cb8d h1:CPwBFl2ecnHMi9sxubA9/peTKn4BVBVpHkCCwRTXUik=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826125854-050e6022cb8d h1:CPwBFl2ecnHMi9sxubA9/peTKn4BVBVpHkCCwRTXUik=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240826125854-050e6022cb8d/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826125854-050e6022cb8d/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826132851-63b02199f62f h1:gQ7mCNs1yK99SY6ilA9J5Ng+hsKhbFfDBtELNzLK6eM=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826132851-63b02199f62f/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826141022-00625eabd631 h1:FYMS7QWERjvjAcdsmYRaq1Ms/PDfWv7Pr+OTKkwJSXQ=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826141022-00625eabd631/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826145224-767c14044f51 h1:rUeRWR3ckK7KKqRabE+HBOLXG+35Tv0jBbhpfrR8c2g=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826145224-767c14044f51/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826155958-463144a0625b h1:wjqnBe8WFxG0jDmSAxRWm2FJsXvLGwAO24JhdDzPm1M=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240826155958-463144a0625b/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240827080713-091cbb9e7fab h1:x3brpRs6nfv9549rvJMxeacYFqnpe1TrlM2qw5kzsXU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240827080713-091cbb9e7fab/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240827104028-772287225f44 h1:7jmT3iSzHJuJ2d1vJYTcwXeiDGv4SUOqQ8p4W04HIDY=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240827104028-772287225f44/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240827112206-45d53fc9a985 h1:4OzzVFOaI/QR/D5+qJiP4si6QsOggFFIPFmGwZ7cbeQ=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240827112206-45d53fc9a985/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240827121739-3c5c065b8d24 h1:naqxVtN3ew0eYVir+z2aagL13gCe1MdKv3Dp/sIBLxw=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240827121739-3c5c065b8d24/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
|
Loading…
Reference in New Issue
Block a user