Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 8695dbe

Browse files
authored
Merge pull request #6 from qjon/develop
v1.0.0
2 parents 448b5dd + e641814 commit 8695dbe

71 files changed

Lines changed: 2805 additions & 751 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
sudo: required
2+
dist: trusty
3+
language: node_js
4+
node_js: "6.11.0"
5+
6+
cache:
7+
directories:
8+
- node_modules
9+
10+
apt:
11+
sources:
12+
- google-chrome
13+
packages:
14+
- google-chrome-stable
15+
- google-chrome-beta
16+
17+
install:
18+
- npm i -g @angular/cli
19+
- npm i
20+
- npm test
21+
22+
before_install:
23+
- export CHROME_BIN=chromium-browser
24+
- export DISPLAY=:99.0
25+
- sh -e /etc/init.d/xvfb start

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013-2017 The angular-translate team and Pascal Precht
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 102 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ This project is a very simple __Angular2 file manager__.
44

55
## Features
66

7+
### v1.0.0
8+
* update angular2-tree to verison 2.x.x
9+
* update angular to version 4.x.x
10+
* use ngrx/store
11+
* prepare events for all actions
12+
* update configuration: allowed file types filter for upload files, allow limit for uploaded file
13+
* create examples: with backend in node, without backend on local storage
14+
715
### v0.5.4
816

917
* fix problem with open "choose file window"
@@ -59,37 +67,110 @@ Install npm package
5967

6068
In your project put this line
6169

62-
<filemanager [multiSelection]="isMultiSelection" (onSingleFileSelect)="selectFile($event)">Loading...</filemanager>
63-
64-
## Override API
65-
66-
To override endpoints to manage files and directories provide special provider in you module
67-
70+
<filemanager>Loading...</filemanager>
71+
72+
### Provide configuration
73+
In your module add following lines with configuration
74+
75+
import {FileManagerModule, IFileManagerConfiguration} from '../../../main';
76+
...
77+
const fileManagerConfiguration: IFileManagerConfiguration = {
78+
urls: {
79+
foldersUrl: '/api/folder',
80+
filesUrl: /api/files,
81+
folderMoveUrl: '/api/folder/move'
82+
},
83+
isMultiSelection: true,
84+
mimeTypes: ['image/jpg', 'image/jpeg', 'image/png'],
85+
maxFileSize: 50 * 1024
86+
}
87+
...
88+
89+
You can create a simple configuration object, it should contains a subset of below options
90+
91+
* __urls__
92+
* _foldersUrl_ - url for create (POST), delete (DELETE), edit (PUT) and get (GET) folders
93+
* _filesUrl_ - url for upload (POST), edit (PUT), delete (DELETE) and get (GET) files
94+
* _folderMoveUrl_ -
95+
* __isMultiselection__ - allow/disallow multiselection
96+
* __mimeTypes__ - list of file type mimes which are allowed to upload
97+
* __maxFileSize__ - limit of the single file size
98+
99+
Then you have to provide this constant as a configuration service
100+
68101
@NgModule({
69-
...
70-
providers: [
71-
...
72-
{
73-
provide: 'fileManagerUrls',
74-
useValue: {foldersUrl: '/api/filemanager/folder', filesUrl: '/api/filemanager/file'}
75-
}
76-
]
77-
...
102+
...
103+
imports: [
104+
...,
105+
FileManagerModule
106+
],
107+
providers: [
108+
{provide: 'fileManagerConfiguration', useValue: fileManagerConfiguration}
109+
],
110+
bootstrap: [AppComponent]
78111
})
112+
export class AppModule {
113+
}
114+
115+
### Create API service
116+
117+
Now you should create your own API service to communicate with backend or use existing one _FileManagerBackendApiService_.
118+
If you create your own API service it should have implemented _IFileManagerApi_ interface
119+
* _add(node: IOuterNode, parentNodeId: string): Observable<IOuterNode>;_ - create new node of the tree
120+
* _load(nodeId: string): Observable<IOuterNode[]>;_ - load tree branch (if nodeId is empty string it loads root level)
121+
* _move(srcNode: IOuterNode, targetNode: IOuterNode | null): Observable<IOuterNode>;_ - move one node (with all its sub nodes) to another parent
122+
* _update(node: IOuterNode): Observable<IOuterNode>;_ - update node name
123+
* _remove(nodeId: string): Observable<IOuterNode>;_ - remove node
124+
* _cropFile(file: IOuterFile, bounds: ICropBounds): Observable<IOuterFile>;_ - crop file to provided bounds
125+
* _loadFiles(nodeId: string): Observable<IOuterFile[]>;_ - load files from given node
126+
* _removeFile(file: IOuterFile): Observable<boolean>;_ - remove single file
127+
* _uploadFile(file: IOuterFile): Observable<IOuterFile>;_ - do actions with uploaded file (real upload is done in ng2-upload-file)
128+
129+
All those actions should manipulate on two protected properties:
130+
* _nodes: IOuterNode[]_ - list of all loaded nodes
131+
* _files: IFileDataProperties[]_ - list of files form current node
132+
133+
You can see two examples of that service:
134+
* [_FileManagerApiService_](src/store/fileManagerApi.service.ts) - works on local storage
135+
* [_FileManagerBackendApiService_](src/store/fileManagerBackendApi.service.ts) - works on backend (written in node)
136+
137+
### Attach to any Effects
138+
139+
Because of using _store_, _actions_ and _effects_ you can attach to any actions by creating your own effects service.
140+
You are able to connect to actions for doing something special (but this is not obligatory, this is only possibility):
141+
* _FileManagerActionsService.FILEMANAGER_CROP_FILE_
142+
* _FileManagerActionsService.FILEMANAGER_CROP_FILE_SUCCESS_
143+
* _FileManagerActionsService.FILEMANAGER_CROP_FILE_ERROR_
144+
* _FileManagerActionsService.FILEMANAGER_DELETE_FILE_
145+
* _FileManagerActionsService.FILEMANAGER_DELETE_FILE_SUCCESS_
146+
* _FileManagerActionsService.FILEMANAGER_DELETE_FILE_SELECTION_
147+
* _FileManagerActionsService.FILEMANAGER_DELETE_FILE_SELECTION_SUCCESS_
148+
* _FileManagerActionsService.FILEMANAGER_INVERSE_FILE_SELECTION_
149+
* _FileManagerActionsService.FILEMANAGER_LOAD_FILES_
150+
* _FileManagerActionsService.FILEMANAGER_LOAD_FILES_SUCCESS_
151+
* _FileManagerActionsService.FILEMANAGER_SELECT_ALL_
152+
* _FileManagerActionsService.FILEMANAGER_SELECT_FILE_
153+
* _FileManagerActionsService.FILEMANAGER_UNSELECT_FILE_
154+
* _FileManagerActionsService.FILEMANAGER_UNSELECT_ALL_
155+
* _FileManagerActionsService.FILEMANAGER_UPLOAD_FILE_
156+
* _FileManagerActionsService.FILEMANAGER_UPLOAD_FILE_ERROR_
157+
* _FileManagerActionsService.FILEMANAGER_UPLOAD_FILE_SUCCESS_
79158

80159
## Demo
81160

82-
To run demo you have to serve frontend and backend. To do this run:
161+
To run local demo you have to serve frontend and backend. To do this run:
83162

84163
* frontend:
85-
164+
* using local storage
165+
86166
npm start
167+
168+
* or using real backend
169+
170+
npm run startWithBackend
87171

88172
* backend
89173

90174
npm run backend
91175

92-
## TODO
93-
94-
* files upload progress
95-
* multi selection events (delete, select)
176+
Or you can see online [demo](https://qjon.github.io/angular2-filemanager/) with _local storage_

angular-cli.json

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
33
"project": {
4-
"version": "1.0.0-beta.32.3",
4+
"version": "1.2.0",
55
"name": "angular2-filemanager"
66
},
77
"apps": [
88
{
9+
"name": "withoutBackend",
910
"root": "demo/src",
1011
"outDir": "dist",
1112
"assets": [
@@ -16,8 +17,37 @@
1617
"index": "index.html",
1718
"main": "main.ts",
1819
"polyfills": "polyfills.ts",
19-
"test": "test.ts",
20+
"test": "../../src/test.ts",
2021
"tsconfig": "tsconfig.json",
22+
"testTsconfig": "../../src/tsconfig.spec.json",
23+
"prefix": "app",
24+
"mobile": false,
25+
"styles": [
26+
"../../node_modules/bootstrap/dist/css/bootstrap.min.css",
27+
"../../node_modules/font-awesome/css/font-awesome.css"
28+
],
29+
"scripts": [],
30+
"environmentSource": "environments/environment.ts",
31+
"environments": {
32+
"dev": "environments/environment.ts",
33+
"prod": "environments/environment.prod.ts"
34+
}
35+
},
36+
{
37+
"name": "withBackend",
38+
"root": "demo/src",
39+
"outDir": "dist",
40+
"assets": [
41+
"assets",
42+
"icons",
43+
"favicon.ico"
44+
],
45+
"index": "index.html",
46+
"main": "mainWithBackend.ts",
47+
"polyfills": "polyfills.ts",
48+
"test": "../../src/test.ts",
49+
"tsconfig": "tsconfig.json",
50+
"testTsconfig": "../../src/tsconfig.spec.json",
2151
"prefix": "app",
2252
"mobile": false,
2353
"styles": [

0 commit comments

Comments
 (0)