75 lines
1.7 KiB
Go
75 lines
1.7 KiB
Go
|
package controllers
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
beego "github.com/beego/beego/v2/server/web"
|
||
|
)
|
||
|
|
||
|
// DetailsController is the controller in chrage of solr
|
||
|
type DetailsController struct {
|
||
|
beego.Controller
|
||
|
}
|
||
|
|
||
|
// @Title GetDetails
|
||
|
// @Description Return details of a resource
|
||
|
// @Success 200 {string} Cool
|
||
|
// @router /data/:id [post]
|
||
|
// @router /computing/:id [post]
|
||
|
// @router /storage/:id [post]
|
||
|
// @router /datacenter/:id [post]
|
||
|
func (c *DetailsController) SubmitToWorkspace(id string) {
|
||
|
rType := c.Ctx.Input.Params()["1"]
|
||
|
|
||
|
var err error
|
||
|
|
||
|
switch rType {
|
||
|
case "data":
|
||
|
case "computing":
|
||
|
case "datacenter":
|
||
|
case "storage":
|
||
|
_, err = OCCatalogAPI.WorkspaceApi.WorkspaceControllerAddModelToWorkspace(context.Background(), id, rType)
|
||
|
default:
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
// @Title GetDetails
|
||
|
// @Description Return details of a resource
|
||
|
// @Success 200 {string} Cool
|
||
|
// @router /data/:id [get]
|
||
|
// @router /computing/:id [get]
|
||
|
// @router /storage/:id [get]
|
||
|
// @router /datacenter/:id [get]
|
||
|
func (c *DetailsController) GetElementInfo(id string) {
|
||
|
rType := c.Ctx.Input.Params()["1"]
|
||
|
|
||
|
var res interface{}
|
||
|
var err error
|
||
|
|
||
|
switch rType {
|
||
|
case "data":
|
||
|
res, _, err = OCCatalogAPI.DataApi.DataControllerGetDataByID(context.Background(), id)
|
||
|
case "computing":
|
||
|
res, _, err = OCCatalogAPI.ComputingApi.ComputingControllerGetComputingByID(context.Background(), id)
|
||
|
case "datacenter":
|
||
|
res, _, err = OCCatalogAPI.DatacenterApi.DatacenterControllerGetOneDatacenter(context.Background(), id)
|
||
|
case "storage":
|
||
|
res, _, err = OCCatalogAPI.StorageApi.StorageControllerGet(context.Background(), id)
|
||
|
default:
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.Data["data"] = res
|
||
|
c.TplName = "details.tpl"
|
||
|
}
|