Browse Source

type of user content implemented on every part

pesvan 4 years ago
parent
commit
1cf6b6923d

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+update.log
+last_update.txt
+error.log
+

+ 2 - 1
map/index.html

@@ -41,7 +41,8 @@
         <a onclick="changeSidebarContent(DATA)">Data & Tagy</a><br/>
         <a onclick="changeSidebarContent(CR_NODE1)">Vytvořit poznámku</a> -
         <a onclick="changeSidebarContent(CR_PART1)">Vyznačit část cesty</a><br/>
-        <a onclick="changeSidebarContent(NODE_LIST)">Seznam poznámek</a>
+        <a onclick="changeSidebarContent(NODE_LIST)">Seznam poznámek</a> -
+        <a onclick="changeSidebarContent(IMPORT)">Hromadný import</a><br />
     </div>
     <br/>
     <div id="side-whatswrong"></div>

+ 43 - 28
map/js/OsmHiCheck.js

@@ -39,6 +39,7 @@ var cycleRelationsAreOn = false;
 
 //pomocna promenna pro zamezeni opakovemu nahravani ve stejny moment
 var canGetData = true;
+var canGetData2 = true;
 
 var selectedElement;
 
@@ -88,6 +89,7 @@ var temporaryMarker = null;
 var selectedWayToControl;
 
 var sidebarContent = null;
+var tempIcon;
 
 function initMap() {
 
@@ -119,11 +121,12 @@ function initMap() {
     /** ikony */
     layers[TRACKS].icon = L.AwesomeMarkers.icon({
         markerColor: 'green',
-        icon: 'android-walk'
+        icon: 'navigate'
     });
     layers[WARNINGS].icon = L.AwesomeMarkers.icon({
         markerColor: 'orange',
-        icon: 'ion-android-walk'
+        icon: 'navigate',
+        iconColor: 'black'
     });
     layers[ERRORS].icon = L.AwesomeMarkers.icon({
         markerColor: 'red',
@@ -134,8 +137,18 @@ function initMap() {
         icon: 'location'
     });
     layers[USERNOTES].icon = L.AwesomeMarkers.icon({
+        markerColor: 'darkpurple',
+        icon: 'compose'
+    });
+    layers[USERPARTS].icon = L.AwesomeMarkers.icon({
         markerColor: 'yellow',
-        icon: 'location'
+        icon: 'navigate',
+        iconColor: 'black'
+    });
+    tempIcon = L.AwesomeMarkers.icon({
+        markerColor: 'white',
+        icon: 'compose',
+        iconColor: 'black'
     });
 
 
@@ -267,37 +280,22 @@ function initMap() {
         id: GUIDE
     });
 
-
-
-
-
-    //ikona pro uzivatelske poznamky
-    var redIcon = L.icon({
-        iconUrl: 'js/leaflet/images/marker_red.png',
-        iconSize: [20, 37],
-        iconAnchor: [10, 37],
-        shadowUrl: 'js/leaflet/images/marker-shadow.png',
-        shadowSize: [35, 50],
-        shadowAnchor: [9, 53]
-    });
-
     /** uzivatelske poznamky **/
     layers[USERNOTES].layer = L.geoJson(null, {
         id: USERNOTES,
         pointToLayer: function (feature, latlng) {
             return L.marker(latlng, {
-                icon: redIcon
+                icon: layers[USERNOTES].icon
             }).bindPopup(
                 "<h3>Poznámka</h3>" +
+                "typ: "+ resolveSelectType(feature.properties.type) + " <br />"+
                 "poznámka: " + feature.properties.note + "<br/>" +
                 "aktuálnost poznámky:" + feature.properties.date + "<br/>" +
                 "čas vložení: " + feature.properties.timestamp + "<br/>" +
                 "uživatel: " + feature.properties.user + "<br/>" +
-                "<a onclick='deleteUserContent(CR_NODE1,"+ feature.properties.id+")'>Odstranit poznamku</a><br/>",
+                "<a onclick='deleteUserContent(CR_NODE1,"+ feature.properties.id+")'>Odstranit poznamku</a><br/>"
+
 
-                {
-                    offset: L.point(0, -37)
-                }
             );
         }
     });
@@ -358,7 +356,8 @@ function createNode(e, bind) {
         dataFromClick = bind;
         changeSidebarContent(CR_NODE2);
         temporaryMarker = L.marker(lngLatFromClick, {
-            clickable: false
+            clickable: false,
+            icon: tempIcon
         });
         temporaryMarker.addTo(map);
     }
@@ -375,6 +374,7 @@ function onEachFeature(feature, layer) {
 function onEachFeatureUserPart(feature, layer){
     layer.bindPopup(
         "<h3>Poznámka</h3>" +
+        "typ: "+ resolveSelectType(feature.properties.type) + " <br />"+
         "poznámka: " + feature.properties.note + "<br/>" +
         "aktuálnost poznámky:" + feature.properties.date + "<br/>" +
         "čas: " + feature.properties.timestamp + "<br/>" +
@@ -450,6 +450,7 @@ function mapMoved() {
  * @param type
  */
 function getSpecifics(type) {
+
     var url = 'data=' + selected[type].id + '&type=' + type;
     $.ajax({
         url: 'php/getElement.php',
@@ -460,6 +461,7 @@ function getSpecifics(type) {
         },
         complete: function () {
             changeSidebarContent(DATA);
+
         }
     });
 }
@@ -717,21 +719,24 @@ function getWaysToDraw(rid, controlType) {
         success: function (data) {
             layers[controlType].layer.addData(data);
             layers[controlType].drawn[layers[controlType].drawn.length] = rid;
-/*
-            layers[ERRORS].layer.bringToFront();
-            layers[TRACKS].layer.bringToBack();*/
-
         }
     })
 }
 
 function getGuideInfo(nid) {
+    if (!canGetData2) {
+        return;
+    }
+    canGetData2 = false;
     $.ajax({
         url: 'php/getGuideInfo.php',
         dataType: 'json',
         data: 'nid=' + nid,
         success: function(data){
             printGuideInfo(data);
+            setTimeout(function () {
+                canGetData2 = true;
+            }, 500);
         }
     });
 }
@@ -1231,7 +1236,8 @@ function saveNote() {
             lat: getFormValue('lat', 'addNote'),
             name: getFormValue('name', 'addNote'),
             note: getFormValue('note', 'addNote'),
-            date: getFormValue('date', 'addNote')
+            date: getFormValue('date', 'addNote'),
+            type: getSelectedValue()
         }, function (data) {
             if (map.hasLayer(temporaryMarker)) {
                 console.log(data);
@@ -1254,6 +1260,7 @@ function savePart() {
             name: getFormValue('name', 'addPart'),
             note: getFormValue('note', 'addPart'),
             date: getFormValue('date', 'addPart'),
+            type: getSelectedValue(),
             obj: JSON.stringify(selectedWayToControl.getSelection())
         }, function () {
             selectedWayToControl.disable();
@@ -1283,6 +1290,10 @@ function saveGuideInfo() {
 
 function validateFormPart() {
     var element = document.forms["addPart"];
+    if (!(validateSelect())){
+        setError(msgErrorSelect);
+        return false;
+    }
     if ((isEmpty(element["name"])) || (isEmpty(element["note"])) || (isEmpty(element['date']))) {
         setError(msgError);
         return false;
@@ -1333,6 +1344,10 @@ function validateFormNote() {
             return false;
         }
     }
+    if (!(validateSelect())){
+        setError(msgErrorSelect);
+        return false;
+    }
     if ((isEmpty(element["name"])) || (isEmpty(element["note"])) || (isEmpty(element["date"]))){
         setError(msgError);
         return false;

+ 8 - 0
map/new_note.html

@@ -12,10 +12,18 @@
     <div id="notice" class="notice-yellow"></div>
     <label>Zadejte jméno pro identifikaci:</label>
     <input type="text" name="name" placeholder="Jméno" maxlength="50"/>
+    <label>Vyberte nejlepe se hodici k situaci na miste nebo na mape:</label>
+    <select id="select">
+        <option value="0" selected>(Vyberte z nabidky)</option>
+        <option value="1">Vse v poradku</option>
+        <option value="2">Je zde jeden nebo vice problemu (viz. komentar)</option>
+        <option value="3">Chci jen vlozit komentar/fotku</option>
+    </select>
     <textarea name="note" placeholder="Zde vložte svou poznámku" maxlength="1000"></textarea>
     <label>Informace platná k (den/měsíc/rok):</label>
     <input type="date" name="date" maxlength="10"/>
     <label>Můžete vložit relevantní fotografie (png/jpeg). Maximalni velikost obrazku je 5MB. Obrazky presahujici jednim rozmerem 1200px budou prislusne zmenseny</label>
+    <div class="red center">Upload obrazku momentalne nefunkcni (chybi GD knihovna (abych nezapomel))</div>
 
     <input type="file" id="file-select" name="photos[]" multiple/>
     <br />

+ 7 - 0
map/new_part.html

@@ -12,6 +12,13 @@
     <div id="notice" class="notice-yellow"></div>
     <label>Zadejte jméno pro identifikaci:</label>
     <input id="name" type="text" name="name" placeholder="Jméno" maxlength="50"/>
+    <label>Vyberte nejlepe se hodici k situaci na miste nebo na mape:</label>
+    <select id="select">
+        <option value="0" selected>(Vyberte z nabidky)</option>
+        <option value="1">Vse v poradku</option>
+        <option value="2">Je zde jeden nebo vice problemu (viz. komentar)</option>
+        <option value="3">Chci jen vlozit komentar/fotku</option>
+    </select>
     <textarea name="note" placeholder="Zde vložte svou poznámku" maxlength="1000"></textarea>
     <label>Informace platná k (den/měsíc/rok):</label>
     <input type="date" name="date" maxlength="10"/>

+ 3 - 2
map/php/getNote.php

@@ -22,10 +22,10 @@ $ways['type'] = 'FeatureCollection';
 
 
 if($type==1){
-    $query_string = "SELECT id, tstamp, hi_user_id, note, date, ST_AsGeoJSON(geom)
+    $query_string = "SELECT id, tstamp, type, hi_user_id, note, date, ST_AsGeoJSON(geom)
 from hicheck.notes where hicheck.notes.id = '$note_id'";
 } else if($type==2){
-    $query_string = "SELECT id, tstamp, hi_user_id, note, date, ST_AsGeoJSON(geom)
+    $query_string = "SELECT id, tstamp, type, hi_user_id, note, date, ST_AsGeoJSON(geom)
 from hicheck.parts where hicheck.parts.id = '$note_id'";
 }
 
@@ -42,6 +42,7 @@ while($row = pg_fetch_assoc($data)){
     $prop['date']=$row['date'];
     $prop['user']=$row['hi_user_id'];
     $prop['note']=$row['note'];
+    $prop['type']=$row['type'];
     $aux['type']='Feature';
     $aux['id']  = $row['id'];
     $aux['properties']=$prop;

+ 3 - 3
map/php/saveNote.php

@@ -6,10 +6,10 @@ $lat = pg_escape_string($_POST['lat']);
 $name = pg_escape_string($_POST['name']);
 $note = pg_escape_string($_POST['note']);
 $date = pg_escape_string($_POST['date']);
+$type = pg_escape_string($_POST['type']);
 $point = "POINT $lng $lat";
-var_dump($date);
-$sql = "INSERT INTO hicheck.notes (hi_user_id, geom, note, date)
-     VALUES ('$name', ST_SetSRID(ST_MakePoint($lng,$lat), 4326),'$note', '$date')";
+$sql = "INSERT INTO hicheck.notes (hi_user_id, geom, note, date, type)
+     VALUES ('$name', ST_SetSRID(ST_MakePoint($lng,$lat), 4326),'$note', '$date', '$type')";
 
 pg_query($db, $sql);
 

+ 3 - 2
map/php/savePart.php

@@ -6,6 +6,7 @@ $obj = pg_escape_string($_POST['obj']);
 $name = pg_escape_string($_POST['name']);
 $note = pg_escape_string($_POST['note']);
 $date = pg_escape_string($_POST['date']);
+$type = pg_escape_string($_POST['type']);
 
 //zpracovani objektu souradnic jako priprava na vytvoreni linestringu
 $coords = explode('{', $obj);
@@ -37,8 +38,8 @@ foreach ($parts as $key=>$part) {
 }
 $linestring .= ")";
 
-$sql = "INSERT INTO hicheck.parts (hi_user_id, note, geom, date)
-     VALUES ('$name', '$note', ST_GeomFromText('$linestring', 4326), '$date')";
+$sql = "INSERT INTO hicheck.parts (hi_user_id, note, geom, date, type)
+     VALUES ('$name', '$note', ST_GeomFromText('$linestring', 4326), '$date', '$type')";
 
 pg_query($db, $sql);
 

+ 1 - 0
sql_import/hicheck_db_notes.sql

@@ -12,6 +12,7 @@ CREATE TABLE notes (
   password text,
   note text,
   image text,
+  type int,
   date varchar(10)
 );
 

+ 1 - 0
sql_import/hicheck_db_parts.sql

@@ -10,6 +10,7 @@ CREATE TABLE parts (
   tstamp TIMESTAMP default CURRENT_TIMESTAMP,
   hi_user_id text NOT NULL,
   note text,
+  type int,
   date varchar(10)
 );