@@ -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
6068In 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_
0 commit comments