// vim: set et sw=2 ts=2: // // This file is part of Moonfire NVR, a security camera digital video recorder. // Copyright (C) 2018 Dolf Starreveld // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // In addition, as a special exception, the copyright holders give // permission to link the code of portions of this program with the // OpenSSL library under certain conditions as described in each // individual source file, and distribute linked combinations including // the two. // // You must obey the GNU General Public License in all respects for all // of the code used other than OpenSSL. If you modify file(s) with this // exception, you may extend this exception to your version of the // file(s), but you are not obligated to do so. If you do not wish to do // so, delete this exception statement from your version. If you delete // this exception statement from all source files in the program, then // also delete it here. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // TODO: test abort. // TODO: add error bar on fetch failure. // TODO: live updating. import 'jquery-ui/themes/base/button.css'; import 'jquery-ui/themes/base/core.css'; import 'jquery-ui/themes/base/datepicker.css'; import 'jquery-ui/themes/base/dialog.css'; import 'jquery-ui/themes/base/resizable.css'; import 'jquery-ui/themes/base/theme.css'; import 'jquery-ui/themes/base/tooltip.css'; // This causes our custom css to be loaded after the above! require('./assets/index.css'); import $ from 'jquery'; import 'jquery-ui/ui/widgets/datepicker'; import 'jquery-ui/ui/widgets/dialog'; import 'jquery-ui/ui/widgets/tooltip'; import Camera from './lib/models/Camera'; import CameraView from './lib/views/CameraView'; import CalendarView from './lib/views/CalendarView'; import NVRSettingsView from './lib/views/NVRSettingsView'; import CheckboxGroupView from './lib/views/CheckboxGroupView'; import RecordingFormatter from './lib/support/RecordingFormatter'; import TimeFormatter, { TimeStamp90kFormatter, } from './lib/support/TimeFormatter'; import MoonfireAPI from './lib/MoonfireAPI'; const api = new MoonfireAPI(); let cameraViews = null; // CameraView objects let calendarView = null; // CalendarView object /** * Currently selected time format specification. * * @type {String} */ let timeFmt = 'YYYY-MM-DD HH:mm:ss'; /** * Currently active time formatter. * This is lazy initialized at the point we receive the timezone information * and never changes afterwards, except possibly for changing the timezone. * * @type {[type]} */ let timeFormatter = null; /** * Currently active time formatter for internal time format. * This is lazy initialized at the point we receive the timezone information * and never changes afterwards, except possibly for changing the timezone. * * @type {[type]} */ let timeFormatter90k = null; /** * Globally set a new timezone for the app. * * @param {String} timeZone Timezone name */ function newTimeZone(timeZone) { timeFormatter = new TimeFormatter(timeFmt, timeZone); timeFormatter90k = new TimeStamp90kFormatter(timeZone); } /** * Globally set a new time format for the app. * * @param {String} format Time format specification */ function newTimeFormat(format) { timeFormatter = new TimeFormatter(format, timeFormatter.tz); } /** * Event handler for clicking on a video. * * A 'dialog' object is attached to the body of the dom and it * properly initialized with the corrcet src url. * * @param {NVRSettings} nvrSettingsView NVRSettingsView in effect * @param {object} camera Object for the camera * @param {object} range Range Object * @param {object} recording Recording object * @return {void} */ function onSelectVideo(nvrSettingsView, camera, range, recording) { console.log('Recording clicked: ', recording); const trimmedRange = recording.range90k(nvrSettingsView.trim ? range : null); const url = api.videoPlayUrl( camera.uuid, recording, trimmedRange, nvrSettingsView.timeStampTrack ); const video = $('