mirror of
https://github.com/corda/corda.git
synced 2025-01-18 10:46:38 +00:00
Added more errror handling for the IRS demo
This commit is contained in:
parent
48bded2ec3
commit
f45c3cc214
@ -6,10 +6,12 @@ define([
|
||||
'utils/semantic',
|
||||
'utils/dayCountBasisLookup',
|
||||
'services/NodeApi',
|
||||
'Deal'
|
||||
'Deal',
|
||||
'services/HttpErrorHandler'
|
||||
], (angular, maskedInput, semantic, dayCountBasisLookup, nodeApi, Deal) => {
|
||||
angular.module('irsViewer').controller('CreateDealController', function CreateDealController($http, $scope, $location, nodeService) {
|
||||
angular.module('irsViewer').controller('CreateDealController', function CreateDealController($http, $scope, $location, nodeService, httpErrorHandler) {
|
||||
semantic.init($scope, nodeService.isLoading);
|
||||
let handleHttpFail = httpErrorHandler.createErrorHandler($scope);
|
||||
|
||||
$scope.dayCountBasisLookup = dayCountBasisLookup;
|
||||
$scope.deal = nodeService.newDeal();
|
||||
@ -17,7 +19,7 @@ define([
|
||||
nodeService.createDeal(new Deal($scope.deal))
|
||||
.then((tradeId) => $location.path('#/deal/' + tradeId), (resp) => {
|
||||
$scope.formError = resp.data;
|
||||
});
|
||||
}, handleHttpFail);
|
||||
};
|
||||
$('input.percent').mask("9.999999%", {placeholder: "", autoclear: false});
|
||||
$('#swapirscolumns').click(() => {
|
||||
|
@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
define(['angular', 'utils/semantic', 'services/NodeApi'], (angular, semantic, nodeApi) => {
|
||||
angular.module('irsViewer').controller('DealController', function DealController($http, $scope, $routeParams, nodeService) {
|
||||
define(['angular', 'utils/semantic', 'services/NodeApi', 'services/HttpErrorHandler'], (angular, semantic) => {
|
||||
angular.module('irsViewer').controller('DealController', function DealController($http, $scope, $routeParams, nodeService, httpErrorHandler) {
|
||||
semantic.init($scope, nodeService.isLoading);
|
||||
|
||||
nodeService.getDeal($routeParams.dealId).then((deal) => $scope.deal = deal);
|
||||
let handleHttpFail = httpErrorHandler.createErrorHandler($scope);
|
||||
nodeService.getDeal($routeParams.dealId).then((deal) => $scope.deal = deal, handleHttpFail);
|
||||
});
|
||||
});
|
@ -1,12 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
define(['angular', 'utils/semantic', 'services/NodeApi'], (angular, semantic, nodeApi) => {
|
||||
angular.module('irsViewer').controller('HomeController', function HomeController($http, $scope, nodeService) {
|
||||
define(['angular', 'utils/semantic', 'services/NodeApi', 'services/HttpErrorHandler'], (angular, semantic) => {
|
||||
angular.module('irsViewer').controller('HomeController', function HomeController($http, $scope, nodeService, httpErrorHandler) {
|
||||
semantic.addLoadingModal($scope, nodeService.isLoading);
|
||||
|
||||
let handleHttpFail = (resp) => {
|
||||
$scope.httpError = resp.data
|
||||
};
|
||||
let handleHttpFail = httpErrorHandler.createErrorHandler($scope);
|
||||
|
||||
$scope.infoMsg = "";
|
||||
$scope.errorText = "";
|
||||
@ -28,7 +26,7 @@ define(['angular', 'utils/semantic', 'services/NodeApi'], (angular, semantic, no
|
||||
return name;
|
||||
};
|
||||
|
||||
nodeService.getDate().then((date) => $scope.date = date);
|
||||
nodeService.getDeals().then((deals) => $scope.deals = deals);
|
||||
nodeService.getDate().then((date) => $scope.date = date, handleHttpFail);
|
||||
nodeService.getDeals().then((deals) => $scope.deals = deals, handleHttpFail);
|
||||
});
|
||||
});
|
||||
|
@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
define(['angular', 'lodash', 'viewmodel/Deal'], (angular, _) => {
|
||||
angular.module('irsViewer').factory('httpErrorHandler', () => {
|
||||
return {
|
||||
createErrorHandler: (scope) => {
|
||||
return (resp) => {
|
||||
if(resp.status == -1) {
|
||||
scope.httpError = "Could not connect to node web server";
|
||||
} else {
|
||||
scope.httpError = resp.data;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
@ -5,7 +5,7 @@ define(['angular', 'lodash', 'viewmodel/Deal'], (angular, _, dealViewModel) => {
|
||||
return new (function() {
|
||||
let date = new Date(2016, 0, 1, 0, 0, 0);
|
||||
let curLoading = {};
|
||||
let serverAddr = ''; // Leave empty to target the same host this page is served from
|
||||
let serverAddr = 'http://localhost:10007'; // Leave empty to target the same host this page is served from
|
||||
|
||||
let load = (type, promise) => {
|
||||
curLoading[type] = true;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<div class="ui container">
|
||||
<div class="ui hidden divider"></div>
|
||||
<div class="ui negative message" id="form-error" ng-show="formError">{{formError}}</div>
|
||||
<div class="ui negative message" id="http-error" ng-show="httpError">{{httpError}}</div>
|
||||
<h3 class="ui horizontal divider header">
|
||||
<i class="list icon"></i>
|
||||
New Deal
|
||||
|
@ -1,5 +1,6 @@
|
||||
<div class="ui container">
|
||||
<div class="ui hidden divider"></div>
|
||||
<div class="ui negative message" id="http-error" ng-show="httpError">{{httpError}}</div>
|
||||
<div class="ui grid">
|
||||
<div class="sixteen wide column" id="common">
|
||||
<table class="ui striped table">
|
||||
|
@ -1,4 +1,5 @@
|
||||
<div class="ui container">
|
||||
<div class="ui hidden divider"></div>
|
||||
<div class="ui negative message" id="http-error" ng-show="httpError">{{httpError}}</div>
|
||||
<div class="ui info message" id="info-message" ng-show="infoMsg">{{infoMsg}}</div>
|
||||
<div class="ui active dimmer" ng-show="isLoading()">
|
||||
|
Loading…
Reference in New Issue
Block a user