remove coffee_scale
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
body {
|
|
||||||
background-color: white;
|
|
||||||
font-family: monospace;
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
#container{
|
|
||||||
position:relative;
|
|
||||||
width:95%;
|
|
||||||
margin-left:auto;
|
|
||||||
margin-right:auto;
|
|
||||||
height:100%;
|
|
||||||
overflow:hidden;
|
|
||||||
|
|
||||||
}
|
|
||||||
#upper{
|
|
||||||
background-size: contain;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: bottom center;
|
|
||||||
background-image: url("/static/coffee_scale/img/smokes.png");
|
|
||||||
transform-origin: bottom;
|
|
||||||
animation: smokes 8s ease-in-out 0s infinite;
|
|
||||||
opacity:0;
|
|
||||||
height:40%;
|
|
||||||
}
|
|
||||||
#lower{
|
|
||||||
position:relative;
|
|
||||||
background-size: contain;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: top center;
|
|
||||||
background-image: url("/static/coffee_scale/img/coffeecup3.png");
|
|
||||||
height:60%;
|
|
||||||
}
|
|
||||||
#scale{
|
|
||||||
position:absolute;
|
|
||||||
top:80%;
|
|
||||||
width:90%;
|
|
||||||
height:10%;
|
|
||||||
margin: 0% 5% 0% 5%;
|
|
||||||
background: lightgrey;
|
|
||||||
border-radius: 10px;
|
|
||||||
overflow:hidden;
|
|
||||||
}
|
|
||||||
#scale2{
|
|
||||||
width: 0%;
|
|
||||||
transition: width 2s;
|
|
||||||
height:100%;
|
|
||||||
background: green;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
.brewtime{
|
|
||||||
text-align:right;
|
|
||||||
position:absolute;
|
|
||||||
right:0px;
|
|
||||||
z-index:5;
|
|
||||||
font-size:10vw;
|
|
||||||
}
|
|
||||||
#address{
|
|
||||||
text-align:left;
|
|
||||||
position:absolute;
|
|
||||||
left:0px;
|
|
||||||
z-index:5;
|
|
||||||
font-size:4vw;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
.layertwo{
|
|
||||||
display: None;
|
|
||||||
}
|
|
||||||
noscript{
|
|
||||||
color:red;
|
|
||||||
}
|
|
||||||
.text{
|
|
||||||
color:green;
|
|
||||||
position:absolute;
|
|
||||||
top:50%;
|
|
||||||
left:50%;
|
|
||||||
}
|
|
||||||
.brewing{
|
|
||||||
animation: brewing 5s ease-in-out 0s infinite;
|
|
||||||
}
|
|
||||||
.hurry{
|
|
||||||
color:red !important;
|
|
||||||
}
|
|
||||||
.unknown{
|
|
||||||
color:orange !important;
|
|
||||||
animation: unknown 5s ease-in-out 0s infinite;
|
|
||||||
}
|
|
||||||
.friday{
|
|
||||||
animation: friday 20s ease-in-out 0s infinite;
|
|
||||||
}
|
|
||||||
.normal{
|
|
||||||
animation: normal 1000s ease-in-out 0s infinite;
|
|
||||||
}
|
|
||||||
.coffeeready{
|
|
||||||
animation: coffeeready 10s ease-in-out 0s;
|
|
||||||
}
|
|
||||||
@keyframes smokes {
|
|
||||||
0% {transform: skewX(-10deg);}
|
|
||||||
50% {transform: skewX(10deg);}
|
|
||||||
100% {transform: skewX(-10deg);}
|
|
||||||
}
|
|
||||||
@keyframes brewing {
|
|
||||||
0% {color:green;}
|
|
||||||
50% {color: transparent;}
|
|
||||||
100% {color:green;}
|
|
||||||
}
|
|
||||||
@keyframes coffeeready {
|
|
||||||
0% {background-color:white;}
|
|
||||||
25% {background-color:rgb(100, 255, 100);}
|
|
||||||
50% {background-color:white;}
|
|
||||||
75% {background-color:rgb(100, 255, 100);}
|
|
||||||
100% {background-color:white;}
|
|
||||||
}
|
|
||||||
@keyframes unknown {
|
|
||||||
0%,40% {transform: rotate(0deg);}
|
|
||||||
60%,100% {transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
@keyframes friday {
|
|
||||||
0% {transform: rotate(0deg);}
|
|
||||||
100% {transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
@keyframes normal {
|
|
||||||
0%,49% {transform: rotate(0deg);}
|
|
||||||
50%,100% {transform: rotate(360deg);}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.0 KiB |
@@ -1,183 +0,0 @@
|
|||||||
//Inner state
|
|
||||||
var lastBrew = new Date(0);
|
|
||||||
var brewing = false;
|
|
||||||
var backoff = 2000;
|
|
||||||
|
|
||||||
//MQTT client config
|
|
||||||
var username = "coffee-user-"+ Math.random();
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
var client = new Paho.MQTT.Client("sika.sahkoinsinoorikilta.fi", 9001, username);
|
|
||||||
client.onMessageArrived = function (message) {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log("Topic: "+message.destinationName+" msg: "+message.payloadString);
|
|
||||||
var ev = new CustomEvent(message.destinationName, {'detail': message.payloadString});
|
|
||||||
window.dispatchEvent(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
function reconnect(responseObject){
|
|
||||||
if (responseObject.errorCode !== 0) {
|
|
||||||
console.log("connection lost! Reason: "+responseObject.errorMessage); // eslint-disable-line no-console
|
|
||||||
setTimeout(function(){
|
|
||||||
client.connect({onSuccess:onConnect, useSSL:true, onFailure: reconnect});
|
|
||||||
}, backoff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onConnect() {
|
|
||||||
console.log("MQTT connected"); // eslint-disable-line no-console
|
|
||||||
//set and reset reconnector
|
|
||||||
client.onConnectionLost = reconnect
|
|
||||||
// subscribe to topics
|
|
||||||
client.subscribe("sik/kiltahuone/kahvivaaka/cups");
|
|
||||||
client.subscribe("sik/kiltahuone/kahvivaaka/brewing");
|
|
||||||
client.subscribe("sik/kiltahuone/kahvivaaka/brewtime");
|
|
||||||
}
|
|
||||||
|
|
||||||
// data update and parse functions
|
|
||||||
function parseCups(ev){
|
|
||||||
var cups = parseFloat(ev.detail).toFixed(1)
|
|
||||||
|
|
||||||
function makeEvent(cups) {
|
|
||||||
return (String(cups) !== '-1.0')
|
|
||||||
? new CustomEvent("cupsChanged", {'detail': cups})
|
|
||||||
: new CustomEvent("cupsError", {'detail': 'Error: unable to fetch cups :('});
|
|
||||||
}
|
|
||||||
|
|
||||||
window.dispatchEvent(makeEvent(cups));
|
|
||||||
}
|
|
||||||
function updateCups(ev){
|
|
||||||
$("#text").text(ev.detail);
|
|
||||||
}
|
|
||||||
function showCupsError(ev) {
|
|
||||||
$('#text').text(ev.detail);
|
|
||||||
$('#text').css({
|
|
||||||
'font-size': '7vh',
|
|
||||||
'left': '0',
|
|
||||||
'top': '40%',
|
|
||||||
'width': '100%',
|
|
||||||
'text-align': 'center',
|
|
||||||
'color': 'red',
|
|
||||||
});
|
|
||||||
$('#lower').css({'background-image': 'none'});
|
|
||||||
}
|
|
||||||
function updateScale(ev){
|
|
||||||
$("#scale2").css({width: Math.min(ev.detail/9*100,100) + '%'});
|
|
||||||
}
|
|
||||||
|
|
||||||
function tick(){
|
|
||||||
var ev = new CustomEvent("tick", {'detail': new Date()});
|
|
||||||
window.dispatchEvent(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateTime(ev){
|
|
||||||
var now = ev.detail;
|
|
||||||
$("#time").html(formatTime(now.getHours(),now.getMinutes(),now.getSeconds()));
|
|
||||||
}
|
|
||||||
|
|
||||||
function coffeeLowEffect(ev){
|
|
||||||
ev.detail <= 2 ? $("#text").addClass("hurry") : $("#text").removeClass("hurry");
|
|
||||||
}
|
|
||||||
function coffeeReadyEffect(){
|
|
||||||
$("body").addClass("coffeeready");
|
|
||||||
// autoclear animation class in 10s
|
|
||||||
setTimeout(function(){$("body").removeClass("coffeeready");}, 10000);
|
|
||||||
}
|
|
||||||
function hotEffect(ev){
|
|
||||||
var opa = Math.max(100 - ev.detail / 90000,0);
|
|
||||||
$("#upper").css({opacity: opa/100});
|
|
||||||
}
|
|
||||||
function brewAnimStart(){
|
|
||||||
$(".text").addClass("brewing");
|
|
||||||
$(".layerone").hide();
|
|
||||||
$(".layertwo").show();
|
|
||||||
}
|
|
||||||
function brewAnimEnd(){
|
|
||||||
$(".text").removeClass("brewing");
|
|
||||||
$(".layertwo").hide();
|
|
||||||
$(".layerone").show();
|
|
||||||
}
|
|
||||||
function brewNotifier(ev){
|
|
||||||
var new_brewing = parseInt(ev.detail);
|
|
||||||
if (new_brewing == 1 && brewing == 0){
|
|
||||||
window.dispatchEvent(new Event("brewStart"));
|
|
||||||
} else if (new_brewing == 0 && brewing == 1){
|
|
||||||
window.dispatchEvent(new Event("brewEnd"));
|
|
||||||
}
|
|
||||||
brewing = new_brewing;
|
|
||||||
}
|
|
||||||
function brewTimeParser(ev){
|
|
||||||
lastBrew = new Date(parseInt(ev.detail)*1000.0);
|
|
||||||
}
|
|
||||||
function updateBrewDiff(){
|
|
||||||
var now = new Date();
|
|
||||||
var timeDiff = Math.max(now.getTime() - lastBrew.getTime(), 0);
|
|
||||||
var eve = new CustomEvent("dtUpdate", {'detail': timeDiff});
|
|
||||||
window.dispatchEvent(eve);
|
|
||||||
}
|
|
||||||
function updateBrewTime(ev){
|
|
||||||
var timeDiff = ev.detail;
|
|
||||||
var timeStr;
|
|
||||||
if (timeDiff < 3600000){
|
|
||||||
timeStr = Math.round(timeDiff / 60000) + ' min'
|
|
||||||
} else if (timeDiff < 10000* 3600 * 1000){ // 1000h
|
|
||||||
timeStr = '~' + Math.round(timeDiff / 3600000 * 2) / 2 + ' h';
|
|
||||||
} else {
|
|
||||||
timeStr = "???"
|
|
||||||
}
|
|
||||||
$("#brewtime").html(timeStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helpers
|
|
||||||
|
|
||||||
function nToS(num){
|
|
||||||
return num < 10 ? "0" + num : "" + num;
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatTime(hours, minutes, seconds){
|
|
||||||
return nToS(hours)+":"+nToS(minutes)+":"+nToS(seconds)
|
|
||||||
}
|
|
||||||
|
|
||||||
function resize(){
|
|
||||||
var w = $("#container").width();
|
|
||||||
var h = $("#container").height();
|
|
||||||
var s = w > h ? h : w;
|
|
||||||
var font = s * 0.8 * 0.38/Math.sqrt(3);
|
|
||||||
$(".text").css({ top: s*0.16-font/2 + 'px',
|
|
||||||
fontSize: font + 'px',
|
|
||||||
marginLeft: -font*3*3/10 + 'px'});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init everything
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
|
||||||
client.connect({onSuccess:onConnect, useSSL:true, onFailure:reconnect});
|
|
||||||
|
|
||||||
//connect MQTT event listeners
|
|
||||||
window.addEventListener("sik/kiltahuone/kahvivaaka/cups", parseCups);
|
|
||||||
window.addEventListener("sik/kiltahuone/kahvivaaka/brewing", brewNotifier);
|
|
||||||
window.addEventListener("sik/kiltahuone/kahvivaaka/brewtime", brewTimeParser);
|
|
||||||
|
|
||||||
//connect other event listeners
|
|
||||||
window.addEventListener("cupsChanged", updateCups);
|
|
||||||
window.addEventListener("cupsChanged", coffeeLowEffect);
|
|
||||||
window.addEventListener("cupsChanged", updateScale);
|
|
||||||
window.addEventListener("cupsChanged", resize);
|
|
||||||
|
|
||||||
window.addEventListener("cupsError", showCupsError);
|
|
||||||
window.addEventListener("cupsError", coffeeLowEffect);
|
|
||||||
window.addEventListener("cupsError", updateScale);
|
|
||||||
|
|
||||||
window.addEventListener("brewStart", brewAnimStart);
|
|
||||||
window.addEventListener("brewEnd", brewAnimEnd);
|
|
||||||
window.addEventListener("brewEnd", coffeeReadyEffect);
|
|
||||||
window.addEventListener("tick", updateTime);
|
|
||||||
window.addEventListener("tick", updateBrewDiff);
|
|
||||||
window.addEventListener("dtUpdate", updateBrewTime);
|
|
||||||
window.addEventListener("dtUpdate", hotEffect);
|
|
||||||
|
|
||||||
//start time based events
|
|
||||||
setInterval(tick, 100);
|
|
||||||
tick();
|
|
||||||
|
|
||||||
});
|
|
||||||
$(window).resize(resize);
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{% load i18n %}
|
|
||||||
{% load static %}
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Coffee Cups @Guild Room - AYY SIK ry</title>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="refresh" content="3600">
|
|
||||||
<meta http-equiv="cache-control" content="max-age=0" />
|
|
||||||
<meta http-equiv="cache-control" content="no-cache" />
|
|
||||||
<meta http-equiv="expires" content="0" />
|
|
||||||
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
|
|
||||||
<meta http-equiv="pragma" content="no-cache" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.2/mqttws31.js"
|
|
||||||
type="text/javascript"></script>
|
|
||||||
<link rel="stylesheet" href="{% static "coffee_scale/css/coffee.css" %}">
|
|
||||||
<script src="{% static "coffee_scale/js/coffee.js" %}"></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div id="container">
|
|
||||||
<span id="brewtime" class="brewtime layerone"></span>
|
|
||||||
<span class="brewtime layertwo">:)</span>
|
|
||||||
<span id="address">
|
|
||||||
ka.dy.fi
|
|
||||||
<noscript><br>This page uses JavaScript!</noscript>
|
|
||||||
<br><span id="time"></span></span>
|
|
||||||
</span>
|
|
||||||
<div id="upper">
|
|
||||||
</div>
|
|
||||||
<!--Kahvinkeitin on rikki. Varakeittimellä keitettyä kahvia saattaa olla.-->
|
|
||||||
<div id="lower" class="normal">
|
|
||||||
<div id="text" class="text layerone">???</div>
|
|
||||||
<div class="text layertwo"> +</div>
|
|
||||||
<div id="scale"><div id="scale2"></div></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
from django.test import TestCase, Client
|
|
||||||
from django.conf import settings
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
from django.conf.urls import url
|
|
||||||
from django.conf import settings
|
|
||||||
from .views import coffee_view
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
# landing page
|
|
||||||
url(r'^$', coffee_view),
|
|
||||||
]
|
|
||||||
|
|
||||||
if settings.DEBUG:
|
|
||||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
|
||||||
urlpatterns += staticfiles_urlpatterns()
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
from django.http import JsonResponse
|
|
||||||
|
|
||||||
from django.utils import timezone
|
|
||||||
|
|
||||||
import logging
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
|
|
||||||
def coffee_view(request):
|
|
||||||
return render(request, 'coffee_scale:coffee.html')
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
PURPLE='\033[0;35m'
|
|
||||||
NC='\033[0m' # No Color
|
|
||||||
|
|
||||||
. "${VIRTUAL_ENV}/bin/activate"
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
printf "${PURPLE}Failed to find virtualenv. Skipping pre-push hook.\n${NC}"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
printf "${PURPLE}Running pre-push tests.${NC}\n"
|
|
||||||
printf "${PURPLE}npm tests...${NC}\n"
|
|
||||||
npm test
|
|
||||||
printf "${PURPLE}pycodestyle tests...${NC}\n"
|
|
||||||
pycodestyle .
|
|
||||||
printf "${PURPLE}unit tests...${NC}\n"
|
|
||||||
python -Wall manage.py test --noinput
|
|
||||||
set +e
|
|
||||||
|
|
||||||
printf "${PURPLE}Tests passed.${NC}\n"
|
|
||||||
@@ -86,7 +86,6 @@ INSTALLED_APPS = [
|
|||||||
'webapp',
|
'webapp',
|
||||||
'members',
|
'members',
|
||||||
'infoscreen',
|
'infoscreen',
|
||||||
'coffee_scale',
|
|
||||||
'kaehmy',
|
'kaehmy',
|
||||||
'ohlhafv',
|
'ohlhafv',
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ from django.views.generic.base import RedirectView
|
|||||||
import webapp.urls
|
import webapp.urls
|
||||||
import infoscreen.urls
|
import infoscreen.urls
|
||||||
import members.urls
|
import members.urls
|
||||||
import coffee_scale.urls
|
|
||||||
|
|
||||||
favicon_view = RedirectView.as_view(
|
favicon_view = RedirectView.as_view(
|
||||||
url='static/img/favicon.png', permanent=True)
|
url='static/img/favicon.png', permanent=True)
|
||||||
@@ -36,7 +35,6 @@ urlpatterns = [
|
|||||||
url(r'', include('webapp.urls')),
|
url(r'', include('webapp.urls')),
|
||||||
url(r'^members/', include('members.urls')),
|
url(r'^members/', include('members.urls')),
|
||||||
url(r'^infoscreen/', include('infoscreen.urls')),
|
url(r'^infoscreen/', include('infoscreen.urls')),
|
||||||
url(r'^coffee/', include('coffee_scale.urls')),
|
|
||||||
url(r'^kaehmy/', include('kaehmy.urls')),
|
url(r'^kaehmy/', include('kaehmy.urls')),
|
||||||
url(r'^ohlhafv/', include('ohlhafv.urls')),
|
url(r'^ohlhafv/', include('ohlhafv.urls')),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user