Added schedule manager
This commit is contained in:
202
schedule.html
Normal file
202
schedule.html
Normal file
@@ -0,0 +1,202 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!-- development version, includes helpful console warnings -->
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script><!-- production version, optimized for size and speed -->
|
||||
<!-- <script src="https://cdn.jsdelivr.net/npm/vue"></script>-->
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dom-to-image/2.6.0/dom-to-image.js"></script>
|
||||
<title>Stundenplan Pflege</title>
|
||||
<style>
|
||||
#editmode table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#editmode input {
|
||||
border: 0;
|
||||
/* color: white;
|
||||
background-color: #996861; */
|
||||
}
|
||||
#editmode #item-title textarea {
|
||||
border: 1px dotted grey;
|
||||
text-align: center;
|
||||
}
|
||||
#editmode #item-reset {
|
||||
color: rgb(211, 206, 206);
|
||||
}
|
||||
|
||||
#readonlydiv {
|
||||
color: white;
|
||||
background-color: #996861;
|
||||
font-family: sans-serif;
|
||||
font-size: large;
|
||||
}
|
||||
|
||||
#readonly-heading {
|
||||
font-size: x-large;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
#readonly-table {
|
||||
border:none;
|
||||
border-collapse: collapse;
|
||||
background-color: #996861;
|
||||
}
|
||||
#readonly-table th {
|
||||
border-top: none;
|
||||
border-bottom: 4px solid white;
|
||||
border-left: 4px solid white;
|
||||
border-right: 4px solid white;
|
||||
padding: 15px;
|
||||
}
|
||||
#readonly-table td {
|
||||
border-left: 4px solid white;
|
||||
border-right: 4px solid white;
|
||||
border-top: none;
|
||||
border-bottom: none;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
text-align: center;
|
||||
}
|
||||
#readonly-table th:first-child {
|
||||
border-left: none;
|
||||
}
|
||||
#readonly-table th:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
#readonly-table td:first-child {
|
||||
border-left: none;
|
||||
}
|
||||
#readonly-table td:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<input type="button"
|
||||
v-on:click="scheduleToImage()"
|
||||
value="Bild speichern">
|
||||
<div id="readonlydiv">
|
||||
<p id="readonly-heading">{{heading}}</p>
|
||||
<table id="readonly-table"
|
||||
ref="table">
|
||||
<tr>
|
||||
<th v-for="day in Object.keys(scheduleData)">{{ day }}</th>
|
||||
</tr>
|
||||
<tr v-for="slot in amountSlots">
|
||||
<td v-for="day in Object.keys(scheduleData)">
|
||||
<div v-if="getSchuduleItem(day, slot).to">
|
||||
<p id="item-time"><span>{{getSchuduleItem(day, slot).from}}</span> - <span>{{getSchuduleItem(day, slot).to}}</span></p>
|
||||
<p id="item-title"><span style="white-space: pre-line;">{{getSchuduleItem(day, slot).title}}</span></p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p style="text-align: center"><span style="white-space: pre-line;">{{caption}}</span></p>
|
||||
</div>
|
||||
<div id="editmode">
|
||||
<input type="text"
|
||||
v-model="heading">
|
||||
<table id="table"
|
||||
ref="table"
|
||||
style="border: 1px solid">
|
||||
<tr>
|
||||
<th v-for="day in Object.keys(scheduleData)">{{ day }}</th>
|
||||
</tr>
|
||||
<tr v-for="slot in amountSlots">
|
||||
<td v-for="day in Object.keys(scheduleData)">
|
||||
<div>
|
||||
<p id="item-time"><input id="item-from"
|
||||
max="20:00"
|
||||
min="09:00"
|
||||
step="900"
|
||||
type="time"
|
||||
v-model="getSchuduleItem(day, slot).from"> - <input id="item-to"
|
||||
max="20:00"
|
||||
min="09:00"
|
||||
step="900"
|
||||
type="time"
|
||||
v-model="getSchuduleItem(day, slot).to"></p>
|
||||
<p id="item-title">
|
||||
<textarea v-model="getSchuduleItem(day, slot).title"></textarea></p>
|
||||
</div>Eingaben löschen
|
||||
</td>
|
||||
</tr>
|
||||
</table><input style="border: 1px solid black"
|
||||
type="text"
|
||||
v-model="pw"
|
||||
v-on:click="pw=undefined">
|
||||
<textarea cols="50"
|
||||
rows="4"
|
||||
v-model="caption"></textarea> <input type="submit"
|
||||
v-on:click="saveSchedule()"
|
||||
value="Speichern"> <input type="button"
|
||||
v-on:click="exportSchedule()"
|
||||
value="Datei exportieren">
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
data: () => {
|
||||
return {
|
||||
amountSlots: 6,
|
||||
pw: "Passwort",
|
||||
heading: "Stundenplan 2019",
|
||||
caption: "* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\nf\u00fcr mehr Angebote rund um Mama/Baby www.stillberatungimrottal.de",
|
||||
scheduleData:{"Montag": [{"from": "09:00", "to": "10:15", "title": "Hatha Joga"}, {"from": "10:30", "to": "11:45", "title": "Joga f\u00fcr Schwangere"}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{}, {}, {"from": "15:30", "to": "16:30", "title": "Musikgarten"}, {"from": "18:00", "to": "19:30", "title": "Hatha/Vinjasa Yoga"}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:15", "title": "R\u00fcckbildung"}, {"from": "10:30", "to": "11:30", "title": "Fit f\u00fcr Dich"}, {}, {}, {}, {}], "Donnerstag": [{"from": "09:00", "to": "10:00", "title": "Babymassage"}, {"from": "10:00", "to": "11:15", "title": "R\u00fcckbildung"}, {}, {}, {}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Stilltreff * 2 w\u00f6chentlich"}, {}, {"from": "16:00", "to": "19:00", "title": "Geburtsvorbereitung"}, {}, {}, {}], "Samstag": [{"from": "09:00", "to": "12:00", "title": "Geburtsvorbereitung"}, {}, {}, {}, {}, {}]}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getSchuduleItem: function(day, slot) {
|
||||
return this.scheduleData[day][slot-1];
|
||||
},
|
||||
resetScheduleItem: function(day, slot) {
|
||||
this.scheduleData[day][slot-1].from = undefined;
|
||||
this.scheduleData[day][slot-1].to = undefined;
|
||||
this.scheduleData[day][slot-1].title = undefined;
|
||||
},
|
||||
saveSchedule: function() {
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
// xhr.open("POST", "https://kurswerkstatt-pan.de/api/schedule", true);
|
||||
xhr.open("POST", "http://localhost:8080", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/html');
|
||||
xhr.onload = function(e) {
|
||||
alert("Gespeichert")
|
||||
}
|
||||
xhr.onerror = function(e) {
|
||||
alert("Fehler: \"Datei exportieren\"-Button klicken und Datei Felix schicken")
|
||||
}
|
||||
xhr.send(JSON.stringify({
|
||||
pw: this.pw,
|
||||
schedule: this.scheduleData,
|
||||
caption: this.caption,
|
||||
heading: this.heading
|
||||
}));
|
||||
},
|
||||
scheduleToImage: function () {
|
||||
domtoimage.toJpeg(document.getElementById('readonlydiv'), { quality: 0.95 })
|
||||
.then(function (dataUrl) {
|
||||
var link = document.createElement('a');
|
||||
link.download = 'Stundenplan.jpg';
|
||||
link.href = dataUrl;
|
||||
link.click();
|
||||
})
|
||||
},
|
||||
exportSchedule: function downloadObjectAsJson(){
|
||||
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify({'schedule': this.scheduleData, 'caption': this.caption, heading: this.heading}));
|
||||
var downloadAnchorNode = document.createElement('a');
|
||||
downloadAnchorNode.setAttribute("href", dataStr);
|
||||
downloadAnchorNode.setAttribute("download", "Studenplan" + ".json");
|
||||
document.body.appendChild(downloadAnchorNode); // required for firefox
|
||||
downloadAnchorNode.click();
|
||||
downloadAnchorNode.remove();
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user