Changeset 82eff76
- Timestamp:
- May 4, 2020, 8:34:54 PM (7 years ago)
- Branches:
- debian/bullseye, master
- Children:
- ac05b52
- Parents:
- 9b8dd22
- Location:
- src/gnuboat
- Files:
-
- 4 added
- 33 deleted
- 3 edited
- 1 moved
-
common/js/GnuBoat.js (modified) (2 diffs)
-
common/lib/js/leaflet.js.map (added)
-
deviceservice_impl/static/css/GnuBoat.Webclient.css (moved) (moved from src/gnuboat/deviceservice_impl/static/css/GnuBoat.css ) (7 diffs)
-
deviceservice_impl/static/index.html (modified) (8 diffs)
-
deviceservice_impl/static/js/GnuBoat.Webclient.js (modified) (23 diffs)
-
deviceservice_impl/static/lib/css/leaflet/images/layers-2x.png (deleted)
-
deviceservice_impl/static/lib/css/leaflet/images/layers.png (deleted)
-
deviceservice_impl/static/lib/css/leaflet/images/marker-icon-2x.png (deleted)
-
deviceservice_impl/static/lib/css/leaflet/images/marker-icon.png (deleted)
-
deviceservice_impl/static/lib/css/leaflet/images/marker-shadow.png (deleted)
-
deviceservice_impl/static/lib/css/leaflet/leaflet.css (deleted)
-
deviceservice_impl/static/lib/css/pure/base-context-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/base-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/buttons-core-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/buttons-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/forms-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/forms-nr-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/grids-core-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/grids-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/grids-responsive-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/grids-responsive-old-ie-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/grids-units-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/menus-core-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/menus-dropdown-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/menus-horizontal-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/menus-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/menus-scrollable-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/menus-skin-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/pure-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/pure-nr-min.css (deleted)
-
deviceservice_impl/static/lib/css/pure/tables-min.css (deleted)
-
deviceservice_impl/static/lib/js/additional-methods.min.js (deleted)
-
deviceservice_impl/static/lib/js/jquery-3.2.1.min.js (deleted)
-
deviceservice_impl/static/lib/js/jquery.validate.min.js (deleted)
-
deviceservice_impl/static/lib/js/leaflet.hotline.min.js (deleted)
-
deviceservice_impl/static/lib/js/leaflet.js (deleted)
-
deviceservice_impl/static/lib/js/three.OrbitControls.js (deleted)
-
deviceservice_impl/static/lib/js/three.min.js (deleted)
-
deviceservice_impl/static/resources/mapservice-error.svg (added)
-
deviceservice_impl/static/resources/mapservice-offline.svg (added)
-
deviceservice_impl/static/resources/mapservice-ok.svg (added)
Legend:
- Unmodified
- Added
- Removed
-
src/gnuboat/common/js/GnuBoat.js
r9b8dd22 r82eff76 1 1 /* 2 2 3 Copyright (C) 2016 - 20 18EngSaS - Langenbach. All rights reserved.3 Copyright (C) 2016 - 2020 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This library is free software; you can redistribute it and/or … … 31 31 $(text).appendTo("#message"); 32 32 location.hash = "#messages"; 33 $('#message').show(); 34 setTimeout(function(){ $('#message').hide(); }, 60000); 33 35 } 34 36 -
src/gnuboat/deviceservice_impl/static/css/GnuBoat.Webclient.css
r9b8dd22 r82eff76 1 1 /* 2 Copyright (C) 2016 - 20 18EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.2 Copyright (C) 2016 - 2020 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 16 16 */ 17 17 18 @import url(" GnuBoat.Colors.css");18 @import url("/client/common/css/GnuBoat.Colors.css"); 19 19 20 20 .l-box { … … 29 29 #display { 30 30 background-color: var(--gnuboat-primary-light); 31 height: 9em; 32 min-width: 14em; 33 font-size: 12pt; 31 font-size: 1.5em; 34 32 font-weight: normal; 35 padding: 0mm; 36 position:relative; 33 padding-left: 0.5em; 34 padding-right: 0.5em; 35 padding-top: 0.25em; 36 padding-bottom: 0.25em; 37 37 line-height: 1.5em; 38 38 color: black; 39 39 } 40 40 41 .display-row:after { 42 content: ""; 43 display: table; 44 clear: both; 45 } 46 47 .display-1-2 { 48 flex: 50%; 49 min-width: 50%; 50 float: left; 51 } 52 53 .display-1-4 { 54 flex: 25%; 55 min-width: 25%; 56 float: left; 57 } 58 41 59 #display h2 { 42 font-size: 1 2pt;60 font-size: 1em; 43 61 font-weight: normal; 44 62 margin: 0em; … … 47 65 48 66 #display span { 49 font-size: 24pt;67 font-size: 1em; 50 68 font-weight: bold; 51 69 margin: 0em; … … 53 71 } 54 72 55 #display #speedthroughwater {56 position: absolute;57 top: 0.5em;58 left: 0.5em;59 }60 61 73 #display .important { 62 font-size: 40pt;74 font-size: 2em; 63 75 line-height: 0.6em; 64 76 } 65 77 66 #display #speedoverground { 67 position: absolute; 68 top: 0.5em; 69 left: 7em; 70 } 71 72 #display #waterdepth { 73 position: absolute; 74 top: 5em; 75 left: 0.5em; 76 } 77 78 #display #watertemperature { 79 position: absolute; 80 top: 5em; 81 left: 7em; 82 } 83 84 #display #gpsfix { 85 position: absolute; 86 top: 5em; 87 left: 11em; 78 #mapserviceStatusIcon { 79 height: 1.5em; 80 width: auto; 88 81 } 89 82 … … 105 98 width: 100%; 106 99 margin-top: 3em; 100 } 101 102 .button-remove { 103 background: var(--gnuboat-warning); 104 color: white; 105 } 106 107 .button-add { 108 background: var(--gnuboat-green-dark); 109 color: white; 107 110 } 108 111 … … 134 137 text-align: right; 135 138 } 139 140 .button-gnuboat { 141 color: white; 142 background: var(--gnuboat-turquois-dark); 143 } 144 145 #mapFileInputDiv { 146 position: relative; 147 overflow: hidden; 148 margin: 10px; 149 } 150 151 #mapFileInputDiv input{ 152 position: absolute; 153 top: 0; 154 right: 0; 155 margin: 0; 156 padding: 0; 157 font-size: 20px; 158 cursor: pointer; 159 opacity: 0; 160 filter: alpha(opacity=0); 161 } -
src/gnuboat/deviceservice_impl/static/index.html
r9b8dd22 r82eff76 1 1 <!-- 2 Copyright (C) 2016 - 20 18EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.2 Copyright (C) 2016 - 2020 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 20 20 <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> 21 21 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 22 <link rel="icon" type="image/png" href=" resources/gnuboat-256-256-transparent.png"/>22 <link rel="icon" type="image/png" href="/client/common/icon/gnuboat-256-256-transparent.png"/> 23 23 <title>GNUBoat Web Application</title> 24 24 25 <link rel="stylesheet" href=" lib/css/pure/pure-min.css" type="text/css"/>25 <link rel="stylesheet" href="/client/common/lib/css/pure/pure-min.css" type="text/css"/> 26 26 <!--[if lte IE 8]> 27 27 <link rel="stylesheet" content="text/css" href="lib/css/pure/grids-responsive-old-ie-min.css"> 28 28 <![endif]--> 29 29 <!--[if gt IE 8]><!--> 30 <link rel="stylesheet" content="text/css" href=" lib/css/pure/grids-responsive-min.css">30 <link rel="stylesheet" content="text/css" href="/client/common/lib/css/pure/grids-responsive-min.css"> 31 31 <!--<![endif]--> 32 <link rel="stylesheet" content="text/css" href="lib/css/leaflet/leaflet.css"/> 32 <link rel="stylesheet" href="/client/common/lib/js/jquery-ui/jquery-ui.min.css" type="text/css"/> 33 <link rel="stylesheet" content="text/css" href="/client/common/lib/css/leaflet/leaflet.css"/> 33 34 34 <script src="lib/js/jquery-3.2.1.min.js" type="text/javascript"></script> 35 <script src="lib/js/jquery.validate.min.js" type="text/javascript"></script> 36 <script src="lib/js/additional-methods.min.js" type="text/javascript"></script> 37 <script src="lib/js/leaflet.js" type="text/javascript"></script> 38 <script src="lib/js/leaflet.hotline.min.js" type="text/javascript"></script> 39 <script src="lib/js/three.min.js"></script> 40 <script src="lib/js/three.OrbitControls.js"></script> 35 <script src="/client/common/lib/js/jquery-3.2.1.min.js" type="text/javascript"></script> 36 <script src="/client/common/lib/js/jquery.validate.min.js" type="text/javascript"></script> 37 <script src="/client/common/lib/js/jquery-ui/jquery-ui.min.js" type="text/javascript"></script> 38 <script src="/client/common/lib/js/additional-methods.min.js" type="text/javascript"></script> 39 <script src="/client/common/lib/js/leaflet.js" type="text/javascript"></script> 40 <script src="/client/common/lib/js/leaflet.hotline.min.js" type="text/javascript"></script> 41 <script src="/client/common/lib/js/three.min.js"></script> 42 <script src="/client/common/lib/js/three.OrbitControls.js"></script> 41 43 42 <link rel="stylesheet" href=" css/GnuBoat.css" type="text/css"/>43 <link rel="stylesheet" href=" css/side-menu.css" type="text/css"/>44 <script language="javascript" src=" js/GnuBoat.js" type="text/javascript"></script>45 <script language="javascript" src=" js/GnuBoat.Webclient.js" type="text/javascript"></script>44 <link rel="stylesheet" href="/client/css/GnuBoat.Webclient.css" type="text/css"/> 45 <link rel="stylesheet" href="/client/common/css/side-menu.css" type="text/css"/> 46 <script language="javascript" src="/client/common/js/GnuBoat.js" type="text/javascript"></script> 47 <script language="javascript" src="/client/js/GnuBoat.Webclient.js" type="text/javascript"></script> 46 48 <script language="javascript" type="text/javascript"> 47 49 var active = 'active'; … … 74 76 75 77 GnuBoat.Webclient.initialize(); 76 GnuBoat.Webclient.setServer(" ../webservice");78 GnuBoat.Webclient.setServer("/deviceservice/v1"); 77 79 GnuBoat.Webclient.start(); 80 81 // To workaround the not stylable browse button of input type file 82 document.getElementById("mapFileInput").onchange = function () { 83 document.getElementById("mapFileInputDummy").value = this.value; 84 }; 78 85 }); 79 86 </script> … … 97 104 <div id="main"> 98 105 <div class="header"> 99 <h1><img src=" resources/gnuboat-256-256-transparent.png" />Boat</h1>106 <h1><img src="/client/common/icon/gnuboat-256-256-transparent.png" />Boat</h1> 100 107 </div> 101 108 <div class="content"> … … 105 112 <div id="display"> 106 113 <a name="display"></a> 107 <div id="speedthroughwater"> 108 <h2>STW</h2> 109 <span id="value" class="important">-</span> kts 114 <div class="display-row"> 115 <div id="speedThroughWater" class="display-1-2"> 116 <h2>STW</h2> 117 <span id="value" class="important">-</span> kts 118 </div> 119 <div id="speedOverGround" class="display-1-2"> 120 <h2>SOG</h2> 121 <span id="value" class="important">-</span> kts 122 </div> 110 123 </div> 111 <div id="speedoverground"> 112 <h2>SOG</h2> 113 <span id="value" class="important">-</span> kts 114 </div> 115 <div id="waterdepth"> 116 <h2>Depth</h2> 117 <span id="value">-</span> m 118 </div> 119 <div id="watertemperature"> 120 <h2>Water</h2> 121 <span id="value">-</span>°C 122 </div> 123 <div id="gpsfix"> 124 <h2>Fix</h2> 125 <span id="value">-</span> 124 <div class="display-row"> 125 <div id="waterDepth" class="display-1-4"> 126 <h2>Depth</h2> 127 <span id="value">-</span> m 128 </div> 129 <div id="waterTemperature" class="display-1-4"> 130 <h2>Water</h2> 131 <span id="value">-</span>°C 132 </div> 133 <div id="gpsFix" class="display-1-4"> 134 <h2>Fix</h2> 135 <span id="value">-</span> 136 </div> 137 <div id="mapserviceStatus" class="display-1-4"> 138 <h2>Remote</h2> 139 <img id="mapserviceStatusIcon" src='/client/resources/mapservice-offline.svg' title='No connection to the remote Mapservice'> 140 </div> 126 141 </div> 127 142 </div> … … 129 144 </div> 130 145 <div class="pure-u-1 pure-u-md-1-2 pure-u-lg-1-2"> 131 <div id=" shutdown" class="l-box">146 <div id="messageBox" class="l-box"> 132 147 <a name="messages"></a> 133 <p id="message"/> 134 <!-- <button type="button" class="pure-button shutdown-button" id="shutdownButton">SHUTDOWN</button> --> 148 <div id="message"></div> 135 149 </div> 136 150 </div> … … 163 177 <legend>Map Upload</legend> 164 178 <div class="pure-control-group"> 165 <label for="mapName">Map Name:</label>166 <input id="mapName" type="text" name="mapName" value="" placeholder="Name of your map" required>167 </div>168 <div class="pure-control-group">169 179 <label for="mapFileInput">MBTiles File:</label> 170 <input id="mapFileInput" type="file" name="mapFile" value="" placeholder="Path to MAPTile file" required><progress id="mapTileUploadProgress"></progress> 171 </div> 172 <input type="submit" class="pure-button pure-button-primary" name="mapUploadButton" value="Upload"/> 180 <!-- To workaround the not stylable browse button of input type file --> 181 <input id="mapFileInputDummy" placeholder="Choose Map" disabled="disabled"> 182 <div id="mapFileInputDiv" class="pure-button button-gnuboat"> 183 <span>Browse</span> 184 <input id="mapFileInput" name="mapFile" type="file" class="upload"> 185 </div> 186 <!-- End of workaround the not stylable browse button of input type file --> 187 <progress id="mapTileUploadProgress"></progress> 188 <p>Make sure the map has a name set!</p> 189 <input id='mapUploadButton' type="submit" class="pure-button button-add" name="mapUploadButton" value="Upload"/> 190 </div> 173 191 </fieldset> 174 192 </form> … … 189 207 <div> 190 208 <a name="logfiles"></a> 191 <form id="logfilesForm" class="pure-form" method="POST" action="../webservice/?request=logfiles"></form> 209 <p id='logfilesNone'></p> 210 <form id="logfilesForm" class="pure-form pure-form-stacked"> 211 <fieldset id='logfilesFieldset'> 212 <select id='logfilesSelect' class='pure-input-1' multiple></select> 213 <div class="pure-controls"> 214 <input type="button" class='pure-button button-add' id='logfilesUploadStart' value='Upload'/> 215 <input type="button" class='pure-button button-gnuboat' id='logfilesDownload' value='Download'/> 216 </div> 217 </fieldset> 218 </form> 219 <h2 id='logfilesUploadMessage'></h2> 220 <form id='logfilesUploadForm' class='pure-form pure-form-aligned'> 221 <fieldset id='logfilesUploadFieldset'> 222 <input type='hidden' id='logfilesUploadLogfile' name='logfilesUploadLogfile' value=''> 223 <div class="pure-control-group"> 224 <label for='logfilesUploadWater'>Water:</label> 225 <input type='text' name='water' id='logfilesUploadWater' placeholder='Start typing to query for waters'> 226 <span class="pure-form-message-inline">Required</span> 227 </div> 228 <div class="pure-control-group"> 229 <label for='logfilesUploadGauge'>Gauge:</label> 230 <input type='text' name='gauge' id='logfilesUploadGauge' placeholder='Start typing to query for gauges'> 231 <span class="pure-form-message-inline">Required</span> 232 </div> 233 <div class="pure-control-group"> 234 <label for='logfilesUploadGaugeHeight'>Gauge Height:</label> 235 <input type='number' name='gaugeHeight' id='logfilesUploadGaugeHeight' placeholder='Relative to reference gauge level'> 236 <span id='logfilesUploadGaugeHeightReference' class="pure-form-message-inline"></span> 237 <span class="pure-form-message-inline">Required</span> 238 </div> 239 <div class="pure-controls"> 240 <label for='logfilesUploadDelete' class='pure-checkbox'> 241 <input type='checkbox' name='delete' id='logfilesUploadDelete' checked> 242 Delete logfile after successfull uploading 243 </label> 244 </div> 245 <div class="pure-control-group"> 246 <label for='logfilesUploadComment'>Comment:</label> 247 <textarea name='comment' id='logfilesUploadGauge' placeholder='Your optional comment'></textarea> 248 </div> 249 <div class="pure-controls"> 250 <input type="submit" class='pure-button button-add' id='logfilesUploadUpload' value='Upload'/> 251 <input type="button" class='pure-button button-remove' id='logfilesUploadCancel' value='Cancel'/> 252 </div> 253 </fieldset> 254 </form> 192 255 </div> 193 256 -
src/gnuboat/deviceservice_impl/static/js/GnuBoat.Webclient.js
r9b8dd22 r82eff76 1 1 /* 2 2 3 Copyright (C) 2016 - 20 18EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.3 Copyright (C) 2016 - 2020 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved. 4 4 5 5 This library is free software; you can redistribute it and/or … … 46 46 { 47 47 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 48 GnuBoat.displayMessage('< span class="error">No server set/found</span>');48 GnuBoat.displayMessage('<p class="error">No server set/found</p>'); 49 49 return; 50 50 } 51 51 var gnuboatApi = GnuBoat.Webclient.private.serverBaseUrl; 52 $.getJSON(gnuboatApi , GnuBoat.Webclient.private.displayDataSet);52 $.getJSON(gnuboatApi +'instrumentdata', GnuBoat.Webclient.private.displayDataSet).fail(GnuBoat.Webclient.private.displayHttpError); 53 53 }; 54 54 55 /** 56 * @brief Gets the metadata of all maps, provided by the tileserver 57 */ 58 GnuBoat.Webclient.getMapInfos = function() 59 { 55 56 /** 57 * @brief Fetches the track to display on the map 58 */ 59 GnuBoat.Webclient.trackGet = function() 60 { 61 if(!GnuBoat.Webclient.private.mapModusLive || GnuBoat.Webclient.private.map == null) 62 return; 60 63 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 61 64 GnuBoat.displayMessage('<span class="error">No server set/found</span>'); 62 65 return; 63 66 } 64 $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"tileserver.php?/index.json", GnuBoat.Webclient.private.mapInfos); 67 var gnuboatApi = GnuBoat.Webclient.private.serverBaseUrl; 68 $.getJSON(gnuboatApi +'track').done(GnuBoat.Webclient.private.trackSet).fail(GnuBoat.Webclient.private.displayHttpError); 65 69 }; 66 70 67 71 /** 68 * @brief Fetches the list of available logfiles and adds them to the log file download form69 */ 70 GnuBoat.Webclient. logfilesLoad= function()72 * @brief Gets the metadata of all maps, provided by the tileserver 73 */ 74 GnuBoat.Webclient.getMapInfos = function() 71 75 { 72 76 if(GnuBoat.Webclient.private.serverBaseUrl == null){ … … 74 78 return; 75 79 } 76 $("#logfilesForm").empty(); 77 $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"?request=logfiles", function(data){ 80 $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"maps", GnuBoat.Webclient.private.mapInfos); 81 }; 82 83 /** 84 * @brief Fetches the list of available logfiles and adds them to the log file download form 85 */ 86 GnuBoat.Webclient.logfilesLoad = function() 87 { 88 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 89 GnuBoat.displayMessage('<span class="error">No server set/found</span>'); 90 return; 91 } 92 93 $('#logfilesNone').empty(); 94 $('#logfilesSelect').empty(); 95 $('#logfilesNone').hide(); 96 $('#logfilesSelect').hide(); 97 $('#logfilesDownload').hide(); 98 99 $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"/logfiles", function(data){ 78 100 GnuBoat.Webclient.private.updateMapModus(data); 79 101 if(!Array.isArray(data) || data.length < 1){ 80 $("<p>No Logfiles found!</p>").appendTo("#logfilesForm"); 81 console.log(data); 82 return; 83 } 84 if(("error" in data) && data["error"] == 1){ 85 GnuBoat.displayMessage('<span class="error">Failed to get log files: '+ data["errormessage"] +'</span>'); 86 $("<p>No Logfiles found!</p>").appendTo("#logfilesForm"); 87 console.log(data); 88 return; 89 } 90 $("<select id=\"logfilesSelect\" name=\"logfilesSelected[]\" class=\"pure-input-1\" multiple></select>").appendTo("#logfilesForm"); 91 $("<input type=\"submit\" class=\"pure-button pure-button-primary\" name=\"logfilesDownload\" value=\"Download\"/>").appendTo("#logfilesForm"); 102 $("<span>No Logfiles found!</span>").appendTo("#logfilesNone"); 103 $('#logfilesNone').show(); 104 return; 105 } 92 106 data.forEach(function(value, index){ 93 107 $("<option value=\""+ value +"\">"+ value +"</option>").appendTo("#logfilesSelect"); 94 108 }); 95 }); 109 $('#logfilesSelect').show(); 110 $('#logfilesDownload').show(); 111 }).fail(GnuBoat.Webclient.private.displayHttpError); 96 112 }; 97 /** 98 * @brief Sends a shutdown request to the webservice 99 */ 100 GnuBoat.Webclient.shutdown = function() 113 114 115 GnuBoat.Webclient.logfileDownload = function() 101 116 { 102 117 if(GnuBoat.Webclient.private.serverBaseUrl == null){ … … 104 119 return; 105 120 } 106 $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"?request=shutdown", function(data){ 107 var shutdownTime = data["shutdownstart"]; 108 var shutdownDate = Date.parse(shutdownTime); 109 var currentDate = new Date(); 110 var shutdownHint = '<span class="info">Shutting down in '+ Math.floor((shutdownDate - currentDate)/1000) +"s at "+ shutdownTime.toLocaleString() +"</span>"; 111 if(shutdownTime == -1){ 112 shutdownHint = '<span class="error">Failed to initiate shutdown: '+ data["errormessage"] +"</span>"; 113 } 114 GnuBoat.displayMessage(shutdownHint); 115 }); 121 var logfiles = $('#logfilesSelect option:selected'); 122 if(logfiles.length < 1){ 123 GnuBoat.displayMessage('<span class="error">No logfile selected</span>'); 124 return; 125 } 126 else if(logfiles.length == 1){ 127 window.location = GnuBoat.Webclient.private.serverBaseUrl +'logfiles/'+ logfiles[0].value; 128 return 129 } 130 else{ 131 var files = Array(); 132 for(var i = 0; i < logfiles.length; i++){ 133 files.push(logfiles[i].value); 134 } 135 files.join(','); 136 window.location = GnuBoat.Webclient.private.serverBaseUrl +'logfiles/'+ files.join(','); 137 } 138 } 139 140 /** 141 * @brief Sends a shutdown request to the webservice 142 */ 143 GnuBoat.Webclient.shutdown = function() 144 { 145 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 146 GnuBoat.displayMessage('<span class="error">No server set/found</span>'); 147 return; 148 } 149 $.ajax({ 150 url: GnuBoat.Webclient.private.serverBaseUrl +"shutdown", 151 }).done(function(){ GnuBoat.displayMessage('<h2>Shutting down</h2>'); }) 152 .fail(GnuBoat.Webclient.private.displayHttpError); 116 153 }; 117 154 118 155 /** 119 * @brief Uploads a map and refreshes the maps metadata on success120 */ 121 GnuBoat.Webclient. uploadMap = function(form)156 * @brief Queries the status of the remote mapservice 157 */ 158 GnuBoat.Webclient.mapserviceStatusGet = function() 122 159 { 123 160 if(GnuBoat.Webclient.private.serverBaseUrl == null){ … … 125 162 return; 126 163 } 164 $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"/mapservice", function(data){ 165 switch(data){ 166 case 'NO_API_KEY': 167 var source = 'mapservice-error.svg'; 168 var description = 'Specifiy API_KEY for the mapservice in deviceservice config file'; 169 break; 170 case 'NO_DEVICE': 171 var source = 'mapservice-error.svg'; 172 var description = 'Specifiy device id for the mapservice in deviceservice config files option DEVICE'; 173 break; 174 case 'DEVICE_NOT_FOUND': 175 var source = 'mapservice-error.svg'; 176 var description = 'Specifiy a valid device id for the mapservice in deviceservice config files option DEVICE'; 177 break; 178 case 'OK': 179 var source = 'mapservice-ok.svg'; 180 var description = 'Connected and Configured'; 181 $('#logfilesUploadStart').prop('disabled', false); 182 break; 183 default: 184 source = 'mapservice-offline.svg'; 185 description = 'Mapservice is offline'; 186 } 187 var imgTag = $('#mapserviceStatusIcon'); 188 imgTag.attr('src', '/client/resources/'+ source); 189 imgTag.attr('title', description); 190 }).fail(GnuBoat.Webclient.private.displayHttpError); 191 }; 192 193 /** 194 * @brief Uploads a map and refreshes the maps metadata on success 195 */ 196 GnuBoat.Webclient.uploadMap = function(form) 197 { 198 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 199 displayMessage('<span class="error">No server set/found</span>'); 200 return; 201 } 127 202 $("#mapFileInput").hide(); 128 203 $("#mapTileUploadProgress").show(); 129 $.ajax({ 130 type: 'POST', 131 url: GnuBoat.Webclient.private.serverBaseUrl +'?request=map', 132 data: new FormData($("#mapTileUpload")[0]), 133 contentType: false, 134 processData: false, 135 success: function(data){ 136 if(("error" in data) && data["error"] == 1){ 137 GnuBoat.displayMessage('<span class="error">Failed to upload map: '+ data["errormessage"] +'</span>'); 138 $("#mapTileUploadProgress").hide(); 139 $("#mapFileInput").show(); 140 return; 141 } 142 GnuBoat.displayMessage('<span class="error">Map upload successfully</span>'); 204 205 var fileReader = new FileReader(); 206 fileReader.onload = function(e) { 207 if(fileReader.result == null){ 208 GnuBoat.displayMessage('<span class="error">Could not read map file.</span>'); 209 return; 210 } 211 var data = fileReader.result.replace('data:application/octet-stream;base64','') 212 $.ajax({ 213 type: 'POST', 214 url: GnuBoat.Webclient.private.serverBaseUrl +'maps', 215 data: data, 216 contentType: 'application/octet-stream', 217 processData: false, 218 }).progress(function(e){ 219 $("#mapTileUploadProgress").attr({value: e.oloaded, max: e.total}); 220 }).done(function(data){ 221 GnuBoat.displayMessage('<h2>Map upload successfully</h2>'); 143 222 $("#mapTileUploadProgress").hide(); 144 223 $("#mapFileInput").show(); 145 GnuBoat.Webclient.getMapInfos(); 146 }, 147 error: function(jqXHR, exception, errorThrown){ 148 GnuBoat.displayMessage('<span class="error">Failed to upload map (XHR): '+ exception +'</span>'); 224 GnuBoat.Webclient.private.mapInfos(data); 225 }).fail(function(error){ 149 226 $("#mapTileUploadProgress").hide(); 150 227 $("#mapFileInput").show(); 151 } 152 }).progress(function(e){ 153 $("#mapTileUploadProgress").attr({value: e.oloaded, max: e.total}); 154 }); 228 console.log(error); 229 GnuBoat.Webclient.private.displayHttpError(error); 230 }); 231 }; 232 fileReader.readAsDataURL($('#mapFileInput')[0].files[0]); 155 233 }; 156 234 … … 164 242 $("#logfilesReload").click(GnuBoat.Webclient.logfilesLoad); 165 243 $("#shutdownButton").click(GnuBoat.Webclient.shutdown); 244 $('#error').hide(); 166 245 167 246 $("#mapTileUpload").validate({ … … 179 258 }); 180 259 260 $('#logfilesNone').hide(); 261 $('#logfilesSelect').hide(); 262 $('#logfilesUploadMessage').hide(); 263 $('#logfilesDownload').hide(); 264 $('#logfilesDownload').click(GnuBoat.Webclient.logfileDownload); 265 $('#logfilesUploadStart').prop('disabled', true); 266 $('#logfilesUploadStart').click(function(){ 267 var logfiles = $('#logfilesSelect option:selected'); 268 if(logfiles.length > 1){ 269 $('#logfilesUploadMessage').show(); 270 $('#logfilesUploadMessage').text('Only one logfile could be uploaded at a time'); 271 setTimeout(function(){ $('#logfilesUploadMessage').hide(); $('#logfilesUploadMessage').empty(); }, 60000); 272 return; 273 } 274 console.log(logfiles[0]); 275 $('#logfilesUploadLogfile').val($(logfiles[0]).val()); 276 $('#logfilesUploadForm').show(); 277 $('#logfilesUploadStart').prop('disabled', true); 278 $('#logfilesUploadGauge').prop('disabled', true); 279 $('#logfilesUploadGaugeHeight').prop('disabled', true); 280 }); 181 281 $("#logfilesForm").validate({ 182 282 rules: { … … 187 287 }); 188 288 289 $("#logfilesUploadWater").autocomplete({ 290 minLength: 3, 291 source: GnuBoat.Webclient.private.uploadAutocompleteWaterGet, 292 select: GnuBoat.Webclient.private.uploadAutocompleteWaterSelected, 293 }); 294 $("#logfilesUploadGauge").autocomplete({ 295 minLength: 0, 296 source: [], 297 select: GnuBoat.Webclient.private.uploadAutocompleteGaugeSelected, 298 }); 299 $('#logfilesUploadForm').hide(); 300 $('#logfilesUploadCancel').click(GnuBoat.Webclient.private.logfilesUploadFormClear); 301 $("#logfilesUploadForm").validate({ 302 submitHandler: GnuBoat.Webclient.private.uploadLogfile, 303 invalidHandler: function(){ 304 var errors = validator.numberOfInvalids(); 305 if (errors) { 306 var message = errors == 1 ? 'You missed 1 field. It has been highlighted' : 'You missed ' + errors + ' fields. They have been highlighted'; 307 $('#logfilesUploadMessage').text(message); 308 $('#logfilesUploadMessage').show(); 309 setTimeout(function(){ $('#logfilesUploadMessage').hide(); $('#logfilesUploadMessage').empty(); }, 60000); 310 } 311 }, 312 rules: { 313 logfilesUploadLogfile: { 314 required: true, 315 minlength: 1 316 }, 317 logfilesUploadWater: { 318 required: true 319 }, 320 logfilesUploadGauge: { 321 required: true 322 }, 323 logfilesUploadGaugeHeight: { 324 required: true, 325 number: true 326 }, 327 328 } 329 }); 330 189 331 $("#rendering").empty(); 190 332 var width = $("#rendering").width(); … … 224 366 GnuBoat.Webclient.getMapInfos(); 225 367 GnuBoat.Webclient.displayDataGet(); 368 GnuBoat.Webclient.mapserviceStatusGet(); 226 369 if(GnuBoat.Webclient.private.timerDisplay == null) 227 GnuBoat.Webclient.private.timerDisplay = setInterval(GnuBoat.Webclient.displayDataGet, 10000); 370 GnuBoat.Webclient.private.timerDisplay = setInterval(GnuBoat.Webclient.displayDataGet, 3000); 371 if(GnuBoat.Webclient.private.timerTracks == null) 372 GnuBoat.Webclient.private.timerTracks = setInterval(GnuBoat.Webclient.trackGet, 30000); 373 if(GnuBoat.Webclient.private.timerMapservice == null) 374 GnuBoat.Webclient.private.timerMapservice = setInterval(GnuBoat.Webclient.mapserviceStatusGet, 30000); 228 375 GnuBoat.Webclient.logfilesLoad(); 229 376 … … 246 393 */ 247 394 GnuBoat.Webclient.private = { 395 // Nautical mile in m 396 nauticalMile: 1.852001 * 1000, 397 248 398 map: null, 249 399 mapLayerCurrent: null, … … 255 405 mapHotlineGradientDefault: { absolute: false, palette: { 0.0: 'green', 0.5: 'yellow', 1.0: 'red' } }, 256 406 dataMappings: { 257 speed throughwater: {display: true, map: true, mapActive: false, titleLong: "Speed Through Water", titleShort: "STW", unit: "kts"},258 speed overground: {display: true, map: true, mapActive: false, titleLong: "Speed Over Ground", titleShort: "SOG", unit: "kts"},259 water depth: {407 speedThroughWater: {display: true, map: true, mapActive: false, titleLong: "Speed Through Water", titleShort: "STW", unit: "kts"}, 408 speedOverGround: {display: true, map: true, mapActive: false, titleLong: "Speed Over Ground", titleShort: "SOG", unit: "kts"}, 409 waterDepth: { 260 410 display: true, map: true, mapActive: true, titleLong: "Waterdepth", titleShort: "Depth", unit: "m", 261 411 gradient: { … … 264 414 } 265 415 }, 266 water temperature: {display: true, map: true, mapActive: false, titleLong: "Watertemperature", titleShort: "Water", unit: "°C"},267 gps fix: {display: true, map: false, mapActive: false, titleLong: "GPS Fix", titleShort: "Fix", unit: ""},416 waterTemperature: {display: true, map: true, mapActive: false, titleLong: "Watertemperature", titleShort: "Water", unit: "°C"}, 417 gpsFix: {display: true, map: false, mapActive: false, titleLong: "GPS Fix", titleShort: "Fix", unit: ""}, 268 418 }, 269 419 serverBaseUrl: null, … … 284 434 displayDataSet: function(data) 285 435 { 286 // if(!Array.isArray(data) || data.length < 1){287 // console.log("No data array returned!");288 // console.log(data);289 // return;290 // }291 if(("error" in data) && data["error"] == 1){292 GnuBoat.displayMessage('<span class="error">Failed to get display data and tracks: '+ data["errormessage"] +'</span>');293 return;294 }295 296 436 var keysDisplay = []; 297 437 for(var key in GnuBoat.Webclient.private.dataMappings){ … … 300 440 } 301 441 302 if(!("lastvalid" in data)){ 303 console.log("No last valid values given!"); 304 } 305 else{ 306 var lastValid = data["lastvalid"]; 307 for(var i = 0; i < keysDisplay.length; i++){ 308 var key = keysDisplay[i]; 309 var value = lastValid[key]; 310 if($.isNumeric(value)){ 311 var text = value.toFixed(1); 312 if(key == "watertemperature"){ 313 text = value.toFixed(0); 314 } 315 $("#display #"+ key +" #value").text(text); 442 for(var i = 0; i < keysDisplay.length; i++){ 443 var key = keysDisplay[i]; 444 if(!key in data){ continue; } 445 var value = data[key]; 446 if($.isNumeric(value)){ 447 var text = value.toFixed(1); 448 if(key == "waterTemperature"){ 449 text = value.toFixed(0); 316 450 } 317 else if(key == "gpsfix"){ 318 $("#display #"+ key +" #value").text(value); 319 } 320 } 321 } 322 323 // map displays logged data 451 else if(key == "speedThroughWater" || key == "speedOverGround"){ 452 text = (value / GnuBoat.Webclient.private.nauticalMile * 3600.0).toFixed(1) 453 } 454 $("#display #"+ key +" #value").text(text); 455 } 456 else if(key == "gpsFix"){ 457 $("#display #"+ key +" #value").text(value); 458 } 459 } 460 }, 461 462 trackSet: function(data) 463 { 464 // map displays logged data 324 465 if(!GnuBoat.Webclient.private.mapModusLive) 325 466 return; 326 else if(!("track" in data)){ 327 console.log("No track given!"); 328 return; 329 } 330 GnuBoat.Webclient.private.mapAddTracks(data["track"]); 331 }, 467 GnuBoat.Webclient.private.mapAddTracks(data); 468 }, 332 469 333 470 mapSetup: function () 334 471 { 335 472 var mapMetadataIndex = $("#mapSelect").val(); 473 if(!mapMetadataIndex){ return; } 336 474 if(GnuBoat.Webclient.private.mapsMetadata == null){ 337 475 console.log("No mapsMetadata set"); … … 345 483 var mapMetadata = GnuBoat.Webclient.private.mapsMetadata[mapMetadataIndex]; 346 484 347 var latitudeTop = mapMetadata["bounds"][3]; 348 var latitudeBottom = mapMetadata["bounds"][1]; 349 var longitudeLeft = mapMetadata["bounds"][0]; 350 var longitudeRight = mapMetadata["bounds"][2]; 351 352 var mapZoomMin = mapMetadata["minzoom"]; 353 var mapZoomMax = mapMetadata["maxzoom"]; 485 var latitudeTop = 90; 486 var latitudeBottom = -90; 487 var longitudeLeft = -180; 488 var longitudeRight = 180; 489 if('bounds' in mapMetadata){ 490 latitudeTop = mapMetadata.bounds[3]; 491 latitudeBottom = mapMetadata.bounds[1]; 492 longitudeLeft = mapMetadata.bounds[0]; 493 longitudeRight = mapMetadata.bounds[2]; 494 } 495 496 var mapZoomMin = ('minzoom' in mapMetadata) ? mapMetadata.minzoom : 0; 497 var mapZoomMax = ('maxzoom' in mapMetadata) ? mapMetadata.maxzoom : 19; 354 498 355 499 var latitudeCenter = (latitudeTop - latitudeBottom)/2 + latitudeBottom; … … 378 522 minZoom: mapZoomMin, maxZoom: mapZoomMax, 379 523 bounds: GnuBoat.Webclient.private.mapBounds, 380 attribution: mapMetadata["name"], 381 opacity: 0.85 524 attribution: mapMetadata.name, 525 opacity: 0.85, 526 tms: true, 382 527 }).addTo(GnuBoat.Webclient.private.map); 383 528 if(GnuBoat.Webclient.private.mapControl != null) … … 398 543 var selected = "selected"; 399 544 data.forEach(function(value, index){ 400 $("<option value=\""+ index.toString() +"\" "+ selected +">"+ value ["name"]+"</option>").appendTo("#mapSelect");545 $("<option value=\""+ index.toString() +"\" "+ selected +">"+ value.name +"</option>").appendTo("#mapSelect"); 401 546 selected = ""; 402 547 }); … … 544 689 $('<option value="live"'+ selectedString +'>Live View</option>').appendTo("#mapModusSelect"); 545 690 if(!Array.isArray(data) || data.length < 1){ 546 console.log(data);547 691 return; 548 692 } … … 579 723 } 580 724 GnuBoat.Webclient.private.mapModusLive = false; 581 $.post({ 582 url: GnuBoat.Webclient.private.serverBaseUrl +'?request=replay', 583 data: { logfile: modus }, 584 success: function(data){ 585 // if(!Array.isArray(data) || data.length < 1){ 586 // console.log("No data array returned!"); 587 // console.log(data); 588 // return; 589 // } 590 if(("error" in data) && data["error"] == 1){ 591 GnuBoat.displayMessage('<span class="error">Failed to get logged tracks: '+ data["errormessage"] +'</span>'); 592 return; 593 } 594 if(!("track" in data)){ 595 console.log("No track given!"); 596 return; 597 } 598 GnuBoat.Webclient.private.mapAddTracks(data["track"]); 599 } 600 }); 725 $.getJSON({ 726 url: GnuBoat.Webclient.private.serverBaseUrl +'logfiles/'+ modus +'/track', 727 }).done(GnuBoat.Webclient.private.mapAddTracks).fail(GnuBoat.Webclient.private.displayHttpError); 601 728 }, 602 729 … … 627 754 for(var i = 0; i < keysMap.length; i++){ 628 755 var key = keysMap[i]; 756 if(!key in track[time]){ continue; } 629 757 var value = track[time][key]; 630 758 if(!$.isNumeric(value)) … … 638 766 else if(minimas[key] > value) 639 767 minimas[key] = value; 640 points[key].push(new L.latLng(track[time] ["latitude"], track[time]["longitude"], value));641 if(key == "water depth")642 densityPoints.push({latitude: track[time] ["latitude"], longitude: track[time]["longitude"], depth: value});768 points[key].push(new L.latLng(track[time].position[1], track[time].position[0], value)); 769 if(key == "waterDepth") 770 densityPoints.push({latitude: track[time].position[1], longitude: track[time].position[0], depth: value}); 643 771 } 644 772 } … … 701 829 } 702 830 var gradient = GnuBoat.Webclient.private.mapHotlineGradientDefault.palette; 703 if("gradient" in GnuBoat.Webclient.private.dataMappings ["waterdepth"])704 gradient = GnuBoat.Webclient.private.dataMappings ["waterdepth"]["gradient"];705 GnuBoat.Webclient.private.drawDensityEstimation(densityPoints, gradient, maximas["water depth"], minimas["waterdepth"]);831 if("gradient" in GnuBoat.Webclient.private.dataMappings.waterDepth) 832 gradient = GnuBoat.Webclient.private.dataMappings.waterDepth.gradient; 833 GnuBoat.Webclient.private.drawDensityEstimation(densityPoints, gradient, maximas["waterDepth"], minimas["waterDepth"]); 706 834 }, 707 835 … … 777 905 } 778 906 }, 907 908 /** 909 * @brief Fetches waters from deviceservice and adds them to the autocompleter 910 */ 911 uploadAutocompleteWaterGet: function(request, response) 912 { 913 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 914 displayMessage('<span class="error">No server set/found</span>'); 915 return; 916 } 917 $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"/mapservice/waters?name="+ request.term, function(data){ 918 var results = Array(); 919 data.forEach(function(value, index){ 920 results.push({ 'label': value.name, 'water': value }); 921 }); 922 response(results); 923 }).fail(GnuBoat.Webclient.private.displayHttpError); 924 }, 925 926 uploadAutocompleteWaterSelected: function(event, ui) 927 { 928 if(ui.item.water.gauges.length < 1){ 929 $('#logfilesUploadMessage').text('Water ' + ui.item.water.name +' has no gauges. Please add them on the mapservice first!'); 930 $('#logfilesUploadMessage').show(); 931 setTimeout(function(){ $('#logfilesUploadMessage').hide(); $('#logfilesUploadMessage').empty(); }, 60000); 932 933 $('#logfilesUploadGauge').prop('disabled', true); 934 $('#logfilesUploadGaugeHeight').prop('disabled', true); 935 936 return; 937 } 938 $('#logfilesUploadWater').attr('data-waterId', ui.item.water.waterId); 939 var gauges = Array(); 940 ui.item.water.gauges.forEach(function(value, index){ 941 gauges.push({ 'value': value.name, 'gauge': value}); 942 }); 943 $('#logfilesUploadGauge').prop('disabled', false); 944 $('#logfilesUploadGauge').autocomplete('option', 'source', gauges); 945 $('#logfilesUploadGauge').autocomplete('search', ''); 946 }, 947 948 uploadAutocompleteGaugeSelected: function(event, ui) 949 { 950 $('#logfilesUploadGauge').attr('data-gaugeId', ui.item.gauge.gaugeId); 951 $('#logfilesUploadGaugeHeightReference').text('Reference Height: '+ ui.item.gauge.referenceWaterLevelGaugeHeight.toFixed(2).toString()); 952 $('#logfilesUploadGaugeHeight').prop('disabled', false); 953 }, 954 955 uploadLogfile: function() 956 { 957 var logCreation = { 958 'water': Number($('#logfilesUploadWater').attr('data-waterId')), 959 'gauge': Number($('#logfilesUploadGauge').attr('data-gaugeId')), 960 'gaugeHeight': Number($('#logfilesUploadGaugeHeight').val()), 961 'delete': $('#logfilesUploadDelete').checked, 962 'comment': $('#logfilesUploadComment').val(), 963 'logfile': $('#logfilesUploadLogfile').val(), 964 } 965 $.ajax({ 966 type: 'POST', 967 url: GnuBoat.Webclient.private.serverBaseUrl +'mapservice/log', 968 data: JSON.stringify(logCreation), 969 contentType: 'application/json', 970 dataType: 'json', 971 }).done(function(data){ 972 GnuBoat.displayMessage('<h2>Log '+ logCreation.logfile +' uploaded successfully</h2>'); 973 GnuBoat.Webclient.private.logfilesUploadFormClear(); 974 GnuBoat.Webclient.logfilesLoad(); 975 }).fail(function(error){ 976 GnuBoat.Webclient.private.displayHttpError(error); 977 }); 978 }, 979 980 981 logfilesUploadFormClear: function(){ 982 $('#logfilesUploadForm').hide(); 983 $('#logfilesUploadStart').prop('disabled', false); 984 // clear up form 985 $('#logfilesUploadLogfile').val(''); 986 $('#logfilesUploadFieldset').find('input:text').val(''); 987 $('#logfilesUploadGaugeHeight').val(''); 988 $('#logfilesUploadDelete').prop('checked', true); 989 $('#logfilesUploadFieldset').find('textarea').val(''); 990 $('#logfilesUploadGaugeHeightReference').text('') 991 }, 992 993 /** 994 * @brief Shows an HttpError 995 */ 996 displayHttpError: function(error, status) 997 { 998 if(error.status == 504){ 999 // ignore 504 caused by Mapservice, because there is a status icon in the 1000 // display section 1001 console.log('Mapservice is not available. Status is: ' + error.statusText); 1002 return; 1003 } 1004 if(error && 'responseJSON' in error){ 1005 error = error.responseJSON; 1006 } 1007 if(!error){ 1008 console.log(error); 1009 error = {}; 1010 error.status = 0; 1011 error.detail = 'Unknown error occured'; 1012 } 1013 var detail = "No details available."; 1014 if(error.detail != null && error.detail != undefined){ detail = error.detail; } 1015 GnuBoat.displayMessage('<h2 class="error">Error '+ error.title +' ('+ error.status.toString() +')</h2><p>'+ detail +'</p>'); 1016 } 779 1017 };
Note:
See TracChangeset
for help on using the changeset viewer.
