#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

@@ -57,6 +57,7 @@ npm install --save ng2-alfresco-core
### Services
- **LogService**, log service implementation
- **NotificationService**, Notification service implementation
- **AlfrescoApiService**, provides access to Alfresco JS API instance
- **AlfrescoAuthenticationService**, main authentication APIs
- **AlfrescoTranslationService**, various i18n-related APIs
@@ -95,6 +96,43 @@ let apiService: any = this.authService.getAlfrescoApi();
apiService.nodes.addNode('-root-', body, {});
```
#### Notification Service
The Notification Service is implemented on top of the Angular 2 Material Design snackbar.
Use this service to show a notification message, and optionaly get feedback from it.
```ts
import { NotificationService } from 'ng2-alfresco-core';
export class MyComponent implements OnInit {
constructor(private notificationService: NotificationService) {
}
ngOnInit() {
this.notificationService.openSnackMessage('test', 200000).afterDismissed().subscribe(() => {
console.log('The snack-bar was dismissed');
});
}
}
```
```ts
import { NotificationService } from 'ng2-alfresco-core';
export class MyComponent implements OnInit {
constructor(private notificationService: NotificationService) {
}
ngOnInit() {
this.notificationService.openSnackMessageAction('Do you want to report this issue?', 'send', 200000).afterDismissed().subscribe(() => {
console.log('The snack-bar was dismissed');
});
}
}
```
#### Context Menu directive
_See **Demo Shell** or **DocumentList** implementation for more details and use cases._

View File

@@ -20,6 +20,7 @@ import { HttpModule, Http } from '@angular/http';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TranslateModule, TranslateLoader } from 'ng2-translate/ng2-translate';
import { MaterialModule } from '@angular/material';
import {
AlfrescoAuthenticationService,
@@ -33,7 +34,9 @@ import {
AuthGuard,
AuthGuardEcm,
AuthGuardBpm,
LogService, LogServiceMock
LogService,
LogServiceMock,
NotificationService
} from './src/services/index';
import { MATERIAL_DESIGN_DIRECTIVES } from './src/components/material/index';
@@ -44,7 +47,9 @@ export * from './src/components/index';
export * from './src/utils/index';
export const ALFRESCO_CORE_PROVIDERS: any[] = [
LogService, LogServiceMock,
NotificationService,
LogService,
LogServiceMock,
AlfrescoAuthenticationService,
AlfrescoContentService,
AlfrescoSettingsService,
@@ -69,6 +74,7 @@ export function createTranslateLoader(http: Http, logService: LogService) {
FormsModule,
ReactiveFormsModule,
HttpModule,
MaterialModule.forRoot(),
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: (createTranslateLoader),
@@ -85,6 +91,7 @@ export function createTranslateLoader(http: Http, logService: LogService) {
exports: [
CommonModule,
FormsModule,
MaterialModule,
ReactiveFormsModule,
HttpModule,
TranslateModule,

View File

@@ -39,6 +39,8 @@ var map = {
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/material': 'npm:@angular/material/bundles/material.umd.js',
// testing
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js',

View File

@@ -62,6 +62,7 @@
"@angular/http": "2.2.2",
"@angular/platform-browser": "2.2.2",
"@angular/platform-browser-dynamic": "2.2.2",
"@angular/material": "2.0.0-beta.1",
"@angular/router": "3.2.2",
"@angular/upgrade": "2.2.2",
"alfresco-js-api": "^1.0.0",

View File

@@ -23,7 +23,7 @@ export * from './renditions.service';
export * from './auth-guard.service';
export * from './auth-guard-ecm.service';
export * from './auth-guard-bpm.service';
export * from './notification.service';
export * from './log.service';
export * from './alfresco-authentication.service';
export * from './alfresco-translation.service';

View File

@@ -0,0 +1,40 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { MdSnackBar, MdSnackBarRef } from '@angular/material';
@Injectable()
export class NotificationService {
static DEFAULT_DURATION_MESSAGE: number = 5000;
constructor(public snackbar: MdSnackBar) {
}
public openSnackMessage(message: string, millisecondsDuration?: number): MdSnackBarRef<any> {
return this.snackbar.open(message, null, {
duration: millisecondsDuration || NotificationService.DEFAULT_DURATION_MESSAGE
});
}
public openSnackMessageAction(message: string, action: string, millisecondsDuration?: number): MdSnackBarRef<any> {
return this.snackbar.open(message, action, {
duration: millisecondsDuration || NotificationService.DEFAULT_DURATION_MESSAGE
});
}
}