Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump jquery from ^3.5.0 to ^3.5.1 in /src/package.json(#18), Updated Project module(#22) #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function projectDeleteButtons(){

function userProjectButtons(){
$(".settingsbuttons").click((value) => {
userjs.setProject(value);
userjs.updateProject(value);
loadPage("project/project.html", ()=>{
projectjs.init();
projectDeleteButtons();
Expand Down
10 changes: 8 additions & 2 deletions src/modules/project/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@
<div class="form-group row">
<label class="col-form-label col-sm-4" for="project-name">Project Name: </label>
<div class="col">
<input readonly type="text" class="form-control" id="project-name">
<input readonly type="text" class="form-control-plaintext" id="project-name">
</div>
</div>
<br>
<div class="form-group row">
<label class="col-form-label col-sm-4" for="project-description">Project Description: </label>
<div class="col">
<input readonly type="text" class="form-control" id="project-description">
<input readonly type="text" class="form-control-plaintext" id="project-description">
</div>
</div>
</form>
<button class="btn btn-primary m-2 updatebuttons">
Update Details
</button>
<button class="btn btn-success m-2 savebuttons">
Save
</button>
<button class="btn btn-primary m-2 cancelbuttons">
Cancel
</button>
<button class="btn btn-danger deletebuttons m-2">
Delete Project
</button>
Expand Down
90 changes: 89 additions & 1 deletion src/modules/project/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
function init(){
$("#project-name").val(globaljs.projectDetails.name);
$("#project-description").val(globaljs.projectDetails.details);
$(".savebuttons").hide();
$(".cancelbuttons").hide();

$(".updatebuttons").click((value) => {
$("#project-name").removeClass("form-control-plaintext").addClass("form-control").attr("readonly", false);
$("#project-description").removeClass("form-control-plaintext").addClass("form-control").attr("readonly", false);
$(".updatebuttons").hide();
$(".savebuttons").show();
$(".cancelbuttons").show();
// swal({
// text: "Project Name",
// title: "Update Project Details",
Expand Down Expand Up @@ -57,7 +64,88 @@ function init(){
// }
// }
// });
swal("Info","This feature is currently in development. Stay tune for updates.","info");
// swal("Info","This feature is currently in development. Stay tune for updates.","info");
});

$(".savebuttons").click((value) => {
let project_name = $("#project-name").val();
let project_description = $("#project-description").val();
if(project_name == "") {
swal("Error", "Project name can't be empty.", "error");
return;
}
if(project_description == "") {
swal("Error", "Project description can't be empty.", "error");
return;
}
if(project_name === globaljs.projectDetails.name && project_description === globaljs.projectDetails.details) {
swal("Error", "You have made no changes.", "error");
return;
}
let dir = project_name.replace(/[^a-z0-9]/gi, '_').toLowerCase();
let old_dir = globaljs.projectDetails.name.replace(/[^a-z0-9]/gi, '_').toLowerCase();;
let projects_path = path.join(process.cwd(), "/../testing/Projects/");
if(fs.existsSync(projects_path + dir)) {
swal("Error", "A Project with this name already exists.", "error");
return;
}

swal({
title: "Save?",
text: "Are you sure you want to save your changes?",
icon: "warning",
buttons: true,
dangerMode: true
}).then((willSave) => {
if(willSave) {
try {
let data = JSON.parse(fs.readFileSync(projects_path + old_dir + "/info.json", "utf-8"));
data.name = dir;
data.details = project_description;

fs.writeFileSync(projects_path + old_dir + "/info.json", JSON.stringify(data), "utf-8");

fs.renameSync(projects_path + old_dir, projects_path + dir);
swal("Success", "Project details have been successfully updated.", "success").then(value => {
globaljs.projectDetails.name = project_name;
globaljs.projectDetails.details = project_description;

$("#project-name").val(globaljs.projectDetails.name).removeClass("form-control")
.addClass("form-control-plaintext").attr("readonly", true);
$("#project-description").val(globaljs.projectDetails.details).removeClass("form-control")
.addClass("form-control-plaintext").attr("readonly", true);
$(".updatebuttons").show();
$(".savebuttons").hide();
$(".cancelbuttons").hide();
});
}
catch(err) {
swal("Error", "Error writing to files", "error");
print(err);
return;
}
}
});
});

$(".cancelbuttons").click((value) => {
swal({
title: "Discard changes?",
text: "Are you sure you want to discard changes?",
icon: "warning",
buttons: true,
dangerMode: true
}).then((willCancel) => {
if(willCancel) {
$("#project-name").val(globaljs.projectDetails.name).removeClass("form-control")
.addClass("form-control-plaintext").attr("readonly", true);
$("#project-description").val(globaljs.projectDetails.details).removeClass("form-control")
.addClass("form-control-plaintext").attr("readonly", true);
$(".updatebuttons").show();
$(".savebuttons").hide();
$(".cancelbuttons").hide();
}
});
});
}

Expand Down
9 changes: 8 additions & 1 deletion src/modules/user/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ function setProject(value) {
globaljs.projectDetails.details = pdosi[1].innerText;
}

function updateProject(value) {
let pdosi = $(value.target).parent()[0].children;
globaljs.projectDetails.name = pdosi[0].innerText;
globaljs.projectDetails.details = pdosi[1].innerText;
}

function loadProjects() {
let dirlist = getDirectories(projects_path)
if (dirlist.length != 0) {
Expand Down Expand Up @@ -186,7 +192,8 @@ module.exports = {
init: init,
killTensorboard: killTensorboard,
startTensorboard: startTensorboard,
setProject: setProject
setProject: setProject,
updateProject: updateProject
}

// $(document).ready(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"electron": "^4.2.3"
},
"dependencies": {
"jquery": "^3.5.0",
"jquery": "^3.5.1",
"jquery-ui-dist": "^1.12.1",
"monaco-editor": "^0.19.2",
"rimraf": "^2.6.3",
Expand Down