summaryrefslogtreecommitdiffstats
path: root/tools/pharos-dashboard/dashboard/static/js/fullcalendar-options.js
diff options
context:
space:
mode:
authormaxbr <maxbr@mi.fu-berlin.de>2016-07-29 12:43:43 +0200
committerMax Breitenfeldt <max.breitenfeldt@gmail.com>2016-07-29 11:25:20 +0000
commit35c34c690ae9616d791c39fa218fe1621fa8d8d2 (patch)
tree6168caaeb4be9144ed6bfde0150850d6559c8b6f /tools/pharos-dashboard/dashboard/static/js/fullcalendar-options.js
parent7ae1f204de947a3c12804c04f32e20d45eb99eba (diff)
import pharos dashboard code
JIRA: RELENG-12 The last commit was missing some JS/CSS dependencies of the site. This happened because they are in folders that are named 'build' or 'dist'. This commit adds a bower.json file, that specifies dependencies. Dependencies can now be installed by running 'bower install' in the dashboard/static folder. Change-Id: I054f319c66771f767e97711cb678d79d3bd6bee4 Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'tools/pharos-dashboard/dashboard/static/js/fullcalendar-options.js')
-rw-r--r--tools/pharos-dashboard/dashboard/static/js/fullcalendar-options.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/tools/pharos-dashboard/dashboard/static/js/fullcalendar-options.js b/tools/pharos-dashboard/dashboard/static/js/fullcalendar-options.js
new file mode 100644
index 00000000..c0417eb1
--- /dev/null
+++ b/tools/pharos-dashboard/dashboard/static/js/fullcalendar-options.js
@@ -0,0 +1,65 @@
+// converts a moment to a readable fomat for the backend
+function convertInputTime(time) {
+ return moment(time).format('YYYY-MM-DD HH:00 ZZ');
+}
+
+function sendEventToForm(event) {
+ var start = convertInputTime(event.start);
+ var end = convertInputTime(event.end);
+ $('#starttimepicker').data("DateTimePicker").date(start);
+ $('#endtimepicker').data("DateTimePicker").date(end);
+ $('#submitform').html("Change Booking");
+ $('#purposefield').val(event.title);
+ $('#id_booking_id').val(event.id); // create a new booking
+ $("#deletebutton").removeClass('hidden'); // show delete button
+}
+
+var calendarOptions = {
+ height: 600,
+ header: {
+ left: 'prev,next today',
+ center: 'title',
+ right: 'agendaWeek,month'
+ },
+ timezone: 'local',
+ defaultView: 'agendaWeek',
+ slotDuration: '00:60:00',
+ slotLabelFormat: "HH:mm",
+ firstDay: 1,
+ allDaySlot: false,
+ selectOverlap: false,
+ eventOverlap: false,
+ selectable: true,
+ selectHelper: true,
+ editable: false,
+ eventLimit: true, // allow "more" link when too many events
+ timeFormat: 'H(:mm)', // uppercase H for 24-hour clock
+ unselectAuto: false,
+
+ select: function (start, end) {
+ var start = convertInputTime(start);
+ var end = convertInputTime(end);
+
+ $('#starttimepicker').data("DateTimePicker").date(start);
+ $('#endtimepicker').data("DateTimePicker").date(end);
+ $('#submitform').html("Book Pod");
+ $('#purposefield').val('');
+ $('#id_booking_id').val(''); // create a new booking
+ $("#deletebutton").addClass('hidden'); // hide delete button
+ },
+
+ eventClick: function (event, jsEvent, view) {
+ $('#calendar').fullCalendar('unselect');
+ sendEventToForm(event);
+ },
+
+ eventDrop: function (event) {
+ $('#calendar').fullCalendar('unselect');
+ sendEventToForm(event);
+ },
+
+ eventResize: function (event) {
+ $('#calendar').fullCalendar('unselect');
+ sendEventToForm(event);
+ }
+}; \ No newline at end of file