added stack traces and a more button to error type notifications

This commit is contained in:
Spencer Alger 2014-03-13 10:21:26 -07:00
parent 328d420fcc
commit c405860f4a
5 changed files with 45 additions and 17 deletions

View file

@ -1,6 +1,7 @@
define(function (require) {
var _ = require('lodash');
var $ = require('jquery');
var createStackTrace = require('stacktrace');
var notifs = [];
var setTO = setTimeout;
@ -63,6 +64,16 @@ define(function (require) {
return rtn;
}
function formatStack(err) {
if (!err) return null;
var isError = (err instanceof Error);
var stack = createStackTrace({ e: isError ? err : void 0 });
var msg = isError ? err.message : err;
return msg + '\n' + stack.map(function (line) { return ' ' + line; }).join('\n');
}
/**
* Track application lifecycle events
* @type {[type]}
@ -112,7 +123,7 @@ define(function (require) {
NotifyManager.prototype.fatal = function (err) {
var html = fatalToastTemplate({
msg: formatMsg(err, this.from),
stack: err.stack
stack: formatStack(err)
});
var $container = $('#fatal-splash-screen');
@ -142,7 +153,8 @@ define(function (require) {
icon: 'warning',
title: 'Error',
lifetime: Infinity,
actions: ['report', 'accept']
actions: ['report', 'accept'],
stack: formatStack(err)
}, cb);
};

View file

@ -6,13 +6,18 @@
<i class="fa" ng-class="'fa-' + notif.icon" tooltip="{{notif.title}}"></i> {{ notif.content }}
</td>
<td>
<button
type="button"
ng-if="notif.stack && !notif.showStack"
class="btn"
ng-class="'btn-' + notif.type"
ng-click="notif.showStack = true"
>More Info</button>
<button
type="button"
ng-if="notif.report"
class="btn"
ng-class="'btn-' + notif.type"
data-dismiss="alert"
aria-hidden="true"
ng-click="notif.report()"
>Report</button>
<button
@ -20,8 +25,6 @@
ng-if="notif.accept"
class="btn"
ng-class="'btn-' + notif.type"
data-dismiss="alert"
aria-hidden="true"
ng-click="notif.accept()"
>OK</button>
<button
@ -29,12 +32,11 @@
ng-if="notif.address"
class="btn"
ng-class="'btn-' + notif.type"
data-dismiss="alert"
aria-hidden="true"
ng-click="notif.address()"
>Fix it</button>
</td>
</tr></table>
<pre ng-if="notif.stack && notif.showStack" ng-bind="notif.stack"></pre>
</div>
</li>
</ul>

View file

@ -16,6 +16,7 @@ require.config({
lodash: '../bower_components/lodash/dist/lodash',
moment: '../bower_components/moment/moment',
gridster: '../bower_components/gridster/dist/jquery.gridster',
stacktrace: '../bower_components/stacktrace.js/stacktrace',
modules: 'utils/modules',
bower_components: '../bower_components'
},

View file

@ -20,7 +20,7 @@
-webkit-box-shadow: 3px 0px 19px 0px rgba(50, 50, 50, 0.67);
-moz-box-shadow: 3px 0px 19px 0px rgba(50, 50, 50, 0.67);
box-shadow: 3px 0px 19px 0px rgba(50, 50, 50, 0.67);
padding: 0px 15px;
padding: 0.00001px 15px;
margin: 0 0 10px 0;
border: none;
@ -36,15 +36,23 @@
td {
vertical-align: middle;
&:first-child {
text-align: left;
width: 80%;
}
// :not(:first-child)
text-align: right;
width: 20%;
&:first-child {
text-align: left;
}
}
}
pre {
display: inline-block;
max-width: 100%;
margin: 10px 0;
word-break: normal;
word-wrap: normal;
}
}
}

View file

@ -7033,7 +7033,7 @@ kbn-table tr.even td {
-webkit-box-shadow: 3px 0px 19px 0px rgba(50, 50, 50, 0.67);
-moz-box-shadow: 3px 0px 19px 0px rgba(50, 50, 50, 0.67);
box-shadow: 3px 0px 19px 0px rgba(50, 50, 50, 0.67);
padding: 0px 15px;
padding: 0.00001px 15px;
margin: 0 0 10px 0;
border: none;
}
@ -7049,11 +7049,16 @@ kbn-table tr.even td {
.toaster-container .alert table td {
vertical-align: middle;
text-align: right;
width: 20%;
}
.toaster-container .alert table td:first-child {
text-align: left;
width: 80%;
}
.toaster-container .alert pre {
display: inline-block;
max-width: 100%;
margin: 10px 0;
word-break: normal;
word-wrap: normal;
}
disc-field-chooser ul {
margin: 0;