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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2909 - (hide annotations) (download) (as text)
Wed Feb 3 22:30:22 2016 UTC (8 years, 3 months ago) by torben
File MIME type: text/html
File size: 6197 byte(s)
First version of logview
1 torben 2838 <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 torben 2903 $.get("rest/tasks/list", function(data) {
23 torben 2838 //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'><h4 class='panel-title'>" + entry.description + "</h4></div>";
45 torben 2899 html += " <div class='panel-body'>";
46 torben 2838
47     html += entry.detail;
48    
49 torben 2844 if (entry.state == "STATE_ABORTED")
50     html += "<br><div style='color: red'>" + entry.errorMessage + "</div>";
51 torben 2891
52     if (entry.state == "STATE_RUNNING") {
53     if (entry.percentCompleted >= 0) {
54     var percent = entry.percentCompleted.toFixed(2);
55     html += "<div class='progress'>";
56     html += "<div class='progress-bar' role='progressbar' aria-valuenow='" + percent + "' aria-valuemin='0' aria-valuemax='100' style='width:" + percent + "%'> " ;
57     html += percent + "%";
58     html += " </div>";
59     html += "</div>";
60     }
61     }
62 torben 2844
63 torben 2909 var viewlog = "";
64     if (entry.state == "STATE_RUNNING" || entry.state == "STATE_DONE" || entry.state == "STATE_ABORTED") {
65     viewlog = "<span style='float: right'><a href='#' class='viewlog' taskid='" + entry.id+ "'>Log</a></span>";
66     }
67 torben 2838
68 torben 2909 html += " <div style='font-size: 8px; '>" + entry.state + viewlog + "</div>";
69    
70 torben 2899 html += " </div>"; //panel-body
71     html += "</div>"; //panel
72 torben 2838
73     });
74     if (html == "") {
75     html = "<div class='panel panel-primary'>Queue is empty</div>";
76     }
77    
78     $("#queue").html(html);
79    
80     }, "json");
81     }
82    
83     function genUploadExtraData (previewId, index) {
84     var dist = $("#distributor").val();
85     var wb = $("#writeback").val();
86    
87     var obj = {
88     distributor: dist,
89     writeback: wb
90     };
91    
92     return obj;
93     }
94    
95     $(document).ready( function() {
96     loadTasks();
97 torben 2909 //setInterval(loadTasks, 2500);
98 torben 2838
99    
100 torben 2909 $(document).on('click', '.viewlog', function(event) { // Bind future elements
101     var taskid = $(this).attr('taskid');
102     $("#logview").load('rest/tasks/log/' + taskid);
103    
104     });
105    
106 torben 2838 $("#file").fileinput({
107     //'showUpload':false,
108     'showRemove': false,
109     'showPreview': false,
110     'showUpload': false,
111     'uploadUrl': 'FileUploadServlet',
112     'uploadExtraData': genUploadExtraData, //brug callback til at finde ekstra data
113    
114     'maxFileCount': 1,
115     'minFileCount': 1
116    
117    
118     });
119    
120     $("#uploadBtn").click( function() {
121     var dist = $("#distributor").val();
122     if (dist == "") {
123     alert("Du skal vælge distributør");
124     return;
125     }
126    
127     $('#file').fileinput('upload');
128     });
129    
130 torben 2890
131     $("#afstandBtn").click( function(){
132     var dist = $("#afstand_distributor").val();
133     if (dist == "") {
134     alert("Du skal vælge distributør");
135     return;
136     }
137    
138    
139 torben 2895 $.get("rest/commands/distancecalculation/" + dist, function() {
140     loadTasks(); //Force reload of tasks immediately
141     } );
142 torben 2890
143     });
144    
145 torben 2838 });
146    
147     </script>
148    
149     </head>
150     <body>
151    
152     <div class="container">
153     <div class="page-header">
154     <h1>Dao Adresse Vedligehold</h1>
155     </div>
156     <div id="body">
157     <div class="row">
158     <div class="col-sm-3" id="leftCol" >
159     <div class="panel panel-primary">
160     <div class="panel-heading">
161     <h3 class="panel-title">Queue</h3>
162     </div>
163     <div class="panel-body" id="queue">
164    
165    
166    
167     </div>
168     </div>
169     </div>
170    
171 torben 2909 <div class="col-sm-6" id="center">
172     <pre id="logview">
173     </pre>
174 torben 2838 </div>
175    
176     <div class="col-sm-3" id="rightCol" >
177     <div class="panel panel-primary">
178     <div class="panel-heading">
179 torben 2890 <h3 class="panel-title">Upload File</h3>
180 torben 2838 </div>
181     <div class="panel-body">
182    
183    
184     <label for="distributor">Distributør:</label>
185     <select class="form-control" id="distributor" name="distributor">
186     <option></option>
187     <option>BK</option>
188 torben 2844 <option>DAO</option>
189 torben 2852 <option>FD</option>
190 torben 2851 <option>NS</option>
191 torben 2838 </select>
192    
193     <label for="writeback">Write-back:</label>
194     <select class="form-control" id="writeback" name="writeback">
195     <option value="false">Nej</option>
196     <option value="true">Ja</option>
197     </select>
198    
199    
200     <label class="control-label">Select File</label>
201    
202     <input type="hidden" name="distributor" value="BK">
203     <input type="file" name="file" id="file"><br>
204    
205     <button class="btn btn-primary" id="uploadBtn">Upload</button>
206    
207    
208    
209     </div>
210 torben 2890 </div> <!-- upload panel -->
211    
212     <div class="panel panel-primary">
213     <div class="panel-heading">
214     <h3 class="panel-title">Afstand anden rute</h3>
215     </div>
216     <div class="panel-body">
217    
218    
219     <label for="distributor">Distributør:</label>
220     <select class="form-control" id="afstand_distributor" name="afstand_distributor">
221     <option></option>
222     <option>BK</option>
223     <option>DAO</option>
224     </select>
225     <br>
226    
227     <button class="btn btn-primary" id="afstandBtn">Beregn</button>
228    
229    
230     </div>
231     </div><!-- Afstand-andenrute panel -->
232    
233    
234    
235     </div><!-- rightcol -->
236     </div> <!-- row -->
237 torben 2838
238 torben 2890 </div><!-- body -->
239    
240    
241 torben 2838 </div>
242    
243    
244    
245     </body>
246     </html>

  ViewVC Help
Powered by ViewVC 1.1.20