Skip to content
This repository was archived by the owner on Mar 6, 2023. It is now read-only.

Commit b4d88bb

Browse files
committed
Added dialog to view and copy Event JSON
1 parent 83ac65f commit b4d88bb

11 files changed

+92
-7
lines changed

src/app.less

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
@import "app/session/session.less";
3737
@import "components/date-range-picker/date-range-picker-directive.less";
3838
@import "components/dialog/confirm-dialog.less";
39+
@import "components/dialog/json-dialog.less";
3940
@import "components/events/events-directive.less";
4041
@import "components/loading-bar/loading-bar-directive.less";
4142
@import "components/log-level/log-level-directive.less";

src/app/event/event-controller.js

+23-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
angular.module('app.event')
5-
.controller('Event', function ($ExceptionlessClient, $scope, $state, $stateParams, $timeout, $window, billingService, clipboard, errorService, eventService, filterService, hotkeys, linkService, notificationService, projectService, simpleErrorService, urlService, translateService) {
5+
.controller('Event', function ($ExceptionlessClient, $scope, $state, $stateParams, $timeout, $window, billingService, clipboard, dialogService, errorService, eventService, filterService, hotkeys, linkService, notificationService, projectService, simpleErrorService, urlService, translateService) {
66
var vm = this;
77

88
function activateSessionEventsTab() {
@@ -312,7 +312,7 @@
312312
}
313313

314314
vm.event = response.data.plain();
315-
vm.event_json = angular.toJson(vm.event);
315+
vm.event_json = angular.toJson(vm.event, true);
316316
vm.sessionEvents.relativeTo = vm.event.date;
317317
vm.errorData = getErrorData(vm.event);
318318
vm.errorType = getErrorType(vm.event);
@@ -428,6 +428,26 @@
428428
return projectService.promoteTab(vm.project.id, tabName).then(onSuccess, onFailure);
429429
}
430430

431+
function viewJSON() {
432+
function onSuccess() {
433+
$ExceptionlessClient.createFeatureUsage(vm._source + '.viewJSON.success')
434+
.setProperty('id', vm._eventId)
435+
.submit();
436+
}
437+
438+
function onFailure() {
439+
$ExceptionlessClient.createFeatureUsage(vm._source + '.viewJSON.error')
440+
.setProperty('id', vm._eventId)
441+
.submit();
442+
}
443+
444+
$ExceptionlessClient.createFeatureUsage(vm._source + '.viewJSON')
445+
.setProperty('id', vm._eventId)
446+
.submit();
447+
448+
return dialogService.viewJSON(vm.event_json).then(onSuccess, onFailure)
449+
}
450+
431451
function updateIsAccordionVisible() {
432452
vm.isAccordionVisible = $window.innerWidth < 768;
433453
}
@@ -535,6 +555,7 @@
535555
hideSessionStartTime: true
536556
};
537557
vm.sessionEventsTabActivated = false;
558+
vm.viewJSON = viewJSON;
538559
vm.tabs = [];
539560

540561
return getEvent().then(getProject).then(function () {

src/app/event/event.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
'exceptionless',
1111
'exceptionless.billing',
12+
'exceptionless.dialog',
1213
'exceptionless.error',
1314
'exceptionless.event',
1415
'exceptionless.events',

src/app/event/event.tpl.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<i class="fa fa-calendar"></i> {{::'Event Occurrence' | translate}}
88

99
<div class="pull-right hidden-print">
10-
<a clipboard text="vm.event_json" on-copied="vm.copied()" supported="vm.clipboardSupported" ng-show="vm.event.stack_id && vm.clipboardSupported" class="btn btn-default btn-xs fa fa-code hidden-xs" role="button" title="{{::'Copy Event JSON to Clipboard' | translate}}"></a>
10+
<a ng-show="vm.event.stack_id" ng-click="vm.viewJSON()" class="btn btn-default btn-xs fa fa-code hidden-xs" role="button" title="{{::'View JSON' | translate}}"></a>
1111
<a ui-sref="app.stack({ id: vm.event.stack_id })" ng-class="{'disabled': !vm.event.stack_id}" class="btn btn-default btn-xs fa fa-fw fa-caret-up" role="button" title="{{::'Go To Stack' | translate}}"></a>
1212
<a ui-sref="app.event({ id: vm.previous, tab: vm.getCurrentTab() })" ng-class="{'disabled': !vm.previous}" class="btn btn-default btn-xs fa fa-fw fa-caret-left" role="button" title="{{::'Previous Occurrence' | translate}}"></a>
1313
<a ui-sref="app.event({ id: vm.next, tab: vm.getCurrentTab() })" ng-class="{'disabled': !vm.next}" class="btn btn-default btn-xs fa fa-fw fa-caret-right" role="button" title="{{::'Next Occurrence' | translate}}"></a>

src/components/dialog/dialog-service.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@
1818
}).result;
1919
}
2020

21-
var service = {
21+
function viewJSON(json, copyButtonText) {
22+
return dialogs.create('components/dialog/json-dialog.tpl.html', 'jsonDialog as vm', {
23+
copyButtonText: copyButtonText,
24+
json: json
25+
}).result;
26+
}
27+
28+
return {
2229
confirm: confirm,
23-
confirmDanger: confirmDanger
30+
confirmDanger: confirmDanger,
31+
viewJSON: viewJSON
2432
};
25-
26-
return service;
2733
});
2834
}());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
(function () {
2+
'use strict';
3+
4+
angular.module('exceptionless.dialog')
5+
.controller('jsonDialog', function ($uibModalInstance, $translate, clipboard, data) {
6+
var vm = this;
7+
function close() {
8+
$uibModalInstance.dismiss('close');
9+
}
10+
11+
function copy() {
12+
clipboard.copyText(vm.json);
13+
$uibModalInstance.close('copy');
14+
}
15+
16+
this.$onInit = function $onInit() {
17+
vm.copyButtonText = angular.isDefined(data.copyButtonText) ? data.copyButtonText : $translate.instant('Copy to Clipboard');
18+
vm.header = angular.isDefined(data.header) ? data.header : $translate.instant('DIALOGS_JSON');
19+
vm.json = data.json;
20+
vm.close = close;
21+
vm.copy = copy;
22+
vm.showCopyButton = clipboard.supported;
23+
};
24+
});
25+
}());
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.btn-dialog-json {
2+
text-transform: capitalize;
3+
}
4+
5+
.json-content {
6+
max-height: 400px;
7+
overflow-y: scroll;
8+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="modal-header dialog-header-json">
2+
<button type="button" role="button" class="close" ng-click="vm.close()">&times;</button>
3+
<h4 class="modal-title">
4+
<span class="fa fa-code"></span>
5+
{{::vm.header}}
6+
</h4>
7+
</div>
8+
9+
<div class="modal-body">
10+
<pre class="json-content" ng-bind="vm.json"></pre>
11+
</div>
12+
13+
<div class="modal-footer">
14+
<button type="button" role="button" class="btn btn-default" ng-click="vm.close()">{{::'DIALOGS_CLOSE' | translate}}</button>
15+
<button type="button" role="button" class="btn btn-primary btn-dialog-copy" ng-click="vm.copy()" autofocus ng-show="vm.showCopyButton">
16+
{{vm.copyButtonText}}
17+
</button>
18+
</div>

src/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
<script src="components/dialog/dialog.js"></script>
133133
<script src="components/dialog/dialog-service.js"></script>
134134
<script src="components/dialog/confirm-dialog-controller.js"></script>
135+
<script src="components/dialog/json-dialog-controller.js"></script>
135136
<script src="components/duration/duration-directive.js"></script>
136137

137138
<script src="components/error/error-service.js"></script>

src/lang/en-us.json

+2
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
"Request":"Request",
188188
"to enable sessions and other premium features!":"to enable sessions and other premium features!",
189189
"is attempting to use a premium feature.":"is attempting to use a premium feature.",
190+
"View JSON": "View JSON",
190191
"Copy Stack Trace to Clipboard":"Copy Stack Trace to Clipboard",
191192
"Copy Event JSON to Clipboard":"Copy Event JSON to Clipboard",
192193
"Copy to Clipboard":"Copy to Clipboard",
@@ -685,6 +686,7 @@
685686
"DIALOGS_NOTIFICATION_MSG": "Unknown application notification.",
686687
"DIALOGS_CONFIRMATION": "Confirmation",
687688
"DIALOGS_CONFIRMATION_MSG": "Confirmation required.",
689+
"DIALOGS_JSON": "JSON",
688690
"DIALOGS_OK": "OK",
689691
"DIALOGS_YES": "Yes",
690692
"DIALOGS_NO": "No",

src/lang/zh-cn.json

+2
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
"Request":"请求",
188188
"to enable sessions and other premium features!":"以启用会话及其他高级特性!",
189189
"is attempting to use a premium feature.":"正在尝试使用高级特性。",
190+
"View JSON": "查看 JSON",
190191
"Copy Stack Trace to Clipboard":"将堆栈跟踪复制到剪贴板",
191192
"Copy Event JSON to Clipboard":"将事件以JSON格式复制到剪贴板",
192193
"Copy to Clipboard":"复制到剪贴板",
@@ -686,6 +687,7 @@
686687
"DIALOGS_NOTIFICATION_MSG": "未知应用程序的通知。",
687688
"DIALOGS_CONFIRMATION": "确认",
688689
"DIALOGS_CONFIRMATION_MSG": "确认要求。",
690+
"DIALOGS_JSON": "JSON",
689691
"DIALOGS_OK": "确定",
690692
"DIALOGS_YES": "确认",
691693
"DIALOGS_NO": "取消",

0 commit comments

Comments
 (0)