-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
134 lines (123 loc) · 3.89 KB
/
Copy pathindex.html
File metadata and controls
134 lines (123 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html>
<head>
<title>ActiveReports Electron Viewer</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<link rel="stylesheet" href="GrapeCity.ActiveReports.Viewer.Html.css" />
<style>
.report-list {
max-height: 200px;
overflow-y: scroll;
}
</style>
<script>
window.$ = window.jQuery = require('jquery');
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-3.3.0.js"></script>
<script type="text/javascript">
var Viewer = require('./GrapeCity.ActiveReports.Viewer.Html.js');
$(function () {
// docks viewer into browser window
function dock() {
var w = window.innerWidth;
var h = window.innerHeight;
w -= $('#viewer').offset().left;
h -= $('#viewer').offset().top;
$('#viewer')
.css('width', w + 'px')
.css('height', h + 'px');
}
$(window).resize(dock);
var arsEndpoint = 'http://localhost:42011';
var login = require('ars-client').login;
login('admin', 1, arsEndpoint).then(init);
function init(token) {
// create viewer
var options = {
element: '#viewer',
uiType: 'desktop',
reportService: {
// url: 'http://localhost:8888/ReportService.svc'
url: arsEndpoint + '/api/',
securityToken: token,
}
};
var viewer = Viewer(options);
// inject custom toolbar
var toolbar = $('#app-toolbar').html();
$('#viewer .toolbar').prepend($(toolbar));
var dlg = $('#open-dialog');
var ArsClient = require('ars-client').ArsClient;
var client = new ArsClient({
endpoint: arsEndpoint,
token: token,
});
client.reports().load().then(function(reports) {
var selected = ko.observable('');
var viewModel = {
selected: ko.observable(''),
reports: reports.map(function(report) {
return Object.assign(report, {
active: ko.computed(function() {
return selected() === report._id ? 'active' : '';
}),
click: function() {
selected(report._id);
},
});
}),
open: function() {
dlg.modal('hide');
var id = selected();
if (!id) return;
viewer.option('report', { id: id });
},
};
ko.applyBindings(viewModel, dlg[0]);
});
// handler to work with micro AR server
// $('.open-report').click(function () {
// var remote = require('remote');
// var dialog = remote.require('dialog');
// dialog.showOpenDialog(function (files) {
// if (files.length !== 1) return;
// viewer.option('report', { id: files[0] });
// });
// });
dock();
}
});
</script>
</head>
<body>
<template id="app-toolbar">
<div class="btn-group btn-group-sm">
<button class="btn btn-default open-report" title="Open report" data-toggle="modal" data-target="#open-dialog">
<span class="glyphicon glyphicon-folder-open" />
</button>
</div>
</template>
<div id="viewer" style="width: 800px; height: 600px;"></div>
<div id="open-dialog" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Open report</h4>
</div>
<div class="modal-body">
<ul class="list-group report-list" data-bind="foreach: $data.reports">
<a class="list-group-item" data-bind="css: active, text: Name, click: click"></a>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dissmis="modal">Close</button>
<button type="button" class="btn btn-primary" data-bind="click: $data.open">Open</button>
</div>
</div>
</div>
</div>
</body>
</html>