add device name to upload info, remove last pieces of OSM upload functionality
authorRobert Kaiser <kairo@kairo.at>
Fri, 6 Oct 2017 21:22:20 +0000 (23:22 +0200)
committerRobert Kaiser <kairo@kairo.at>
Fri, 6 Oct 2017 21:22:20 +0000 (23:22 +0200)
index.html
js/ui.js
style/lantea.css

index 5cb6382..969178f 100644 (file)
@@ -49,7 +49,7 @@
 </select>
 <p class="dialogHelp">Public Domain tracks can be forwarded by the server
 operator to any other services, e.g. OpenStreetMap.</p>
-<label for="uploadDesc">Description:</label>
+<label for="uploadDesc">Comment:</label>
 <input type="text" id="uploadDesc" maxlength="255" size="25"
        value="Lantea Maps">
 <input type="button" id="uploadDialogUploadButton" value="Upload Track"
@@ -101,14 +101,13 @@ operator to any other services, e.g. OpenStreetMap.</p>
 <input type="button" id="clearCacheButton" value="Clear Cached Maps"
        onclick="gTileService.clearDB();">
 </p>
-<div id="uploadSettingsArea" class="debugHide">
-<p class="settingsSubTitle">OpenStreetMap Track Upload:</p>
-<label for="uploadUser">User name:</label>
-<input type="text" id="uploadUser" maxlength="255"
-       onchange="setUploadField(this);"><br/>
-<label for="uploadPwd">Password:</label>
-<input type="password" id="uploadPwd" maxlength="255"
+<div id="uploadSettingsArea">
+<p class="settingsSubTitle">Track Upload:</p>
+<label for="uploadDevName">Device name:</label>
+<input type="text" id="uploadDevName" maxlength="255" placeholder="My Device"
        onchange="setUploadField(this);">
+<p class="dialogHelp">The device name enables you to tell apart tracks you may
+upload from multiple devices.</p>
 </div>
 </div>
 
index a44a462..22e46a1 100644 (file)
--- a/js/ui.js
+++ b/js/ui.js
@@ -14,13 +14,6 @@ var gTrackUpdateInterval;
 var gAction, gActionLabel;
 var gBackendURL = "https://backend.lantea.kairo.at";
 var gAuthClientID = "lantea";
-var gOSMAPIURL = "https://api.openstreetmap.org/";
-var gOSMOAuthData = {
-    oauth_consumer_key: "6jjWwlbhGqyYeCdlFE1lTGG6IRGOv1yKpFxkcq2z",
-    oauth_secret: "A21gUeDM6mdoQgbA9uF7zJ13sbUQrNG7QQ4oSrKA",
-    url: "https://www.openstreetmap.org",
-    landing: "auth-done.html",
-}
 
 window.onload = function() {
   if (/\/login\.html/.test(window.location)) {
@@ -85,11 +78,6 @@ window.onload = function() {
     // Call any UI preparation that needs the backend.
   });
 
-  if (gDebug) {
-    // Note that GPX upload returns an error 500 on the dev API right now.
-    gOSMAPIURL = "http://api06.dev.openstreetmap.org/";
-  }
-
   gAction.addEventListener("dbinit-done", initMap, false);
   gAction.addEventListener("mapinit-done", postInit, false);
   console.log("starting DB init...");
@@ -106,17 +94,11 @@ function postInit(aEvent) {
   gActionLabel.textContent = "";
   gAction.style.display = "none";
   setTracking(document.getElementById("trackCheckbox"));
-  gPrefs.get(gDebug ? "osm_dev_user" : "osm_user", function(aValue) {
+  gPrefs.get("devicename", function(aValue) {
     if (aValue) {
-      document.getElementById("uploadUser").value = aValue;
-      document.getElementById("uploadTrackButton").disabled = false;
+      document.getElementById("uploadDevName").value = aValue;
     }
   });
-  gPrefs.get(gDebug ? "osm_dev_pwd" : "osm_pwd", function(aValue) {
-    var upwd = document.getElementById("uploadPwd");
-    if (aValue)
-      document.getElementById("uploadPwd").value = aValue;
-  });
 }
 
 window.onresize = function() {
@@ -400,12 +382,8 @@ var uiEvHandler = {
 
 function setUploadField(aField) {
   switch (aField.id) {
-    case "uploadUser":
-      gPrefs.set(gDebug ? "osm_dev_user" : "osm_user", aField.value);
-      document.getElementById("uploadTrackButton").disabled = !aField.value.length;
-      break;
-    case "uploadPwd":
-      gPrefs.set(gDebug ? "osm_dev_pwd" : "osm_pwd", aField.value);
+    case "uploadDevName":
+      gPrefs.set("devicename", aField.value);
       break;
   }
 }
@@ -497,7 +475,8 @@ function uploadTrack() {
   var desc = document.getElementById("uploadDesc").value;
   formData.append("comment",
                   desc.length ? desc : "Track recorded via Lantea Maps");
-  //formData.append("devicename", "");
+  formData.append("devicename",
+                  document.getElementById("uploadDevName").value);
   formData.append("public",
                   document.getElementById("uploadPublic").value);
 
@@ -673,7 +652,14 @@ function fetchBackend(aEndpoint, aMethod, aSendData, aCallback, aCallbackForward
       var result = {};
       if (XHR.getResponseHeader("Content-Type") == "application/json") {
         // Got a JSON object, see if we have success.
-        result = JSON.parse(XHR.responseText);
+        try {
+          result = JSON.parse(XHR.responseText);
+        }
+        catch (e) {
+          console.log(e);
+          result = {"error": e,
+                    "message": XHR.responseText};
+        }
       }
       else {
         result = XHR.responseText;
index c13f814..8abba24 100644 (file)
@@ -283,6 +283,45 @@ h1 {
   color: #404040;
 }
 
+.menuDrawer input[type="text"],
+.menuDrawer input[type="number"] {
+  vertical-align: middle;
+  background-image: none;
+  background-color: rgba(204, 204, 204, .7);
+  color: #404040;
+  padding: 1px .5em;
+  margin: 1px 0;
+  border: 1px solid #CCCCCC;
+  border-radius: 3px;
+}
+
+.menuDrawer input[type="text"] {
+  text-align: left;
+}
+
+.menuDrawer input[type="number"] {
+  text-align: right;
+}
+
+.menuDrawer input[type="text"]:disabled,
+.menuDrawer input[type="number"]:disabled {
+  background-color: rgba(204, 204, 204, .1);
+  color: rgba(204, 204, 204, .5);
+  border: 1px solid rgba(255, 255, 255, .5);
+}
+
+.menuDrawer input[type="text"]:not(:disabled):hover,
+.menuDrawer input[type="number"]:not(:disabled):hover {
+  border: 1px solid #FFFFFF;
+}
+
+.menuDrawer input[type="text"]:not(:disabled):focus,
+.menuDrawer input[type="number"]:not(:disabled):focus {
+  background-color: rgba(204, 204, 255, .8);
+  border: 1px solid #FFFFFF;
+  color: #202020;
+}
+
 #trackData {
   margin: 0;
 }
@@ -332,7 +371,7 @@ h1 {
   bottom: 5px;
   right: .5em;
   margin: 0;
-  font-size: small;
+  font-size: .8em;
   opacity: .66;
   z-index: 2;
   background-color: rgba(255, 255, 255, 1);
@@ -371,7 +410,7 @@ h1 {
 
 .dialogHelp {
   margin: .5em 0;
-  font-size: small;
+  font-size: .8em;
   opacity: .66;
 }
 
@@ -399,6 +438,5 @@ h1 {
   #copyright {
     bottom: 1px;
     right: 1px;
-    font-size: 8px;
   }
 }