Adds run status to dashboard. Fixes type in run status db script

This commit is contained in:
Patrick McDonagh
2017-02-23 14:58:09 -06:00
parent b943c99301
commit bc38ab3404
8 changed files with 103 additions and 21 deletions

42
.idea/workspace.xml generated
View File

@@ -2,8 +2,10 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="28cc251f-c94f-44ee-a66d-77aaab6e3483" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/com/henrypump/poc/Database.java" afterPath="$PROJECT_DIR$/src/main/java/com/henrypump/poc/Database.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/com/henrypump/poc/Well.java" afterPath="$PROJECT_DIR$/src/main/java/com/henrypump/poc/Well.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/www/pocwww/pocwww/__init__.py" afterPath="$PROJECT_DIR$/www/pocwww/pocwww/__init__.py" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/www/pocwww/pocwww/templates/gaugeoff_all.jinja2" afterPath="$PROJECT_DIR$/www/pocwww/pocwww/templates/gaugeoff_all.jinja2" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/www/pocwww/pocwww/json.py" afterPath="$PROJECT_DIR$/www/pocwww/pocwww/json.py" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/www/pocwww/pocwww/templates/layout.jinja2" afterPath="$PROJECT_DIR$/www/pocwww/pocwww/templates/layout.jinja2" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/www/pocwww/pocwww/views.py" afterPath="$PROJECT_DIR$/www/pocwww/pocwww/views.py" />
</list>
@@ -107,11 +109,11 @@
</provider>
</entry>
</file>
<file leaf-file-name="Well.java" pinned="false" current-in-tab="false">
<file leaf-file-name="Well.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/com/henrypump/poc/Well.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="26" column="28" lean-forward="false" selection-start-line="26" selection-start-column="28" selection-end-line="26" selection-end-column="28" />
<state relative-caret-position="385">
<caret line="1019" column="47" lean-forward="false" selection-start-line="1019" selection-start-column="47" selection-end-line="1019" selection-end-column="47" />
<folding>
<element signature="imports" expanded="true" />
</folding>
@@ -182,11 +184,11 @@
</provider>
</entry>
</file>
<file leaf-file-name="Database.java" pinned="false" current-in-tab="true">
<file leaf-file-name="Database.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/henrypump/poc/Database.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1029">
<caret line="194" column="55" lean-forward="false" selection-start-line="194" selection-start-column="55" selection-end-line="194" selection-end-column="55" />
<state relative-caret-position="2610">
<caret line="232" column="29" lean-forward="false" selection-start-line="232" selection-start-column="29" selection-end-line="232" selection-end-column="29" />
<folding>
<element signature="imports" expanded="true" />
</folding>
@@ -623,10 +625,10 @@
<option value="$PROJECT_DIR$/build.gradle" />
<option value="$PROJECT_DIR$/poc.service.txt" />
<option value="$PROJECT_DIR$/src/main/java/com/henrypump/poc/Measurement.java" />
<option value="$PROJECT_DIR$/src/main/java/com/henrypump/poc/Database.java" />
<option value="$PROJECT_DIR$/src/main/java/com/henrypump/poc/CLScanner.java" />
<option value="$PROJECT_DIR$/src/main/java/com/henrypump/poc/IOControl.java" />
<option value="$PROJECT_DIR$/src/main/java/com/henrypump/poc/POC.java" />
<option value="$PROJECT_DIR$/src/main/java/com/henrypump/poc/Database.java" />
<option value="$PROJECT_DIR$/src/main/java/com/henrypump/poc/Well.java" />
</list>
</option>
@@ -1399,16 +1401,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/henrypump/poc/Well.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="26" column="28" lean-forward="false" selection-start-line="26" selection-start-column="28" selection-end-line="26" selection-end-column="28" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/henrypump/poc/CLScanner.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-735">
@@ -1419,8 +1411,18 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/henrypump/poc/Database.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1029">
<caret line="194" column="55" lean-forward="false" selection-start-line="194" selection-start-column="55" selection-end-line="194" selection-end-column="55" />
<state relative-caret-position="2610">
<caret line="232" column="29" lean-forward="false" selection-start-line="232" selection-start-column="29" selection-end-line="232" selection-end-column="29" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/henrypump/poc/Well.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="385">
<caret line="1019" column="47" lean-forward="false" selection-start-line="1019" selection-start-column="47" selection-end-line="1019" selection-end-column="47" />
<folding>
<element signature="imports" expanded="true" />
</folding>

View File

@@ -230,7 +230,7 @@ public class Database {
Document doc = new Document("status", runStatus)
.append("initiator", initiator)
.append("timesstamp", Date.from(ZonedDateTime.now().toInstant()));
.append("timestamp", Date.from(ZonedDateTime.now().toInstant()));
collection.insertOne(doc);
return collection.count();
}

View File

@@ -1017,6 +1017,7 @@ public class Well {
pointCounter = -1;
if (strokesSinceStart > startupStrokes){
runStatus = RUNSTATUS_RUNNING;
db.newRunStatus("Running", "startup");
}
if (runStatus == RUNSTATUS_RUNNING) {

View File

@@ -137,8 +137,12 @@ def main(global_config, **settings):
config.add_route('welltests_all', '/welltests')
config.add_route('json_welltests_all', '/json/welltests')
config.add_route('runstatus', '/runstatus')
config.add_route('json_runstatus', '/json/runstatus')
# JSON-ONLY ROUTES
config.add_route('json_lastcard', "/json/lastcard")
config.add_route('json_runstatusnow', "/json/runstatusnow")
config.add_route('json_valuesbetween_wparams', "/json/values/between/{startdt}/{enddt}")
config.add_route('json_valuesbetween', "/json/values/between")

View File

@@ -102,3 +102,14 @@ def json_singlevaluedaterange(request):
}}
]))[0]
return {'first_date': date_limits['first'], 'last_date': date_limits['last']}
@view_config(route_name="json_runstatusnow", renderer="prettyjson")
def json_runstatusnow(request):
status = False
try:
status = list(request.db['runStatus'].find().sort("timestamp", -1).limit(1))[0]
except IndexError:
pass
return {'runstatus': status}

View File

@@ -61,6 +61,8 @@
<li {% if (navgroup == 'cards') %}class="visible-xs-inline active" {% else %} class="visible-xs-inline" {% endif %}><a href="/cards">Cards</a></li>
<li {% if (navgroup == 'values') %}class="visible-xs-inline active" {% else %} class="visible-xs-inline" {% endif %}><a href="/values">Values</a></li>
<li {% if (navgroup == 'gaugeoff') %}class="visible-xs-inline active" {% else %} class="visible-xs-inline" {% endif %}><a href="/gaugeoff">Gauge-Off</a></li>
<li {% if (navgroup == 'fluidshots') %}class="visible-xs-inline active" {% else %} class="visible-xs-inline" {% endif %}><a href="/fluidshots">Fluid Shots</a></li>
<li {% if (navgroup == 'welltests') %}class="visible-xs-inline active" {% else %} class="visible-xs-inline" {% endif %}><a href="/welltests">Well Tests</a></li>
<li><a href="/configuration">Configuration</a></li>
</ul>
</div>
@@ -70,6 +72,11 @@
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<h3 class="allcaps" style="text-align:center">Run Status</h3>
<h4 style="text-align:center"><span id="runstatus"></span></h4>
<h5 style="text-align:center">at <span id="runstatustimestamp"></span></h5>
<h5 style="text-align:center"><a class="btn btn-primary" href="/runstatus">History</a></h5>
<hr />
<ul class="nav nav-sidebar">
<li {% if (navgroup == 'dashboard') %}class="active"{% endif %}><a href="/">Dashboard</a></li>
<li {% if (navgroup == 'cards') %}class="active"{% endif %}><a href="/cards">Cards</a></li>
@@ -102,4 +109,19 @@
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script>
function setRunStatus(data){
$("#runstatus").text(data.runstatus.status);
$("#runstatustimestamp").text(data.runstatus.timestamp);
}
$.ajax({
dataType: 'json',
url: "/json/runstatusnow",
success: setRunStatus
});
</script>
</html>

View File

@@ -0,0 +1,35 @@
{% extends "layout.jinja2" %}
{% block content %}
<div class="content">
<div class="row">
<div class="col-xs-12">
<h2>Run Status Log</h2>
{% if data|length > 0 %}
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Timestamp</th>
<th>Status</th>
<th>Initiator</th>
</tr>
</thead>
<tbody>
{% for d in data %}
<tr>
<td>{{d.timestamp | datetime('medium')}}</td>
<td>{{d.status}}</td>
<td>{{d.initiator}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<h3>No fluid shots yet...</h3>
{% endif %}
</div>
</div>
</div>
{% endblock content %}

View File

@@ -113,3 +113,10 @@ def fluidshots_all(request):
def welltests_all(request):
welltests = list(request.db['wellTests'].find())
return {'navgroup': 'welltests', 'data': welltests}
@view_config(route_name="runstatus", renderer="templates/runstatus.jinja2")
@view_config(route_name="json_runstatus", renderer="prettyjson")
def welltests_all(request):
runStatuses = list(request.db['runStatus'].find())
return {'navgroup': 'runstatus', 'data': runStatuses}