-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
109 lines (101 loc) · 5.47 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sittings Logger</title>
<link rel="manifest" href="manifest.json">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100">
<div class="container mx-auto mt-8 p-4">
<h1 class="text-2xl font-bold mb-4">Sittings Logger</h1>
<div x-data="app()" x-init="loadData()">
<!-- Entry form -->
<div class="max-w-full bg-white p-4 rounded-lg shadow-lg">
<div class="mb-4">
<label for="datetime" class="block font-medium text-gray-700">Date and Time</label>
<input x-model="datetime" type="datetime-local" id="datetime" name="datetime" class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
<div class="mb-4">
<div class="inline-block space-x-2">
<label for="duration" class="inline-block font-medium text-gray-700">Length (minutes)</label>
<button class="inline-block px-2 py-1 bg-gray-100 rounded" @click="duration = 5">5</button>
<button class="inline-block px-2 py-1 bg-gray-100 rounded" @click="duration = 15">15</button>
<button class="inline-block px-2 py-1 bg-gray-100 rounded" @click="duration = 30">30</button>
</div>
<input x-model="duration" type="number" id="duration" name="duration" class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
<div class="mb-4">
<details>
<summary>Adjust type</summary>
<label for="type" class="block font-medium text-gray-700">Type</label>
<select x-model="type" id="type" name="type" class="w-full mt-1 p-2 border border-gray-300 rounded-md">
<option value="Sitting">Sitting</option>
<option value="Walking">Walking</option>
<option value="Bodyscan">Bodyscan</option>
<option value="Other">Other</option>
</select>
</details>
</div>
<div class="mb-4">
<details>
<summary>Add comment</summary>
<label for="comment" class="block font-medium text-gray-700">Comment</label>
<textarea x-model="comment" id="comment" name="comment" class="w-full mt-1 p-2 border border-gray-300 rounded-md resize-none" rows="4"></textarea>
</div>
<button @click="saveEntry()" class="bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600">Save</button>
</details>
</div>
<!-- Previous sessions -->
<div class="mt-8">
<h2 class="text-xl font-bold mb-4">Previous Sessions</h2>
<table class="w-full max-w-full divide-y divide-gray-200 bg-white shadow rounded-lg shadow-lg">
<thead class="bg-gray-50">
<tr>
<th class="px-2 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Time</th>
<th class="px-2 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">min</th>
<th class="px-2 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">T</th>
<th class="px-2 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Edit</th>
<th class="px-2 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Delete</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<template x-for="entry in entries" :key="entry.id">
<tr>
<td class="px-2 py-2 whitespace-nowrap text-sm" x-text="entry.shorttime"></td>
<td class="px-2 py-2 whitespace-nowrap text-sm" x-text="entry.duration"></td>
<td class="px-2 py-2 whitespace-nowrap text-sm" x-text="entry.shorttype"></td>
<td class="px-2 py-2 whitespace-nowrap">
<button @click="editEntry(entry.id)" class="bg-blue-500 text-white py-1 px-2 rounded hover:bg-blue-600">Edit</button>
</td>
<td class="px-2 py-2 whitespace-nowrap">
<button @click="deleteEntry(entry.id)" class="bg-red-500 text-white py-1 px-2 rounded hover:bg-red-600">Delete</button>
</td>
</tr>
</template>
</tbody>
</table>
</div>
<!-- Chart -->
<div class="mt-8">
<canvas id="chart" width="400" height="200"></canvas>
</div>
<!-- Edit LocalStorage data -->
<details class="mt-8">
<summary>Edit LocalStorage Data</summary>
<div class="font-mono">
<div class="w-full bg-white p-4 rounded-lg shadow-lg">
<label for="localStorageData" class="block font-medium text-gray-700">LocalStorage Data (JSON format)</label>
<textarea x-model="localStorageData" id="localStorageData" name="localStorageData" class="w-full mt-1 p-2 border border-gray-300 rounded-md resize-none" rows="8"></textarea>
<button @click="saveLocalStorageData()" class="mt-2 bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600">Save LocalStorage Data</button>
</div>
</div>
</details>
</div>
</div>
<script defer src="https://unpkg.com/alpinejs"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="app.js"></script>
</body>
</html>