Closed klmhsb42 closed 1 year ago
I'm trying to add this, but I need some help. I edited backup.html and backup.js https://github.com/syncloud/platform/compare/master...klmhsb42:master
I need to know: (1) Which backup script do I need to run to zip all? Because then I would set a link to this file (Download all) (2) Where are the tar.gz files stored (can't find them under /data/platform/backup), I would like to set a download link with: (3) Where are the scripts for restore and remove, I would like to adapt them as download script. (4) I would add a upload script as well to upload files
First of all you are making changes on outdated master branch so that is why it always shows all the past changes which may have been already merged to remote master branch. You need to add remote:
git remote add syncloud https://github.com/syncloud/platform.git
Fetch latest changes:
git fetch syncloud
Create a branch for a feature
git checkout -b feature syncloud/master
Make (commit) some changes and push to your repo (origin) as you cannot push to syncloud
git push feature origin
Then you can create a pull request on github.
As to the questions:
Thanks for the help.
What is your workflow on local desktop? I would like to make changes on a running syncloud to see changes and also I need a complete installation to have data directory, apps, etc... Or do I have to modify platform and then to create an new image and then start it with VM?
I can see how you are calling bash scripts with go scripts, but I don't get in which line of backup.js you are calling go scripts. Is it $.get('/rest/backup/restore', { file: file }, () => { reload(); })
?
Do you remove backup files completly or move them to some trash folder? And if an app is restored by backup file, what happens with the current app data? Is it displaced completly? If so, it would be nice to create a backup before restoring...
Just in case my desktop is Ubuntu.
If I am changing backend (python, go) usually I just write unit tests for vatious pieces (you do not have to do it just for trying things) and in the end build a platform package and just install it over existing platform on a device.
Sone info here: https://github.com/syncloud/platform/blob/master/README.md#building-a-package-locally
The usual architecture of a web app is the following:
When backup is removed it is removed completly (no trash). Restore removes all app configs from previous installation, you can crrate an issue to offer a backup before restoring.
I'm trying to create buttons after the grid in the backup.js
const backupallOptions = () => {
var div2 = document.createElement('div');
div2.innerHTML = `
<button class="submit buttongreen control" id="" type="submit" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> Working..." style="width: 150px">Download all</button>
<button class="submit buttongreen control" id="" type="submit" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> Working..." style="width: 150px">Backup all</button>
<button class="submit buttonblue control" id="" type="submit" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> Working..." style="width: 150px">Restore all</button>
<button class="submit buttonred control" id="" type="submit" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> Working..." style="width: 150px">Delete all</button>
`;
var buttons = div2.querySelectorAll('i');
buttons[0].addEventListener('click', () => {
$('#backup_file').val(params.data.file);
$('#backup_action').val('downloadall');
$('#confirm_caption').html('Download');
$('#confirm_question').html('Do you want to download all backup files?');
$('#backup_action_confirmation').modal('show');
});
buttons[1].addEventListener('click', () => {
$('#backup_file').val(params.data.file);
$('#backup_action').val('backupall');
$('#confirm_caption').html('Backup');
$('#confirm_question').html('Do you want to backup all apps?');
$('#backup_action_confirmation').modal('show');
});
buttons[2].addEventListener('click', () => {
$('#backup_file').val(params.data.file);
$('#backup_action').val('restoreall');
$('#confirm_caption').html('Restore');
$('#confirm_question').html('Do you want to restore all apps from respective latest backup?');
$('#backup_action_confirmation').modal('show');
});
buttons[3].addEventListener('click', () => {
$('#backup_file').val(params.data.file);
$('#backup_action').val('removeall');
$('#confirm_caption').html('Remove');
$('#confirm_question').html('Do you want to remove all backup files completely?');
$('#backup_action_confirmation').modal('show');
});
return div2;
};
And to show it with the existing function:
$( document ).ready(function () {
let backupallbuttons = document.querySelector('#backupAll');
//backupallbuttons.innerHTML += backupallOptions;
backupallbuttons.appendChild(backupallOptions);
reload();
});
But innerHTML
shows only everything inside the function as text and appendChild
shows nothing. Any idea?
Of course <div id="backupAll" style="margin-top: 2%;"></div>
exists in backup.html
.
You are not calling backupallOptions function. You need to call it with backupallOptions()
I tried but nothing happens. I guess maybe div2
is not returned? Or it breaks the function after backupallOptions()
.
$( document ).ready(function () {
let backupallbuttons = document.querySelector('#backupAll');
backupallOptions();
backupallbuttons.appendChild(div2);
reload();
});
You are not using the returned div now.
$( document ).ready(function () {
let backupallbuttons = document.querySelector('#backupAll');
backupallbuttons.appendChild(backupallOptions());
reload();
});
That's what I tested, too. I don't get any output on the html page. Maybe backupallOptions() breaks somehow?
Check what browser's developer tools says (F12), console tab.
You can also debug your js there.
Or just reading docs :) https://www.w3schools.com/jsref/met_document_queryselectorall.asp
var buttons = div2.querySelectorAll('button');
instead of
var buttons = div2.querySelectorAll('i');
Also, you do not have to create these elements programmatically in js, they can be simply added to html herr below the grid: https://github.com/syncloud/platform/blob/master/www/public/backup.html#L18
You need to use js for more dynamic content, for example grid row buttoms are easier to create dynamically.
Stale
(1) What is inside the backup files? (2) Add Download links each file (+ Download all button) (3) Info, how to backup SD/System (Link to Wiki)