\ No newline at end of file
diff --git a/app/components/graphPanel/graph.panel.component.html b/app/components/graphPanel/graph.panel.component.html
index 7588c63..29caa5e 100644
--- a/app/components/graphPanel/graph.panel.component.html
+++ b/app/components/graphPanel/graph.panel.component.html
@@ -23,6 +23,9 @@
Merge branches
+
+
+
diff --git a/app/misc/authenticate.ts b/app/misc/authenticate.ts
index 23f8e31..45d1277 100644
--- a/app/misc/authenticate.ts
+++ b/app/misc/authenticate.ts
@@ -23,36 +23,36 @@ let signedAfter = false;
//Called then user pushes to sign out even if they have commited changes but not pushed; prompts a confirmation modal
function CommitNoPush() {
- if (CommitButNoPush == 1) {
- $("#modalW2").modal();
- }
+ if (CommitButNoPush == 1) {
+ $("#modalW2").modal();
+ }
}
function signInHead(callback) {
- encryptTemp(document.getElementById("Email1").value, document.getElementById("Password1").value);
- continuedWithoutSignIn = false;
- signedAfter = true;
- if (signed == 1){
- if ((changes == 1) || (CommitButNoPush == 1)){
- $("#modalW2").modal();
- }
- else {
- getUserInfo(callback);
- }
- }
- else{
- getUserInfo(callback);
- }
+ encryptTemp(document.getElementById("Email1").value, document.getElementById("Password1").value);
+ continuedWithoutSignIn = false;
+ signedAfter = true;
+ if (signed == 1) {
+ if ((changes == 1) || (CommitButNoPush == 1)) {
+ $("#modalW2").modal();
+ }
+ else {
+ getUserInfo(callback);
+ }
+ }
+ else {
+ getUserInfo(callback);
+ }
}
function LogInAfterConfirm(callback) {
- encryptTemp(document.getElementById("Email1").value, document.getElementById("Password1").value);
- getUserInfo(callback);
+ encryptTemp(document.getElementById("Email1").value, document.getElementById("Password1").value);
+ getUserInfo(callback);
}
function ModalSignIn(callback) {
- encryptTemp(document.getElementById("Email1").value, document.getElementById("Password1").value);
- getUserInfo(callback);
+ encryptTemp(document.getElementById("Email1").value, document.getElementById("Password1").value);
+ getUserInfo(callback);
}
@@ -63,43 +63,42 @@ function loginWithSaved(callback) {
}
function searchRepoName() {
- let ul = document.getElementById("repo-dropdown");
+ let ul = document.getElementById("repo-dropdown");
- ul.innerHTML = ''; // clears the dropdown menu which shows all the repos
+ ul.innerHTML = ''; // clears the dropdown menu which shows all the repos
- // Gets users name and password
- encryptTemp(document.getElementById("username").value, document.getElementById("password").value);
+ // Gets users name and password
+ encryptTemp(document.getElementById("username").value, document.getElementById("password").value);
- cred = Git.Cred.userpassPlaintextNew(getUsernameTemp(), getPasswordTemp());
+ cred = Git.Cred.userpassPlaintextNew(getUsernameTemp(), getPasswordTemp());
- client = github.client({
- username: getUsernameTemp(),
- password: getPasswordTemp()
- });
+ client = github.client({
+ username: getUsernameTemp(),
+ password: getPasswordTemp()
+ });
- var ghme = client.me();
- ghme.repos(function (err, data, head) {
var ghme = client.me();
+ ghme.repos(function (err, data, head) {
+ var ghme = client.me();
- for (let i = 0; i < data.length; i++) {
+ for (let i = 0; i < data.length; i++) {
- let rep = Object.values(data)[i];
- console.log("url of repo: " + rep['html_url']);
-
- // Searches from the text input and adds to the list if repo name is found
- if (parseInt(rep['forks_count']) == 0) {
- if (rep['full_name'].search(document.getElementById("searchRep").value) != -1) {
- displayBranch(rep['full_name'], "repo-dropdown", "selectRepo(this)");
- repoList[rep['full_name']] = rep['html_url'];
- }
- }
+ let rep = Object.values(data)[i];
+ console.log("url of repo: " + rep['html_url']);
- }
- });
+ // Searches from the text input and adds to the list if repo name is found
+ if (parseInt(rep['forks_count']) == 0) {
+ if (rep['full_name'].search(document.getElementById("searchRep").value) != -1) {
+ displayBranch(rep['full_name'], "repo-dropdown", "selectRepo(this)");
+ repoList[rep['full_name']] = rep['html_url'];
+ }
+ }
+
+ }
+ });
}
function getUserInfo(callback) {
-
if (signedAfter === true){ // if the trys to login after clicking "continues without sign in"
encryptTemp(document.getElementById("Email1").value, document.getElementById("Password1").value);
@@ -210,121 +209,181 @@ function processLogin(ghme, callback) {
signed = 1;
callback();
+
}
- });
- ghme.repos(function(err, data, head) {
- if (err) {
- return;
- } else {
- displayUsername();
- document.getElementById("avatar").innerHTML = "Sign out";
- console.log("number of repos: " + data.length);
- for (let i = 0; i < data.length; i++) {
- let rep = Object.values(data)[i];
- console.log("url of repo: " + rep['html_url']);
-
- if(rep['fork'] == false) {
- if(parseInt(rep['forks_count']) == 0) {
- displayBranch(rep['full_name'], "repo-dropdown", "selectRepo(this)");
- repoList[rep['full_name']] = rep['html_url'];
- }
- else {
- //Create a collapseable list for the forked repo
- createDropDownFork(rep['full_name'],"repo-dropdown","showDropDown(this)");
- repoList[rep['full_name']] = rep['html_url'];
- //Reiterate through and get all the forks of the repo and add to list
- for(let i = 0; i < data.length; i++) {
- let rep2 = Object.values(data)[i];
- if(rep2['name'] == rep['name']) {
- displayBranch(" " +rep2['full_name'],rep['full_name'],"selectRepo(this)")
- repoList[" "+rep2['full_name']] = rep2['html_url'];
- }
+ cred = Git.Cred.userpassPlaintextNew(getUsernameTemp(), getPasswordTemp());
+
+ client = github.client({
+ username: getUsernameTemp(),
+ password: getPasswordTemp()
+ });
+ var ghme = client.me();
+ ghme.info(function (err, data, head) {
+ if (err) {
+ if (err == "Error: Bad credentials" || "Error: Requires authentication") {
+ $('#username').css('border-color', 'red');
+ $('#password').css('border-color', 'red');
+ var username = document.getElementById('username');
+ var password = document.getElementById('password');
+ username.classList.add('error');
+ password.classList.add('error');
+
+ // remove the class after the animation completes
+ setTimeout(function () {
+ username.classList.remove('error');
+ password.classList.remove('error');
+ }, 300);
+ } else {
+ displayModal(err);
}
- }
+ } else {
+ // assigning the check box to a variable to check the value
+ let rememberLogin: any = (document.getElementById("rememberLogin"));
+
+ // username and password values taken to be stored.
+ let username: any = (document.getElementById("username")).value;
+ let password: any = (document.getElementById("password")).value;
+ if (rememberLogin.checked == true) {
+ encrypt(username, password);
+ }
+ avaterImg = Object.values(data)[2]
+ // let doc = document.getElementById("avater");
+ // doc.innerHTML = "";
+ // var elem = document.createElement("img");
+ // elem.width = 40;
+ // elem.height = 40;
+ // elem.src = avaterImg;
+ // doc.appendChild(elem);
+ // doc = document.getElementById("log");
+ // doc.innerHTML = 'sign out';
+ document.getElementById("githubname").innerHTML = data["login"]
+ var docGitUser = document.getElementById("githubname");
+ //docGitUser.innerHTML = Object.values(data)[0];
+
+ let doc = document.getElementById("avatar");
+ //doc.innerHTML = 'Sign out'; //HAD TO REMOVE THIS LINE OR THE PROGRAM BROKE.
+ signed = 1;
+
+ callback();
}
- }
- }
- });
+ });
+
+ ghme.repos(function (err, data, head) {
+ if (err) {
+ return;
+ } else {
+ displayUsername();
+ document.getElementById("avatar").innerHTML = "Sign out";
+ console.log("number of repos: " + data.length);
+ for (let i = 0; i < data.length; i++) {
+ let rep = Object.values(data)[i];
+ console.log("url of repo: " + rep['html_url']);
+
+ if (rep['fork'] == false) {
+ if (parseInt(rep['forks_count']) == 0) {
+ displayBranch(rep['full_name'], "repo-dropdown", "selectRepo(this)");
+ repoList[rep['full_name']] = rep['html_url'];
+ }
+ else {
+ //Create a collapseable list for the forked repo
+ createDropDownFork(rep['full_name'], "repo-dropdown", "showDropDown(this)");
+ repoList[rep['full_name']] = rep['html_url'];
+ //Reiterate through and get all the forks of the repo and add to list
+ for (let i = 0; i < data.length; i++) {
+ let rep2 = Object.values(data)[i];
+ if (rep2['name'] == rep['name']) {
+ displayBranch(" " + rep2['full_name'], rep['full_name'], "selectRepo(this)")
+ repoList[" " + rep2['full_name']] = rep2['html_url'];
+ }
+ }
+ }
+ }
+ }
+ }
+ });
}
//Converts string to base 64 to be used for Basic Authorization in external API calls
function make_base_auth(user, password) {
- var tok = user + ':' + password;
- var hash = btoa(tok);
- return 'Basic ' + hash;
+ var tok = user + ':' + password;
+ var hash = btoa(tok);
+ return 'Basic ' + hash;
}
function showDropDown(ele) {
- //If the forked Repo is clicked collapse or uncollapse the forked repo list
- let div = document.getElementById(ele.className)
- if(div.style.display === 'none') {
- div.style.display = 'block';
- }
- else {
- div.style.display = 'none';
- }
+ //If the forked Repo is clicked collapse or uncollapse the forked repo list
+ let div = document.getElementById(ele.className)
+ if (div.style.display === 'none') {
+ div.style.display = 'block';
+ }
+ else {
+ div.style.display = 'none';
+ }
}
function selectRepo(ele) {
- url = repoList[ele.innerHTML];
- let butt = document.getElementById("cloneButton");
- butt.innerHTML = 'Clone ' + ele.innerHTML;
- butt.setAttribute('class', 'btn btn-primary');
- console.log("selected " + ele.innerHTML + " as repository");
+ url = repoList[ele.innerHTML];
+ let butt = document.getElementById("cloneButton");
+ butt.innerHTML = 'Clone ' + ele.innerHTML;
+ butt.setAttribute('class', 'btn btn-primary');
+ console.log("selected " + ele.innerHTML + " as repository");
}
function cloneRepo() {
- if (url === null) {
- updateModalText("Web URL for repo could not be found. Try cloning by providing the repo's web URL directly in the 'Add repository' window");
- return;
- }
+ if (url === null) {
+ updateModalText("Web URL for repo could not be found. Try cloning by providing the repo's web URL directly in the 'Add repository' window");
+ return;
+ }
- console.log("cloning " + url);
- let splitUrl = url.split("/");
- let local;
- if (splitUrl.length >= 2) {
- local = splitUrl[splitUrl.length - 1];
- }
- console.log("cloning " + local);
+ console.log("cloning " + url);
+ let splitUrl = url.split("/");
+ let local;
+ if (splitUrl.length >= 2) {
+ local = splitUrl[splitUrl.length - 1];
+ }
+ console.log("cloning " + local);
- if (local == null) {
- updateModalText("Error: could not define name of repo");
- return;
- }
+ if (local == null) {
+ updateModalText("Error: could not define name of repo");
+ return;
+ }
- downloadFunc(url, local);
- url = null;
- $('#repo-modal').modal('hide');
+ downloadFunc(url, local);
+ url = null;
+ $('#repo-modal').modal('hide');
- switchToMainPanel();
+ switchToMainPanel();
+ let butt = document.getElementById("cloneButton");
+ butt.innerHTML = 'Clone';
+ butt.setAttribute('class', 'btn btn-primary');
}
function signInOrOut() {
- let doc = document.getElementById("avatar");
- if(doc.innerHTML === "Sign In"){
- doc.innerHTML = "";
- }
- else if(doc.innerHTML === ""){
- doc.innerHTML = "Sign In";
- }
-
- if (doc.innerHTML === "Sign out") {
- $("#avatar").removeAttr("data-toggle");
+ let doc = document.getElementById("avatar");
+ if (doc.innerHTML === "Sign In") {
+ doc.innerHTML = "";
+ }
+ else if (doc.innerHTML === "") {
+ doc.innerHTML = "Sign In";
+ }
- if (changes == 1 || CommitButNoPush == 1) {
- $("#modalW2").modal();
- } else {
- redirectToHomePage();
+ if (doc.innerHTML === "Sign out") {
+ $("#avatar").removeAttr("data-toggle");
+
+ if (changes == 1 || CommitButNoPush == 1) {
+ $("#modalW2").modal();
+ } else {
+ redirectToHomePage();
+ }
}
- }
}
function redirectToHomePage() {
- window.onbeforeunload = Confirmed;
- window.location.href = "index.html";
- signed = 0;
- changes = 0;
- CommitButNoPush = 0;
- //LogInAfterConfirm();
+ window.onbeforeunload = Confirmed;
+ window.location.href = "index.html";
+ signed = 0;
+ changes = 0;
+ CommitButNoPush = 0;
+ //LogInAfterConfirm();
}
diff --git a/app/misc/repo.ts b/app/misc/repo.ts
index 35cb8a1..8b73056 100644
--- a/app/misc/repo.ts
+++ b/app/misc/repo.ts
@@ -26,17 +26,16 @@ function downloadRepository() {
fullLocalPath = document.getElementById("dirPickerSaveNew").files[0].path;
console.log(repoFullPath)
+ }
- }
-
- let cloneURL = document.getElementById("repoClone").value;
+ let cloneURL = document.getElementById("repoClone").value;
- if (!cloneURL || cloneURL.length === 0) {
- updateModalText("Clone Failed - Empty URL Given");
- switchToAddRepositoryPanel();
- } else {
- downloadFunc(cloneURL, fullLocalPath);
- }
+ if (!cloneURL || cloneURL.length === 0) {
+ updateModalText("Clone Failed - Empty URL Given");
+ switchToAddRepositoryPanel();
+ } else {
+ downloadFunc(cloneURL, fullLocalPath);
+ }
}
function downloadFunc(cloneURL, fullLocalPath) {
@@ -60,347 +59,345 @@ function downloadFunc(cloneURL, fullLocalPath) {
let bytesRatio = data.receivedObjects() / data.totalObjects();
updateProgressBar(bytesRatio);
}
- }
- }
- };
-
- console.log("cloning into " + fullLocalPath);
- let repository = Git.Clone.clone(cloneURL, fullLocalPath, options)
- .then(function (repository) {
- progressDiv.style.visibility = 'collapse';
- updateProgressBar(0);
- console.log("Repo successfully cloned");
- displayModal("Drawing graph, please wait");
- refreshAll(repository);
- updateModalText("Clone Successful, repository saved under: " + fullLocalPath);
- addCommand("git clone " + cloneURL + " " + fullLocalPath);
- repoFullPath = fullLocalPath;
- repoLocalPath = fullLocalPath;
- displayModal("Drawing graph, please wait");
- refreshAll(repository);
- switchToMainPanel();
- },
- function (err) {
- updateModalText("Clone Failed - " + err);
- console.log("repo.ts, line 64, failed to clone repo: " + err); // TODO show error on screen
- switchToAddRepositoryPanel();
- });
+ };
+
+ console.log("cloning into " + fullLocalPath);
+ let repository = Git.Clone.clone(cloneURL, fullLocalPath, options)
+ .then(function (repository) {
+ progressDiv.style.visibility = 'collapse';
+ updateProgressBar(0);
+ console.log("Repo successfully cloned");
+ displayModal("Drawing graph, please wait");
+ refreshAll(repository);
+ updateModalText("Clone Successful, repository saved under: " + fullLocalPath);
+ addCommand("git clone " + cloneURL + " " + fullLocalPath);
+ repoFullPath = fullLocalPath;
+ repoLocalPath = fullLocalPath;
+ displayModal("Drawing graph, please wait");
+ refreshAll(repository);
+ switchToMainPanel();
+ },
+ function (err) {
+ updateModalText("Clone Failed - " + err);
+ console.log("repo.ts, line 64, failed to clone repo: " + err); // TODO show error on screen
+ switchToAddRepositoryPanel();
+ });
}
function updateProgressBar(ratio) {
- let progressBar = document.getElementById("cloneProgressBar");
- let percentage = Math.floor(ratio * 100) + "%";
- progressBar.style.width = percentage;
- progressBar.innerHTML = percentage;
+ let progressBar = document.getElementById("cloneProgressBar");
+ let percentage = Math.floor(ratio * 100) + "%";
+ progressBar.style.width = percentage;
+ progressBar.innerHTML = percentage;
}
function openRepository() {
- console.log("Open Repository")
- if(document.getElementById("dirPickerOpenLocal").value === previousOpen && previousOpen != undefined){
- return;
- }
- // Full path is determined by either handwritten directory or selected by file browser
- if (document.getElementById("repoOpen").value == null || document.getElementById("repoOpen").value == "") {
- let localPath = document.getElementById("dirPickerOpenLocal").files[0].webkitRelativePath;
- let fullLocalPath = document.getElementById("dirPickerOpenLocal").files[0].path;
- previousOpen = document.getElementById("dirPickerOpenLocal").value;
- document.getElementById("repoOpen").value = fullLocalPath;
- document.getElementById("repoOpen").text = fullLocalPath;
- } else {
- let localPath = document.getElementById("repoOpen").value;
- let fullLocalPath;
- if (checkFile.existsSync(localPath)) {
- fullLocalPath = localPath;
+ console.log("Open Repository")
+ if (document.getElementById("dirPickerOpenLocal").value === previousOpen && previousOpen != undefined) {
+ return;
+ }
+ // Full path is determined by either handwritten directory or selected by file browser
+ if (document.getElementById("repoOpen").value == null || document.getElementById("repoOpen").value == "") {
+ let localPath = document.getElementById("dirPickerOpenLocal").files[0].webkitRelativePath;
+ let fullLocalPath = document.getElementById("dirPickerOpenLocal").files[0].path;
+ previousOpen = document.getElementById("dirPickerOpenLocal").value;
+ document.getElementById("repoOpen").value = fullLocalPath;
+ document.getElementById("repoOpen").text = fullLocalPath;
} else {
- fullLocalPath = require("path").join(__dirname, localPath);
+ let localPath = document.getElementById("repoOpen").value;
+ let fullLocalPath;
+ if (checkFile.existsSync(localPath)) {
+ fullLocalPath = localPath;
+ } else {
+ fullLocalPath = require("path").join(__dirname, localPath);
+ }
}
- }
- console.log("Trying to open repository at " + fullLocalPath);
- displayModal("Opening Local Repository...");
-
- Git.Repository.open(fullLocalPath).then(function (repository) {
- repoFullPath = fullLocalPath;
- repoLocalPath = localPath;
- if (readFile.exists(repoFullPath + "/.git/MERGE_HEAD")) {
- let tid = readFile.read(repoFullPath + "/.git/MERGE_HEAD", null);
- console.log("current HEAD commit: " + tid);
- }
- //Reads the git config file and extracts info about the remote "origin" branch on GitHub
- if (readFile.exists(repoFullPath + "/.git/config")) {
- let gitConfigFileText = readFile.read(repoFullPath + "/.git/config", null);
- let searchString = "[remote \"origin\"]";
-
- gitConfigFileText = gitConfigFileText.substr(gitConfigFileText.indexOf(searchString) + searchString.length, gitConfigFileText.length);
- gitConfigFileText = gitConfigFileText.substr(0, gitConfigFileText.indexOf(".git"));
-
- let gitConfigFileSubstrings = gitConfigFileText.split('/');
-
- //If the remote branch was set up using ssh, separate the elements between colons"
- if (gitConfigFileSubstrings[0].indexOf("@") != -1) {
- gitConfigFileSubstrings[0] = gitConfigFileSubstrings[0].substring(gitConfigFileSubstrings[0].indexOf(":") + 1);
+ console.log("Trying to open repository at " + fullLocalPath);
+ displayModal("Opening Local Repository...");
+
+ Git.Repository.open(fullLocalPath).then(function (repository) {
+ repoFullPath = fullLocalPath;
+ repoLocalPath = localPath;
+ if (readFile.exists(repoFullPath + "/.git/MERGE_HEAD")) {
+ let tid = readFile.read(repoFullPath + "/.git/MERGE_HEAD", null);
+ console.log("current HEAD commit: " + tid);
}
+ //Reads the git config file and extracts info about the remote "origin" branch on GitHub
+ if (readFile.exists(repoFullPath + "/.git/config")) {
+ let gitConfigFileText = readFile.read(repoFullPath + "/.git/config", null);
+ let searchString = "[remote \"origin\"]";
- let repoOwner = gitConfigFileSubstrings[gitConfigFileSubstrings.length - 2]
- let repoName = gitConfigFileSubstrings[gitConfigFileSubstrings.length - 1]
- //If the user is signed in, an API call can performed
- if(!continuedWithoutSignIn){
- //Call to get all usernames
- $.ajax({
- url: "https://api.github.com/repos/" + repoOwner + "/" + repoName + "/contributors",
- type: "GET",
- beforeSend: function (xhr) {
- xhr.setRequestHeader('Authorization', make_base_auth(getUsername(), getPassword()));
- },
- headers: {
- 'Accept': 'application/vnd.github.v3+json'
- },
- success: function (response) {
-
- for (var i = 0; i < response.length; i++) {
- //Store list of logins here.
- contributors[i] = {
- "username": response[i].login,
- "name": "",
- "email": ""
- }
- }
- console.log("The contributors for this project are ", contributors)
- },
- error(xhr,status,error){
- console.log("The XML Http Request of the GitHub API call is: ", xhr);
- console.log("The status of the GitHub API call is: ", status);
- console.log("The error of the GitHub API call is: ", error);
+ gitConfigFileText = gitConfigFileText.substr(gitConfigFileText.indexOf(searchString) + searchString.length, gitConfigFileText.length);
+ gitConfigFileText = gitConfigFileText.substr(0, gitConfigFileText.indexOf(".git"));
+
+ let gitConfigFileSubstrings = gitConfigFileText.split('/');
+
+ //If the remote branch was set up using ssh, separate the elements between colons"
+ if (gitConfigFileSubstrings[0].indexOf("@") != -1) {
+ gitConfigFileSubstrings[0] = gitConfigFileSubstrings[0].substring(gitConfigFileSubstrings[0].indexOf(":") + 1);
}
- })
- }
- }
- displayModal("Drawing graph, please wait");
- refreshAll(repository);
- console.log("Repo successfully opened");
- updateModalText("Repository successfully opened");
- },
- function(err) {
- updateModalText("No repository found. Select a folder with a repository.");
- console.log("repo.ts, line 101, cannot open repository: "+err); // TODO show error on screen
- switchToAddRepositoryPanel();
- });
- document.getElementById("dirPickerOpenLocal").value = "";
+ let repoOwner = gitConfigFileSubstrings[gitConfigFileSubstrings.length - 2]
+ let repoName = gitConfigFileSubstrings[gitConfigFileSubstrings.length - 1]
+ //If the user is signed in, an API call can performed
+ if (!continuedWithoutSignIn) {
+ //Call to get all usernames
+ $.ajax({
+ url: "https://api.github.com/repos/" + repoOwner + "/" + repoName + "/contributors",
+ type: "GET",
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('Authorization', make_base_auth(getUsername(), getPassword()));
+ },
+ headers: {
+ 'Accept': 'application/vnd.github.v3+json'
+ },
+ success: function (response) {
+
+ for (var i = 0; i < response.length; i++) {
+ //Store list of logins here.
+ contributors[i] = {
+ "username": response[i].login,
+ "name": "",
+ "email": ""
+ }
+ }
+ console.log("The contributors for this project are ", contributors)
+ },
+ error(xhr, status, error) {
+ console.log("The XML Http Request of the GitHub API call is: ", xhr);
+ console.log("The status of the GitHub API call is: ", status);
+ console.log("The error of the GitHub API call is: ", error);
+ }
+ })
+ }
+
+ }
+ displayModal("Drawing graph, please wait");
+ refreshAll(repository);
+ console.log("Repo successfully opened");
+ updateModalText("Repository successfully opened");
+ },
+ function (err) {
+ updateModalText("No repository found. Select a folder with a repository.");
+ console.log("repo.ts, line 101, cannot open repository: " + err); // TODO show error on screen
+ switchToAddRepositoryPanel();
+ });
+ document.getElementById("dirPickerOpenLocal").value = "";
}
function createLocalRepository() {
- //console.log("createLocalRepo")
- if (document.getElementById("repoCreate").value == null || document.getElementById("repoCreate").value == "") {
- document.getElementById("dirPickerCreateLocal").click();
- let localPath = document.getElementById("dirPickerCreateLocal").files[0].webkitRelativePath;
- let fullLocalPath = document.getElementById("dirPickerCreateLocal").files[0].path;
- document.getElementById("repoCreate").value = fullLocalPath;
- document.getElementById("repoCreate").text = fullLocalPath;
- } else {
- let localPath = document.getElementById("repoCreate").value;
- let fullLocalPath;
- if (!require('path').isAbsolute(localPath)) {
- updateModalText('The filepath is not valid. For OSX and Ubuntu the filepath should start with /, for Windows C:\\\\')
- return
+ //console.log("createLocalRepo")
+ if (document.getElementById("repoCreate").value == null || document.getElementById("repoCreate").value == "") {
+ document.getElementById("dirPickerCreateLocal").click();
+ let localPath = document.getElementById("dirPickerCreateLocal").files[0].webkitRelativePath;
+ let fullLocalPath = document.getElementById("dirPickerCreateLocal").files[0].path;
+ document.getElementById("repoCreate").value = fullLocalPath;
+ document.getElementById("repoCreate").text = fullLocalPath;
} else {
- if (checkFile.existsSync(localPath)) {
- fullLocalPath = localPath;
- } else {
- checkFile.mkdirSync(localPath);
- fullLocalPath = localPath;
- }
+ let localPath = document.getElementById("repoCreate").value;
+ let fullLocalPath;
+ if (!require('path').isAbsolute(localPath)) {
+ updateModalText('The filepath is not valid. For OSX and Ubuntu the filepath should start with /, for Windows C:\\\\')
+ return
+ } else {
+ if (checkFile.existsSync(localPath)) {
+ fullLocalPath = localPath;
+ } else {
+ checkFile.mkdirSync(localPath);
+ fullLocalPath = localPath;
+ }
+ }
}
- }
- //console.log("pre-git check")
- //console.log("fullLocalPath is " + fullLocalPath)
- //console.log(require("path").join(fullLocalPath,".git"));
- if (checkFile.existsSync(require("path").join(fullLocalPath, ".git"))) {
- //console.log("Is git repository already")
- updateModalText("This folder is already a git repository. Please try to open it instead.");
- } else {
- displayModal("creating repository at " + require("path").join(fullLocalPath, ".git"));
- Git.Repository.init(fullLocalPath, 0).then(function (repository) {
- repoFullPath = fullLocalPath;
- repoLocalPath = localPath;
- refreshAll(repository);
- //console.log("Repo successfully created");
- updateModalText("Repository successfully created");
- document.getElementById("repoCreate").value = "";
- document.getElementById("dirPickerCreateLocal").value = null;
- switchToMainPanel();
- },
- function (err) {
- updateModalText("Creating Failed - " + err);
- //console.log("repo.ts, line 131, cannot open repository: "+err); // TODO show error on screen
- });
- }
+ //console.log("pre-git check")
+ //console.log("fullLocalPath is " + fullLocalPath)
+ //console.log(require("path").join(fullLocalPath,".git"));
+ if (checkFile.existsSync(require("path").join(fullLocalPath, ".git"))) {
+ //console.log("Is git repository already")
+ updateModalText("This folder is already a git repository. Please try to open it instead.");
+ } else {
+ displayModal("creating repository at " + require("path").join(fullLocalPath, ".git"));
+ Git.Repository.init(fullLocalPath, 0).then(function (repository) {
+ repoFullPath = fullLocalPath;
+ repoLocalPath = localPath;
+ refreshAll(repository);
+ //console.log("Repo successfully created");
+ updateModalText("Repository successfully created");
+ document.getElementById("repoCreate").value = "";
+ document.getElementById("dirPickerCreateLocal").value = null;
+ switchToMainPanel();
+ },
+ function (err) {
+ updateModalText("Creating Failed - " + err);
+ //console.log("repo.ts, line 131, cannot open repository: "+err); // TODO show error on screen
+ });
+ }
}
function addBranchestoNode(thisB: string) {
- let elem = document.getElementById("otherBranches");
- elem.innerHTML = '';
- for (let i = 0; i < localBranches.length; i++) {
- if (localBranches[i] !== thisB) {
- console.log("local branch: " + localBranches[i]);
- let li = document.createElement("li");
- let a = document.createElement("a");
- a.appendChild(document.createTextNode(localBranches[i]));
- a.setAttribute("tabindex", "0");
- a.setAttribute("href", "#");
- li.appendChild(a);
- elem.appendChild(li);
+ let elem = document.getElementById("otherBranches");
+ elem.innerHTML = '';
+ for (let i = 0; i < localBranches.length; i++) {
+ if (localBranches[i] !== thisB) {
+ console.log("local branch: " + localBranches[i]);
+ let li = document.createElement("li");
+ let a = document.createElement("a");
+ a.appendChild(document.createTextNode(localBranches[i]));
+ a.setAttribute("tabindex", "0");
+ a.setAttribute("href", "#");
+ li.appendChild(a);
+ elem.appendChild(li);
+ }
}
- }
}
function refreshAll(repository) {
- displayModal("Drawing graph, please wait");
- let branch;
- bname = [];
- //Get the current branch from the repo
- repository.getCurrentBranch()
- .then(function (reference) {
- //Get the simplified name from the branch
- let branchParts = reference.name().split("/");
- console.log("branch parts: " + branchParts);
- branch = branchParts[branchParts.length - 1];
- })
- .then(function () {
- //Get the list of branches from the repo
- return repository.getReferences(Git.Reference.TYPE.LISTALL);
- })
- .then(function (branchList) {
- let count = 0;
- clearBranchElement();
- //for each branch
- for (let i = 0; i < branchList.length; i++) {
- console.log("branch name: " + branchList[i].name());
- //get simplified name
- let bp = branchList[i].name().split("/")[branchList[i].name().split("/").length - 1];
-
- Git.Reference.nameToId(repository, branchList[i].name()).then(function (oid) {
- // Use oid
- console.log("old id " + oid);
- if (branchList[i].isRemote()) {
- // for remote branches add oid and branch name to remote branches map
- remoteName[bp] = oid;
- } else {
- //add branch name to the branch list
- branchCommit.push(branchList[i]);
- console.log(bp + " adding to end of " + oid.tostrS());
- if (oid.tostrS() in bname) {
- bname[oid.tostrS()].push(branchList[i]);
- } else {
- bname[oid.tostrS()] = [branchList[i]];
+ displayModal("Drawing graph, please wait");
+ let branch;
+ bname = [];
+ //Get the current branch from the repo
+ repository.getCurrentBranch()
+ .then(function (reference) {
+ //Get the simplified name from the branch
+ let branchParts = reference.name().split("/");
+ console.log("branch parts: " + branchParts);
+ branch = branchParts[branchParts.length - 1];
+ })
+ .then(function () {
+ //Get the list of branches from the repo
+ return repository.getReferences(Git.Reference.TYPE.LISTALL);
+ })
+ .then(function (branchList) {
+ let count = 0;
+ clearBranchElement();
+ //for each branch
+ for (let i = 0; i < branchList.length; i++) {
+ console.log("branch name: " + branchList[i].name());
+ //get simplified name
+ let bp = branchList[i].name().split("/")[branchList[i].name().split("/").length - 1];
+
+ Git.Reference.nameToId(repository, branchList[i].name()).then(function (oid) {
+ // Use oid
+ console.log("old id " + oid);
+ if (branchList[i].isRemote()) {
+ // for remote branches add oid and branch name to remote branches map
+ remoteName[bp] = oid;
+ } else {
+ //add branch name to the branch list
+ branchCommit.push(branchList[i]);
+ console.log(bp + " adding to end of " + oid.tostrS());
+ if (oid.tostrS() in bname) {
+ bname[oid.tostrS()].push(branchList[i]);
+ } else {
+ bname[oid.tostrS()] = [branchList[i]];
+ }
+ }
+ }, function (err) {
+ console.log("repo.ts, line 273, could not find referenced branch" + err);
+ });
+ if (branchList[i].isRemote()) {
+ if (localBranches.indexOf(bp) < 0) {
+ displayBranch(bp, "branch-dropdown", "checkoutRemoteBranch(this)");
+ }
+ } else {
+ localBranches.push(bp);
+ displayBranch(bp, "branch-dropdown", "checkoutLocalBranch(this)");
+ }
+
+ }
+ })
+ .then(function () {
+ console.log("Updating the graph and the labels");
+ drawGraph();
+ let breakStringFrom;
+ if (repoLocalPath.length > 20) {
+ for (var i = 0; i < repoLocalPath.length; i++) {
+ if (repoLocalPath[i] == "/") {
+ breakStringFrom = i;
+ }
+ }
+ repoLocalPath = "..." + repoLocalPath.slice(breakStringFrom, repoLocalPath.length);
}
- }
+ document.getElementById("repo-name").innerHTML = repoLocalPath;
+ document.getElementById("branch-name").innerHTML = branch + '';
}, function (err) {
- console.log("repo.ts, line 273, could not find referenced branch" + err);
+ //If the repository has no commits, getCurrentBranch will throw an error.
+ //Default values will be set for the branch labels
+ window.alert("Warning:\n" +
+ "No branches have been found in this repository.\n" +
+ "This is likely because there have been no commits made.");
+ console.log("No branches found. Setting default label values to master");
+ console.log("Updating the labels and graph");
+ drawGraph();
+ document.getElementById("repo-name").innerHTML = repoLocalPath;
+ //default label set to master
+ document.getElementById("branch-name").innerHTML = "master" + '';
});
- if (branchList[i].isRemote()) {
- if (localBranches.indexOf(bp) < 0) {
- displayBranch(bp, "branch-dropdown", "checkoutRemoteBranch(this)");
- }
- } else {
- localBranches.push(bp);
- displayBranch(bp, "branch-dropdown", "checkoutLocalBranch(this)");
- }
-
- }
- })
- .then(function () {
- console.log("Updating the graph and the labels");
- drawGraph();
- let breakStringFrom;
- if(repoLocalPath.length > 20){
- for(var i = 0; i < repoLocalPath.length ; i++ ){
- if(repoLocalPath[i] == "/"){
- breakStringFrom = i;
- }
- }
- repoLocalPath = "..." + repoLocalPath.slice(breakStringFrom,repoLocalPath.length);
- }
- document.getElementById("repo-name").innerHTML = repoLocalPath;
- document.getElementById("branch-name").innerHTML = branch + '';
- }, function (err) {
- //If the repository has no commits, getCurrentBranch will throw an error.
- //Default values will be set for the branch labels
- window.alert("Warning:\n" +
- "No branches have been found in this repository.\n" +
- "This is likely because there have been no commits made.");
- console.log("No branches found. Setting default label values to master");
- console.log("Updating the labels and graph");
- drawGraph();
- document.getElementById("repo-name").innerHTML = repoLocalPath;
- //default label set to master
- document.getElementById("branch-name").innerHTML = "master" + '';
- });
}
function getAllBranches() {
- let repos;
- Git.Repository.open(repoFullPath)
- .then(function (repo) {
- repos = repo;
- return repo.getReferenceNames(Git.Reference.TYPE.LISTALL);
- })
- .then(function (branchList) {
- clearBranchElement();
- for (let i = 0; i < branchList.length; i++) {
- console.log("branch discovered: " + branchList[i]);
- let bp = branchList[i].split("/");
- if (bp[1] !== "remotes") {
- displayBranch(bp[bp.length - 1], "branch-dropdown", "checkoutLocalBranch(this)");
- }
- Git.Reference.nameToId(repos, branchList[i]).then(function (oid) {
- // Use oid
- console.log("old id " + oid);
+ let repos;
+ Git.Repository.open(repoFullPath)
+ .then(function (repo) {
+ repos = repo;
+ return repo.getReferenceNames(Git.Reference.TYPE.LISTALL);
+ })
+ .then(function (branchList) {
+ clearBranchElement();
+ for (let i = 0; i < branchList.length; i++) {
+ console.log("branch discovered: " + branchList[i]);
+ let bp = branchList[i].split("/");
+ if (bp[1] !== "remotes") {
+ displayBranch(bp[bp.length - 1], "branch-dropdown", "checkoutLocalBranch(this)");
+ }
+ Git.Reference.nameToId(repos, branchList[i]).then(function (oid) {
+ // Use oid
+ console.log("old id " + oid);
+ });
+ }
});
- }
- });
}
function getOtherBranches() {
- let list;
- let repos;
- Git.Repository.open(repoFullPath)
- .then(function (repo) {
- repos = repo;
- return repo.getReferenceNames(Git.Reference.TYPE.LISTALL);
- })
- .then(function (branchList) {
- clearMergeElement();
- list = branchList;
- })
- .then(function () {
- return repos.getCurrentBranch()
- })
- .then(function (ref) {
- let name = ref.name().split("/");
- console.log("merging remote branch with tracked local branch");
- clearBranchElement();
- for (let i = 0; i < list.length; i++) {
- let bp = list[i].split("/");
- if (bp[1] !== "remotes" && bp[bp.length - 1] !== name[name.length - 1]) {
- displayBranch(bp[bp.length - 1], "merge-dropdown", "mergeLocalBranches(this)");
- }
- }
- })
+ let list;
+ let repos;
+ Git.Repository.open(repoFullPath)
+ .then(function (repo) {
+ repos = repo;
+ return repo.getReferenceNames(Git.Reference.TYPE.LISTALL);
+ })
+ .then(function (branchList) {
+ clearMergeElement();
+ list = branchList;
+ })
+ .then(function () {
+ return repos.getCurrentBranch()
+ })
+ .then(function (ref) {
+ let name = ref.name().split("/");
+ console.log("merging remote branch with tracked local branch");
+ clearBranchElement();
+ for (let i = 0; i < list.length; i++) {
+ let bp = list[i].split("/");
+ if (bp[1] !== "remotes" && bp[bp.length - 1] !== name[name.length - 1]) {
+ displayBranch(bp[bp.length - 1], "merge-dropdown", "mergeLocalBranches(this)");
+ }
+ }
+ })
}
function clearMergeElement() {
- let ul = document.getElementById("merge-dropdown");
- ul.innerHTML = '';
+ let ul = document.getElementById("merge-dropdown");
+ ul.innerHTML = '';
}
function clearBranchElement() {
- let ul = document.getElementById("branch-dropdown");
- let li = document.getElementById("create-branch");
- ul.innerHTML = '';
- ul.appendChild(li);
+ let ul = document.getElementById("branch-dropdown");
+ let li = document.getElementById("create-branch");
+ ul.innerHTML = '';
+ ul.appendChild(li);
}
function displayBranch(name, id, onclick) {
@@ -468,18 +465,18 @@ function displayBranch(name, id, onclick) {
}
function createDropDownFork(name, id, onclick) {
- let ul = document.getElementById(id);
- let button = document.createElement("div");
- let div = document.createElement("ul");
- let innerText = document.createTextNode("↨" + name + " (Forked List)");
- button.className = name;
- button.appendChild(innerText);
- div.setAttribute("id", name);
- div.setAttribute("role", "menu");
- div.setAttribute("class", "list-group")
- button.setAttribute("onclick", onclick)
- button.appendChild(div);
- ul.appendChild(button);
+ let ul = document.getElementById(id);
+ let button = document.createElement("div");
+ let div = document.createElement("ul");
+ let innerText = document.createTextNode("↨" + name + " (Forked List)");
+ button.className = name;
+ button.appendChild(innerText);
+ div.setAttribute("id", name);
+ div.setAttribute("role", "menu");
+ div.setAttribute("class", "list-group")
+ button.setAttribute("onclick", onclick)
+ button.appendChild(div);
+ ul.appendChild(button);
}
function checkoutLocalBranch(element) {
@@ -618,13 +615,13 @@ function chooseLocalPath() {
// }
function displayModal(text) {
-// initModal();
-// handleModal();
- document.getElementById("modal-text-box").innerHTML = text;
- $('#modal').modal('show');
+ // initModal();
+ // handleModal();
+ document.getElementById("modal-text-box").innerHTML = text;
+ $('#modal').modal('show');
}
function updateModalText(text) {
- document.getElementById("modal-text-box").innerHTML = text;
- $('#modal').modal('show');
+ document.getElementById("modal-text-box").innerHTML = text;
+ $('#modal').modal('show');
}
diff --git a/app/misc/router.ts b/app/misc/router.ts
index 6de2b8d..09b0c6f 100644
--- a/app/misc/router.ts
+++ b/app/misc/router.ts
@@ -8,15 +8,15 @@ let showUsername = true;
let previousWindow = "repoPanel";
function collapseSignPanel() {
- $("#nav-collapse1").collapse("hide");
+ $("#nav-collapse1").collapse("hide");
}
function switchToClonePanel() {
- console.log("switch to clone panel");
- hideAuthenticatePanel();
- hideFilePanel();
- hideGraphPanel();
- displayClonePanel();
+ console.log("switch to clone panel");
+ hideAuthenticatePanel();
+ hideFilePanel();
+ hideGraphPanel();
+ displayClonePanel();
}
function switchToMainPanel() {
@@ -39,14 +39,17 @@ function switchToMainPanel() {
}
function checkSignedIn() {
- if (continuedWithoutSignIn) {
- displayModal("You need to sign in");
- // Don't open the repo modal
- $('#repo-name').removeAttr("data-target");
- } else {
- // Ensure repo modal is connected
- $('#repo-name').attr("data-target", "#repo-modal");
- }
+ if (continuedWithoutSignIn) {
+ displayModal("You need to sign in");
+ // Don't open the repo modal
+ $('#repo-name').removeAttr("data-target");
+ } else {
+ // Ensure repo modal is connected
+ let butt = document.getElementById("cloneButton");
+ butt.innerHTML = 'Clone';
+ butt.setAttribute('class', 'btn btn-primary');
+ $('#repo-name').attr("data-target", "#repo-modal");
+ }
}
function checkIfInTheApp(){
@@ -90,14 +93,15 @@ function hideSignInButton():void{
}
function wait(ms) {
- var start = new Date().getTime();
- var end = start;
- while (end < start + ms) {
- end = new Date().getTime();
- }
+ var start = new Date().getTime();
+ var end = start;
+ while (end < start + ms) {
+ end = new Date().getTime();
+ }
}
function displayUsername() {
+
console.log("Display Username called");
document.getElementById("Button_Sign_out").style.display = "block";
showUsername = true;
@@ -109,19 +113,19 @@ function displayUsername() {
}
function displayClonePanel() {
- document.getElementById("add-repository-panel").style.zIndex = "10";
- $("#open-local-repository").hide();
+ document.getElementById("add-repository-panel").style.zIndex = "10";
+ $("#open-local-repository").hide();
}
function displayFilePanel() {
- document.getElementById("file-panel").style.zIndex = "10";
- document.getElementById("commit-message-input").style="visibility: visible";
- document.getElementById("commit-button").style="visiblity: visible";
- document.getElementById("fileEdit-button").style="visiblity: visible";
+ document.getElementById("file-panel").style.zIndex = "10";
+ document.getElementById("commit-message-input").style = "visibility: visible";
+ document.getElementById("commit-button").style = "visiblity: visible";
+ document.getElementById("fileEdit-button").style = "visiblity: visible";
}
function displayGraphPanel() {
- document.getElementById("graph-panel").style.zIndex = "10";
+ document.getElementById("graph-panel").style.zIndex = "10";
}
function displayAddRepositoryPanel() {
@@ -131,55 +135,55 @@ function displayAddRepositoryPanel() {
}
function hideFilePanel() {
- document.getElementById("file-panel").style.zIndex = "-10";
- document.getElementById("commit-message-input").style="visibility: hidden";
- document.getElementById("commit-button").style="visibility: hidden";
- document.getElementById("fileEdit-button").style="visibility: hidden";
+ document.getElementById("file-panel").style.zIndex = "-10";
+ document.getElementById("commit-message-input").style = "visibility: hidden";
+ document.getElementById("commit-button").style = "visibility: hidden";
+ document.getElementById("fileEdit-button").style = "visibility: hidden";
}
function hideGraphPanel() {
- document.getElementById("graph-panel").style.zIndex = "-10";
+ document.getElementById("graph-panel").style.zIndex = "-10";
}
function hideAddRepositoryPanel() {
- document.getElementById("add-repository-panel").style.zIndex = "-10";
+ document.getElementById("add-repository-panel").style.zIndex = "-10";
}
function displayDiffPanel() {
- document.getElementById("graph-panel").style.width = "60%";
- document.getElementById("diff-panel").style.width = "40%";
- displayDiffPanelButtons();
+ document.getElementById("graph-panel").style.width = "60%";
+ document.getElementById("diff-panel").style.width = "40%";
+ displayDiffPanelButtons();
}
function hideDiffPanel() {
- document.getElementById("diff-panel").style.width = "0";
- document.getElementById("graph-panel").style.width = "100%";
- disableDiffPanelEditOnHide();
- hideDiffPanelButtons();
+ document.getElementById("diff-panel").style.width = "0";
+ document.getElementById("graph-panel").style.width = "100%";
+ disableDiffPanelEditOnHide();
+ hideDiffPanelButtons();
}
function hideDiffPanelIfNoChange() {
- let filename = document.getElementById("diff-panel-file-name") == null ? null : document.getElementById("diff-panel-file-name").innerHTML;
- let filePaths = document.getElementsByClassName('file-path');
- let nochange = true;
- for (let i = 0; i < filePaths.length; i++) {
- if (filePaths[i].innerHTML === filename) {
-
- nochange = false;
+ let filename = document.getElementById("diff-panel-file-name") == null ? null : document.getElementById("diff-panel-file-name").innerHTML;
+ let filePaths = document.getElementsByClassName('file-path');
+ let nochange = true;
+ for (let i = 0; i < filePaths.length; i++) {
+ if (filePaths[i].innerHTML === filename) {
+
+ nochange = false;
+ }
}
- }
- if (nochange == true){
- hideDiffPanel();
- }
- filename = null;
+ if (nochange == true) {
+ hideDiffPanel();
+ }
+ filename = null;
}
function hideAuthenticatePanel() {
- document.getElementById("authenticate").style.zIndex = "-20";
+ document.getElementById("authenticate").style.zIndex = "-20";
}
function displayAuthenticatePanel() {
- document.getElementById("authenticate").style.zIndex = "20";
+ document.getElementById("authenticate").style.zIndex = "20";
}
function displayDiffPanelButtons() {
@@ -197,26 +201,26 @@ function hideDiffPanelButtons() {
}
function disableSaveCancelButton() {
- let saveButton = document.getElementById("save-button");
- let cancelButton = document.getElementById("cancel-button");
- saveButton.disabled = true;
- saveButton.style.backgroundColor = gray;
- cancelButton.disabled = true;
- cancelButton.style.backgroundColor = gray;
+ let saveButton = document.getElementById("save-button");
+ let cancelButton = document.getElementById("cancel-button");
+ saveButton.disabled = true;
+ saveButton.style.backgroundColor = gray;
+ cancelButton.disabled = true;
+ cancelButton.style.backgroundColor = gray;
}
function enableSaveCancelButton() {
- let saveButton = document.getElementById("save-button");
- let cancelButton = document.getElementById("cancel-button");
- saveButton.disabled = false;
- saveButton.style.backgroundColor = blue;
- cancelButton.disabled = false;
- cancelButton.style.backgroundColor = blue;
+ let saveButton = document.getElementById("save-button");
+ let cancelButton = document.getElementById("cancel-button");
+ saveButton.disabled = false;
+ saveButton.style.backgroundColor = blue;
+ cancelButton.disabled = false;
+ cancelButton.style.backgroundColor = blue;
}
function disableDiffPanelEditOnHide() {
- let doc = document.getElementById("diff-panel-body");
- doc.contentEditable = "false";
+ let doc = document.getElementById("diff-panel-body");
+ doc.contentEditable = "false";
}
function useSavedCredentials() : boolean {
diff --git a/stylesheets/styles.css b/stylesheets/styles.css
index c312f48..98d087a 100644
--- a/stylesheets/styles.css
+++ b/stylesheets/styles.css
@@ -1,3 +1,15 @@
+.error {
+ position: relative;
+ animation: shake .1s linear;
+ animation-iteration-count: 3;
+}
+
+@keyframes shake {
+ 0% { left: -5px; }
+ 100% { right: -5px; }
+}
+
+
p, h1 {
color: #ccc;
font-family: 'Montserrat', sans-serif;