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

  ViewVC Help
Powered by ViewVC 1.1.20