Eugenio Romano 368f949fc4
[no-issue] general fix e2e and unit test (#3903)
* add missing import
remove creation folder in redirect test in main folder
fix update script
update node js-api to last alpha before to install
improve share dialog test

* update gnu

* fix notification and search e2e

* change name compatible with file name

* improve failing test to avoid cdk overlay problems

* [ADF-3561] fix Outcome not translatable

* increase sleep in user permission
checklist missing uppercase
comment possible different value in test due time

* improve document list actions

* improve document list action test

* tag refresh bbefore next test
comment possible value due the time
2018-10-20 18:16:44 +01:00

121 lines
4.0 KiB
TypeScript

/*!
* @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 { Component, OnInit } from '@angular/core';
import { NotificationService } from '@alfresco/adf-core';
import { MatSnackBarConfig } from '@angular/material';
import { FormBuilder, FormGroup, FormControl } from '@angular/forms';
@Component({
templateUrl: './notifications.component.html',
styleUrls: ['./notifications.component.scss']
})
export class NotificationsComponent implements OnInit {
message = 'I ♥️ ADF';
withAction = false;
actionOutput = '';
snackBarConfigObject = '';
configForm: FormGroup;
snackBarConfig: MatSnackBarConfig = new MatSnackBarConfig();
directions = [
{ value: 'ltr', title: 'Left to right' },
{ value: 'rtl', title: 'Right to left' }
];
horizontalPositions = [
{ value: 'start', title: 'Start' },
{ value: 'center', title: 'Center' },
{ value: 'end', title: 'End' },
{ value: 'left', title: 'Left' },
{ value: 'right', title: 'Right' }
];
verticalPositions = [
{ value: 'top', title: 'Top' },
{ value: 'bottom', title: 'Bottom' }
];
defaultDuration = 20000;
constructor(private notificationService: NotificationService,
private formBuilder: FormBuilder) {
this.snackBarConfig.duration = this.defaultDuration;
}
ngOnInit() {
this.configForm = this.formBuilder.group({
direction: new FormControl(''),
horizontalPosition: new FormControl(''),
verticalPosition: new FormControl(''),
duration: new FormControl('')
});
this.configForm.valueChanges
.subscribe(configFormValues =>
this.setSnackBarConfig(configFormValues)
);
}
setSnackBarConfig(configFormValues: any) {
if (configFormValues.announcementMessage) {
this.snackBarConfig.announcementMessage = configFormValues.announcementMessage;
}
if (configFormValues.direction) {
this.snackBarConfig.direction = configFormValues.direction;
}
if (configFormValues.duration) {
this.snackBarConfig.duration = configFormValues.duration;
}
if (configFormValues.horizontalPosition) {
this.snackBarConfig.horizontalPosition = configFormValues.horizontalPosition;
}
if (configFormValues.verticalPosition) {
this.snackBarConfig.verticalPosition = configFormValues.verticalPosition;
}
}
sendCustomConfig() {
this.actionOutput = '';
this.snackBarConfigObject = `{"direction": "${this.snackBarConfig.direction}",
"duration": "${this.snackBarConfig.duration}",
"horizontalPosition": "${ this.snackBarConfig.horizontalPosition}",
"verticalPosition": "${ this.snackBarConfig.verticalPosition}"}`;
if (this.message) {
if (this.withAction) {
this.notificationService
.openSnackMessageAction(this.message, 'Some action', this.snackBarConfig)
.onAction()
.subscribe(() => this.actionOutput = 'Action clicked');
} else {
this.notificationService.openSnackMessage(this.message, this.snackBarConfig);
}
}
}
dismissSnackBar() {
this.notificationService.dismissSnackMessageAction();
}
}