diff --git a/client_side/app.py b/client_side/app.py index 0d060bf..a94eaf3 100644 --- a/client_side/app.py +++ b/client_side/app.py @@ -40,6 +40,25 @@ def handle_my_custom_namespace_event(): emit("new", json.dumps(json_data), namespace="/denunciations_socket") + +@socketio.on("check",namespace="/complaints_socket") +def denunciation_handle(msg): + + change,data = file_check("complaints") + if change: + emit("new", data, namespace="/complaints_socket") + + +@socketio.on('connect', namespace='/complaints_socket') +def handle_my_custom_namespace_event(): + print("[INFO]: Received socket connection!") + + src = os.path.join(src_path,"complaints.json") + with open(src,"r") as f: + json_data = json.loads(f.read()) + + emit("new", json.dumps(json_data), namespace="/complaints_socket") + @app.route('/gui/') def send_img(path): return send_from_directory('interface/UserData', path) diff --git a/client_side/interface/UserData/complaints.html b/client_side/interface/UserData/complaints.html new file mode 100644 index 0000000..d0e9e75 --- /dev/null +++ b/client_side/interface/UserData/complaints.html @@ -0,0 +1,316 @@ + + + + + Complaints + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/client_side/interface/UserData/denunciation_map.html b/client_side/interface/UserData/denunciation.html similarity index 97% rename from client_side/interface/UserData/denunciation_map.html rename to client_side/interface/UserData/denunciation.html index caf5d13..76e206b 100644 --- a/client_side/interface/UserData/denunciation_map.html +++ b/client_side/interface/UserData/denunciation.html @@ -40,21 +40,10 @@ max-height: 150px; } - .close { - /* Position it in the top right corner outside of the modal */ - float:right; - right: 25px; - top: 0; - color: #000; - font-size: 35px; - font-weight: bold; - margin-top:10px; - } - - .title{ text-align: left; } + td{ padding: 20px 10px; } @@ -71,15 +60,18 @@ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ padding-top: 60px; } + #table,#table-user{ background: white; padding: 40px 60px; } + #content, #user-content{ display: inline-block; margin-top: 125px; background: white; } + diff --git a/client_side/interface/UserData/denunciation_view.html b/client_side/interface/UserData/denunciation_view.html deleted file mode 100644 index e512386..0000000 --- a/client_side/interface/UserData/denunciation_view.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - Denunction Info - - - - -Denunciated by

-Information:
-

-Emergency Type:

-Priority:
- - - - - diff --git a/client_side/interface/UserData/voting_results.html b/client_side/interface/UserData/votings.html similarity index 100% rename from client_side/interface/UserData/voting_results.html rename to client_side/interface/UserData/votings.html diff --git a/server_side/api/app.py b/server_side/api/app.py index 030ece0..081b25c 100644 --- a/server_side/api/app.py +++ b/server_side/api/app.py @@ -47,6 +47,6 @@ if __name__ == '__main__': api.add_resource(complaint.Complaint,"/complaint","/complaint/") api.add_resource(complaint.Complaints,"/complaints","/complaints/") - api.add_resource(complaint.ComplaintsAdmin,"/complaints_admin","/complaints_admin/") + api.add_resource(complaint.ComplaintsUpdate,"/complaints_update","/complaints_update/") app.run(host='0.0.0.0', port=5000, ssl_context=context) diff --git a/server_side/api/modules/complaint.py b/server_side/api/modules/complaint.py index ee15d77..7ec761b 100644 --- a/server_side/api/modules/complaint.py +++ b/server_side/api/modules/complaint.py @@ -93,7 +93,7 @@ def process_img(img_base64): index = np.where(output_dict['detection_classes'] == i)[0][0] score = output_dict['detection_scores'][index] if score > 0.3: - defects.append(score) + defects.append(i) priority = sum(defects) // 0.5 if priority > 10: @@ -105,7 +105,6 @@ def process_img(img_base64): class Complaint(Resource): def post(self): - complaint = {} args = request.form.to_dict() complaint = args @@ -135,6 +134,12 @@ class Complaints(Resource): return complaints[id] -class ComplaintsAdmin(Resource): +class ComplaintsUpdate(Resource): + def get(self): + args = request.args + complaints[args.get("id")][int(args.get("index"))]["response"]["message"] = args.get("message") + complaints[args["id"]][int(args["index"])]["response"]["status"] = True + with open('modules/databases/complaints.json', 'w') as complaints_file: + json.dump(complaints, complaints_file, indent=4) + return - def get(self): return complaints \ No newline at end of file diff --git a/server_side/api/modules/databases/complaints.json b/server_side/api/modules/databases/complaints.json index 092c15d..72135b5 100644 --- a/server_side/api/modules/databases/complaints.json +++ b/server_side/api/modules/databases/complaints.json @@ -6,8 +6,9 @@ "lat": "37.2482491", "content": "dddddddddddddddd", "response": { - "status": false, - "priority": 7 + "status": true, + "priority": 7, + "message": "Reviewed data" }, "datetime": "Jun-04-12:56 PM-2019" },