|
|
|
@ -4,7 +4,45 @@ class Controller {
|
|
|
|
|
this.view = view;
|
|
|
|
|
|
|
|
|
|
this.redrawDirTree(view);
|
|
|
|
|
//this.pullRep();
|
|
|
|
|
|
|
|
|
|
this.addListeners();
|
|
|
|
|
this.init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
init() {
|
|
|
|
|
let repo = localStorage.getItem("repo");
|
|
|
|
|
let name = localStorage.getItem("name");
|
|
|
|
|
let email = localStorage.getItem("email");
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
repo == null ||
|
|
|
|
|
name == null ||
|
|
|
|
|
email == null ||
|
|
|
|
|
repo == "" ||
|
|
|
|
|
name == "" ||
|
|
|
|
|
email == ""
|
|
|
|
|
) {
|
|
|
|
|
this.view.openSettings();
|
|
|
|
|
} else {
|
|
|
|
|
this.model.getDirTree().then(
|
|
|
|
|
function (value) {
|
|
|
|
|
if (value.length == 1) {
|
|
|
|
|
//Nic nenaklonovaného, klonovat
|
|
|
|
|
this.cloneRep();
|
|
|
|
|
} else {
|
|
|
|
|
//Udělat Pull
|
|
|
|
|
this.pullRep();
|
|
|
|
|
}
|
|
|
|
|
}.bind(this),
|
|
|
|
|
function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addListeners() {
|
|
|
|
|
var cloneBtn = document.getElementsByClassName("clone")[0];
|
|
|
|
|
var purgeBtn = document.getElementsByClassName("wipe")[0];
|
|
|
|
|
var settingsBtn = document.getElementsByClassName("settingsBtn")[0];
|
|
|
|
@ -14,12 +52,18 @@ class Controller {
|
|
|
|
|
|
|
|
|
|
cloneBtn.addEventListener("click", this.cloneRep.bind(this));
|
|
|
|
|
purgeBtn.addEventListener("click", this.wipeFS.bind(this));
|
|
|
|
|
settingsBtn.addEventListener("click", view.openSettings.bind(this));
|
|
|
|
|
settingsBtn.addEventListener(
|
|
|
|
|
"click",
|
|
|
|
|
this.view.openSettings.bind(this.view)
|
|
|
|
|
);
|
|
|
|
|
for (let i = 0; i < settingsClose.length; i++) {
|
|
|
|
|
settingsClose[i].addEventListener("click", view.closeSettings.bind(this));
|
|
|
|
|
settingsClose[i].addEventListener(
|
|
|
|
|
"click",
|
|
|
|
|
this.view.closeSettings.bind(this)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
settingsSubmit.addEventListener("click", this.saveSettings.bind(this));
|
|
|
|
|
view.simplemde.codemirror.on("change", this.saveButton.bind(this));
|
|
|
|
|
this.view.simplemde.codemirror.on("change", this.saveButton.bind(this));
|
|
|
|
|
saveBtn.addEventListener("click", this.saveFile.bind(this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -35,7 +79,7 @@ class Controller {
|
|
|
|
|
this.redrawDirTree(this.view);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cloneRep(repurl) {
|
|
|
|
|
cloneRep() {
|
|
|
|
|
var loading = document.getElementsByClassName("loading")[0];
|
|
|
|
|
loading.style.display = "grid";
|
|
|
|
|
this.model.cloneRep().then(
|
|
|
|
@ -43,7 +87,23 @@ class Controller {
|
|
|
|
|
loading.style.removeProperty("display");
|
|
|
|
|
this.redrawDirTree(this.view);
|
|
|
|
|
}.bind(this),
|
|
|
|
|
function (error) {}
|
|
|
|
|
function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pullRep() {
|
|
|
|
|
var loading = document.getElementsByClassName("loading")[0];
|
|
|
|
|
loading.style.display = "grid";
|
|
|
|
|
this.model.pullRep().then(
|
|
|
|
|
function (value) {
|
|
|
|
|
loading.style.removeProperty("display");
|
|
|
|
|
this.redrawDirTree(this.view);
|
|
|
|
|
}.bind(this),
|
|
|
|
|
function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -55,7 +115,9 @@ class Controller {
|
|
|
|
|
view.dirTreeToggler();
|
|
|
|
|
this.updateFileStats();
|
|
|
|
|
}.bind(this),
|
|
|
|
|
function (error) {}
|
|
|
|
|
function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -63,7 +125,6 @@ class Controller {
|
|
|
|
|
this.model.getGitStatusTree().then(
|
|
|
|
|
function (value) {
|
|
|
|
|
this.view.statDirTree(value, undefined);
|
|
|
|
|
console.log(value);
|
|
|
|
|
}.bind(this),
|
|
|
|
|
function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
@ -74,13 +135,28 @@ class Controller {
|
|
|
|
|
saveSettings() {
|
|
|
|
|
let repo = document.getElementById("inputRepository");
|
|
|
|
|
let baseDir = document.getElementById("inputBaseDir");
|
|
|
|
|
let name = document.getElementById("inputName");
|
|
|
|
|
let email = document.getElementById("inputEmail");
|
|
|
|
|
|
|
|
|
|
let oldRepoURL = localStorage.getItem("repo");
|
|
|
|
|
this.model.setRepo(repo.value);
|
|
|
|
|
this.model.setBaseDir(baseDir.value);
|
|
|
|
|
this.model.setName(name.value);
|
|
|
|
|
this.model.setEmail(email.value);
|
|
|
|
|
|
|
|
|
|
this.redrawDirTree(this.view);
|
|
|
|
|
if (repo.value == "" || name.value == "" || email.value == "") {
|
|
|
|
|
this.view.openSettings();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (repo.value != oldRepoURL) {
|
|
|
|
|
// udělej clone
|
|
|
|
|
this.cloneRep();
|
|
|
|
|
} else {
|
|
|
|
|
// udelej jenom pull
|
|
|
|
|
this.pullRep();
|
|
|
|
|
}
|
|
|
|
|
this.view.closeSettings();
|
|
|
|
|
console.log(repo.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadFile(file) {
|
|
|
|
@ -90,7 +166,9 @@ class Controller {
|
|
|
|
|
this.openedFileValue = value;
|
|
|
|
|
this.view.openFile(value);
|
|
|
|
|
}.bind(this),
|
|
|
|
|
function (error) {}
|
|
|
|
|
function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|