Skip to content

Commit 9acdcee

Browse files
authored
Merge pull request joni2back#1 from joni2back/master
Merge
2 parents c9b0a1b + 47cba6c commit 9acdcee

File tree

8 files changed

+41
-16
lines changed

8 files changed

+41
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ angular.module('FileManagerApp').config(['fileManagerConfigProvider', function (
112112
</script>
113113
```
114114

115-
You can do many things by extending the configuration. Like hide the sidebar or the search button. See [/src/js/providers/config.js](You can see the list of default configurations).
115+
You can do many things by extending the configuration. Like hide the sidebar or the search button. See [the list of default configurations](/src/js/providers/config.js).
116116

117117
---------
118118

bridges/php/handler.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ public function getContent($path)
274274
$fileName = explode('/', $filePath);
275275
$fileName = end($fileName);
276276
$tmpFilePath = $oFtp->downloadTemp($filePath);
277+
278+
@register_shutdown_function(function() use ($tmpFilePath) {
279+
if (file_exists($tmpFilePath)) {
280+
@unlink($tmpFilePath);
281+
}
282+
});
283+
277284
if ($fileContent = @file_get_contents($tmpFilePath)) {
278285
$oResponse->setData($fileContent);
279286
$oResponse->setHeaders(array(
@@ -304,4 +311,4 @@ public function getContent($path)
304311
$oResponse->flush();
305312
}
306313

307-
throw new \Exception('This action is not available in the demo');
314+
throw new \Exception('This action is not available in the demo');

dist/angular-filemanager.min.js

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

src/js/providers/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
compressUrl: 'bridges/php/handler.php',
2121
extractUrl: 'bridges/php/handler.php',
2222
permissionsUrl: 'bridges/php/handler.php',
23+
basePath: '/',
2324

2425
searchForm: true,
2526
sidebar: true,
@@ -44,6 +45,7 @@
4445
},
4546

4647
multipleDownloadFileName: 'angular-filemanager.zip',
48+
filterFileExtensions: [],
4749
showExtensionIcons: true,
4850
showSizeForDirectories: false,
4951
useBinarySizePrefixes: false,

src/js/services/apihandler.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333
return deferred.resolve(data);
3434
};
3535

36-
ApiHandler.prototype.list = function(apiUrl, path, customDeferredHandler) {
36+
ApiHandler.prototype.list = function(apiUrl, path, customDeferredHandler, exts) {
3737
var self = this;
3838
var dfHandler = customDeferredHandler || self.deferredHandler;
3939
var deferred = $q.defer();
4040
var data = {
4141
action: 'list',
42-
path: path
42+
path: path,
43+
fileExtensions: exts && exts.length ? exts : undefined
4344
};
4445

4546
self.inprocess = true;

src/js/services/filenavigator.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
this.apiMiddleware = new ApiMiddleware();
88
this.requesting = false;
99
this.fileList = [];
10-
this.currentPath = [];
10+
this.currentPath = this.getBasePath();
1111
this.history = [];
1212
this.error = '';
1313

1414
this.onRefresh = function() {};
1515
};
1616

17+
FileNavigator.prototype.getBasePath = function() {
18+
var path = (fileManagerConfig.basePath || '').replace(/^\//, '');
19+
return path.trim() ? path.split('/') : [];
20+
};
21+
1722
FileNavigator.prototype.deferredHandler = function(data, deferred, code, defaultMsg) {
1823
if (!data || typeof data !== 'object') {
1924
this.error = 'Error %s - Bridge response error, please check the API docs or this ajax response.'.replace('%s', code);
@@ -22,7 +27,7 @@
2227
this.error = 'Error 404 - Backend bridge is not working, please check the ajax response.';
2328
}
2429
if (code == 200) {
25-
this.error = '';
30+
this.error = null;
2631
}
2732
if (!this.error && data.result && data.result.error) {
2833
this.error = data.result.error;
@@ -46,7 +51,7 @@
4651
FileNavigator.prototype.refresh = function() {
4752
var self = this;
4853
if (! self.currentPath.length) {
49-
self.currentPath = fileManagerConfig.basePath || [];
54+
self.currentPath = this.getBasePath();
5055
}
5156
var path = self.currentPath.join('/');
5257
self.requesting = true;
@@ -67,7 +72,7 @@
6772

6873
function recursive(parent, item, path) {
6974
var absName = path ? (path + '/' + item.model.name) : item.model.name;
70-
if (parent.name.trim() && path.trim().indexOf(parent.name) !== 0) {
75+
if (parent.name && parent.name.trim() && path.trim().indexOf(parent.name) !== 0) {
7176
parent.nodes = [];
7277
}
7378
if (parent.name !== path) {
@@ -102,7 +107,7 @@
102107
}
103108

104109
//!this.history.length && this.history.push({name: '', nodes: []});
105-
!this.history.length && this.history.push({ name: fileManagerConfig.basePath ? fileManagerConfig.basePath[0] : '', nodes: [] });
110+
!this.history.length && this.history.push({ name: this.getBasePath()[0] || '', nodes: [] });
106111
flatten(this.history[0], flatNodes);
107112
selectedNode = findNode(flatNodes, path);
108113
selectedNode && (selectedNode.nodes = []);
@@ -135,7 +140,7 @@
135140

136141
FileNavigator.prototype.fileNameExists = function(fileName) {
137142
return this.fileList.find(function(item) {
138-
return fileName.trim && item.model.name.trim() === fileName.trim();
143+
return fileName && item.model.name.trim() === fileName.trim();
139144
});
140145
};
141146

@@ -145,6 +150,10 @@
145150
});
146151
};
147152

153+
FileNavigator.prototype.getCurrentFolderName = function() {
154+
return this.currentPath.slice(-1)[0] || '/';
155+
};
156+
148157
return FileNavigator;
149158
}]);
150159
})(angular);

src/templates/navbar.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
</div>
1111
<div class="col-sm-3 col-md-2">
1212
<div class="navbar-collapse">
13-
<div class="navbar-form navbar-right text-right">
13+
<div class="navbar-form navbar-right text-right visible-xs">
14+
<div class="pull-left" ng-if="fileNavigator.currentPath.length">
15+
<button class="btn btn-primary btn-flat" ng-click="fileNavigator.upDir()">
16+
<i class="glyphicon glyphicon-chevron-left"></i>
17+
</button>
18+
{{fileNavigator.getCurrentFolderName() | strLimit : 12}}
19+
</div>
1420
<div class="btn-group">
1521
<button class="btn btn-flat btn-sm dropdown-toggle" type="button" id="dropDownMenuSearch" data-toggle="dropdown" aria-expanded="true">
1622
<i class="glyphicon glyphicon-search mr2"></i>

src/templates/sidebar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<i class="glyphicon glyphicon-folder-open mr2" ng-show="isInThisPath(item.name)"></i>
1414
<i class="glyphicon glyphicon-folder-close mr2" ng-show="!isInThisPath(item.name)"></i>
15-
{{ (item.name.split('/').pop() || '/') | strLimit : 30 }}
15+
{{ (item.name.split('/').pop() || fileNavigator.getBasePath().join('/') || '/') | strLimit : 30 }}
1616
</a>
1717
<ul class="nav nav-sidebar">
1818
<li ng-repeat="item in item.nodes" ng-include="'folder-branch-item'" ng-class="{'active': item.name == fileNavigator.currentPath.join('/')}"></li>

0 commit comments

Comments
 (0)