Commit 31baa14fe818b56f7cbb79304692e4b881371dc9

Authored by kristinlaahneolsen
1 parent e5f78946

Nå er det mulig å slette hendelser fra databasen. Jeg har gjort klart det samme …

…for vurderinger i koden, men oppdaget at dette ikke var implementert i Api. Spørsmålet er da om vi skal legge til dette eller om det er unødvendig?
Risiko/app/src/main/java/activity/Evaluations.java
1 1 package activity;
2 2  
  3 +import android.content.DialogInterface;
3 4 import android.content.Intent;
4 5 import android.graphics.Typeface;
5 6 import android.support.v7.app.AlertDialog;
... ... @@ -31,6 +32,7 @@ public class Evaluations extends AppCompatActivity {
31 32 TextView tvNameOfActivity;
32 33 Button btnNewEvaluation;
33 34 DatabaseSource dbs;
  35 + String id;
34 36  
35 37 @Override
36 38 protected void onCreate(Bundle savedInstanceState) {
... ... @@ -60,6 +62,8 @@ public class Evaluations extends AppCompatActivity {
60 62 System.out.println(e.getTitle());
61 63 if (e.getAssociatedactivity().equals(activityId))
62 64 associatedEvaluations.add(e);
  65 + id = e.getId();
  66 + //System.out.println("HALLOOOOOOOO" + uuid);
63 67 }
64 68 }
65 69 insertEvaluations(associatedEvaluations);
... ... @@ -166,8 +170,28 @@ public class Evaluations extends AppCompatActivity {
166 170 new AlertDialog.Builder(this)
167 171 .setTitle(R.string.delete)
168 172 .setMessage(R.string.areYouSure)
169   - .setPositiveButton(R.string.yes, null)
170   - //TODO IMPLEMENTER SLETTING AV SAK
  173 + .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
  174 + @Override
  175 + public void onClick(DialogInterface dialogInterface, int i) {
  176 + finish();
  177 +
  178 + /*
  179 + //TODO: HER ER DET KLART FOR SLETTING AV VURDERING HVIS VI TAR HØYDE FOR DET I API. OBS, bytt ut id med rett string
  180 + Api.get().deleteEvaluation(id).enqueue(new Callback<String>() {
  181 + @Override
  182 + public void onResponse(Call<String> call, Response<String> response) {
  183 + finish();
  184 + }
  185 +
  186 + @Override
  187 + public void onFailure(Call<String> call, Throwable t) {
  188 + //Something went completely south (maybe you lost internet connection)
  189 + Log.d("Error", t.getMessage());
  190 + finish();
  191 + }
  192 + });*/
  193 + }
  194 + })
171 195 .setNegativeButton(R.string.no, null)
172 196 .show();
173 197 }
... ...
Risiko/app/src/main/java/activity/Incident.java
1 1 package activity;
2 2  
  3 +import android.content.DialogInterface;
3 4 import android.support.v7.app.AlertDialog;
4 5 import android.support.v7.app.AppCompatActivity;
5 6 import android.os.Bundle;
... ... @@ -27,6 +28,7 @@ public class Incident extends AppCompatActivity {
27 28 ListView lv;
28 29 String chosenEventId;
29 30 DatabaseSource dbs;
  31 + String id;
30 32  
31 33 @Override
32 34 protected void onCreate(Bundle savedInstanceState) {
... ... @@ -101,17 +103,34 @@ public class Incident extends AppCompatActivity {
101 103 AlertDialog alert = alertDialogBuilder.create();
102 104 alert.show();
103 105  
104   - }
  106 + }
105 107  
106 108  
107 109 private void deleteEventDialog() {
108 110 new AlertDialog.Builder(this)
109 111 .setTitle(R.string.delete)
110 112 .setMessage(R.string.areYouSureEvent)
111   - .setPositiveButton(R.string.yes, null)
  113 + .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
  114 + @Override
  115 + public void onClick(DialogInterface dialogInterface, int i) {
  116 +
  117 + //TODO: ORDNE DETTE SLIK AT VURDERINGER FAKTISK BLIR SLETTET. MÅ HENTE UT UUID
  118 + Api.get().deleteIncident(chosenEventId).enqueue(new Callback<String>() {
  119 + @Override
  120 + public void onResponse(Call<String> call, Response<String> response) {
  121 + finish();
  122 + }
  123 +
  124 + @Override
  125 + public void onFailure(Call<String> call, Throwable t) {
  126 + //Something went completely south (maybe you lost internet connection)
  127 + Log.d("Error", t.getMessage());
  128 + finish();
  129 + }
  130 + });
  131 + }
  132 + })
112 133 .setNegativeButton(R.string.no, null)
113 134 .show();
114 135 }
115   - }
116   -
117   -
  136 +}
... ...
Risiko/app/src/main/java/api/Endpoints.java
... ... @@ -27,10 +27,10 @@ public interface Endpoints {
27 27 //String BASEURL = "http://172.20.10.4:3000/";
28 28  
29 29 //HOS KRISTIN
30   - //String BASEURL = "http://192.168.84.58:3000/";
  30 + String BASEURL = "http://192.168.84.60:3000/";
31 31  
32 32 //ØYVIN FIX
33   - String BASEURL ="http://risikoapi.harm.no/";
  33 + //String BASEURL ="http://risikoapi.harm.no/";
34 34  
35 35  
36 36 @GET("evaluation")
... ... @@ -60,7 +60,11 @@ public interface Endpoints {
60 60  
61 61  
62 62 @DELETE("incident/{id}")
63   - Call<String> deleteIncident(@Path("uuid") String uuid);
  63 + Call<String> deleteIncident(@Path("id") String id);
  64 +
  65 + @FormUrlEncoded
  66 + @DELETE("evaluation/{id}")
  67 + Call<String> deleteEvaluation(@Path("id") String id);
64 68  
65 69  
66 70 }
... ...
Risiko/app/src/main/java/dataclasses/Evaluation.java
... ... @@ -16,6 +16,8 @@ public class Evaluation {
16 16 String title;
17 17 String outcome;
18 18 String measures;
  19 + String uuid;
  20 +
19 21 int consequence;
20 22 int probability;
21 23  
... ... @@ -67,6 +69,7 @@ public class Evaluation {
67 69 return consequence;
68 70 }
69 71  
  72 +
70 73 public String getConsequenceString() {
71 74 switch (consequence) {
72 75 case CONSEQUENCE_HARMLESS: return "Ufarlig";
... ... @@ -105,3 +108,6 @@ public class Evaluation {
105 108 this.outcome = outcome;
106 109 }
107 110 }
  111 +
  112 +
  113 +
... ...
Risiko/app/src/main/res/layout/activity_new_incident.xml
... ... @@ -56,7 +56,7 @@
56 56 <LinearLayout
57 57 android:padding="10dp"
58 58 android:background="@color/colorLightGray"
59   - android:layout_marginVertical="35dp"
  59 + android:layout_marginVertical="25dp"
60 60 android:layout_width="match_parent"
61 61 android:layout_height="wrap_content"
62 62 android:orientation="horizontal">
... ... @@ -75,6 +75,32 @@
75 75  
76 76 </LinearLayout>
77 77  
  78 +
  79 + <LinearLayout
  80 + android:padding="10dp"
  81 + android:background="@color/colorLightGray"
  82 + android:layout_marginTop="5dp"
  83 + android:layout_marginBottom="25dp"
  84 + android:layout_width="match_parent"
  85 + android:layout_height="wrap_content"
  86 + android:orientation="horizontal">
  87 +
  88 + <TextView
  89 +
  90 + android:id="@+id/tv_read_access"
  91 + android:layout_width="wrap_content"
  92 + android:layout_height="wrap_content"
  93 + android:text="Kan leses av:" />
  94 +
  95 + <Spinner
  96 + android:id="@+id/spinner_read_access"
  97 + android:layout_width="fill_parent"
  98 + android:layout_height="wrap_content" />
  99 +
  100 + </LinearLayout>
  101 +
  102 +
  103 +
78 104 <Button
79 105 android:id="@+id/btn_newIncident"
80 106 android:layout_width="wrap_content"
... ...
restApi/.idea/workspace.xml
... ... @@ -2,15 +2,8 @@
2 2 <project version="4">
3 3 <component name="ChangeListManager">
4 4 <list default="true" id="0e20d303-9de8-4113-bfd9-019e72b304dc" name="Default" comment="">
5   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Evaluations.java" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Evaluations.java" />
6   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Incident.java" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Incident.java" />
7 5 <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/api/Endpoints.java" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/api/Endpoints.java" />
8   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/res/drawable/ic_delete.xml" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/res/drawable/ic_delete.xml" />
9   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/res/drawable/ic_edit.xml" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/res/drawable/ic_edit.xml" />
10   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/res/layout/evaluationlist.xml" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/res/layout/evaluationlist.xml" />
11   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/res/layout/popup_evaluation.xml" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/res/layout/popup_evaluation.xml" />
12   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/res/layout/popup_event.xml" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/res/layout/popup_event.xml" />
13   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/res/values/strings.xml" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/res/values/strings.xml" />
  6 + <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
14 7 </list>
15 8 <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
16 9 <option name="TRACKING_ENABLED" value="true" />
... ... @@ -58,8 +51,8 @@
58 51 <file leaf-file-name="routes.js" pinned="false" current-in-tab="true">
59 52 <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
60 53 <provider selected="true" editor-type-id="text-editor">
61   - <state relative-caret-position="282">
62   - <caret line="68" column="78" lean-forward="true" selection-start-line="68" selection-start-column="78" selection-end-line="68" selection-end-column="78" />
  54 + <state relative-caret-position="891">
  55 + <caret line="354" column="7" lean-forward="true" selection-start-line="354" selection-start-column="7" selection-end-line="354" selection-end-column="7" />
63 56 <folding />
64 57 </state>
65 58 </provider>
... ... @@ -77,6 +70,11 @@
77 70 </file>
78 71 </leaf>
79 72 </component>
  73 + <component name="FindInProjectRecents">
  74 + <findStrings>
  75 + <find>delete</find>
  76 + </findStrings>
  77 + </component>
80 78 <component name="Git.Settings">
81 79 <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
82 80 </component>
... ... @@ -104,7 +102,7 @@
104 102 <path value="$PROJECT_DIR$/package.json" />
105 103 </packageJsonPaths>
106 104 </component>
107   - <component name="ProjectFrameBounds">
  105 + <component name="ProjectFrameBounds" extendedState="1">
108 106 <option name="y" value="23" />
109 107 <option name="width" value="1440" />
110 108 <option name="height" value="873" />
... ... @@ -199,8 +197,8 @@
199 197 </list>
200 198 <recent_temporary>
201 199 <list size="3">
202   - <item index="0" class="java.lang.String" itemvalue="npm.api" />
203   - <item index="1" class="java.lang.String" itemvalue="npm.debug" />
  200 + <item index="0" class="java.lang.String" itemvalue="npm.debug" />
  201 + <item index="1" class="java.lang.String" itemvalue="npm.api" />
204 202 <item index="2" class="java.lang.String" itemvalue="Node.js.server.js" />
205 203 </list>
206 204 </recent_temporary>
... ... @@ -223,24 +221,24 @@
223 221 <workItem from="1541155443683" duration="1473000" />
224 222 <workItem from="1541596156631" duration="9351000" />
225 223 <workItem from="1541681303243" duration="9060000" />
226   - <workItem from="1542189792461" duration="2884000" />
  224 + <workItem from="1542189792461" duration="3677000" />
227 225 </task>
228 226 <servers />
229 227 </component>
230 228 <component name="TimeTrackingManager">
231   - <option name="totallyTimeSpent" value="24666000" />
  229 + <option name="totallyTimeSpent" value="25459000" />
232 230 </component>
233 231 <component name="ToolWindowManager">
234   - <frame x="0" y="23" width="1440" height="873" extended-state="0" />
  232 + <frame x="0" y="23" width="1440" height="873" extended-state="1" />
235 233 <editor active="true" />
236 234 <layout>
237   - <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.20014094" sideWeight="0.71465296" order="0" side_tool="false" content_ui="combo" />
  235 + <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.20014094" sideWeight="0.71128106" order="0" side_tool="false" content_ui="combo" />
238 236 <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
239 237 <window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
240 238 <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="true" content_ui="tabs" />
241   - <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3286334" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
  239 + <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.3277635" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
242 240 <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
243   - <window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.20014094" sideWeight="0.28534704" order="2" side_tool="true" content_ui="tabs" />
  241 + <window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.20014094" sideWeight="0.28871894" order="2" side_tool="true" content_ui="tabs" />
244 242 <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
245 243 <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
246 244 <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39903265" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
... ... @@ -291,8 +289,8 @@
291 289 </entry>
292 290 <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
293 291 <provider selected="true" editor-type-id="text-editor">
294   - <state relative-caret-position="282">
295   - <caret line="68" column="78" lean-forward="true" selection-start-line="68" selection-start-column="78" selection-end-line="68" selection-end-column="78" />
  292 + <state relative-caret-position="891">
  293 + <caret line="354" column="7" lean-forward="true" selection-start-line="354" selection-start-column="7" selection-end-line="354" selection-end-column="7" />
296 294 <folding />
297 295 </state>
298 296 </provider>
... ...