Commit b592692b05241b01110cd54d90fb68da5b5a79d2

Authored by kristinlaahneolsen
1 parent f6784e90

Startet på redigerings-knapp og sletteknapp for brukere som vil gjøre endringer …

…på sine egne varsler. Pusher dette opp før jeg skrifter til en mer passende branch
Showing 2496 changed files with 293274 additions and 84 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 2496 files are displayed.

Risiko/app/src/main/res/drawable/ic_delete.xml 0 → 100644
  1 +<vector xmlns:android="http://schemas.android.com/apk/res/android"
  2 + android:width="24dp"
  3 + android:height="24dp"
  4 + android:viewportWidth="24.0"
  5 + android:viewportHeight="24.0">
  6 + <path
  7 + android:fillColor="#f1754d"
  8 + android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8.46,11.88l1.41,-1.41L12,12.59l2.12,-2.12 1.41,1.41L13.41,14l2.12,2.12 -1.41,1.41L12,15.41l-2.12,2.12 -1.41,-1.41L10.59,14l-2.13,-2.12zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z"/>
  9 +</vector>
... ...
Risiko/app/src/main/res/drawable/ic_edit.xml 0 → 100644
  1 +<vector xmlns:android="http://schemas.android.com/apk/res/android"
  2 + android:width="24dp"
  3 + android:height="24dp"
  4 + android:viewportWidth="24.0"
  5 + android:viewportHeight="24.0">
  6 + <path
  7 + android:fillColor="#f1754d"
  8 + android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
  9 +</vector>
... ...
Risiko/app/src/main/res/layout/evaluationlist.xml
... ... @@ -10,6 +10,21 @@
10 10 android:layout_height="wrap_content"
11 11 android:orientation="horizontal">
12 12  
  13 + <ImageView
  14 + android:layout_gravity="center_vertical"
  15 + android:layout_width="30dp"
  16 + android:layout_height="30dp"
  17 + android:background="@drawable/ic_edit"
  18 + android:layout_marginRight="10dp"/>
  19 +
  20 + <ImageView
  21 + android:layout_gravity="center_vertical"
  22 + android:layout_width="30dp"
  23 + android:layout_height="30dp"
  24 + android:background="@drawable/ic_delete"
  25 + android:layout_marginRight="10dp" />
  26 +
  27 +
13 28  
14 29 <TextView
15 30 android:id="@+id/tv_headline"
... ... @@ -17,6 +32,7 @@
17 32 android:layout_height="wrap_content"
18 33 android:layout_marginBottom="10dp"
19 34 android:text="Navn på vurdering"
  35 + android:textStyle="bold"
20 36 android:textSize="20dp" />
21 37  
22 38 <ImageView
... ...
kol075@158.39.52.99/.DS_Store 0 → 100644
No preview for this file type
kol075@158.39.52.99/.idea/misc.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="JavaScriptSettings">
  4 + <option name="languageLevel" value="JS_1_8_5" />
  5 + </component>
  6 +</project>
0 7 \ No newline at end of file
... ...
kol075@158.39.52.99/.idea/modules.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ProjectModuleManager">
  4 + <modules>
  5 + <module fileurl="file://$PROJECT_DIR$/.idea/restApi.iml" filepath="$PROJECT_DIR$/.idea/restApi.iml" />
  6 + </modules>
  7 + </component>
  8 +</project>
0 9 \ No newline at end of file
... ...
kol075@158.39.52.99/.idea/restApi.iml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<module type="WEB_MODULE" version="4">
  3 + <component name="NewModuleRootManager">
  4 + <content url="file://$MODULE_DIR$" />
  5 + <orderEntry type="inheritedJdk" />
  6 + <orderEntry type="sourceFolder" forTests="false" />
  7 + </component>
  8 +</module>
0 9 \ No newline at end of file
... ...
kol075@158.39.52.99/.idea/vcs.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="VcsDirectoryMappings">
  4 + <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
  5 + </component>
  6 +</project>
0 7 \ No newline at end of file
... ...
kol075@158.39.52.99/.idea/workspace.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ChangeListManager">
  4 + <list default="true" id="0e20d303-9de8-4113-bfd9-019e72b304dc" name="Default" comment="" />
  5 + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
  6 + <option name="TRACKING_ENABLED" value="true" />
  7 + <option name="SHOW_DIALOG" value="false" />
  8 + <option name="HIGHLIGHT_CONFLICTS" value="true" />
  9 + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
  10 + <option name="LAST_RESOLUTION" value="IGNORE" />
  11 + </component>
  12 + <component name="FUSProjectUsageTrigger">
  13 + <session id="535790383">
  14 + <usages-collector id="statistics.lifecycle.project">
  15 + <counts>
  16 + <entry key="project.closed" value="2" />
  17 + <entry key="project.open.time.1" value="1" />
  18 + <entry key="project.open.time.31" value="1" />
  19 + <entry key="project.opened" value="2" />
  20 + </counts>
  21 + </usages-collector>
  22 + <usages-collector id="statistics.file.extensions.edit">
  23 + <counts>
  24 + <entry key="js" value="3212" />
  25 + </counts>
  26 + </usages-collector>
  27 + <usages-collector id="statistics.file.types.edit">
  28 + <counts>
  29 + <entry key="JavaScript" value="3212" />
  30 + </counts>
  31 + </usages-collector>
  32 + <usages-collector id="statistics.file.types.open">
  33 + <counts>
  34 + <entry key="JavaScript" value="1" />
  35 + </counts>
  36 + </usages-collector>
  37 + <usages-collector id="statistics.vcs.git.usages" />
  38 + <usages-collector id="statistics.js.language.service.starts" />
  39 + <usages-collector id="statistics.file.extensions.open">
  40 + <counts>
  41 + <entry key="js" value="1" />
  42 + </counts>
  43 + </usages-collector>
  44 + </session>
  45 + </component>
  46 + <component name="FileEditorManager">
  47 + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
  48 + <file leaf-file-name="routes.js" pinned="false" current-in-tab="true">
  49 + <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
  50 + <provider selected="true" editor-type-id="text-editor">
  51 + <state relative-caret-position="486">
  52 + <caret line="35" column="65" lean-forward="true" selection-start-line="35" selection-start-column="65" selection-end-line="35" selection-end-column="65" />
  53 + <folding />
  54 + </state>
  55 + </provider>
  56 + </entry>
  57 + </file>
  58 + <file leaf-file-name="package.json" pinned="false" current-in-tab="false">
  59 + <entry file="file://$PROJECT_DIR$/package.json">
  60 + <provider selected="true" editor-type-id="text-editor">
  61 + <state relative-caret-position="120">
  62 + <caret line="8" column="48" lean-forward="false" selection-start-line="8" selection-start-column="48" selection-end-line="8" selection-end-column="48" />
  63 + <folding />
  64 + </state>
  65 + </provider>
  66 + </entry>
  67 + </file>
  68 + </leaf>
  69 + </component>
  70 + <component name="Git.Settings">
  71 + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
  72 + </component>
  73 + <component name="IdeDocumentHistory">
  74 + <option name="CHANGED_PATHS">
  75 + <list>
  76 + <option value="$PROJECT_DIR$/package.json" />
  77 + <option value="$PROJECT_DIR$/api/routes/routes.js" />
  78 + </list>
  79 + </option>
  80 + </component>
  81 + <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
  82 + <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER">
  83 + <package-json value="$PROJECT_DIR$/package.json" />
  84 + </component>
  85 + <component name="JsGulpfileManager">
  86 + <detection-done>true</detection-done>
  87 + <sorting>DEFINITION_ORDER</sorting>
  88 + </component>
  89 + <component name="NodeModulesDirectoryManager">
  90 + <handled-path value="$PROJECT_DIR$/node_modules" />
  91 + </component>
  92 + <component name="NodePackageJsonFileManager">
  93 + <packageJsonPaths>
  94 + <path value="$PROJECT_DIR$/package.json" />
  95 + </packageJsonPaths>
  96 + </component>
  97 + <component name="ProjectFrameBounds">
  98 + <option name="y" value="23" />
  99 + <option name="width" value="1440" />
  100 + <option name="height" value="873" />
  101 + </component>
  102 + <component name="ProjectView">
  103 + <navigator currentView="ProjectPane" proportions="" version="1">
  104 + <flattenPackages />
  105 + <showMembers />
  106 + <showModules />
  107 + <showLibraryContents />
  108 + <hideEmptyPackages />
  109 + <abbreviatePackageNames />
  110 + <autoscrollToSource />
  111 + <autoscrollFromSource />
  112 + <sortByType />
  113 + <manualOrder />
  114 + <foldersAlwaysOnTop value="true" />
  115 + </navigator>
  116 + <panes>
  117 + <pane id="Scope" />
  118 + <pane id="Scratches" />
  119 + <pane id="ProjectPane">
  120 + <subPane>
  121 + <expand>
  122 + <path>
  123 + <item name="restApi" type="b2602c69:ProjectViewProjectNode" />
  124 + <item name="restApi" type="462c0819:PsiDirectoryNode" />
  125 + </path>
  126 + <path>
  127 + <item name="restApi" type="b2602c69:ProjectViewProjectNode" />
  128 + <item name="restApi" type="462c0819:PsiDirectoryNode" />
  129 + <item name="api" type="462c0819:PsiDirectoryNode" />
  130 + </path>
  131 + <path>
  132 + <item name="restApi" type="b2602c69:ProjectViewProjectNode" />
  133 + <item name="restApi" type="462c0819:PsiDirectoryNode" />
  134 + <item name="api" type="462c0819:PsiDirectoryNode" />
  135 + <item name="modules" type="462c0819:PsiDirectoryNode" />
  136 + </path>
  137 + <path>
  138 + <item name="restApi" type="b2602c69:ProjectViewProjectNode" />
  139 + <item name="restApi" type="462c0819:PsiDirectoryNode" />
  140 + <item name="api" type="462c0819:PsiDirectoryNode" />
  141 + <item name="routes" type="462c0819:PsiDirectoryNode" />
  142 + </path>
  143 + </expand>
  144 + <select />
  145 + </subPane>
  146 + </pane>
  147 + </panes>
  148 + </component>
  149 + <component name="PropertiesComponent">
  150 + <property name="WebServerToolWindowFactoryState" value="false" />
  151 + <property name="nodejs_package_manager_path" value="npm" />
  152 + </component>
  153 + <component name="RunDashboard">
  154 + <option name="ruleStates">
  155 + <list>
  156 + <RuleState>
  157 + <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
  158 + </RuleState>
  159 + <RuleState>
  160 + <option name="name" value="StatusDashboardGroupingRule" />
  161 + </RuleState>
  162 + </list>
  163 + </option>
  164 + </component>
  165 + <component name="RunManager" selected="npm.debug">
  166 + <configuration name="server.js" type="NodeJSConfigurationType" factoryName="Node.js" temporary="true" path-to-js-file="server.js" working-dir="$PROJECT_DIR$" />
  167 + <configuration name="api" type="js.build_tools.npm" factoryName="npm" temporary="true" nameIsGenerated="true">
  168 + <package-json value="$PROJECT_DIR$/package.json" />
  169 + <command value="run" />
  170 + <scripts>
  171 + <script value="api" />
  172 + </scripts>
  173 + <node-interpreter value="project" />
  174 + <envs />
  175 + </configuration>
  176 + <configuration name="debug" type="js.build_tools.npm" factoryName="npm" temporary="true" nameIsGenerated="true">
  177 + <package-json value="$PROJECT_DIR$/package.json" />
  178 + <command value="run" />
  179 + <scripts>
  180 + <script value="debug" />
  181 + </scripts>
  182 + <node-interpreter value="project" />
  183 + <envs />
  184 + </configuration>
  185 + <list size="3">
  186 + <item index="0" class="java.lang.String" itemvalue="Node.js.server.js" />
  187 + <item index="1" class="java.lang.String" itemvalue="npm.api" />
  188 + <item index="2" class="java.lang.String" itemvalue="npm.debug" />
  189 + </list>
  190 + <recent_temporary>
  191 + <list size="3">
  192 + <item index="0" class="java.lang.String" itemvalue="npm.api" />
  193 + <item index="1" class="java.lang.String" itemvalue="npm.debug" />
  194 + <item index="2" class="java.lang.String" itemvalue="Node.js.server.js" />
  195 + </list>
  196 + </recent_temporary>
  197 + </component>
  198 + <component name="ShelveChangesManager" show_recycled="false">
  199 + <option name="remove_strategy" value="false" />
  200 + </component>
  201 + <component name="SvnConfiguration">
  202 + <configuration />
  203 + </component>
  204 + <component name="TaskManager">
  205 + <task active="true" id="Default" summary="Default task">
  206 + <changelist id="0e20d303-9de8-4113-bfd9-019e72b304dc" name="Default" comment="" />
  207 + <created>1541088603899</created>
  208 + <option name="number" value="Default" />
  209 + <option name="presentableId" value="Default" />
  210 + <updated>1541088603899</updated>
  211 + <workItem from="1541088608198" duration="134000" />
  212 + <workItem from="1541088784358" duration="1764000" />
  213 + <workItem from="1541155443683" duration="1473000" />
  214 + <workItem from="1541596156631" duration="9351000" />
  215 + <workItem from="1541681303243" duration="9060000" />
  216 + <workItem from="1542189792461" duration="1932000" />
  217 + </task>
  218 + <servers />
  219 + </component>
  220 + <component name="TimeTrackingManager">
  221 + <option name="totallyTimeSpent" value="23714000" />
  222 + </component>
  223 + <component name="ToolWindowManager">
  224 + <frame x="0" y="23" width="1440" height="873" extended-state="6" />
  225 + <editor active="true" />
  226 + <layout>
  227 + <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" />
  228 + <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" />
  229 + <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" />
  230 + <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" />
  231 + <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" />
  232 + <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" />
  233 + <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" />
  234 + <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" />
  235 + <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" />
  236 + <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" />
  237 + <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="true" content_ui="tabs" />
  238 + <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
  239 + <window_info id="Messages" 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="11" side_tool="false" content_ui="tabs" />
  240 + <window_info id="Message" 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="0" side_tool="false" content_ui="tabs" />
  241 + <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
  242 + <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
  243 + <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
  244 + <window_info id="Find" 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="1" side_tool="false" content_ui="tabs" />
  245 + <window_info id="Ant Build" active="false" anchor="right" 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" />
  246 + </layout>
  247 + </component>
  248 + <component name="TypeScriptGeneratedFilesManager">
  249 + <option name="version" value="1" />
  250 + </component>
  251 + <component name="VcsContentAnnotationSettings">
  252 + <option name="myLimit" value="2678400000" />
  253 + </component>
  254 + <component name="XDebuggerManager">
  255 + <breakpoint-manager />
  256 + <watches-manager />
  257 + </component>
  258 + <component name="editorHistoryManager">
  259 + <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
  260 + <provider selected="true" editor-type-id="text-editor">
  261 + <state relative-caret-position="0">
  262 + <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
  263 + <folding />
  264 + </state>
  265 + </provider>
  266 + </entry>
  267 + <entry file="file://$PROJECT_DIR$/package.json">
  268 + <provider selected="true" editor-type-id="text-editor">
  269 + <state relative-caret-position="120">
  270 + <caret line="8" column="48" lean-forward="false" selection-start-line="8" selection-start-column="48" selection-end-line="8" selection-end-column="48" />
  271 + <folding />
  272 + </state>
  273 + </provider>
  274 + </entry>
  275 + <entry file="file://$PROJECT_DIR$/node_modules/cassandra-driver/lib/requests.js">
  276 + <provider selected="true" editor-type-id="text-editor">
  277 + <state relative-caret-position="190">
  278 + <caret line="106" column="9" lean-forward="false" selection-start-line="106" selection-start-column="9" selection-end-line="106" selection-end-column="9" />
  279 + </state>
  280 + </provider>
  281 + </entry>
  282 + <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
  283 + <provider selected="true" editor-type-id="text-editor">
  284 + <state relative-caret-position="486">
  285 + <caret line="35" column="65" lean-forward="true" selection-start-line="35" selection-start-column="65" selection-end-line="35" selection-end-column="65" />
  286 + <folding />
  287 + </state>
  288 + </provider>
  289 + </entry>
  290 + <entry file="file://$PROJECT_DIR$/package.json">
  291 + <provider selected="true" editor-type-id="text-editor">
  292 + <state relative-caret-position="120">
  293 + <caret line="8" column="48" lean-forward="false" selection-start-line="8" selection-start-column="48" selection-end-line="8" selection-end-column="48" />
  294 + <folding />
  295 + </state>
  296 + </provider>
  297 + </entry>
  298 + </component>
  299 +</project>
0 300 \ No newline at end of file
... ...
kol075@158.39.52.99/Deployment Diagram.docx 0 → 100644
No preview for this file type
kol075@158.39.52.99/README.txt 0 → 100644
  1 +How to run the server:
  2 +
  3 +1 - This is a node.js server so node is required. https://nodejs.org/en/download/
  4 +2 - Start Windows Powershell on windows or terminal on Mac.
  5 +3 - Navigate to this folder (.....\ITE1893_Risikovurdering_Gruppe4\restApi)
  6 +4 - Use command: "npm run api"
  7 +5 - The server should start running on localhost and listen to port 3000 (and should auto-restart if changes are made in the code)
  8 +6 - Endpoints are documented in the code (routes.js)
  9 +7 - Use Postman to test endpoints where a body is expected
0 10 \ No newline at end of file
... ...
kol075@158.39.52.99/api/.DS_Store 0 → 100644
No preview for this file type
kol075@158.39.52.99/api/modules/activity.js 0 → 100644
  1 +var object = Activity.prototype;
  2 +
  3 +function Activity(id, title) {
  4 + this.id = id;
  5 + this.title = title;
  6 +}
  7 +
  8 +module.exports = Activity;
0 9 \ No newline at end of file
... ...
kol075@158.39.52.99/api/modules/evaluation.js 0 → 100644
  1 +var object = Evaluation.prototype;
  2 +
  3 +function Evaluation(id, title, outcome, measures, consequence, probabillity, associatedActivity) {
  4 + this.id = id;
  5 + this.title = title;
  6 + this.outcome = outcome;
  7 + this.measures = measures;
  8 + this.consequence = consequence;
  9 + this.probability = probabillity;
  10 + this.associatedActivity = associatedActivity;
  11 +}
  12 +
  13 +module.exports = Evaluation;
0 14 \ No newline at end of file
... ...
kol075@158.39.52.99/api/modules/incident.js 0 → 100644
  1 +var object = Incident.prototype;
  2 +
  3 +function Incident(id, date, location, title, description, associatedEval) {
  4 + this.id = id;
  5 + this.date = date;
  6 + this.location = location;
  7 + this.title = title;
  8 + this.description = description;
  9 + this.associatedEval = associatedEval;
  10 +}
  11 +
  12 +module.exports = Incident;
0 13 \ No newline at end of file
... ...
kol075@158.39.52.99/api/routes/routes.js 0 → 100644
  1 +//All endpoints will be defined in this file
  2 +const Incident = require("../modules/incident.js");
  3 +const Evaluation = require("../modules/evaluation.js");
  4 +const Activity = require("../modules/activity.js");
  5 +
  6 +const uuid = require('uuid');
  7 +var cassandra = require("cassandra-driver");
  8 +
  9 +var db = setupDatabase('127.0.0.1');
  10 +
  11 +var appRouter = function(app) {
  12 +
  13 + //Root endpoint (http://localhost:3000)
  14 + app.get("/", function(req, res) {
  15 + res.send("Evaluation API by Ali, Kristin and Anna is up and running...");
  16 + });
  17 +
  18 +
  19 + /**
  20 + * Get incident by id endpoint (a get request at http://localhost:3000/incident/1 will return incident with id 1)
  21 + */
  22 + app.get("/incident/:id", function (req, res) {
  23 + if (!req.params.id) {
  24 + logEndpoint("get /incident/{id}", null, "ID missing");
  25 + return req.status(400).send("No id entered");
  26 + }
  27 +
  28 + const params = [req.params.id];
  29 + db.execute('SELECT * ' +
  30 + 'FROM risk.incident ' +
  31 + 'WHERE id = ?',
  32 + params,
  33 + { prepare: true },
  34 + function(err, result) {
  35 + if(err) {
  36 + logEndpoint("get /incident/{id}", err, null);
  37 + return res.status(400).send("Bad request, see API log");
  38 + } else {
  39 + if (result.rows.length != 0) {
  40 + logEndpoint("get /incident/{id}", err, "Success, incident returned");
  41 + return res.status(200).send(result.rows[0]);
  42 + } else {
  43 + logEndpoint("get /incident/{id}", err, "Success but id not found in database");
  44 + return res.status(204).send("Id not found in database");
  45 + }
  46 + }
  47 + }
  48 + );
  49 + });
  50 +
  51 + /**
  52 + * See all incidents (a get request at http://localhost:3000/incident will return all incidents)
  53 + */
  54 + app.get("/incident", function (req, res) {
  55 +
  56 + db.execute('SELECT * ' +
  57 + 'FROM risk.incident',
  58 + function (err, result) {
  59 + if(err) {
  60 + logEndpoint("get /incident", err, null);
  61 + return res.status(400).send("Bad request, see API log");
  62 +
  63 + } else {
  64 + if (result.rows.length != 0) {
  65 + logEndpoint("get /incident", err, "Success. All incidents returned");
  66 + return res.status(200).send(result.rows);
  67 + } else {
  68 + logEndpoint("get /incident", err, "Success but no incidents found in database");
  69 + return res.status(204).send("No registered incidents");
  70 + }
  71 + }
  72 + }
  73 + );
  74 + });
  75 +
  76 + /**
  77 + * Add a new incident (a post request at http://localhost:3000/incident - with an "x-www-form-urlencoded" body of params)
  78 + */
  79 + app.post("/incident", function(req, res) {
  80 +
  81 + // All these parameters must exist in the body with the exact name for this method to work
  82 + if(!req.body.date || !req.body.location || !req.body.title || !req.body.description || !req.body.associatedEval) {
  83 + logEndpoint("post /incident", null, "Missing params in body");
  84 + return res.status(400).send("Missing params");
  85 + } else {
  86 + const query = 'INSERT INTO risk.incident(id, date, location, title, description, associatedEval) ' +
  87 + 'VALUES(?,?,?,?,?,?)';
  88 + const params = [uuid(), new Date(req.body.date), req.body.location, req.body.title, req.body.description, req.body.associatedEval];
  89 + db.execute(query, params, { prepare: true }, function (err) {
  90 + if (err) {
  91 + logEndpoint("post /incident", err, "Bad request, see API log");
  92 + return res.status(400).send("Bad Request");
  93 + }
  94 + logEndpoint("post /incident", err, "Success, incident created");
  95 + return res.status(200).send("Incident Created");
  96 + });
  97 + }
  98 + });
  99 +
  100 + /**
  101 + * Update an incident (a patch request at http://localhost:3000/incident/{id} will update the incident with the params passed in the request body)
  102 + */
  103 + app.patch("/incident/:id", function (req, res) {
  104 +
  105 + if (!req.params.id) {
  106 + logEndpoint("patch /incident", null, "ID missing");
  107 + return res.status(400).send("Missing id");
  108 + }
  109 +
  110 + if (!req.body.date || !req.body.location || !req.body.title || !req.body.description || !req.body.associatedEval) {
  111 + logEndpoint("patch /incident", null, "Missing params in body");
  112 + return res.status(400).send("Missing params");
  113 + }
  114 +
  115 + const params = [new Date(req.body.date), req.body.location, req.body.title, req.body.description, req.body.associatedEval, req.params.id];
  116 + db.execute("UPDATE risk.incident " +
  117 + "SET date=?, location=?, title=?, description=?, associatedEval=? " +
  118 + "WHERE id=?",
  119 + params,
  120 + { prepare: true },
  121 + function (err) {
  122 + if (err) {
  123 + logEndpoint("patch /incident", err, "Bad request, see API log");
  124 + return res.status(400).send("Bad Request");
  125 + }
  126 + logEndpoint("patch /incident", err, "Success, incident updated");
  127 + return res.status(200).send("Incident updated");
  128 + }
  129 + );
  130 + });
  131 +
  132 + /**
  133 + * Delete an incident (a delete request at http://localhost:3000/incident/{id} should delete incident with the id passed in)
  134 + */
  135 + app.delete("/incident/:id", function (req, res) {
  136 + if (!req.params.id) {
  137 + logEndpoint("delete /incident", null, "ID missing");
  138 + return res.status(400).send("Missing id");
  139 + }
  140 +
  141 + const params = [req.params.id];
  142 + db.execute("DELETE FROM risk.incident " +
  143 + "WHERE id = ?",
  144 + params,
  145 + { prepare: true },
  146 + function (err) {
  147 + if (err) {
  148 + logEndpoint("delete /incident", err, "Bad request, see API log");
  149 + return res.status(400).send("Bad request");
  150 + }
  151 + logEndpoint("del