Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Add create project function
Browse files Browse the repository at this point in the history
This patch replaces apply button to create button, when it comes the following
functions: files, folders and projects.

Signed-off-by: Bruno Bottazzini <[email protected]>
  • Loading branch information
Bruno Bottazzini committed Mar 31, 2016
1 parent 5cff6c5 commit cdb0eb0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
50 changes: 48 additions & 2 deletions client/js/controllers/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,52 @@

}

$scope.createProject = function () {
var dialog = $('<div></div>').
html($compile('<input class="inputControls"' +
' type="text" style="width: 256px; outline: 0;"' +
' ng-model="prj_name" />')($scope)).
dialog({
title: "Choose the name of the project",
autoOpen: false,
modal: true,
position: { at: "center top"},
height: 167,
width: 300,
show: { effect: "fade", duration: 300 },
hide: {effect: "fade", duration: 300 },
resizable: 'disable',
buttons: {
"Create": function() {
var name = "/" + $scope.prj_name;
if (name) {
$http.post('/api/git/repo/create/project',
{
params: {
"project_name": name
}
}).success(function(data) {
$scope.refreshTree();
}).error(function(){
alert("Oh uh, something went wrong. Try again");
});
} else {
alert("Oh uh, something went wrong. Try again");
}
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
},
close: function(ev, ui){
$(this).dialog("close");
}
});
dialog.dialog("open");

};

$scope.newFolder = function () {
var file = filePath;
if (isLeaf) {
Expand All @@ -548,7 +594,7 @@
hide: {effect: "fade", duration: 300 },
resizable: 'disable',
buttons: {
"Apply": function() {
"Create": function() {
var name = "/" + $scope.folder_name;
if (name) {
$http.post('/api/git/repo/create/folder',
Expand Down Expand Up @@ -600,7 +646,7 @@
hide: {effect: "fade", duration: 300 },
resizable: 'disable',
buttons: {
"Apply": function() {
"Create": function() {
var name = "/" + $scope.file_name;
if (name) {
$http.post('/api/git/repo/create/file',
Expand Down
15 changes: 15 additions & 0 deletions server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,21 @@
});
});

router.post('/api/git/repo/create/project', function (req, res) {
var project_name = req.body.params.project_name;
if (!project_name) {
res.status(400).send("Failed to get project name");
}
execOnServer('mkdir ' + home_dir(current_user(req)) + project_name,
function(returns) {
if (returns.error === true) {
res.status(400).send("Failed to run command on server");
} else {
res.send(returns.message);
}
});
})

router.post('/api/git/repo/create/folder', function (req, res) {
var folder_path = req.body.params.folder_path;
if (!folder_path) {
Expand Down
1 change: 1 addition & 0 deletions server/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
<!-- DROP DOWN MENU !-->
<div class="dropdown" style="position: fixed; z-index: 9999;" id="menu-1">
<ul class="dropdown-menu" role="menu">
<li><a class="pointer" role="menuitem" tabindex="1" ng-click="createProject()">New project</a></li>
<li><a class="pointer" role="menuitem" tabindex="1" ng-click="newFolder()">Create folder</a></li>
<li><a class="pointer" role="menuitem" tabindex="2" ng-click="newFile()">Create file</a></li>
<li><a class="pointer" role="menuitem" tabindex="3" ng-click="remove()">Remove</a></li>
Expand Down

0 comments on commit cdb0eb0

Please sign in to comment.