-
Notifications
You must be signed in to change notification settings - Fork 13
WIP: Import and Export File to Dev-App #114
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -831,6 +831,64 @@ | |
} | ||
}; | ||
|
||
$scope.importFile = function () { | ||
var file = filePath; | ||
if (file) { | ||
if (isLeaf) { | ||
var cached = file.split("/"); | ||
cached.pop(); | ||
file = cached.join("/"); | ||
} | ||
var dialog = $('<div></div>'). | ||
html($compile('<form ng-controller="editor"> <input' + | ||
' type="file" class="inputControls"' + | ||
' multiple onChange="angular.element(this).scope().filesChanged(this)"/> <input type="button" class="inputControls" ng-click="uploadFiles()" value="Upload" /><li ng-repeat="file in files">{{file.name}}</li></form>')($scope)). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. try breaking some lines here it is too wide |
||
dialog({ | ||
title: "Choose file to import", | ||
autoOpen: false, | ||
modal: true, | ||
position: { at: "center top"}, | ||
height: 167, | ||
width: 300, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. height and width too small to me here, I put the following values: |
||
show: { effect: "fade", duration: 300 }, | ||
hide: {effect: "fade", duration: 300 }, | ||
resizable: 'disable', | ||
buttons: { | ||
Cancel: function() { | ||
$(this).dialog("close"); | ||
} | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can create Upload button like the Cancel one (with the same style and position). It should be something like this:
Try avoiding creating the html button you've created for Upload :) |
||
close: function(ev, ui){ | ||
$(this).dialog("close"); | ||
} | ||
}); | ||
dialog.dialog("open"); | ||
} else { | ||
console.log("Error: repository not selected"); | ||
alert("Folder destination must be selected!"); | ||
} | ||
}; | ||
|
||
$scope.filesChanged = function(elm){ | ||
$scope.files = elm.files | ||
$scope.$apply(); | ||
} | ||
|
||
$scope.uploadFiles = function() { | ||
var formdata = new FormData(); | ||
angular.forEach($scope.files,function(file){ | ||
formdata.append('file',file) | ||
}) | ||
$http.post('/api/git/repo/upload',formdata, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you haven't created this api so, I would change the name to
|
||
{ | ||
transformRequest:angular.identity, | ||
headers:{'Content-Type':undefined} | ||
}) | ||
.success(function(d){ | ||
console.log(d) | ||
}); | ||
}; | ||
|
||
$scope.remove = function () { | ||
if (filePath) { | ||
var file_name = filePath.split("/").pop(); | ||
|
@@ -943,6 +1001,9 @@ | |
case "file.remove": | ||
$scope.remove(); | ||
break; | ||
case "file.importfile": | ||
$scope.importFile(); | ||
break; | ||
case "file.import": | ||
$scope.importGITProject(); | ||
break; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, AngularJS does not allow declaration of the the same controller in two different forms.
Also, the $compile and $scope would inject the new code inside the editor controller so this form is not needed.