diff --git a/internal/auth/base.go b/internal/auth/base.go index 77a809c..0814c17 100644 --- a/internal/auth/base.go +++ b/internal/auth/base.go @@ -261,7 +261,6 @@ func GetNRDMS(params *models.ProviderConfig) (*nrdbc.NRDBController, error) { if err != nil { return nil, err } - NRDBC, err = nrdbc.New(ncpmgdb.New(ncpnrdb, params.DatabaseName)) if err != nil { return nil, err diff --git a/web/js/scripts.js b/web/js/scripts.js index 97815c2..e0759b3 100644 --- a/web/js/scripts.js +++ b/web/js/scripts.js @@ -32,6 +32,9 @@ window.addEventListener('DOMContentLoaded', event => { if (document.getElementById('backForm')) { backUpFormSubmit(); } + if (document.getElementById('restoreForm')) { + RestoreFormSubmit(); + } }); @@ -210,16 +213,32 @@ function backUpFormSubmit() { resultCollpase(); const payload = new FormData(form); - const dest = document.getElementById('backDest').value; - const source = document.getElementById('backSource').value; - let url = "/backup/" + source; + var service = document.getElementById('srcService').value; + let url = "/backup/" + service; console.log(url); - fetch(url, { + + let jsonData= formDataToObject(payload) + console.log(jsonData) + + + if ( (jsonData.targetPoint.provider =="ncp") && (jsonData.targetPoint.endpoint =="") ) { + jsonData.targetPoint.endpoint ="https://kr.object.ncloudstorage.com" + } + if ( (jsonData.sourcePoint.provider =="ncp") && (jsonData.sourcePoint.endpoint =="") ) { + jsonData.sourcePoint.endpoint ="https://kr.object.ncloudstorage.com" + } + + let req= { method: 'POST', - body: payload - }) + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(jsonData) + }; + + fetch(url, req ) .then(response => { return response.json(); }) @@ -241,6 +260,63 @@ function backUpFormSubmit() { }); } +function RestoreFormSubmit() { + const form = document.getElementById('restoreForm'); + + form.addEventListener('submit', (e) => { + e.preventDefault(); + loadingButtonOn(); + resultCollpase(); + + const payload = new FormData(form); + + var service = document.getElementById('srcService').value; + let url = "/restore/" + service; + console.log(url); + + + let jsonData= formDataToObject(payload) + console.log(jsonData) + + + if ( (jsonData.targetPoint.provider =="ncp") && (jsonData.targetPoint.endpoint =="") ) { + jsonData.targetPoint.endpoint ="https://kr.object.ncloudstorage.com" + } + if ( (jsonData.sourcePoint.provider =="ncp") && (jsonData.sourcePoint.endpoint =="") ) { + jsonData.sourcePoint.endpoint ="https://kr.object.ncloudstorage.com" + } + + let req= { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(jsonData) + }; + + fetch(url, req ) + .then(response => { + return response.json(); + }) + .then(json => { + const resultText = document.getElementById('resultText'); + resultText.value = json.Result; + console.log(json); + console.log("restore done."); + }) + .catch(reason => { + console.log(reason); + alert(reason); + }) + .finally(() => { + loadingButtonOff(); + }); + + console.log("restore progressing..."); + }); +} + + function loadingButtonOn() { let btn = document.getElementById('submitBtn'); btn.disabled = true; diff --git a/web/templates/back-backup.html b/web/templates/back-backup.html index 000a8e4..a07a7a4 100644 --- a/web/templates/back-backup.html +++ b/web/templates/back-backup.html @@ -10,48 +10,291 @@

백업

Back Up
-
+
+ +
+ + +
+
+ +
+ + +
+ +
+ + +
+
+
+ + + + +
- - + + + +
-
- -
- - + -
- -
- - + -
- -
- - + - + + + + + + + + + +
-
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/web/templates/content.html b/web/templates/content.html index 91647a6..7811656 100644 --- a/web/templates/content.html +++ b/web/templates/content.html @@ -5,6 +5,11 @@ {{ template "main.html" }} {{ end }} + + {{ if eq .Content "dashboard" }} + {{ template "dash-board.html" . }} + {{ end }} + {{ if eq .Content "Generate-Linux" }} @@ -47,6 +52,11 @@ {{ if eq .Content "Backup" }} {{ template "back-backup.html" . }} {{ end }} + + + {{ if eq .Content "Restore" }} + {{ template "res-restore.html" . }} + {{ end }} @@ -158,11 +168,7 @@ {{ template "mig-mongodbToFirestore.html" . }} {{ end }} - - {{ if eq .Content "BackUp" }} - {{ template "back-backup.html" . }} - {{ end }} - + {{ if ne .Content "main" }} {{ template "result.html" . }} {{ end }} diff --git a/web/templates/dash-board.html b/web/templates/dash-board.html new file mode 100644 index 0000000..bdfbdb2 --- /dev/null +++ b/web/templates/dash-board.html @@ -0,0 +1,405 @@ + + + + + 서비스 상태 + + + + + + +
+ +
+
+
+ + +
+
+
+ + +
+ +
+
+
+ AWS +
+
+

활성화된 서비스 개수: 0

+

이번 달 청구 비용: ₩0

+
+
+
+ + +
+
+
+ GCP +
+
+

활성화된 서비스 개수: 0

+

이번 달 청구 비용: ₩0

+
+
+
+ + +
+
+
+ NCP +
+
+

활성화된 서비스 개수: 0

+

이번 달 청구 비용: ₩0

+
+
+
+
+ + +
+ +
+ + + +
+
+
+
+ AWS 데일리 로그 +
+
+ +
    + +
+
+
+
+
+ + +
+
+
+
+ GCP 데일리 로그 +
+
+ +
    + +
+
+
+
+
+ + +
+
+
+
+ NCP 데일리 로그 +
+
+ +
    + +
+
+
+
+
+ + + + +
+ + + + + + + + diff --git a/web/templates/index.html b/web/templates/index.html index a4bddd4..7ab5d49 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -16,7 +16,7 @@ --> -
데이터 생성
+
Generate
+ +
Restore
+ + + + +
diff --git a/web/templates/mig-firestoreToDynamodb.html b/web/templates/mig-firestoreToDynamodb.html index da3d886..db18493 100644 --- a/web/templates/mig-firestoreToDynamodb.html +++ b/web/templates/mig-firestoreToDynamodb.html @@ -13,12 +13,14 @@

마이그레이션 Firestore

+ +
- {{ range $index, $value := .GCPRegions }} @@ -27,8 +29,14 @@

마이그레이션 Firestore

- -
+
+ +
+ + +
+
+
- {{ range $index, $value := .AWSRegions }} @@ -54,8 +62,14 @@

마이그레이션 Firestore

-
+ +
+ + +
+
+ diff --git a/web/templates/mig-firestoreToMongodb.html b/web/templates/mig-firestoreToMongodb.html index 8a3ff76..9193804 100644 --- a/web/templates/mig-firestoreToMongodb.html +++ b/web/templates/mig-firestoreToMongodb.html @@ -13,12 +13,13 @@

마이그레이션 Firestore

- + +
- {{ range $index, $value := .Regions }} @@ -27,8 +28,14 @@

마이그레이션 Firestore

- -
+
+ +
+ + +
+
+
- +
@@ -54,7 +61,7 @@

마이그레이션 Firestore

- +
@@ -62,7 +69,7 @@

마이그레이션 Firestore

- +
@@ -70,7 +77,7 @@

마이그레이션 Firestore

- +
@@ -78,7 +85,7 @@

마이그레이션 Firestore

- +
diff --git a/web/templates/mig-mongodbToDynamodb.html b/web/templates/mig-mongodbToDynamodb.html index 2b83775..03e5674 100644 --- a/web/templates/mig-mongodbToDynamodb.html +++ b/web/templates/mig-mongodbToDynamodb.html @@ -13,13 +13,15 @@

마이그레이션 MongoDB

+ +
- +
@@ -27,7 +29,7 @@

마이그레이션 MongoDB

- +
@@ -35,7 +37,7 @@

마이그레이션 MongoDB

- +
@@ -43,7 +45,7 @@

마이그레이션 MongoDB

- +
@@ -51,7 +53,7 @@

마이그레이션 MongoDB

- +
@@ -60,7 +62,7 @@

마이그레이션 MongoDB

- {{ range $index, $value := .Regions }} @@ -69,8 +71,14 @@

마이그레이션 MongoDB

-
+ +
+ + +
+
+ diff --git a/web/templates/mig-mongodbToFirestore.html b/web/templates/mig-mongodbToFirestore.html index 0d57c47..0effe13 100644 --- a/web/templates/mig-mongodbToFirestore.html +++ b/web/templates/mig-mongodbToFirestore.html @@ -13,13 +13,14 @@

마이그레이션 MongoDB

- + +
- +
@@ -27,7 +28,7 @@

마이그레이션 MongoDB

- +
@@ -35,7 +36,7 @@

마이그레이션 MongoDB

- +
@@ -43,7 +44,7 @@

마이그레이션 MongoDB

- +
@@ -51,16 +52,15 @@

마이그레이션 MongoDB

- +
-
- {{ range $index, $value := .Regions }} @@ -69,8 +69,14 @@

마이그레이션 MongoDB

- -
+
+ +
+ + +
+
+ diff --git a/web/templates/res-restore.html b/web/templates/res-restore.html new file mode 100644 index 0000000..3b6afda --- /dev/null +++ b/web/templates/res-restore.html @@ -0,0 +1,300 @@ +

복구

+ + +
+
+ + Restore +
+
+
+ + + + +
+ +
+ + +
+
+ +
+ + +
+ +
+ + +
+
+
+ + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + +
+
+
+ + \ No newline at end of file diff --git a/web/templates/task.html b/web/templates/task.html new file mode 100644 index 0000000..1b52eb6 --- /dev/null +++ b/web/templates/task.html @@ -0,0 +1,84 @@ +

백업

+ + +
+
+ + Back Up +
+
+ +
+ + + + + +
+ + +
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ + +
+
+
+ +
+
+ + +
+ +

+ + +
+
+ +
\ No newline at end of file diff --git a/websrc/controllers/backupHandlers.go b/websrc/controllers/backupHandlers.go index 9e48e3a..bc51955 100644 --- a/websrc/controllers/backupHandlers.go +++ b/websrc/controllers/backupHandlers.go @@ -33,7 +33,7 @@ import ( // // @Summary Export data from objectstorage // @Description Export data from a objectstorage to files. -// @Tags [Data Export], [Object Storage] +// @Tags [Data Backup], [Object Storage] // @Accept json // @Produce json // @Param RequestBody body models.BackupTask true "Parameters required for backup" @@ -72,7 +72,7 @@ func BackupOSPostHandler(ctx echo.Context) error { // // @Summary Export data from MySQL // @Description Export data from a MySQL database to SQL files. -// @Tags [Data Export], [RDBMS] +// @Tags [Data Backup], [RDBMS] // @Accept json // @Produce json // @Param RequestBody body models.BackupTask true "Parameters required for backup" @@ -160,7 +160,7 @@ func BackupRDBPostHandler(ctx echo.Context) error { // // @Summary Export data from MySQL // @Description Export data from a MySQL database to SQL files. -// @Tags [Data Export], [RDBMS] +// @Tags [Data Backup], [RDBMS] // @Accept json // @Produce json // @Param RequestBody body models.BackupTask true "Parameters required for backup" @@ -177,33 +177,37 @@ func BackupNRDBPostHandler(ctx echo.Context) error { params := models.BackupTask{} if !getDataWithReBind(logger, start, ctx, ¶ms) { + errorMsg := fmt.Sprintf("err getDataWithReBind: %v", params) return ctx.JSON(http.StatusOK, models.BasicResponse{ Result: logstrings.String(), - Error: nil, + Error: &errorMsg, }) } - + logger.Debug().Msgf("%+v", params) NRDBC, err = auth.GetNRDMS(¶ms.SourcePoint) if err != nil { + errorMsg := fmt.Sprintf("err provider: %v", err) return ctx.JSON(http.StatusInternalServerError, models.BasicResponse{ Result: logstrings.String(), - Error: nil, + Error: &errorMsg, }) } err = os.MkdirAll(params.TargetPoint.Path, 0755) if err != nil { + errorMsg := fmt.Sprintf("err Mkdir: %v", err) return ctx.JSON(http.StatusInternalServerError, models.BasicResponse{ Result: logstrings.String(), - Error: nil, + Error: &errorMsg, }) } tableList, err := NRDBC.ListTables() if err != nil { + errorMsg := fmt.Sprintf("err Get ListTables: %v", err) return ctx.JSON(http.StatusInternalServerError, models.BasicResponse{ Result: logstrings.String(), - Error: nil, + Error: &errorMsg, }) } diff --git a/websrc/controllers/pageHandlers.go b/websrc/controllers/pageHandlers.go index 489531a..6f020a5 100644 --- a/websrc/controllers/pageHandlers.go +++ b/websrc/controllers/pageHandlers.go @@ -33,6 +33,22 @@ func MainGetHandler(ctx echo.Context) error { }) } +/////////////////////////////////////////////////////////////////////////////////////////////// +// Page handlers related to Dashboard data + +func DashBoardHandler(ctx echo.Context) error { + logger := getLogger("dashboard") + logger.Info().Msg("dashboard get page accessed") + return ctx.Render(http.StatusOK, "index.html", models.BasicPageResponse{ + Content: "dashboard", + AWSRegions: GetAWSRegions(), + GCPRegions: GetGCPRegions(), + NCPRegions: GetNCPRegions(), + OS: runtime.GOOS, + Error: nil, + }) +} + /////////////////////////////////////////////////////////////////////////////////////////////// // Page handlers related to generate data @@ -147,14 +163,32 @@ func BackupHandler(ctx echo.Context) error { logger := getLogger("backup") logger.Info().Msg("backup get page accessed") return ctx.Render(http.StatusOK, "index.html", models.BasicPageResponse{ - Content: "Backup", - Regions: GetAWSRegions(), - OS: runtime.GOOS, - Error: nil, + Content: "Backup", + AWSRegions: GetAWSRegions(), + GCPRegions: GetGCPRegions(), + NCPRegions: GetNCPRegions(), + OS: runtime.GOOS, + Error: nil, }) } /////////////////////////////////////////////////////////////////////////////////////////////// +// Page handlers related to backup data + +func RestoreHandler(ctx echo.Context) error { + logger := getLogger("restore") + logger.Info().Msg("restore get page accessed") + return ctx.Render(http.StatusOK, "index.html", models.BasicPageResponse{ + Content: "Restore", + AWSRegions: GetAWSRegions(), + GCPRegions: GetGCPRegions(), + NCPRegions: GetNCPRegions(), + OS: runtime.GOOS, + Error: nil, + }) +} + +/////////////////////////////////////////////////////////////////////////////////////////// // Page handlers related to migration data // linux to object storage diff --git a/websrc/controllers/restoreHandlers.go b/websrc/controllers/restoreHandlers.go index 0278221..d73d778 100644 --- a/websrc/controllers/restoreHandlers.go +++ b/websrc/controllers/restoreHandlers.go @@ -37,7 +37,7 @@ import ( // @ID RestoreOSPostHandler // @Summary Import data from objectstorage // @Description Import data from a objectstorage to files. -// @Tags [Data Import], [Object Storage] +// @Tags [Data Restore], [Object Storage] // @Accept json // @Produce json // @Param RequestBody body models.RestoreTask true "Parameters required for Restore" @@ -77,7 +77,7 @@ func RestoreOSPostHandler(ctx echo.Context) error { // @ID RestoreRDBPostHandler // @Summary Import data from MySQL // @Description Import data from a MySQL database to SQL files. -// @Tags [Data Import], [RDBMS] +// @Tags [Data Restore], [RDBMS] // @Accept json // @Produce json // @Param RequestBody body models.RestoreTask true "Parameters required for Restore" @@ -165,7 +165,7 @@ func RestoreRDBPostHandler(ctx echo.Context) error { // @ID RestoreNRDBPostHandler // @Summary Import data from MySQL // @Description Import data from a MySQL database to SQL files. -// @Tags [Data Import], [RDBMS] +// @Tags [Data Restore], [RDBMS] // @Accept json // @Produce json // @Param RequestBody body models.RestoreTask true "Parameters required for Restore" diff --git a/websrc/routes/restoreRoutes.go b/websrc/routes/restoreRoutes.go index 1bc2b84..df17432 100644 --- a/websrc/routes/restoreRoutes.go +++ b/websrc/routes/restoreRoutes.go @@ -33,7 +33,7 @@ func RestoreRoutes(g *echo.Group) { } func RestoreRoot(g *echo.Group) { - // g.GET("", controllers.RestoreHandler) + g.GET("", controllers.RestoreHandler) } func RestoreObjectStorage(g *echo.Group) { diff --git a/websrc/routes/taskRoutes.go b/websrc/routes/taskRoutes.go index 6e986ca..9562f82 100644 --- a/websrc/routes/taskRoutes.go +++ b/websrc/routes/taskRoutes.go @@ -37,4 +37,5 @@ func TaskRoot(g *echo.Group, scheduleManager *task.FileScheduleManager) { g.POST("", taskController.CreateTaskHandler) // Create a new task g.PUT("/:id", taskController.UpdateTaskHandler) // Update an existing task by ID or OperationID g.DELETE("/:id", taskController.DeleteTaskHandler) // Delete a task by ID or OperationID + g.GET("/dash", controllers.DashBoardHandler) }