Skip to content

Commit

Permalink
Add : Back up, Restore page
Browse files Browse the repository at this point in the history
  • Loading branch information
heedaeshin committed Sep 20, 2024
1 parent 0113193 commit 4f9da7c
Show file tree
Hide file tree
Showing 17 changed files with 1,282 additions and 85 deletions.
1 change: 0 additions & 1 deletion internal/auth/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
88 changes: 82 additions & 6 deletions web/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ window.addEventListener('DOMContentLoaded', event => {
if (document.getElementById('backForm')) {
backUpFormSubmit();
}
if (document.getElementById('restoreForm')) {
RestoreFormSubmit();
}

});

Expand Down Expand Up @@ -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();
})
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 4f9da7c

Please sign in to comment.