diff --git a/src/filemanager.html b/src/filemanager.html index 028b2f453..29123a342 100644 --- a/src/filemanager.html +++ b/src/filemanager.html @@ -136,6 +136,9 @@

+ + +
Path: {{ cwd }} diff --git a/src/js/client.js b/src/js/client.js index 6d64f97b9..b002bd18c 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -2421,7 +2421,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }); }; - Client.prototype.filesUploadFile = function (appId, path, file, callback) { + Client.prototype.filesUpload = function (appId, path, file, callback) { var fd = new FormData(); fd.append('file', file); diff --git a/src/js/filemanager.js b/src/js/filemanager.js index 59751e7e5..1acf6bacc 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -1,6 +1,6 @@ 'use strict'; -/* global angular, $ */ +/* global angular, $, async */ // create main application module var app = angular.module('Application', ['angular-md5', 'ui-notification']); @@ -82,6 +82,54 @@ app.controller('FileManagerController', ['$scope', 'Client', function ($scope, C $scope.refresh(); } + $scope.uploadStatus = { + busy: false, + count: 0, + size: 0, + done: 0, + percentDone: 0 + }; + + function uploadFiles(files) { + if (!files || !files.length) return; + + $scope.uploadStatus.busy = true; + $scope.uploadStatus.count = files.length; + $scope.uploadStatus.size = 0; + $scope.uploadStatus.done = 0; + $scope.uploadStatus.percentDone = 0; + + for (var i = 0; i < files.length; ++i) { + $scope.uploadStatus.size += files[i].size; + } + + async.eachSeries(files, function (file, callback) { + var finishedUploadSize = $scope.uploadStatus.done; + + var filePath = sanitize($scope.cwd + '/' + (file.webkitRelativePath || file.name)); + + Client.filesUpload($scope.appId, filePath, file, callback); + }, function (error) { + if (error) console.error(error); + + $scope.uploadStatus.busy = false; + $scope.uploadStatus.count = 0; + $scope.uploadStatus.size = 0; + $scope.uploadStatus.done = 0; + $scope.uploadStatus.percentDone = 100; + + $scope.refresh(); + }); + } + + $('#uploadFileInput').on('change', function (e) { + uploadFiles(e.target.files || []); + }); + + $scope.uploadFile = function () { + $('#uploadFileInput').click(); + }; + $scope.newDirectory = { busy: false, error: null,