From 62b1c9e223e9ea20f6f143839bae7bb6e65b8c14 Mon Sep 17 00:00:00 2001
From: lewa <lene.wasskog@nibio.no>
Date: Sun, 16 Jun 2024 09:01:17 +0200
Subject: [PATCH] feat(observations): Add timeseries link to observation list,
 dummy view

---
 observations/static/observations/js/observationList.js | 8 ++++++++
 observations/templates/observations/index.html         | 1 +
 observations/templates/observations/timeseries.html    | 1 +
 observations/urls.py                                   | 1 +
 observations/views.py                                  | 6 ++++++
 5 files changed, 17 insertions(+)
 create mode 100644 observations/templates/observations/timeseries.html

diff --git a/observations/static/observations/js/observationList.js b/observations/static/observations/js/observationList.js
index 3a6ed604..2cbc5b23 100644
--- a/observations/static/observations/js/observationList.js
+++ b/observations/static/observations/js/observationList.js
@@ -351,6 +351,14 @@ var renderObservationTable = function(data)
         tbodyHTML.push("<td>" + obs.cropOrganismName + "</td>");
         tbodyHTML.push("<td>" + obs.observationHeading + "</td>");
 
+        if (obs.observationTimeSeriesId) {
+          tbodyHTML.push(
+              "<td><a href='/observations/timeseries/" + obs.observationTimeSeriesId + "' target='new'><i class='fa fa-list'/></a></td>"
+          );
+        } else {
+          tbodyHTML.push("<td></td>");
+        }
+
         if(Object.keys(measuredVal).length != 0){
             tbodyHTML.push("<td><a tabindex='0' class='btn btn-lg' role='button' data-toggle='popover' data-placement='left' data-trigger='focus' data-html='true' data-content='" + printVal.join("<br/>") + "' ><i class='fa fa-balance-scale' aria-hidden='true' </i></a></td>")
         } else{
diff --git a/observations/templates/observations/index.html b/observations/templates/observations/index.html
index bfbce1a6..77955ab5 100644
--- a/observations/templates/observations/index.html
+++ b/observations/templates/observations/index.html
@@ -69,6 +69,7 @@
                             <th>{% trans "Crop" %}</th>
                             <th>{% trans "Heading" %}</th>
                             <th></th>
+                            <th></th>
                     </thead>
                     <tbody id="observationTableBody">
                     </tbody>
diff --git a/observations/templates/observations/timeseries.html b/observations/templates/observations/timeseries.html
new file mode 100644
index 00000000..215a66e9
--- /dev/null
+++ b/observations/templates/observations/timeseries.html
@@ -0,0 +1 @@
+<h1>TIMESERIES {{ observation_time_series_id }}</h1>
\ No newline at end of file
diff --git a/observations/urls.py b/observations/urls.py
index 0f75f017..f7cc4794 100755
--- a/observations/urls.py
+++ b/observations/urls.py
@@ -31,4 +31,5 @@ urlpatterns = [
     re_path(r'old', views.index_old, name='index_old'),
     # ex: /observations/5/
     re_path(r'^(?P<observation_id>\d+)/$', (views.detail), name='detail'),
+    re_path(r'^timeseries/(?P<observation_time_series_id>\w+)/$', views.timeseries, name='timeseries'),
 ]
\ No newline at end of file
diff --git a/observations/views.py b/observations/views.py
index 94caa444..31b680e9 100755
--- a/observations/views.py
+++ b/observations/views.py
@@ -73,3 +73,9 @@ def detail(request, observation_id):
               "observation_id" : observation_id,
                }
     return render(request, 'observations/detail.html', context)
+
+def timeseries(request, observation_time_series_id):
+    context = {
+        "observation_time_series_id" : observation_time_series_id,
+    }
+    return render(request, 'observations/timeseries.html', context)
\ No newline at end of file
-- 
GitLab