Skip to content
Snippets Groups Projects
Commit ade2db43 authored by Muthukrishnanmatriot's avatar Muthukrishnanmatriot
Browse files

TMSS-997 Show error details in growl message

parent 7c177abb
Branches
No related tags found
2 merge requests!634WIP: COBALT commissioning delta,!573Resolve TMSS-997
......@@ -283,3 +283,18 @@ In Excel View the for Accordion background color override
background-color: black;
margin-left: -3px;
}
.show_error {
width: 40em;
margin-left: 67em;
height: auto !important;
}
.show_error_details {
max-height: 16em;
overflow: auto;
padding: 5px;
background-color: white;
}
.show_error_hide {
margin-top: 1em;
margin-bottom: 1em;
}
\ No newline at end of file
......@@ -3,6 +3,8 @@ import axios from "axios";
import { appGrowl } from './layout/components/AppGrowl';
import UIConstants from './utils/ui.constants';
import Auth from './authenticate/auth';
import ShowErrorDetails from './show.error.details';
/**
* Trigger and validate the response for https status code
* @param {*} Wrapped
......@@ -32,9 +34,10 @@ const handleResponse= Wrapped => {
function showMessage(response) {
const httpStatusMsg = UIConstants.httpStatusMessages[response.status];
if(httpStatusMsg) {
appGrowl.show({severity: httpStatusMsg.severity, summary: httpStatusMsg.summary, sticky: httpStatusMsg.sticky, detail: '['+response.status+'] '+JSON.stringify(response.statusText)+ ' ['+httpStatusMsg.detail+']'});
appGrowl.show({severity: httpStatusMsg.severity, summary: httpStatusMsg.summary, sticky: httpStatusMsg.sticky,
detail: <ShowErrorDetails response={response} /> });
} else {
appGrowl.show({severity: 'error', summary: 'Error', sticky: 'true', detail: '['+response.status+'] '+JSON.stringify(response.statusText)+ ' '+JSON.stringify(response.data)});
appGrowl.show({severity: 'error', summary: 'Error', sticky: 'true', detail: <ShowErrorDetails response={response} /> });
}
if (response.status === 401) {
Auth.logout();
......
import React, {Component} from 'react';
import UIConstants from './utils/ui.constants';
export class ShowErrorDetails extends Component {
constructor(props) {
super(props);
this.state={
buttonLabel: 'show more...',
showMore: false
}
this.showHideErrorDetails = this.showHideErrorDetails.bind(this);
}
/**
* Show/Hide the Error details
*/
showHideErrorDetails() {
if(this.state.buttonLabel === 'show more...') {
this.setState({buttonLabel: 'show less...', showMore: true});
var elements = document.getElementsByClassName('p-growl p-component p-growl-topright');
for(var i = 0 ; i < elements.length; i++){
elements[i].classList.add("show_error");
}
} else {
this.setState({buttonLabel: 'show more...', showMore: false})
var elements = document.getElementsByClassName('p-growl p-component p-growl-topright');
for(var i = 0 ; i < elements.length; i++){
elements[i].classList.remove("show_error");
}
}
}
render() {
const httpStatusMsg = UIConstants.httpStatusMessages[this.props.response.status];
const data = httpStatusMsg? httpStatusMsg.detail: '';
var message = '['+this.props.response.status+'] '+JSON.stringify(this.props.response.statusText)+ ' ['+data+']';
return (
<div>
<div>
{message}
</div>
<div>
<div className="show_error_hide" >
<a href='#' onClick={this.showHideErrorDetails} > {this.state.buttonLabel} </a>
</div>
{this.state.showMore &&
<div>
<p style={{fontWeight: 'bold'}}> Error Details: </p>
<div className="show_error_details" >
{this.props.response.request.response}
</div>
</div>
}
</div>
</div>
);
}
}
export default ShowErrorDetails;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment