|
|
@ -3,9 +3,6 @@ class Controller {
|
|
|
|
this.model = model;
|
|
|
|
this.model = model;
|
|
|
|
this.view = view;
|
|
|
|
this.view = view;
|
|
|
|
|
|
|
|
|
|
|
|
this.redrawDirTree(view);
|
|
|
|
|
|
|
|
//this.pullRep();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.addListeners();
|
|
|
|
this.addListeners();
|
|
|
|
this.init();
|
|
|
|
this.init();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -40,15 +37,22 @@ class Controller {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (localStorage.getItem("pushError")) {
|
|
|
|
|
|
|
|
this.view.openPublish();
|
|
|
|
|
|
|
|
this.view.errorPublish("Máte nepublikované změny: publikujte je.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
addListeners() {
|
|
|
|
addListeners() {
|
|
|
|
var cloneBtn = document.getElementsByClassName("clone")[0];
|
|
|
|
var cloneBtn = document.getElementsByClassName("clone")[0];
|
|
|
|
var purgeBtn = document.getElementsByClassName("wipe")[0];
|
|
|
|
var purgeBtn = document.getElementsByClassName("wipe")[0];
|
|
|
|
var settingsBtn = document.getElementsByClassName("settingsBtn")[0];
|
|
|
|
var settingsBtn = document.getElementsByClassName("settingsBtn")[0];
|
|
|
|
var settingsClose = document.getElementsByClassName("close");
|
|
|
|
var closeDialog = document.getElementsByClassName("close");
|
|
|
|
var settingsSubmit = document.getElementById("settingsSubmit");
|
|
|
|
var settingsSubmit = document.getElementById("settingsSubmit");
|
|
|
|
var saveBtn = document.getElementById("saveBtn");
|
|
|
|
var saveBtn = document.getElementById("saveBtn");
|
|
|
|
|
|
|
|
var publishBtn = document.getElementsByClassName("publishBtn")[0];
|
|
|
|
|
|
|
|
var commitSubmit = document.getElementById("commitSubmit");
|
|
|
|
|
|
|
|
|
|
|
|
cloneBtn.addEventListener("click", this.cloneRep.bind(this));
|
|
|
|
cloneBtn.addEventListener("click", this.cloneRep.bind(this));
|
|
|
|
purgeBtn.addEventListener("click", this.wipeFS.bind(this));
|
|
|
|
purgeBtn.addEventListener("click", this.wipeFS.bind(this));
|
|
|
@ -56,15 +60,17 @@ class Controller {
|
|
|
|
"click",
|
|
|
|
"click",
|
|
|
|
this.view.openSettings.bind(this.view)
|
|
|
|
this.view.openSettings.bind(this.view)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
for (let i = 0; i < settingsClose.length; i++) {
|
|
|
|
for (let i = 0; i < closeDialog.length; i++) {
|
|
|
|
settingsClose[i].addEventListener(
|
|
|
|
closeDialog[i].addEventListener(
|
|
|
|
"click",
|
|
|
|
"click",
|
|
|
|
this.view.closeSettings.bind(this)
|
|
|
|
this.view.closeDialog.bind(this)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
settingsSubmit.addEventListener("click", this.saveSettings.bind(this));
|
|
|
|
settingsSubmit.addEventListener("click", this.saveSettings.bind(this));
|
|
|
|
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));
|
|
|
|
saveBtn.addEventListener("click", this.saveFile.bind(this));
|
|
|
|
|
|
|
|
publishBtn.addEventListener("click", this.view.openPublish.bind(this.view));
|
|
|
|
|
|
|
|
commitSubmit.addEventListener("click", this.publish.bind(this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
saveButton() {
|
|
|
|
saveButton() {
|
|
|
@ -102,8 +108,10 @@ class Controller {
|
|
|
|
this.redrawDirTree(this.view);
|
|
|
|
this.redrawDirTree(this.view);
|
|
|
|
}.bind(this),
|
|
|
|
}.bind(this),
|
|
|
|
function (error) {
|
|
|
|
function (error) {
|
|
|
|
|
|
|
|
// zatim to teda znovu naclonuj
|
|
|
|
|
|
|
|
this.cloneRep();
|
|
|
|
console.log(error);
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
}.bind(this)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -153,10 +161,9 @@ class Controller {
|
|
|
|
// udělej clone
|
|
|
|
// udělej clone
|
|
|
|
this.cloneRep();
|
|
|
|
this.cloneRep();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// udelej jenom pull
|
|
|
|
this.redrawDirTree(this.view);
|
|
|
|
this.pullRep();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.view.closeSettings();
|
|
|
|
this.view.closeDialog();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
loadFile(file) {
|
|
|
|
loadFile(file) {
|
|
|
@ -172,6 +179,53 @@ class Controller {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
publish() {
|
|
|
|
|
|
|
|
let msg = document.getElementById("inputCommitMsg");
|
|
|
|
|
|
|
|
let gitUser = document.getElementById("inputUser");
|
|
|
|
|
|
|
|
let gitPass = document.getElementById("inputPasswd");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg.value == "" || gitUser.value == "" || gitPass.gitPass == "") {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let loading = document.getElementsByClassName("publishLoading")[0];
|
|
|
|
|
|
|
|
loading.style.display = "block";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.model.gitAddAll().then(
|
|
|
|
|
|
|
|
function (value) {
|
|
|
|
|
|
|
|
this.model.gitCommit(msg.value).then(
|
|
|
|
|
|
|
|
function (value) {
|
|
|
|
|
|
|
|
this.updateFileStats();
|
|
|
|
|
|
|
|
this.model.gitPush(gitUser.value, gitPass.value).then(
|
|
|
|
|
|
|
|
function (value) {
|
|
|
|
|
|
|
|
localStorage.setItem("pushError", "false");
|
|
|
|
|
|
|
|
loading.style.removeProperty("display");
|
|
|
|
|
|
|
|
this.view.closeDialog();
|
|
|
|
|
|
|
|
this.view.errorPublish();
|
|
|
|
|
|
|
|
}.bind(this),
|
|
|
|
|
|
|
|
function (error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
if (error == "HttpError: HTTP Error: 401 Unauthorized") {
|
|
|
|
|
|
|
|
this.view.errorPublish(
|
|
|
|
|
|
|
|
"Změny nebyly publikovány: Chyba přihlášení"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
loading.style.removeProperty("display");
|
|
|
|
|
|
|
|
localStorage.setItem("pushError", "true");
|
|
|
|
|
|
|
|
}.bind(this)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}.bind(this),
|
|
|
|
|
|
|
|
function (error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}.bind(this),
|
|
|
|
|
|
|
|
function (error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
saveFile() {
|
|
|
|
saveFile() {
|
|
|
|
var textArea = this.view.simplemde;
|
|
|
|
var textArea = this.view.simplemde;
|
|
|
|
this.model.saveFile(this.openedFile, textArea.value());
|
|
|
|
this.model.saveFile(this.openedFile, textArea.value());
|
|
|
|