You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2018/04/17 13:42:40 UTC
[ambari] branch trunk updated: [AMBARI-23593] - Logsearch UI: Fix
Log Feeder Config issues
This is an automated email from the ASF dual-hosted git repository.
ababiichuk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 7b6e697 [AMBARI-23593] - Logsearch UI: Fix Log Feeder Config issues
7b6e697 is described below
commit 7b6e6977116bb4fa0bfb5500fcaf4802569c3355
Author: Istvan Tobias <to...@gmail.com>
AuthorDate: Tue Apr 17 13:50:23 2018 +0200
[AMBARI-23593] - Logsearch UI: Fix Log Feeder Config issues
---
.../src/app/modules/shared/notifications.less | 1 +
.../shared/services/notification.service.ts | 9 ++++++++
.../shipper-configuration.component.ts | 27 ++++++++--------------
...ipper-service-configuration-form.component.html | 5 ++--
.../services/shipper-configuration.service.ts | 13 ++++-------
.../ambari-logsearch-web/src/assets/i18n/en.json | 9 ++++----
6 files changed, 33 insertions(+), 31 deletions(-)
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/notifications.less b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/notifications.less
index 7a0a045..e9f4fd9 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/notifications.less
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/notifications.less
@@ -56,6 +56,7 @@
.sn-content {
font-size: @notification-content-font-size;
padding: 0;
+ white-space: pre-wrap;
}
.sn-progress-loader {
height: 2px;
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/services/notification.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/services/notification.service.ts
index e6b39ee..b149e38 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/services/notification.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/services/notification.service.ts
@@ -51,6 +51,15 @@ export class NotificationService {
addNotification(payload: NotificationInterface): Notification {
const {message, title, ...config} = payload;
const method: string = typeof this.notificationService[config.type] === 'function' ? config.type : 'info';
+ if (config.type === NotificationType.ERROR) {
+ Object.assign(config, {
+ clickToClose: true,
+ timeOut: 0,
+ showProgressBar: false,
+ pauseOnHover: false,
+ ...config
+ });
+ }
return this.notificationService[method](
this.translateService.instant(title),
this.translateService.instant(message),
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/components/shipper-configuration/shipper-configuration.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/components/shipper-configuration/shipper-configuration.component.ts
index 0031a70..761dc3b 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/components/shipper-configuration/shipper-configuration.component.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/components/shipper-configuration/shipper-configuration.component.ts
@@ -17,6 +17,7 @@
*/
import {Component, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
+import {Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/skipWhile';
@@ -140,20 +141,12 @@ export class ShipperConfigurationComponent implements CanComponentDeactivate, On
getResponseHandler(cmd: string, type: string, msgVariables?: {[key: string]: any}) {
return (response: Response) => {
- Observable.combineLatest(
- this.translate.get(`shipperConfiguration.action.${cmd}.title`),
- this.translate.get(`shipperConfiguration.action.${cmd}.${type}.message`)
- ).first().subscribe(([title, message]: [string, string]) => {
- let msg: string = message;
- if (msgVariables) {
- Object.keys(msgVariables).forEach((key: string) => {
- if (typeof msgVariables[key] === 'string') {
- msg = msg.replace(new RegExp('\\$\\{' + key + '\\}', 'gi'), msgVariables[key]);
- }
- });
- }
- this.notificationService.addNotification({type, title, message: msg});
- });
+ const result = response.json();
+ const resultType = response ? (response.ok && !result.errorMessage ? NotificationType.SUCCESS : NotificationType.ERROR) : type;
+ const translateParams = {errorMessage: '', ...msgVariables, ...result};
+ const title = this.translate.instant(`shipperConfiguration.action.${cmd}.title`, translateParams);
+ const message = this.translate.instant(`shipperConfiguration.action.${cmd}.${resultType}.message`, translateParams);
+ this.notificationService.addNotification({type: resultType, title, message});
};
}
@@ -171,18 +164,18 @@ export class ShipperConfigurationComponent implements CanComponentDeactivate, On
});
}
- private handleValidationResult = (result: {[key: string]: any}) => {
+ private setValidationResult = (result: {[key: string]: any}) => {
this.validationResponse = result;
}
onValidationFormSubmit(rawValue: ShipperClusterServiceValidationModel): void {
this.validationResponse = null;
- const request$: Observable<any> = this.shipperConfigurationService.testConfiguration(rawValue);
+ const request$: Observable<Response> = this.shipperConfigurationService.testConfiguration(rawValue);
request$.subscribe(
this.getResponseHandler('validate', NotificationType.SUCCESS, rawValue),
this.getResponseHandler('validate', NotificationType.ERROR, rawValue)
);
- request$.map((response: Response) => response.json()).subscribe(this.handleValidationResult);
+ request$.map((response: Response) => response.json()).subscribe(this.setValidationResult);
}
canDeactivate() {
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/components/shipper-service-configuration-form/shipper-service-configuration-form.component.html b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/components/shipper-service-configuration-form/shipper-service-configuration-form.component.html
index 445741d..42d364b 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/components/shipper-service-configuration-form/shipper-service-configuration-form.component.html
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/components/shipper-service-configuration-form/shipper-service-configuration-form.component.html
@@ -96,8 +96,9 @@
<label>
{{'shipperConfiguration.validator.result' | translate}}
</label>
- <textarea class="form-control validation-result" name="validationResult"
- [disableControl]="configurationForm.invalid" [value]="validationResponse | json"></textarea>
+ <!--textarea class="form-control validation-result" name="validationResult"
+ [disableControl]="configurationForm.invalid" [value]="validationResponse | json"></textarea-->
+ <pre>{{validationResponse | json}}</pre>
</div>
<button class="btn btn-default pull-right" type="submit"
[disabled]="(!validatorForm.valid)">
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/services/shipper-configuration.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/services/shipper-configuration.service.ts
index acdee37..fd9ac2c 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/services/shipper-configuration.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shipper/services/shipper-configuration.service.ts
@@ -19,12 +19,10 @@ import { Injectable } from '@angular/core';
import {Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
-import {Store} from '@ngrx/store';
import {HttpClientService} from '@app/services/http-client.service';
import {ShipperClusterServiceConfigurationModel} from '@modules/shipper/models/shipper-cluster-service-configuration.model';
import {ShipperClusterServiceValidationModel} from '@modules/shipper/models/shipper-cluster-service-validation.model';
-import {ShipperCluster} from '@modules/shipper/models/shipper-cluster.type';
@Injectable()
export class ShipperConfigurationService {
@@ -80,16 +78,15 @@ export class ShipperConfigurationService {
});
}
- testConfiguration(payload: ShipperClusterServiceValidationModel): Observable<any> {
+ testConfiguration(payload: ShipperClusterServiceValidationModel): Observable<Response> {
const requestPayload: {[key: string]: any} = {
- shipper_config: payload.configuration,
- log_id: payload.componentName,
- test_entry: payload.sampleData
+ shipperConfig: encodeURIComponent(payload.configuration),
+ logId: payload.componentName,
+ testEntry: payload.sampleData
};
return this.httpClientService.postFormData('shipperClusterServiceConfigurationTest', requestPayload, null, {
cluster: payload.clusterName
- })
- .map((response: Response) => response.json());
+ });
}
}
diff --git a/ambari-logsearch/ambari-logsearch-web/src/assets/i18n/en.json b/ambari-logsearch/ambari-logsearch-web/src/assets/i18n/en.json
index 8628033..bc96827 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/assets/i18n/en.json
+++ b/ambari-logsearch/ambari-logsearch-web/src/assets/i18n/en.json
@@ -242,15 +242,16 @@
"shipperConfiguration.validator.componentNameLabel": "Component Name",
"shipperConfiguration.validator.sampleDataLabel": "Sample Data",
"shipperConfiguration.validator.filters": "Filters",
+ "shipperConfiguration.validator.result": "Validation result",
"shipperConfiguration.action.add.title": "New Configuration",
"shipperConfiguration.action.add.success.message": "New configuration has been added successfully.",
- "shipperConfiguration.action.add.error.message": "Error at adding new configuration:<br>Cluster: ${cluster}<br>Service: ${service}",
+ "shipperConfiguration.action.add.error.message": "Error at adding new configuration.\nCluster: {{clusterName}}\nService: {{componentName}}",
"shipperConfiguration.action.update.title": "Update Configuration",
- "shipperConfiguration.action.update.success.message": "The configuration has been updated successfully.",
- "shipperConfiguration.action.update.error.message": "Error at updating the configuration:<br>Cluster: ${cluster}<br>Service: ${service}",
+ "shipperConfiguration.action.update.success.message": "The configuration has been updated successfully.\nCluster: {{clusterName}}\nService: {{componentName}}",
+ "shipperConfiguration.action.update.error.message": "Error at updating the configuration.\nCluster: {{clusterName}}\nService: {{componentName}}",
"shipperConfiguration.action.validate.title": "Validate Configuration",
"shipperConfiguration.action.validate.success.message": "The configuration is valid.",
- "shipperConfiguration.action.validate.error.message": "The configuration is not valid."
+ "shipperConfiguration.action.validate.error.message": "The configuration is not valid.\nCluster: {{clusterName}}\nService: {{componentName}}\n{{errorMessage}}"
}
--
To stop receiving notification emails like this one, please contact
ababiichuk@apache.org.