/[projects]/dao/DaoAdresseVedligehold/src/main/webapp/index.html
ViewVC logotype

Contents of /dao/DaoAdresseVedligehold/src/main/webapp/index.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2918 - (show annotations) (download) (as text)
Thu Feb 4 14:40:36 2016 UTC (8 years, 3 months ago) by torben
File MIME type: text/html
File size: 6745 byte(s)
Add posibility for removing done and aborted tasks
1 <html>
2 <head>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
6 <link rel="stylesheet" href="webjars/bootstrap/3.3.5/css/bootstrap.min.css" />
7
8 <link rel="stylesheet" href="webjars/bootstrap-fileinput/4.2.7/css/fileinput.min.css" />
9
10 <!-- use webjars for dependencies -->
11 <script src="webjars/jquery/2.1.4/jquery.js"></script>
12 <script src="webjars/bootstrap/3.3.5/js/bootstrap.min.js"></script>
13
14 <script src="webjars/bootstrap-fileinput/4.2.7/js/fileinput.min.js"></script>
15
16 <script src="webjars/chartjs/1.0.2/Chart.min.js"></script>
17
18 <script>
19
20
21 function loadTasks() {
22 $.get("rest/tasks/list", function(data) {
23 //console.log(data);
24
25
26 var html = "";
27 data.forEach( function(entry) {
28 var pclass;
29
30 if (entry.state == "STATE_DONE")
31 pclass = "panel-success";
32
33 if (entry.state == "STATE_RUNNING")
34 pclass = "panel-info";
35
36 if (entry.state == "STATE_QUEUED")
37 pclass = "panel-warning";
38
39 if (entry.state == "STATE_ABORTED")
40 pclass = "panel-danger";
41
42
43 html += "<div class='panel " + pclass + "'>";
44 html += "<div class='panel-heading'>";
45 if (entry.state == "STATE_DONE" || entry.state == "STATE_ABORTED") {
46 html += "<button type='button' class='close removetask' aria-label='Close' taskid='" + entry.id+ "'><span aria-hidden='true'>&times;</span></button>";
47 }
48 html += "<h4 class='panel-title'>" + entry.description + "</h4>";
49 html += "</div>";
50 html += " <div class='panel-body'>";
51
52 html += entry.detail;
53
54 if (entry.state == "STATE_ABORTED")
55 html += "<br><div style='color: red'>" + entry.errorMessage + "</div>";
56
57 if (entry.state == "STATE_RUNNING") {
58 if (entry.percentCompleted >= 0) {
59 var percent = entry.percentCompleted.toFixed(2);
60 html += "<div class='progress'>";
61 html += "<div class='progress-bar' role='progressbar' aria-valuenow='" + percent + "' aria-valuemin='0' aria-valuemax='100' style='width:" + percent + "%'> " ;
62 html += percent + "%";
63 html += " </div>";
64 html += "</div>";
65 }
66 }
67
68 var viewlog = "";
69 if (entry.state == "STATE_RUNNING" || entry.state == "STATE_DONE" || entry.state == "STATE_ABORTED") {
70 viewlog = "<span style='float: right'><a href='#' class='viewlog' taskid='" + entry.id+ "'>Log</a></span>";
71 }
72
73 html += " <div style='font-size: 8px; '>" + entry.state + viewlog + "</div>";
74
75 html += " </div>"; //panel-body
76 html += "</div>"; //panel
77
78 });
79 if (html == "") {
80 html = "<div class='panel panel-primary'>Queue is empty</div>";
81 }
82
83 $("#queue").html(html);
84
85 }, "json");
86 }
87
88 function genUploadExtraData (previewId, index) {
89 var dist = $("#distributor").val();
90 var wb = $("#writeback").val();
91
92 var obj = {
93 distributor: dist,
94 writeback: wb
95 };
96
97 return obj;
98 }
99
100 $(document).ready( function() {
101 loadTasks();
102 setInterval(loadTasks, 5000);
103
104
105 $(document).on('click', '.viewlog', function(event) { // Bind future elements
106 var taskid = $(this).attr('taskid');
107 $("#logview").load('rest/tasks/log/' + taskid);
108
109 });
110
111 $(document).on('click', '.removetask', function(event) { // Bind future elements
112 var taskid = $(this).attr('taskid');
113 $.get('rest/tasks/remove/' + taskid, function() {
114 loadTasks();
115 });
116 });
117
118 $("#file").fileinput({
119 //'showUpload':false,
120 'showRemove': false,
121 'showPreview': false,
122 'showUpload': false,
123 'uploadUrl': 'FileUploadServlet',
124 'uploadExtraData': genUploadExtraData, //brug callback til at finde ekstra data
125
126 'maxFileCount': 1,
127 'minFileCount': 1
128
129
130 });
131
132 $("#uploadBtn").click( function() {
133 var dist = $("#distributor").val();
134 if (dist == "") {
135 alert("Du skal vælge distributør");
136 return;
137 }
138
139 $('#file').fileinput('upload');
140 });
141
142
143 $("#afstandBtn").click( function(){
144 var dist = $("#afstand_distributor").val();
145 if (dist == "") {
146 alert("Du skal vælge distributør");
147 return;
148 }
149
150
151 $.get("rest/commands/distancecalculation/" + dist, function() {
152 loadTasks(); //Force reload of tasks immediately
153 } );
154
155 });
156
157 });
158
159 </script>
160
161 </head>
162 <body>
163
164 <div class="container-fluid">
165 <div class="page-header">
166 <h1>Dao Adresse Vedligehold</h1>
167 </div>
168 <div id="body">
169 <div class="row">
170 <div class="col-sm-1" id="leftCol-blank" >
171 </div>
172
173 <div class="col-sm-2" id="leftCol" >
174 <div class="panel panel-primary">
175 <div class="panel-heading">
176 <h3 class="panel-title">Queue</h3>
177 </div>
178 <div class="panel-body" id="queue">
179
180
181
182 </div>
183 </div>
184 </div>
185
186 <div class="col-sm-6" id="center">
187 <pre id="logview">
188 </pre>
189 </div>
190
191 <div class="col-sm-2" id="rightCol" >
192 <div class="panel panel-primary">
193 <div class="panel-heading">
194 <h3 class="panel-title">Upload File</h3>
195 </div>
196 <div class="panel-body">
197
198
199 <label for="distributor">Distributør:</label>
200 <select class="form-control" id="distributor" name="distributor">
201 <option></option>
202 <option>BK</option>
203 <option>DAO</option>
204 <option>FD</option>
205 <option>NS</option>
206 </select>
207
208 <label for="writeback">Write-back:</label>
209 <select class="form-control" id="writeback" name="writeback">
210 <option value="false">Nej</option>
211 <option value="true">Ja</option>
212 </select>
213
214
215 <label class="control-label">Select File</label>
216
217 <input type="hidden" name="distributor" value="BK">
218 <input type="file" name="file" id="file"><br>
219
220 <button class="btn btn-primary" id="uploadBtn">Upload</button>
221
222
223
224 </div>
225 </div> <!-- upload panel -->
226
227 <div class="panel panel-primary">
228 <div class="panel-heading">
229 <h3 class="panel-title">Afstand anden rute</h3>
230 </div>
231 <div class="panel-body">
232
233
234 <label for="distributor">Distributør:</label>
235 <select class="form-control" id="afstand_distributor" name="afstand_distributor">
236 <option></option>
237 <option>BK</option>
238 <option>DAO</option>
239 </select>
240 <br>
241
242 <button class="btn btn-primary" id="afstandBtn">Beregn</button>
243
244
245 </div>
246 </div><!-- Afstand-andenrute panel -->
247
248
249
250 </div><!-- rightcol -->
251 </div> <!-- row -->
252
253 </div><!-- body -->
254
255
256 </div>
257
258
259
260 </body>
261 </html>

  ViewVC Help
Powered by ViewVC 1.1.20