Skip to content

Commit 6532587

Browse files
committed
important refactor, using deferreds, etc
1 parent 9626c44 commit 6532587

File tree

22 files changed

+508
-443
lines changed

22 files changed

+508
-443
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/nbproject/private/
22
nbproject/
3+
node_modules/

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,21 @@ A very smart filemanager to manage your files in the browser developed in Angula
6565
```html
6666
<!-- Uncomment if you need to use raw source code
6767
<script src="src/js/app.js"></script>
68-
<script src="src/js/config.js"></script>
69-
<script src="src/js/chmod.js"></script>
70-
<script src="src/js/item.js"></script>
71-
<script src="src/js/filenavigator.js"></script>
72-
<script src="src/js/fileuploader.js"></script>
73-
<script src="src/js/translations.js"></script>
74-
<script src="src/js/controller.js"></script>
75-
<script src="src/js/selector-controller.js"></script>
76-
<link rel="stylesheet" href="src/css/angular-filemanager.css">
68+
<script src="src/js/directives/directives.js"></script>
69+
<script src="src/js/filters/filters.js"></script>
70+
<script src="src/js/providers/config.js"></script>
71+
<script src="src/js/entities/chmod.js"></script>
72+
<script src="src/js/entities/item.js"></script>
73+
<script src="src/js/services/filenavigator.js"></script>
74+
<script src="src/js/services/fileuploader.js"></script>
75+
<script src="src/js/providers/translations.js"></script>
76+
<script src="src/js/controllers/main.js"></script>
77+
<script src="src/js/controllers/selector-controller.js"></script>
78+
<link href="src/css/angular-filemanager.css" rel="stylesheet">
7779
-->
7880

7981
<!-- Comment if you need to use raw source code -->
80-
<link rel="stylesheet" href="dist/angular-filemanager.css">
82+
<link href="dist/angular-filemanager.css" rel="stylesheet">
8183
<script src="dist/angular-filemanager.min.js"></script>
8284
<!-- /Comment if you need to use raw source code -->
8385
```
@@ -87,15 +89,12 @@ A very smart filemanager to manage your files in the browser developed in Angula
8789
### Extending the configuration file
8890
```html
8991
<script type="text/javascript">
90-
//example to override angular-filemanager default config
91-
angular.module('FileManagerApp').config(['fileManagerConfigProvider', function (fileManagerConfig) {
92-
var defaults = fileManagerConfig.$get();
93-
fileManagerConfig.set({
94-
appName: 'Demo - github.com/joni2back/angular-filemanager',
95-
sidebar: false,
92+
angular.module('FileManagerApp').config(['fileManagerConfigProvider', function (config) {
93+
var defaults = config.$get();
94+
config.set({
95+
appName: 'github.com/joni2back/angular-filemanager',
9696
allowedActions: angular.extend(defaults.allowedActions, {
9797
remove: true
98-
copy: false
9998
})
10099
});
101100
}]);

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-filemanager",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"homepage": "https://github.com/joni2back/angular-filemanager",
55
"authors": [
66
"Jonas Sciangula Street <[email protected]>"

bridges/php/handler.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ public static function getPost($param = null, $default = null)
4848
return $_POST;
4949
}
5050

51+
public static function getFile($param = null, $default = null)
52+
{
53+
if ($param) {
54+
return isset($_FILES[$param]) ?
55+
$_FILES[$param] : $default;
56+
}
57+
return $_FILES;
58+
}
59+
5160
public static function getPostContent()
5261
{
5362
$rawData = file_get_contents('php://input');
@@ -127,29 +136,30 @@ public function getContent($path)
127136
}
128137

129138
ExceptionCatcherJSON::register();
130-
139+
$oResponse = new Response();
131140
$oFtp = new FileManager(array(
132141
'hostname' => '',
133142
'username' => '',
134143
'password' => ''
135144
));
136145

137-
$oFtp->connect();
138-
$oResponse = new Response();
146+
if (! $oFtp->connect()) {
147+
throw new Exception("Cannot connect to the FTP server");
148+
}
139149

140-
if ($_FILES) {
141-
$dest = Request::getPost('destination');
150+
if (Request::getFile() && $dest = Request::getPost('destination')) {
142151
$errors = array();
143-
foreach ($_FILES as $file) {
152+
foreach (Request::getFile() as $file) {
144153
$filePath = $file['tmp_name'];
145154
$destPath = $dest .'/'. $file['name'];
146155
$result = $oFtp->upload($filePath, $destPath);
147156
if (! $result) {
148157
$errors[] = $file['name'];
149158
}
150159
}
160+
151161
if ($errors) {
152-
throw new Exception("Unknown error uploading: " . "\n" . implode($errors, ", \n"));
162+
throw new Exception("Unknown error uploading: \n\n" . implode(", \n", $errors));
153163
}
154164

155165
$oResponse->setData($result);
@@ -199,7 +209,7 @@ public function getContent($path)
199209
$oResponse->setData($fileContent);
200210
$oResponse->setHeaders(array(
201211
'Content-Type' => @mime_content_type($tmpFilePath),
202-
'Content-disposition' => "$download filename=$fileName"
212+
'Content-disposition' => sprintf('%s filename="%s"', $download, $fileName)
203213
));
204214
}
205215
$oResponse->flush();

dist/angular-filemanager.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ gulp.task('cache-templates', function () {
3232

3333
gulp.task('concat-uglify-js', ['clean', 'cache-templates'], function() {
3434
return gulp.src([
35-
src + 'js/*.js',
35+
src + 'js/app.js',
36+
src + 'js/*/*.js',
3637
dst + '/' + jsFile
3738
])
3839
.pipe(concat(jsFile))

index.html

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en" data-ng-app="FileManagerApp">
33
<head>
44
<!--
5-
* Angular FileManager v1.3.1 (https://github.com/joni2back/angular-filemanager)
5+
* Angular FileManager v1.4.0 (https://github.com/joni2back/angular-filemanager)
66
* Jonas Sciangula Street <[email protected]>
77
* Licensed under MIT (https://github.com/joni2back/angular-filemanager/blob/master/LICENSE)
88
-->
@@ -21,39 +21,48 @@
2121

2222
<!-- Uncomment if you need to use raw source code
2323
<script src="src/js/app.js"></script>
24-
<script src="src/js/config.js"></script>
25-
<script src="src/js/chmod.js"></script>
26-
<script src="src/js/item.js"></script>
27-
<script src="src/js/filenavigator.js"></script>
28-
<script src="src/js/fileuploader.js"></script>
29-
<script src="src/js/translations.js"></script>
30-
<script src="src/js/controller.js"></script>
31-
<script src="src/js/selector-controller.js"></script>
32-
<link rel="stylesheet" href="src/css/angular-filemanager.css">
24+
<script src="src/js/directives/directives.js"></script>
25+
<script src="src/js/filters/filters.js"></script>
26+
<script src="src/js/providers/config.js"></script>
27+
<script src="src/js/entities/chmod.js"></script>
28+
<script src="src/js/entities/item.js"></script>
29+
<script src="src/js/services/filenavigator.js"></script>
30+
<script src="src/js/services/fileuploader.js"></script>
31+
<script src="src/js/providers/translations.js"></script>
32+
<script src="src/js/controllers/main.js"></script>
33+
<script src="src/js/controllers/selector-controller.js"></script>
34+
<link href="src/css/angular-filemanager.css" rel="stylesheet">
3335
-->
3436

3537
<!-- Comment if you need to use raw source code -->
36-
<link rel="stylesheet" href="dist/angular-filemanager.css">
38+
<link href="dist/angular-filemanager.css" rel="stylesheet">
3739
<script src="dist/angular-filemanager.min.js"></script>
3840
<!-- /Comment if you need to use raw source code -->
3941

4042
<script type="text/javascript">
4143
//example to override angular-filemanager default config
42-
angular.module('FileManagerApp').config(['fileManagerConfigProvider', function (fileManagerConfig) {
43-
var defaults = fileManagerConfig.$get();
44-
45-
fileManagerConfig.set({
46-
appName: 'Demo - github.com/joni2back/angular-filemanager',
44+
angular.module('FileManagerApp').config(['fileManagerConfigProvider', function (config) {
45+
var defaults = config.$get();
46+
config.set({
47+
appName: 'github.com/joni2back/angular-filemanager',
4748
allowedActions: angular.extend(defaults.allowedActions, {
4849
remove: true
4950
})
5051
});
51-
5252
}]);
5353
</script>
5454
</head>
5555

5656
<body class="ng-cloak">
5757
<angular-filemanager></angular-filemanager>
58+
59+
<script>
60+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
61+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
62+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
63+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
64+
ga('create', 'UA-35182652-1', 'auto');
65+
ga('send', 'pageview');
66+
</script>
5867
</body>
5968
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-filemanager",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"description": "A very smart filemanager to manage your files in the browser.",
55
"main": "src/app.js",
66
"scripts": {

src/js/app.js

Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Angular FileManager v1.3.1 (https://github.com/joni2back/angular-filemanager)
2+
* Angular FileManager v1.4.0 (https://github.com/joni2back/angular-filemanager)
33
* Jonas Sciangula Street <[email protected]>
44
* Licensed under MIT (https://github.com/joni2back/angular-filemanager/blob/master/LICENSE)
55
*/
@@ -8,76 +8,20 @@
88
"use strict";
99
var app = angular.module('FileManagerApp', ['pascalprecht.translate', 'ngCookies']);
1010

11-
app.directive('angularFilemanager', ['$parse', 'fileManagerConfig', function($parse, fileManagerConfig) {
12-
return {
13-
restrict: 'EA',
14-
templateUrl: fileManagerConfig.tplPath + '/index.html'
15-
};
16-
}]);
17-
18-
app.directive('ngFile', ['$parse', function($parse) {
19-
return {
20-
restrict: 'A',
21-
link: function(scope, element, attrs) {
22-
var model = $parse(attrs.ngFile);
23-
var modelSetter = model.assign;
24-
25-
element.bind('change', function() {
26-
scope.$apply(function() {
27-
modelSetter(scope, element[0].files);
28-
});
29-
});
30-
}
31-
};
32-
}]);
33-
34-
app.directive('ngRightClick', ['$parse', function($parse) {
35-
return function(scope, element, attrs) {
36-
var fn = $parse(attrs.ngRightClick);
37-
element.bind('contextmenu', function(event) {
38-
scope.$apply(function() {
39-
event.preventDefault();
40-
fn(scope, {$event: event});
41-
});
42-
});
43-
};
44-
}]);
45-
46-
app.filter('strLimit', ['$filter', function($filter) {
47-
return function(input, limit) {
48-
if (input.length <= limit) {
49-
return input;
50-
}
51-
return $filter('limitTo')(input, limit) + '...';
52-
};
53-
}]);
54-
55-
app.filter('formatDate', ['$filter', function($filter) {
56-
return function(input, limit) {
57-
return input instanceof Date ?
58-
input.toISOString().substring(0, 19).replace('T', ' ') :
59-
(input.toLocaleString || input.toString).apply(input);
60-
};
61-
}]);
62-
6311
/**
6412
* jQuery inits
6513
*/
66-
var menuSelectors = '.main-navigation .table-files td:first-child, .iconset a.thumbnail';
67-
6814
$(window.document).on('shown.bs.modal', '.modal', function() {
69-
var self = this;
70-
var timer = setTimeout(function() {
71-
$('[autofocus]', self).focus();
72-
timer && clearTimeout(timer);
73-
}, 100);
15+
setTimeout(function() {
16+
$('[autofocus]', this).focus();
17+
}.bind(this), 100);
7418
});
7519

7620
$(window.document).on('click', function() {
7721
$("#context-menu").hide();
7822
});
7923

80-
$(window.document).on('contextmenu', menuSelectors, function(e) {
24+
$(window.document).on('contextmenu', '.main-navigation .table-files td:first-child, .iconset a.thumbnail', function(e) {
8125
$("#context-menu").hide().css({
8226
left: e.pageX,
8327
top: e.pageY

0 commit comments

Comments
 (0)