Skip to content

Commit

Permalink
Add new Connection Managements Part of AdminWeb2
Browse files Browse the repository at this point in the history
  • Loading branch information
powerkimhub committed Jul 23, 2024
1 parent bd303ad commit 460fa14
Show file tree
Hide file tree
Showing 62 changed files with 3,995 additions and 603 deletions.
21 changes: 20 additions & 1 deletion api-runtime/rest-runtime/CBSpiderRuntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package restruntime
import (
"crypto/subtle"
"fmt"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -434,6 +435,12 @@ func RunServer() {
{"GET", "/countcluster", CountAllClusters},
{"GET", "/countcluster/:ConnectionName", CountClustersByConnection},

//----------Tag Handler
{"POST", "/tag", AddTag},
{"GET", "/tag", ListTag},
{"GET", "/tag/:Name", GetTag},
{"DELETE", "/tag/:Name", RemoveTag},

//----------Destory All Resources in a Connection
{"DELETE", "/destroy", Destroy},

Expand All @@ -459,12 +466,24 @@ func RunServer() {
{"GET", "/adminweb/top", aw.Top},
{"GET", "/adminweb/log", aw.Log},

{"GET", "/adminweb2", aw.MainPage},
{"GET", "/adminweb2/", aw.MainPage},
{"GET", "/adminweb/left_menu", aw.LeftMenu},
{"GET", "/adminweb/body_frame", aw.BodyFrame},

{"GET", "/adminweb/dashboard", aw.Dashboard},

{"GET", "/adminweb/driver", aw.Driver},
{"GET", "/adminweb2/driver", aw.DriverManagement},

{"GET", "/adminweb/credential", aw.Credential},
{"GET", "/adminweb2/credential", aw.CredentialManagement},

{"GET", "/adminweb/region", aw.Region},
{"GET", "/adminweb2/region", aw.RegionManagement},

{"GET", "/adminweb/connectionconfig", aw.Connectionconfig},
{"GET", "/adminweb2/connectionconfig", aw.ConnectionManagement},

{"GET", "/adminweb/dashboard", aw.Dashboard},

Expand Down Expand Up @@ -568,7 +587,7 @@ func ApiServer(routes []route) {
}

// for spider logo
e.File("/spider/adminweb/images/logo.png", cbspiderRoot+"/api-runtime/rest-runtime/admin-web/images/cb-spider-circle-logo.png")
e.Static("/spider/adminweb/images", filepath.Join(cbspiderRoot, "api-runtime/rest-runtime/admin-web/images"))

// for admin-web
e.File("/spider/adminweb/html/priceinfo-filter-gen.html", cbspiderRoot+"/api-runtime/rest-runtime/admin-web/html/priceinfo-filter-gen.html")
Expand Down
63 changes: 54 additions & 9 deletions api-runtime/rest-runtime/CIMRest.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,24 @@ func RegisterCloudDriver(c echo.Context) error {
func ListCloudDriver(c echo.Context) error {
cblog.Info("call ListCloudDriver()")

infoList, err := dim.ListCloudDriver()
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
var providerName string
providerName = c.QueryParam("provider")
if providerName == "" {
providerName = c.QueryParam("ProviderName")
}

infoList := []*dim.CloudDriverInfo{}
var err error
if providerName != "" {
infoList, err = dim.ListCloudDriverByProvider(providerName)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
} else {
infoList, err = dim.ListCloudDriver()
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
}

var jsonResult struct {
Expand Down Expand Up @@ -166,9 +181,24 @@ func RegisterCredential(c echo.Context) error {
func ListCredential(c echo.Context) error {
cblog.Info("call ListCredential()")

infoList, err := cim.ListCredential()
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
var providerName string
providerName = c.QueryParam("provider")
if providerName == "" {
providerName = c.QueryParam("ProviderName")
}

infoList := []*cim.CredentialInfo{}
var err error
if providerName != "" {
infoList, err = cim.ListCredentialByProvider(providerName)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
} else {
infoList, err = cim.ListCredential()
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
}

var jsonResult struct {
Expand Down Expand Up @@ -227,9 +257,24 @@ func RegisterRegion(c echo.Context) error {
func ListRegion(c echo.Context) error {
cblog.Info("call ListRegion()")

infoList, err := rim.ListRegion()
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
var providerName string
providerName = c.QueryParam("provider")
if providerName == "" {
providerName = c.QueryParam("ProviderName")
}

infoList := []*rim.RegionInfo{}
var err error
if providerName != "" {
infoList, err = rim.ListRegionByProvider(providerName)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
} else {
infoList, err = rim.ListRegion()
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
}

var jsonResult struct {
Expand Down
Loading

0 comments on commit 460fa14

Please sign in to comment.