Compare commits

..

10 Commits

Author SHA1 Message Date
ducoterra
54c6336e22 proper slash handling in button.js 2020-04-25 17:07:45 -04:00
ducoterra
7da888aa09 proper / on button 2020-04-25 16:37:53 -04:00
ducoterra
07d98bf11d remove admin panel 2020-04-25 15:54:10 -04:00
ducoterra
4584ba0143 split out helper functions from button.js 2020-04-25 15:23:12 -04:00
ducoterra
6feac7ef2e apply to html and body, not button 2020-04-25 15:14:01 -04:00
ducoterra
5efb93ea68 don't zoom on double tap 2020-04-25 15:03:03 -04:00
ducoterra
1ee6b890ef remove snippets urls for now 2020-04-25 12:58:31 -04:00
ducoterra
18aab648c6 you have got to be kidding me 2020-04-25 12:34:03 -04:00
ducoterra
57328a7fc8 need secret mounts 2020-04-25 12:30:04 -04:00
ducoterra
948569a659 spacing... spacing 2020-04-25 12:21:31 -04:00
9 changed files with 46 additions and 27 deletions

View File

@@ -46,4 +46,5 @@ deploy:
- for f in $(find k8s -regex '.*\.ya*ml'); do envsubst < $f > "/deploy/$(basename $f)"; done
- ./kubectl apply -f /deploy
- ./kubectl rollout status deploy $DEPLOY
- ./kubectl exec $(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}') -- python manage.py migrate
- POD=$(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}')
- ./kubectl exec $POD -- python manage.py migrate

13
.vscode/launch.json vendored
View File

@@ -5,7 +5,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django",
"name": "Test",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
@@ -13,6 +13,17 @@
"test",
],
"django": true
},
{
"name": "Run Server",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload"
],
"django": true
}
]
}

View File

@@ -18,7 +18,7 @@ from django.urls import path, include
from django.http import JsonResponse
urlpatterns = [
path('', include('api.urls')),
# path('api/', include('api.urls')),
path('', include('ui.urls')),
path('admin/', admin.site.urls),
# path('admin/', admin.site.urls),
]

View File

@@ -16,7 +16,9 @@ spec:
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
envFrom:
- configMapRef:
name: $DEPLOY
name: $DEPLOY
- secretRef:
name: django-secrets
volumeMounts:
- mountPath: /app/db
name: $DEPLOY

View File

@@ -1,6 +1,7 @@
html, body {
height: 100%;
width: 100%;
touch-action: manipulation;
}
.section, .container {

View File

@@ -1,26 +1,12 @@
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
var csrftoken = getCookie('csrftoken');
var button = document.getElementById("BUTTON");
var count = document.getElementById("COUNT");
const csrftoken = getCookie('csrftoken');
const button = document.getElementById("BUTTON");
const count = document.getElementById("COUNT");
// when button is clicked submit an empty post request
button.addEventListener("click", event => {
button.disabled = true;
fetch('/button', {
button.classList.add("is-loading");
fetch('/button/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -34,7 +20,9 @@ button.addEventListener("click", event => {
count.innerText = data.pressed;
}).finally(() => {
button.disabled = false;
button.classList.remove("is-loading");
});
});
// when the page is loaded automatically select the button
button.focus();

16
ui/static/ui/helper.js Normal file
View File

@@ -0,0 +1,16 @@
// get cookies when fetching with django
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}

View File

@@ -7,10 +7,10 @@
{% endblock %}
{% block js %}
<script src="{% static 'ui/helper.js' %}"></script>
<script src="{% static 'ui/button.js' %}"></script>
{% endblock %}
{% block body %}
<section class="section">
<div class="container">

View File

@@ -2,5 +2,5 @@ from django.urls import path
from . import views
urlpatterns = [
path('button', views.button, name = 'button'),
path('button/', views.button, name = 'button'),
]