From 17e49a536cd2bfecdcc8c4db16d59b2da75c5a63 Mon Sep 17 00:00:00 2001 From: Patrick McDonagh Date: Mon, 13 Feb 2017 17:40:59 -0600 Subject: [PATCH] Drawing cards is working --- src/main/java/com/henrypump/poc/Database.java | 2 +- www/pocwww/development.ini | 4 +- www/pocwww/pocwww/__init__.py | 37 ++++ www/pocwww/pocwww/static/theme.css | 27 +++ www/pocwww/pocwww/templates/cardlist.jinja2 | 4 +- www/pocwww/pocwww/templates/cardsingle.jinja2 | 173 +++++++++++++++++- www/pocwww/pocwww/templates/dashboard.jinja2 | 8 + www/pocwww/pocwww/templates/datelist.jinja2 | 2 +- www/pocwww/pocwww/templates/mytemplate.jinja2 | 8 - www/pocwww/pocwww/views.py | 4 +- 10 files changed, 248 insertions(+), 21 deletions(-) create mode 100644 www/pocwww/pocwww/templates/dashboard.jinja2 delete mode 100644 www/pocwww/pocwww/templates/mytemplate.jinja2 diff --git a/src/main/java/com/henrypump/poc/Database.java b/src/main/java/com/henrypump/poc/Database.java index 84e6814..2751715 100644 --- a/src/main/java/com/henrypump/poc/Database.java +++ b/src/main/java/com/henrypump/poc/Database.java @@ -27,7 +27,7 @@ public class Database { private MongoDatabase database; Database(){ - mongoClient = new MongoClient("10.20.155.202"); + mongoClient = new MongoClient(); database = mongoClient.getDatabase(pocDatabase); } diff --git a/www/pocwww/development.ini b/www/pocwww/development.ini index 396142f..f1e5520 100644 --- a/www/pocwww/development.ini +++ b/www/pocwww/development.ini @@ -18,8 +18,8 @@ pyramid.includes = # '127.0.0.1' and '::1'. # debugtoolbar.hosts = 127.0.0.1 ::1 -# mongo_uri = mongodb://localhost:27017/poc -mongo_uri = mongodb://10.20.155.202:27017/poc +mongo_uri = mongodb://localhost:27017/poc +# mongo_uri = mongodb://10.20.155.202:27017/poc ### diff --git a/www/pocwww/pocwww/__init__.py b/www/pocwww/pocwww/__init__.py index 65c7d62..6685a47 100644 --- a/www/pocwww/pocwww/__init__.py +++ b/www/pocwww/pocwww/__init__.py @@ -1,4 +1,5 @@ from pyramid.config import Configurator +from datetime import datetime try: # for python 2 @@ -10,11 +11,47 @@ except ImportError: from pymongo import MongoClient +def format_datetime(inpDate, format='medium'): + if format == 'long': + format = "%A, %B %d %Y at %I:%M:%S %p" + elif format == 'medium': + format = "%a, %b %d %Y %I:%M:%S %p" + elif format == 'short': + format = "%m/%d/%Y %I:%M:%S %p" + return inpDate.strftime(format) + + +def format_dateString(inpDate, format='medium'): + iDate = datetime.strptime(inpDate, '%Y-%m-%d') + if format == 'long': + format = "%A, %B %d %Y" + elif format == 'medium': + format = "%a, %b %d %Y" + elif format == 'short': + format = "%m/%d/%Y" + return iDate.strftime(format) + + +def format_date(inpDate, format='medium'): + if format == 'long': + format = "%A, %B %d %Y" + elif format == 'medium': + format = "%a, %b %d %Y" + elif format == 'short': + format = "%m/%d/%Y" + return inpDate.strftime(format) + + def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ config = Configurator(settings=settings) config.include('pyramid_jinja2') + config.commit() # this is needed or you will get None back on the next line + jinja2_env = config.get_jinja2_environment() + jinja2_env.filters['datetime'] = format_datetime + jinja2_env.filters['date'] = format_date + jinja2_env.filters['datestring'] = format_dateString db_url = urlparse(settings['mongo_uri']) config.registry.db = MongoClient( diff --git a/www/pocwww/pocwww/static/theme.css b/www/pocwww/pocwww/static/theme.css index 8e97fc7..9f2ad39 100644 --- a/www/pocwww/pocwww/static/theme.css +++ b/www/pocwww/pocwww/static/theme.css @@ -119,3 +119,30 @@ body { display: inline-block; border-radius: 50%; } + +.card { + font: 10px sans-serif; +} + +.axis path, +.axis line { + fill: none; + stroke: #000; + shape-rendering: crispEdges; +} + +.grid path, +.grid line { + fill: none; + stroke: rgba(0, 0, 0, 0.25); + shape-rendering: crispEdges; +} + +.x.axis path { + display: none; +} + +.line { + fill: none; + stroke-width: 2.5px; +} diff --git a/www/pocwww/pocwww/templates/cardlist.jinja2 b/www/pocwww/pocwww/templates/cardlist.jinja2 index 1b50abf..d89f77b 100644 --- a/www/pocwww/pocwww/templates/cardlist.jinja2 +++ b/www/pocwww/pocwww/templates/cardlist.jinja2 @@ -5,7 +5,7 @@ {% block content %}
-

Card Data Page {{page_num}} / {{total_pages}}

+

Cards for {{cards_date | datestring('long')}}

{{render_pagination(pagination, "/cards/" + cards_date)}} @@ -22,7 +22,7 @@ {% for card in cards %} {{card.strokeNumber}} - {{card.timestamp}} + {{card.timestamp | datetime('long')}} {% endfor %} diff --git a/www/pocwww/pocwww/templates/cardsingle.jinja2 b/www/pocwww/pocwww/templates/cardsingle.jinja2 index f0aaf40..ebeb9f1 100644 --- a/www/pocwww/pocwww/templates/cardsingle.jinja2 +++ b/www/pocwww/pocwww/templates/cardsingle.jinja2 @@ -1,11 +1,174 @@ {% extends "layout.jinja2" %} {% block content %} +
-
{{card.timestamp}}
-
{{card.surface_position}}
-
{{card.surface_load}}
-
{{card.downhole_position}}
-
{{card.downhole_load}}
+

{{card.timestamp | date}}

+ + +
+
+ + + {% endblock content %} diff --git a/www/pocwww/pocwww/templates/dashboard.jinja2 b/www/pocwww/pocwww/templates/dashboard.jinja2 new file mode 100644 index 0000000..c2cfd98 --- /dev/null +++ b/www/pocwww/pocwww/templates/dashboard.jinja2 @@ -0,0 +1,8 @@ +{% extends "layout.jinja2" %} + +{% block content %} +
+

Henry Pump POC

+ +
+{% endblock content %} diff --git a/www/pocwww/pocwww/templates/datelist.jinja2 b/www/pocwww/pocwww/templates/datelist.jinja2 index ae65d06..4ab2e45 100644 --- a/www/pocwww/pocwww/templates/datelist.jinja2 +++ b/www/pocwww/pocwww/templates/datelist.jinja2 @@ -13,7 +13,7 @@ {% for day in datelist %} - {{day.date}} + {{day.date | date('long')}} {{day.count}} cards {% endfor %} diff --git a/www/pocwww/pocwww/templates/mytemplate.jinja2 b/www/pocwww/pocwww/templates/mytemplate.jinja2 deleted file mode 100644 index 1bd9fd1..0000000 --- a/www/pocwww/pocwww/templates/mytemplate.jinja2 +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "layout.jinja2" %} - -{% block content %} -
-

Pyramid Starter project

-

Welcome to POC Web Interface, a Pyramid application generated by
Cookiecutter.

-
-{% endblock content %} diff --git a/www/pocwww/pocwww/views.py b/www/pocwww/pocwww/views.py index 7fc101a..769626a 100644 --- a/www/pocwww/pocwww/views.py +++ b/www/pocwww/pocwww/views.py @@ -39,9 +39,9 @@ class Pagination(object): last = num -@view_config(route_name='home', renderer='templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='templates/dashboard.jinja2') def my_view(request): - return {'project': 'POC Web Interface', 'navgroup':'dashboard'} + return {'project': 'POC Web Interface', 'navgroup': 'dashboard'} def card_page(request):