Commit 098fb047 authored by Andreas Heimann's avatar Andreas Heimann Committed by GitHub

Merge pull request #2 from jy1263/master

Drag and drop install implemented
parents 69fcd2b8 878d6712
const DOMLibrarySongsList = document.querySelector(".song-row-library .song-list"); const DOMLibrarySongsList = document.querySelector(".song-row-library .song-list");
function InstallBackupManually() { //The Extraction Process
dialog.showOpenDialog({ title: "Open Backup", properties: ['openFile'], filters: [{"name": "Backup Archive", "extensions": ["zip"]}] }).then(result => { function ExtractionProcess(filePath){
if(!result.canceled) { //Basic .zip detection so the console doesnt throw a flurry of errors complaining it can't unzip.
let filePath = result.filePaths[0]; if (filePath.endsWith('.zip')){
let fileName = path.basename(filePath); let fileName = path.basename(filePath)
srxdControl.extractBackup(filePath, fileName).then(function(extractResults) {
srxdControl.extractBackup(filePath, fileName).then(function(extractResults) {
if(extractResults) { if(extractResults) {
installBackup(extractResults); installBackup(extractResults);
setTimeout(function() { setTimeout(function() {
RefreshLibrary(); RefreshLibrary();
}, 200); }, 200);
} else { }
else {
console.error("Backup could not be loaded!"); console.error("Backup could not be loaded!");
} }
}); });
}
else {console.error('Not a zip!');}
}
//Upload Manually
function InstallBackupManually() {
dialog.showOpenDialog({ title: "Open Backup", properties: ['openFile'], filters: [{"name": "Backup Archive", "extensions": ["zip"]}] }).then(result => {
if(!result.canceled) {
let filePath = result.filePaths[0];
ExtractionProcess(filePath);
} }
}); });
} }
//Drag and Drop
document.ondragover = document.ondrop = (dragndrop) => {
dragndrop.preventDefault();
}
document.body.ondrop = (ev) => {
let filePath = (ev.dataTransfer.files[0].path)
ev.preventDefault()
ExtractionProcess(filePath);
}
function RefreshLibrary() { function RefreshLibrary() {
// Clear current songs // Clear current songs
let installElement = DOMLibrarySongsList.firstElementChild; let installElement = DOMLibrarySongsList.firstElementChild;
......
...@@ -164,3 +164,4 @@ function BuildSongDOM(songItem) { ...@@ -164,3 +164,4 @@ function BuildSongDOM(songItem) {
return songContainer; return songContainer;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment