#537 snackbar notification system (#1527)

* #537 snackbar notification system

* #537 add test dependencies

* #537 add export material module

* #537 fix demo project
This commit is contained in:
Mario Romano
2017-01-24 17:09:13 +00:00
committed by Maurizio Vitale
parent d8c433c055
commit 1c21875607
75 changed files with 256 additions and 140 deletions

View File

@@ -35,10 +35,3 @@
multiple #uploadFolders>
</div>
</form>
<!--Notification bar-->
<div id="undo-notification-bar" class="mdl-js-snackbar mdl-snackbar"
#undoNotificationBar>
<div class="mdl-snackbar__text"></div>
<button data-automation-id="undo_upload_button" class="mdl-snackbar__action" type="button">{{'FILE_UPLOAD.ACTION.UNDO' | translate}}</button>
</div>

View File

@@ -18,7 +18,7 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { UploadButtonComponent } from './upload-button.component';
import { DebugElement } from '@angular/core';
import { CoreModule, AlfrescoTranslationService } from 'ng2-alfresco-core';
import { CoreModule, AlfrescoTranslationService, NotificationService } from 'ng2-alfresco-core';
import { TranslationMock } from '../assets/translation.service.mock';
import { UploadService } from '../services/upload.service';
@@ -73,7 +73,8 @@ describe('UploadButtonComponent', () => {
],
providers: [
UploadService,
{ provide: AlfrescoTranslationService, useClass: TranslationMock }
NotificationService,
{provide: AlfrescoTranslationService, useClass: TranslationMock}
]
}).compileComponents();
}));

View File

@@ -15,9 +15,9 @@
* limitations under the License.
*/
import { Component, ViewChild, ElementRef, Input, Output, EventEmitter } from '@angular/core';
import { Component, ElementRef, Input, Output, EventEmitter } from '@angular/core';
import 'rxjs/Rx';
import { AlfrescoTranslationService, LogService } from 'ng2-alfresco-core';
import { AlfrescoTranslationService, LogService, NotificationService } from 'ng2-alfresco-core';
import { UploadService } from '../services/upload.service';
import { FileModel } from '../models/file.model';
@@ -55,9 +55,6 @@ export class UploadButtonComponent {
private static DEFAULT_ROOT_ID: string = '-root-';
@ViewChild('undoNotificationBar')
undoNotificationBar: any;
@Input()
showUdoNotificationBar: boolean = true;
@@ -91,7 +88,8 @@ export class UploadButtonComponent {
constructor(private el: ElementRef,
private uploadService: UploadService,
private translateService: AlfrescoTranslationService,
private logService: LogService) {
private logService: LogService,
private notificationService: NotificationService) {
if (translateService) {
translateService.addTranslationFolder('ng2-alfresco-upload', 'node_modules/ng2-alfresco-upload/src');
}
@@ -217,26 +215,15 @@ export class UploadButtonComponent {
* @param {FileModel[]} latestFilesAdded - files in the upload queue enriched with status flag and xhr object.
*/
private _showUndoNotificationBar(latestFilesAdded: FileModel[]) {
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
let messageTranslate: any, actionTranslate: any;
messageTranslate = this.translateService.get('FILE_UPLOAD.MESSAGES.PROGRESS');
actionTranslate = this.translateService.get('FILE_UPLOAD.ACTION.UNDO');
if (this.undoNotificationBar.nativeElement.MaterialSnackbar) {
this.undoNotificationBar.nativeElement.MaterialSnackbar.showSnackbar({
message: messageTranslate.value,
timeout: 3000,
actionHandler: function () {
latestFilesAdded.forEach((uploadingFileModel: FileModel) => {
uploadingFileModel.emitAbort();
});
},
actionText: actionTranslate.value
this.notificationService.openSnackMessageAction(messageTranslate.value, actionTranslate.value, 3000).afterDismissed().subscribe(() => {
latestFilesAdded.forEach((uploadingFileModel: FileModel) => {
uploadingFileModel.emitAbort();
});
}
});
}
/**
@@ -258,16 +245,7 @@ export class UploadButtonComponent {
* @private
*/
private _showErrorNotificationBar(errorMessage: string) {
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
if (this.undoNotificationBar.nativeElement.MaterialSnackbar) {
this.undoNotificationBar.nativeElement.MaterialSnackbar.showSnackbar({
message: errorMessage,
timeout: 3000
});
}
this.notificationService.openSnackMessage(errorMessage, 3000);
}
/**

View File

@@ -5,10 +5,3 @@
dropzone="" webkitdropzone="*" #droparea>
<ng-content></ng-content>
</div>
<!--Notification bar-->
<div id="undo-notification-bar" class="mdl-js-snackbar mdl-snackbar"
#undoNotificationBar>
<div class="mdl-snackbar__text"></div>
<button data-automation-id="undo_upload_button" class="mdl-snackbar__action" type="button">{{'FILE_UPLOAD.ACTION.UNDO' | translate}}</button>
</div>

View File

@@ -17,7 +17,7 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { EventEmitter, DebugElement } from '@angular/core';
import { AlfrescoTranslationService, CoreModule, LogService, LogServiceMock } from 'ng2-alfresco-core';
import { AlfrescoTranslationService, CoreModule, LogService, LogServiceMock, NotificationService } from 'ng2-alfresco-core';
import { UploadDragAreaComponent } from './upload-drag-area.component';
import { TranslationMock } from '../assets/translation.service.mock';
@@ -42,6 +42,7 @@ describe('UploadDragAreaComponent', () => {
],
providers: [
UploadService,
NotificationService,
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
{ provide: LogService, useClass: LogServiceMock }
]

View File

@@ -15,8 +15,8 @@
* limitations under the License.
*/
import { Component, ViewChild, Input, Output, EventEmitter } from '@angular/core';
import { AlfrescoTranslationService, LogService } from 'ng2-alfresco-core';
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { AlfrescoTranslationService, LogService, NotificationService } from 'ng2-alfresco-core';
import { UploadService } from '../services/upload.service';
import { FileModel } from '../models/file.model';
@@ -43,9 +43,6 @@ export class UploadDragAreaComponent {
private static DEFAULT_ROOT_ID: string = '-root-';
@ViewChild('undoNotificationBar')
undoNotificationBar: any;
@Input()
showUdoNotificationBar: boolean = true;
@@ -63,7 +60,8 @@ export class UploadDragAreaComponent {
constructor(private uploadService: UploadService,
private translateService: AlfrescoTranslationService,
private logService: LogService) {
private logService: LogService,
private notificationService: NotificationService) {
if (translateService) {
translateService.addTranslationFolder('ng2-alfresco-upload', 'node_modules/ng2-alfresco-upload/src');
}
@@ -117,7 +115,7 @@ export class UploadDragAreaComponent {
* @param item - FileEntity
*/
onFilesEntityDropped(item: any): void {
item.file( (file: any) => {
item.file((file: any) => {
this.uploadService.addToQueue([file]);
let path = item.fullPath.replace(item.name, '');
let filePath = this.currentFolderPath + path;
@@ -186,23 +184,14 @@ export class UploadDragAreaComponent {
* @param {FileModel[]} latestFilesAdded - files in the upload queue enriched with status flag and xhr object.
*/
showUndoNotificationBar(latestFilesAdded: FileModel[]) {
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
let messageTranslate: any, actionTranslate: any;
messageTranslate = this.translateService.get('FILE_UPLOAD.MESSAGES.PROGRESS');
actionTranslate = this.translateService.get('FILE_UPLOAD.ACTION.UNDO');
this.undoNotificationBar.nativeElement.MaterialSnackbar.showSnackbar({
message: messageTranslate.value,
timeout: 3000,
actionHandler: function () {
latestFilesAdded.forEach((uploadingFileModel: FileModel) => {
uploadingFileModel.emitAbort();
});
},
actionText: actionTranslate.value
this.notificationService.openSnackMessageAction(messageTranslate.value, actionTranslate.value, 3000).afterDismissed().subscribe(() => {
latestFilesAdded.forEach((uploadingFileModel: FileModel) => {
uploadingFileModel.emitAbort();
});
});
}
@@ -212,14 +201,7 @@ export class UploadDragAreaComponent {
* @private
*/
showErrorNotificationBar(errorMessage: string) {
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
this.undoNotificationBar.nativeElement.MaterialSnackbar.showSnackbar({
message: errorMessage,
timeout: 3000
});
this.notificationService.openSnackMessage(errorMessage, 3000);
}
/**