Commit 2859532a authored by Hive's avatar Hive

Myo connected

parent fbb3b570
# Generated by Django 2.1.2 on 2018-12-07 18:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0011_auto_20181125_2042'),
]
operations = [
migrations.RenameField(
model_name='data',
old_name='value',
new_name='d1',
),
migrations.AddField(
model_name='data',
name='d2',
field=models.IntegerField(default=1),
preserve_default=False,
),
migrations.AddField(
model_name='data',
name='d3',
field=models.IntegerField(default=1),
preserve_default=False,
),
migrations.AddField(
model_name='data',
name='d4',
field=models.IntegerField(default=1),
preserve_default=False,
),
migrations.AddField(
model_name='data',
name='d5',
field=models.IntegerField(default=1),
preserve_default=False,
),
migrations.AddField(
model_name='data',
name='d6',
field=models.IntegerField(default=1),
preserve_default=False,
),
migrations.AddField(
model_name='data',
name='d7',
field=models.IntegerField(default=1),
preserve_default=False,
),
migrations.AddField(
model_name='data',
name='d8',
field=models.IntegerField(default=1),
preserve_default=False,
),
]
# Generated by Django 2.1.2 on 2018-12-07 18:09
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0012_auto_20181207_1802'),
]
operations = [
migrations.RemoveField(
model_name='data',
name='timestamp',
),
]
......@@ -28,5 +28,12 @@ class Raspi(models.Model):
class Data(models.Model):
timestamp = models.CharField(max_length=300)
value = models.IntegerField()
#timestamp = models.CharField(max_length=300)
d1 = models.IntegerField()
d2 = models.IntegerField()
d3 = models.IntegerField()
d4 = models.IntegerField()
d5 = models.IntegerField()
d6 = models.IntegerField()
d7 = models.IntegerField()
d8 = models.IntegerField()
......@@ -42,131 +42,47 @@
<li class="breadcrumb-item active">Overview</li>
</ol>
<!-- Icon Cards-->
<div class="row">
<div class="col-xl-3 col-sm-6 mb-3">
<div class="card text-white bg-primary o-hidden h-100">
<div class="card-body">
<div class="card-body-icon">
<i class="fas fa-fw fa-comments"></i>
</div>
<div class="mr-5">26 New Messages!</div>
</div>
<a class="card-footer text-white clearfix small z-1" href="#">
<span class="float-left">View Details</span>
<span class="float-right">
<i class="fas fa-angle-right"></i>
</span>
</a>
</div>
</div>
<div class="col-xl-3 col-sm-6 mb-3">
<div class="card text-white bg-warning o-hidden h-100">
<div class="card-body">
<div class="card-body-icon">
<i class="fas fa-fw fa-list"></i>
</div>
<div class="mr-5">11 New Tasks!</div>
</div>
<a class="card-footer text-white clearfix small z-1" href="#">
<span class="float-left">View Details</span>
<span class="float-right">
<i class="fas fa-angle-right"></i>
</span>
</a>
</div>
</div>
<div class="col-xl-3 col-sm-6 mb-3">
<div class="card text-white bg-success o-hidden h-100">
<div class="card-body">
<div class="card-body-icon">
<i class="fas fa-fw fa-shopping-cart"></i>
</div>
<div class="mr-5">123 New Orders!</div>
</div>
<a class="card-footer text-white clearfix small z-1" href="#">
<span class="float-left">View Details</span>
<span class="float-right">
<i class="fas fa-angle-right"></i>
</span>
</a>
</div>
</div>
<div class="col-xl-3 col-sm-6 mb-3">
<div class="card text-white bg-danger o-hidden h-100">
<div class="card-body">
<div class="card-body-icon">
<i class="fas fa-fw fa-life-ring"></i>
</div>
<div class="mr-5">13 New Tickets!</div>
</div>
<a class="card-footer text-white clearfix small z-1" href="#">
<span class="float-left">View Details</span>
<span class="float-right">
<i class="fas fa-angle-right"></i>
</span>
</a>
</div>
</div>
</div>
{{data}}
<!-- Area Chart Example-->
<div class="card mb-3">
<div class="card-header">
<i class="fas fa-chart-area"></i>
Area Chart Example</div>
<div class="card-body">
<canvas id="myAreaChart" width="100%" height="30"></canvas>
</div>
<div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div>
</div>
<!-- DataTables Example -->
<div class="card mb-3">
<div class="card-header">
<i class="fas fa-table"></i>
Data Table Example</div>
Data Table</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
<th>ID</th>
<th>Tmstp</th>
<th>D1</th>
<th>D2</th>
<th>D3</th>
<th>D4</th>
<th>D5</th>
<th>D6</th>
<th>D7</th>
<th>D8</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
{% for value in data %}
<tr>
<td>ID : {{value.id}}</td>
<td>Tmstp : {{value.timestamp|date:'Y-m-d H:i'}}</td>
<td>Value : {{value.value}}</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
<td>{{value.id}}</td>
<td>XXX</td><!-- {{value.timestamp|date:'Y-m-d H:i'}} -->
<td>{{value.d1}}</td>
<td>{{value.d2}}</td>
<td>{{value.d3}}</td>
<td>{{value.d4}}</td>
<td>{{value.d5}}</td>
<td>{{value.d6}}</td>
<td>{{value.d7}}</td>
<td>{{value.d8}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="card-footer small text-muted">footer</div>
</div>
</div>
......
......@@ -9,6 +9,7 @@ from collections import OrderedDict
from .fusioncharts import FusionCharts
import plotly.offline as opy
import plotly.graph_objs as go
from datetime import date
def patient_new(request):
if request.method == "POST":
......@@ -43,7 +44,7 @@ def test(request):
datasource['charts'] = {"caption":"Data for Shimmer3 GSR Platform"}
datasource['data'] = []
for key in all_data:
print(key)
#print(key)
data = {}
data['label'] = key.timestamp
data['value'] = key.value
......@@ -112,8 +113,8 @@ def patients(request):
@login_required
def dashboard(request):
data = Data.objects.all()
for item in data:
print(item.timestamp)
#for item in data:
#print(item.timestamp)
return render(request, 'dashboard.html', {"data" : data})
def delete_raspi(request, id):
......
No preview for this file type
from channels.generic.websocket import WebsocketConsumer
from dashboard.models import Data
import json
from datetime import *
from datetime import date
import datetime
class ChatConsumer(WebsocketConsumer):
......@@ -12,9 +13,16 @@ class ChatConsumer(WebsocketConsumer):
def receive(self, text_data):
print(text_data)
recieved = json.loads(text_data)
tmstp = datetime.strptime(recieved['timestamp'],'%Y-%m-%d %H:%M:%S')
d = Data.objects.create(timestamp=tmstp, value=recieved['data'])
#recieved = json.loads(text_data)
#tmstp = datetime.strptime(recieved['timestamp'],'%Y-%m-%d %H:%M:%S')
#td = date.today()
#tmstp = datetime.datetime.strptime(str(td), '%Y-%m-%d %H:%M:%S')
#print("temp : "+text_data)
temp = text_data.strip('()').split(',')
#print(temp)
#print(temp)
d = Data.objects.create(d1=temp[0],d2=temp[1],d3=temp[2],d4=temp[3],d5=temp[4],d6=temp[5],d7=temp[6],d8=temp[7])
d.save()
# print(d.__dict__)
# patient = Patient()
# patient.first_name = form.cleaned_data['first_name']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment