(File Manager App) first steps.

This commit is contained in:
mustafahlvc 2017-08-01 15:27:32 +03:00
parent 0a049ff9f4
commit 9a2acb0e64
17 changed files with 618 additions and 1 deletions

View File

@ -42,6 +42,10 @@ const appRoutes: Routes = [
path : 'apps/todo',
loadChildren: './main/apps/todo/todo.module#FuseTodoModule'
},
{
path : 'apps/file-manager',
loadChildren: './main/apps/file-manager/file-manager.module#FuseFileManagerModule'
},
{
path : '**',
redirectTo: 'apps/dashboards/project'

View File

@ -0,0 +1,146 @@
export class FileManagerFakeDb
{
public static files = [
{
'name' : 'Work Documents',
'type' : 'folder',
'owner' : 'me',
'size' : '',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true
},
{
'name' : 'Public Documents',
'type' : 'folder',
'owner' : 'public',
'size' : '',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true
},
{
'name' : 'Private Documents',
'type' : 'folder',
'owner' : 'me',
'size' : '',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true
},
{
'name' : 'Ongoing projects',
'type' : 'document',
'owner' : 'Emily Bennett',
'size' : '1.2 Mb',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true,
'preview' : 'assets/images/etc/sample-file-preview.jpg'
},
{
'name' : 'Shopping list',
'type' : 'document',
'owner' : 'Emily Bennett',
'size' : '980 Kb',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true,
'preview' : 'assets/images/etc/sample-file-preview.jpg'
},
{
'name' : 'Invoices',
'type' : 'spreadsheet',
'owner' : 'Emily Bennett',
'size' : '750 Kb',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true,
'preview' : 'assets/images/etc/sample-file-preview.jpg'
},
{
'name' : 'Crash logs',
'type' : 'document',
'owner' : 'Emily Bennett',
'size' : '980 Mb',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true,
'preview' : 'assets/images/etc/sample-file-preview.jpg'
},
{
'name' : 'System logs',
'type' : 'document',
'owner' : 'Emily Bennett',
'size' : '52 Kb',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true,
'preview' : 'assets/images/etc/sample-file-preview.jpg'
},
{
'name' : 'Prices',
'type' : 'spreadsheet',
'owner' : 'Emily Bennett',
'size' : '27 Mb',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true,
'preview' : 'assets/images/etc/sample-file-preview.jpg'
},
{
'name' : 'Anabelle Manual',
'type' : 'document',
'owner' : 'Emily Bennett',
'size' : '1.1 Kb',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true,
'preview' : 'assets/images/etc/sample-file-preview.jpg'
},
{
'name' : 'Steam summer sale budget',
'type' : 'spreadsheet',
'owner' : 'Emily Bennett',
'size' : '505 Kb',
'modified' : 'July 8, 2015',
'opened' : 'July 8, 2015',
'created' : 'July 8, 2015',
'extention': '',
'location' : 'My Files > Documents',
'offline' : true,
'preview' : 'assets/images/etc/sample-file-preview.jpg'
}
];
}

View File

@ -6,6 +6,7 @@ import { CalendarFakeDb } from './calendar';
import { TodoFakeDb } from './todo';
import { ProfileFakeDb } from './profile';
import { ContactsFakeDb } from './contacts';
import { FileManagerFakeDb } from './file-manager';
export class FuseFakeDbService implements InMemoryDbService
{
@ -26,7 +27,8 @@ export class FuseFakeDbService implements InMemoryDbService
'profile-timeline' : ProfileFakeDb.timeline,
'profile-photos-videos': ProfileFakeDb.photosVideos,
'profile-about' : ProfileFakeDb.about,
'contacts' : ContactsFakeDb.contacts
'contacts' : ContactsFakeDb.contacts,
'file-manager' : FileManagerFakeDb.files
};
}
}

View File

@ -0,0 +1,44 @@
<ngx-datatable
class="material"
[rows]="rows"
[loadingIndicator]="loadingIndicator"
[columnMode]="'force'"
[headerHeight]="48"
[footerHeight]="56"
[rowHeight]="'auto'"
[scrollbarH]="true"
[reorderable]="reorderable"
[selected]="selected"
[selectionType]="'single'"
(select)='onSelect($event)'
[limit]="10">
<ngx-datatable-column [width]="48"
[canAutoResize]="false"
[sortable]="false">
<ng-template ngx-datatable-header-template>
</ng-template>
<ng-template ngx-datatable-cell-template let-row="row">
<md-icon class="type-icon" [class]="row.type"></md-icon>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column name="Name" prop="name">
</ngx-datatable-column>
<ngx-datatable-column name="Type" prop="type">
</ngx-datatable-column>
<ngx-datatable-column name="Owner" prop="owner">
</ngx-datatable-column>
<ngx-datatable-column name="Size" prop="size">
</ngx-datatable-column>
<ngx-datatable-column name="Last Modified" prop="modified">
</ngx-datatable-column>
</ngx-datatable>

View File

@ -0,0 +1,29 @@
:host {
.ngx-datatable {
background: transparent;
box-shadow: none;
}
.type-icon {
&.folder {
&:before {
content: 'folder';
color: #FFB300;
}
}
&.document {
&:before {
content: 'insert_drive_file';
color: #1565C0;
}
}
&.spreadsheet {
&:before {
content: 'insert_chart';
color: #4CAF50;
}
}
}
}

View File

@ -0,0 +1,36 @@
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import { FileManagerService } from '../file-manager.service';
@Component({
selector : 'fuse-file-list',
templateUrl: './file-list.component.html',
styleUrls : ['./file-list.component.scss']
})
export class FileListComponent implements OnInit
{
rows: any[];
selected = [];
loadingIndicator = false;
reorderable = true;
constructor(private fileManagerService: FileManagerService)
{
}
ngOnInit()
{
this.rows = this.fileManagerService.files;
this.selected = [this.rows[0]];
this.fileManagerService.onFileSelected.next(this.selected[0]);
}
onSelect(ev)
{
this.fileManagerService.onFileSelected.next(this.selected[0]);
}
}

View File

@ -0,0 +1,83 @@
<div id="file-manager" class="page-layout simple right-sidenav" fxLayout="row">
<md-sidenav-container>
<!-- SIDENAV -->
<md-sidenav class="sidenav p-24" align="start" opened="false" mode="over"
fuseMdSidenavHelper="simple-left-sidenav">
Sidenav
</md-sidenav>
<!-- / SIDENAV -->
<!-- CENTER -->
<div class="center" fxFlex perfect-scrollbar>
<!-- HEADER -->
<div class="header md-accent-bg p-24" fxLayout="column">
<!-- TOOLBAR -->
<div class="toolbar" fxLayout="row" fxLayoutAlign="space-between center">
<div class="left-side" fxLayout="row">
<button md-button class="mat-icon-button sidenav-toggle"
fuseMdSidenavToggler="simple-left-sidenav">
<md-icon>menu</md-icon>
</button>
<button md-button class="mat-icon-button sidenav-toggle"
fuseMdSidenavToggler="simple-right-sidenav"
fxHide.gt-md>
<md-icon>menu</md-icon>
</button>
</div>
<div class="right-side" fxLayout="row">
<button md-button class="mat-icon-button" aria-label="Search" md-tooltip="Search">
<md-icon>search</md-icon>
</button>
</div>
</div>
<!-- / TOOLBAR -->
<!-- BREADCRUMB -->
<div class="breadcrumb text-truncate" fxLayout="row" fxLayoutAlign="start center">
<span data-ng-repeat="path in vm.path">
{{path}}
<md-icon md-font-icon="icon-chevron-right" class="icon separator"></md-icon>
</span>
</div>
<!-- / BREADCRUMB -->
<!-- ADD FILE BUTTON -->
<div id="file-uploader">
<button md-fab class="add-file-button mat-accent"
aria-label="Add file">
<md-icon>add</md-icon>
</button>
</div>
<!-- / ADD FILE BUTTON -->
</div>
<!-- / HEADER -->
<!-- CONTENT -->
<div class="content">
<fuse-file-list></fuse-file-list>
</div>
<!-- / CONTENT -->
</div>
<!-- / CENTER -->
<!-- SIDENAV -->
<md-sidenav class="sidenav mat-sidenav-opened" align="end" opened="true" mode="side"
fuseMdSidenavHelper="simple-right-sidenav" md-is-locked-open="gt-md">
<fuse-file-manager-details-sidenav></fuse-file-manager-details-sidenav>
</md-sidenav>
<!-- / SIDENAV -->
</md-sidenav-container>
</div>

View File

@ -0,0 +1,15 @@
#file-manager {
md-sidenav-container {
.sidenav {
width: 320px !important;
min-width: 320px !important;;
max-width: 320px !important;;
}
.mat-sidenav-content {
z-index: 60;
}
}
}

View File

@ -0,0 +1,20 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector : 'fuse-file-manager',
templateUrl : './file-manager.component.html',
styleUrls : ['./file-manager.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class FileManagerComponent implements OnInit
{
constructor()
{
}
ngOnInit()
{
}
}

View File

@ -0,0 +1,38 @@
import { NgModule } from '@angular/core';
import { SharedModule } from '../../../core/modules/shared.module';
import { RouterModule, Routes } from '@angular/router';
import { FileManagerComponent } from './file-manager.component';
import { FileManagerService } from './file-manager.service';
import { FileListComponent } from './file-list/file-list.component';
import { MainSidenavComponent } from './sidenavs/main/main.component';
import { DetailsSidenavComponent } from './sidenavs/details/details.component';
const routes: Routes = [
{
path : '**',
component: FileManagerComponent,
children : [],
resolve : {
files: FileManagerService
}
}
];
@NgModule({
imports : [
SharedModule,
RouterModule.forChild(routes)
],
declarations: [
FileManagerComponent,
FileListComponent,
MainSidenavComponent,
DetailsSidenavComponent
],
providers : [
FileManagerService
]
})
export class FuseFileManagerModule
{
}

View File

@ -0,0 +1,50 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { Http } from '@angular/http';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable()
export class FileManagerService implements Resolve<any>
{
files: any[];
onFileSelected = new BehaviorSubject<any>(null);
constructor(private http: Http)
{
}
/**
* The File Manager App Main Resolver
* @param {ActivatedRouteSnapshot} route
* @param {RouterStateSnapshot} state
* @returns {Observable<any> | Promise<any> | any}
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> | Promise<any> | any
{
return new Promise((resolve, reject) => {
Promise.all([
this.getFiles()
]).then(
([files]) => {
this.files = files;
resolve();
},
reject
);
});
}
getFiles(): Promise<any>
{
return new Promise((resolve, reject) => {
this.http.get('api/file-manager')
.subscribe(response => {
resolve(response.json().data);
}, reject);
});
}
}

View File

@ -0,0 +1,84 @@
<!-- SIDENAV HEADER -->
<div class="header md-accent-bg p-24" fxLayout="column" fxLayoutAlign="space-between">
<div class="toolbar" fxLayout="row" fxLayoutAlign="end center">
<button md-icon-button class="mat-icon-button" md-tooltip="Delete">
<md-icon>delete</md-icon>
</button>
<button md-icon-button class="" aria-label="Download" md-tooltip="Download">
<md-icon>file_download</md-icon>
</button>
<button md-icon-button class="mat-icon-button" aria-label="More" md-tooltip="more">
<md-icon>more_vert</md-icon>
</button>
</div>
<div>
<div class="title">{{selected.name}}</div>
<div class="subtitle secondary-text">
<span>Edited</span>
: {{selected.modified}}
</div>
</div>
</div>
<!-- / SIDENAV HEADER -->
<!-- SIDENAV CONTENT -->
<div class="content p-24" perfect-scrollbar>
<div class="file-details">
<div class="preview file-icon" fxLayout="row" fxLayoutAlign="center center">
<md-icon class="{{selected.type}} s-48"></md-icon>
</div>
<md-list class="offline-switch">
<md-list-item>
<md-slide-toggle ([ngModel])="selected.offline">Available Offline</md-slide-toggle>
</md-list-item>
</md-list>
<div class="title">Info</div>
<table>
<tr class="type">
<th>Type</th>
<td>{{selected.type}}</td>
</tr>
<tr class="size">
<th>Size</th>
<td>{{selected.size === '' ? '-': selected.size}}</td>
</tr>
<tr class="location">
<th>Location</th>
<td>{{selected.location}}</td>
</tr>
<tr class="owner">
<th>Owner</th>
<td>{{selected.owner}}</td>
</tr>
<tr class="modified">
<th>Modified</th>
<td>{{selected.modified}}</td>
</tr>
<tr class="opened">
<th>Opened</th>
<td>{{selected.opened}}</td>
</tr>
<tr class="created">
<th>Created</th>
<td>{{selected.created}}</td>
</tr>
</table>
</div>
</div>
<!-- / SIDENAV CONTENT -->

View File

@ -0,0 +1,16 @@
:host {
display: flex;
flex-direction: column;
flex: 1 0 auto;
height: 100%;
> .header {
flex: 0 1 200px;
}
> .content {
flex: 1 0 auto;
}
}

View File

@ -0,0 +1,26 @@
import { Component, OnInit } from '@angular/core';
import { FileManagerService } from '../../file-manager.service';
@Component({
selector : 'fuse-file-manager-details-sidenav',
templateUrl: './details.component.html',
styleUrls : ['./details.component.scss']
})
export class DetailsSidenavComponent implements OnInit
{
selected: any;
constructor(private fileManagerService: FileManagerService)
{
}
ngOnInit()
{
this.fileManagerService.onFileSelected.subscribe(selected => {
this.selected = selected;
});
}
}

View File

@ -0,0 +1,3 @@
<p>
main works!
</p>

View File

@ -0,0 +1,21 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector : 'fuse-file-manager-main-sidenav',
templateUrl: './main.component.html',
styleUrls : ['./main.component.scss']
})
export class MainSidenavComponent implements OnInit
{
selected: any;
constructor()
{
}
ngOnInit()
{
}
}