Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
esq => {
toast.info(this.$translate.instant('sitnet_question_saved'));
// apply changes back to scope
ng.extend(this.sectionQuestion, esq);
});
}).catch(err => {
// Roll back
answer.essayAnswer.evaluatedScore = answer.essayAnswer.temporaryScore;
toast.error(err.data);
resolve();
});
});
componentWillReceiveProps(nextProps) {
if(this.props.saveCompleted != nextProps.saveCompleted
&& nextProps.saveCompleted) {
// Show toast
toastr.success('Author saved.');
// using hashHistory, TODO: proper configure browserHistory on app and here
hashHistory.push('/members')
// Reset saveCompleted flag
this.props.resetSaveCompletedFlag();
}
}
export const toastError = (err, header = 'Error', option = toastrOption.error) => {
const errs = toArrayIfNot(err);
for (const err of errs) {
toastr.error(err.message, header, option);
}
};
handle(error:any) {
if (error.status === 401) {
this.translate.get('error.pleaseSignIn').subscribe((msg: string) => toastr.error(msg));
this.auth.logout();
this.router.navigate(['/Login']);
}
if (error.status === 422) {
let msg:string = _.chain(error.json()).values().first().value();
toastr.error(msg);
}
return Observable.throw('Server error');
}
}
apiErrorHandler(error) {
toastr.error(error.message, 'Error occured', {
closeButton: true,
progressBar: true,
newestOnTop: false,
showDuration: '100',
hideDuration: '100',
timeOut: '3000',
});
}
private onLoginFailure(message: any): void {
this.$location.path('/');
toastr.error(message);
}
this.CollaborativeExam.createExam().then((exam: CollaborativeExam) => {
toast.info(this.$translate.instant('sitnet_exam_created'));
this.$location.path(`/exams/collaborative/${exam.id}/1`);
}).catch(resp => toast.error(resp.data));
}
.then((resp: angular.IHttpResponse) => {
toast.info(this.$translate.instant('sitnet_updated'));
this.close(
{
$value: {
msg: 'Accepted',
machine: resp.data
}
});
}).catch(resp => toast.error(resp.data));
}