This commit is contained in:
Sercan Yemen 2017-07-26 12:43:45 +03:00
parent b0e4f87a8a
commit 141b4b1528
13 changed files with 951 additions and 945 deletions

1700
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,33 +12,34 @@
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/animations": "^4.3.0", "@angular/animations": "^4.3.1",
"@angular/cdk": "^2.0.0-beta.8", "@angular/cdk": "^2.0.0-beta.8",
"@angular/common": "^4.3.0", "@angular/common": "^4.3.1",
"@angular/compiler": "^4.3.0", "@angular/compiler": "^4.3.1",
"@angular/core": "^4.3.0", "@angular/core": "^4.3.1",
"@angular/flex-layout": "2.0.0-beta.8", "@angular/flex-layout": "2.0.0-beta.8",
"@angular/forms": "^4.3.0", "@angular/forms": "^4.3.1",
"@angular/http": "^4.3.0", "@angular/http": "^4.3.1",
"@angular/material": "^2.0.0-beta.8", "@angular/material": "^2.0.0-beta.8",
"@angular/platform-browser": "^4.3.0", "@angular/platform-browser": "^4.3.1",
"@angular/platform-browser-dynamic": "^4.3.0", "@angular/platform-browser-dynamic": "^4.3.1",
"@angular/router": "^4.3.0", "@angular/router": "^4.3.1",
"@swimlane/ngx-datatable": "^9.3.1",
"angular-in-memory-web-api": "^0.3.2", "angular-in-memory-web-api": "^0.3.2",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"firebase": "^4.1.3", "firebase": "^4.1.5",
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"ngx-perfect-scrollbar": "^4.5.2", "ngx-perfect-scrollbar": "^4.5.2",
"rxjs": "^5.4.2", "rxjs": "^5.4.2",
"zone.js": "^0.8.13" "zone.js": "^0.8.14"
}, },
"devDependencies": { "devDependencies": {
"@angular/cli": "^1.2.1", "@angular/cli": "^1.2.4",
"@angular/compiler-cli": "^4.3.0", "@angular/compiler-cli": "^4.3.1",
"@angular/language-service": "^4.3.0", "@angular/language-service": "^4.3.1",
"@types/jasmine": "^2.5.53", "@types/jasmine": "^2.5.53",
"@types/jasminewd2": "^2.0.2", "@types/jasminewd2": "^2.0.2",
"@types/node": "^6.0.83", "@types/node": "^6.0.85",
"codelyzer": "~3.0.1", "codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2", "jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0", "jasmine-spec-reporter": "~4.1.0",

View File

@ -55,7 +55,6 @@ const appRoutes: Routes = [
FuseLayoutModule, FuseLayoutModule,
// MailModule,
ChatModule, ChatModule,
ProjectModule, ProjectModule,

View File

@ -4,6 +4,8 @@ import { CommonModule } from '@angular/common';
import { MaterialModule } from './material.module'; import { MaterialModule } from './material.module';
import { FlexLayoutModule } from '@angular/flex-layout'; import { FlexLayoutModule } from '@angular/flex-layout';
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar'; import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
import { import {
@ -20,6 +22,7 @@ import { FusePipesModule } from '../pipes/pipes.module';
imports : [ imports : [
FlexLayoutModule, FlexLayoutModule,
MaterialModule, MaterialModule,
NgxDatatableModule,
CommonModule, CommonModule,
FormsModule, FormsModule,
FusePipesModule, FusePipesModule,
@ -28,6 +31,7 @@ import { FusePipesModule } from '../pipes/pipes.module';
exports : [ exports : [
FlexLayoutModule, FlexLayoutModule,
MaterialModule, MaterialModule,
NgxDatatableModule,
CommonModule, CommonModule,
FormsModule, FormsModule,
FuseMdSidenavHelperDirective, FuseMdSidenavHelperDirective,

View File

@ -1,4 +1,11 @@
// ngx-datatable
@import '~@swimlane/ngx-datatable/release/index.css';
@import '~@swimlane/ngx-datatable/release/themes/material.css';
@import '~@swimlane/ngx-datatable/release/assets/icons.css';
// Perfect Scrollbar
@import "~perfect-scrollbar/src/css/main"; @import "~perfect-scrollbar/src/css/main";
// Fuse // Fuse
@import "fuse"; @import "fuse";

View File

@ -15,6 +15,7 @@ export class MailDetailsComponent implements OnInit, OnDestroy
showDetails = false; showDetails = false;
onCurrentMailChanged: Subscription; onCurrentMailChanged: Subscription;
onLabelsChanged: Subscription;
constructor( constructor(
private mailService: MailService private mailService: MailService
@ -24,15 +25,19 @@ export class MailDetailsComponent implements OnInit, OnDestroy
ngOnInit() ngOnInit()
{ {
// Set initial values
this.labels = this.mailService.labels;
this.mail = this.mailService.currentMail;
// Subscribe to update the current mail // Subscribe to update the current mail
this.onCurrentMailChanged = this.mailService.onCurrentMailChanged this.onCurrentMailChanged =
.subscribe(currentMail => { this.mailService.onCurrentMailChanged
this.mail = currentMail; .subscribe(currentMail => {
}); this.mail = currentMail;
});
// Subscribe to update on label change
this.onLabelsChanged =
this.mailService.onLabelsChanged
.subscribe(labels => {
this.labels = labels;
});
} }
ngOnDestroy() ngOnDestroy()

View File

@ -1,4 +1,4 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { Component, HostBinding, Input, OnDestroy, OnInit } from '@angular/core';
import { Mail } from '../../mail.model'; import { Mail } from '../../mail.model';
import { MailService } from '../../mail.service'; import { MailService } from '../../mail.service';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
@ -12,34 +12,21 @@ export class MailListItemComponent implements OnInit, OnDestroy
{ {
@Input() mail: Mail; @Input() mail: Mail;
labels: any[]; labels: any[];
selected: boolean; @HostBinding('class.selected') selected: boolean;
onSelectedMailsChanged: Subscription; onSelectedMailsChanged: Subscription;
onLabelsChanged: Subscription;
constructor( constructor(
private mailService: MailService private mailService: MailService
) )
{ {
} }
ngOnInit() ngOnInit()
{ {
// Set the initial values // Set the initial values
this.mail = new Mail(this.mail); this.mail = new Mail(this.mail);
this.labels = this.mailService.labels;
if ( this.mailService.selectedMails.length > 0 )
{
for ( const mail of this.mailService.selectedMails )
{
if ( mail.id === this.mail.id )
{
this.selected = true;
break;
}
}
}
// Subscribe to update on selected mail change // Subscribe to update on selected mail change
this.onSelectedMailsChanged = this.onSelectedMailsChanged =
@ -59,6 +46,13 @@ export class MailListItemComponent implements OnInit, OnDestroy
} }
} }
}); });
// Subscribe to update on label change
this.onLabelsChanged =
this.mailService.onLabelsChanged
.subscribe(labels => {
this.labels = labels;
});
} }
ngOnDestroy() ngOnDestroy()

View File

@ -28,12 +28,6 @@ export class MailListComponent implements OnInit, OnDestroy
ngOnInit() ngOnInit()
{ {
// Get mails for the first time
this.mails = this.mailService.mails;
// Get current mail for the first time if available
this.currentMail = this.mailService.currentMail || null;
// Subscribe to update mails on changes // Subscribe to update mails on changes
this.onMailsChanged = this.onMailsChanged =
this.mailService.onMailsChanged this.mailService.onMailsChanged
@ -52,12 +46,17 @@ export class MailListComponent implements OnInit, OnDestroy
// Handle the location changes // Handle the location changes
const labelHandle = this.route.snapshot.params.labelHandle, const labelHandle = this.route.snapshot.params.labelHandle,
filterHandle = this.route.snapshot.params.filterHandle,
folderHandle = this.route.snapshot.params.folderHandle; folderHandle = this.route.snapshot.params.folderHandle;
if ( labelHandle ) if ( labelHandle )
{ {
this.location.go('apps/mail/label/' + labelHandle); this.location.go('apps/mail/label/' + labelHandle);
} }
else if ( filterHandle )
{
this.location.go('apps/mail/filter/' + filterHandle);
}
else else
{ {
this.location.go('apps/mail/' + folderHandle); this.location.go('apps/mail/' + folderHandle);
@ -83,12 +82,17 @@ export class MailListComponent implements OnInit, OnDestroy
readMail(mailId) readMail(mailId)
{ {
const labelHandle = this.route.snapshot.params.labelHandle, const labelHandle = this.route.snapshot.params.labelHandle,
filterHandle = this.route.snapshot.params.filterHandle,
folderHandle = this.route.snapshot.params.folderHandle; folderHandle = this.route.snapshot.params.folderHandle;
if ( labelHandle ) if ( labelHandle )
{ {
this.location.go('apps/mail/label/' + labelHandle + '/' + mailId); this.location.go('apps/mail/label/' + labelHandle + '/' + mailId);
} }
else if ( filterHandle )
{
this.location.go('apps/mail/filter/' + filterHandle + '/' + mailId);
}
else else
{ {
this.location.go('apps/mail/' + folderHandle + '/' + mailId); this.location.go('apps/mail/' + folderHandle + '/' + mailId);

View File

@ -102,4 +102,4 @@
</md-sidenav-container> </md-sidenav-container>
</div> </div>

View File

@ -12,23 +12,22 @@ export class MailComponent implements OnInit, OnDestroy
hasSelectedMails: boolean; hasSelectedMails: boolean;
isIndeterminate: boolean; isIndeterminate: boolean;
folders: any[]; folders: any[];
filters: any[];
labels: any[]; labels: any[];
onSelectedMailsChanged: Subscription; onSelectedMailsChanged: Subscription;
onFoldersChanged: Subscription;
onFiltersChanged: Subscription;
onLabelsChanged: Subscription;
constructor( constructor(
private mailService: MailService private mailService: MailService
) )
{ {
} }
ngOnInit() ngOnInit()
{ {
// Get the values for the first time
this.labels = this.mailService.labels;
this.folders = this.mailService.folders;
this.onSelectedMailsChanged = this.onSelectedMailsChanged =
this.mailService.onSelectedMailsChanged this.mailService.onSelectedMailsChanged
.subscribe(selectedMails => { .subscribe(selectedMails => {
@ -38,11 +37,32 @@ export class MailComponent implements OnInit, OnDestroy
this.isIndeterminate = (selectedMails.length !== this.mailService.mails.length && selectedMails.length > 0); this.isIndeterminate = (selectedMails.length !== this.mailService.mails.length && selectedMails.length > 0);
}, 0); }, 0);
}); });
this.onFoldersChanged =
this.mailService.onFoldersChanged
.subscribe(folders => {
this.folders = this.mailService.folders;
});
this.onFiltersChanged =
this.mailService.onFiltersChanged
.subscribe(folders => {
this.filters = this.mailService.filters;
});
this.onLabelsChanged =
this.mailService.onLabelsChanged
.subscribe(labels => {
this.labels = this.mailService.labels;
});
} }
ngOnDestroy() ngOnDestroy()
{ {
this.onSelectedMailsChanged.unsubscribe(); this.onSelectedMailsChanged.unsubscribe();
this.onFoldersChanged.unsubscribe();
this.onFiltersChanged.unsubscribe();
this.onLabelsChanged.unsubscribe();
} }
toggleSelectAll() toggleSelectAll()

View File

@ -53,7 +53,7 @@ const routes: Routes = [
}, },
{ {
path : '**', path : '**',
redirectTo: 'inbox' redirectTo: 'folder/inbox'
} }
]; ];

View File

@ -3,7 +3,7 @@ import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/r
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { Http } from '@angular/http'; import { Http } from '@angular/http';
import { Mail } from './mail.model'; import { Mail } from './mail.model';
import { Subject } from 'rxjs/Subject'; import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable() @Injectable()
export class MailService implements Resolve<any> export class MailService implements Resolve<any>
@ -17,13 +17,13 @@ export class MailService implements Resolve<any>
labels: any[]; labels: any[];
routeParams: any; routeParams: any;
onMailsChanged = new Subject<Mail[]>(); onMailsChanged: BehaviorSubject<any> = new BehaviorSubject([]);
onSelectedMailsChanged = new Subject<Mail[]>(); onSelectedMailsChanged: BehaviorSubject<any> = new BehaviorSubject([]);
onCurrentMailChanged = new Subject<Mail>(); onCurrentMailChanged: BehaviorSubject<any> = new BehaviorSubject([]);
onFoldersChanged = new Subject<any[]>(); onFoldersChanged: BehaviorSubject<any> = new BehaviorSubject([]);
onFiltersChanged = new Subject<any[]>(); onFiltersChanged: BehaviorSubject<any> = new BehaviorSubject([]);
onLabelsChanged = new Subject<any[]>(); onLabelsChanged: BehaviorSubject<any> = new BehaviorSubject([]);
constructor( constructor(
private http: Http private http: Http

View File

@ -1,12 +1,13 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { MailService } from '../../mail.service'; import { MailService } from '../../mail.service';
import { Subscription } from 'rxjs/Subscription';
@Component({ @Component({
selector : 'fuse-mail-main-sidenav', selector : 'fuse-mail-main-sidenav',
templateUrl: './main-sidenav.component.html', templateUrl: './main-sidenav.component.html',
styleUrls : ['./main-sidenav.component.scss'] styleUrls : ['./main-sidenav.component.scss']
}) })
export class MainSidenavComponent implements OnInit export class MainSidenavComponent implements OnInit, OnDestroy
{ {
folders: any[]; folders: any[];
filters: any[]; filters: any[];
@ -14,6 +15,10 @@ export class MainSidenavComponent implements OnInit
accounts: object; accounts: object;
selectedAccount: string; selectedAccount: string;
onFoldersChanged: Subscription;
onFiltersChanged: Subscription;
onLabelsChanged: Subscription;
constructor( constructor(
private mailService: MailService private mailService: MailService
) )
@ -29,20 +34,29 @@ export class MainSidenavComponent implements OnInit
ngOnInit() ngOnInit()
{ {
this.folders = this.mailService.folders; this.onFoldersChanged =
this.filters = this.mailService.filters; this.mailService.onFoldersChanged
this.labels = this.mailService.labels; .subscribe(folders => {
this.folders = folders;
});
this.mailService.onFoldersChanged.subscribe(folders => { this.onFiltersChanged =
this.folders = this.mailService.folders; this.mailService.onFiltersChanged
}); .subscribe(filters => {
this.filters = filters;
});
this.mailService.onFiltersChanged.subscribe(folders => { this.onLabelsChanged =
this.filters = this.mailService.filters; this.mailService.onLabelsChanged
}); .subscribe(labels => {
this.labels = labels;
});
}
this.mailService.onLabelsChanged.subscribe(labels => { ngOnDestroy()
this.labels = this.mailService.labels; {
}); this.onFoldersChanged.unsubscribe();
this.onFiltersChanged.unsubscribe();
this.onLabelsChanged.unsubscribe();
} }
} }