diff --git a/client/components/alert.js b/client/components/alert.js index 304eef74..23003ef0 100644 --- a/client/components/alert.js +++ b/client/components/alert.js @@ -1,10 +1,9 @@ -import React from 'react'; -import PropTypes from 'prop-types'; +import React from "react"; -import { Input, Button, Modal, NgIf } from './'; -import { alert } from '../helpers/'; -import { Popup } from './popup'; -import { t } from '../locales/'; +import { Button } from "./"; +import { alert } from "../helpers/"; +import { Popup } from "./popup"; +import { t } from "../locales/"; import "./alert.scss"; @@ -23,7 +22,7 @@ export class ModalAlert extends Popup { }); } - onSubmit(e){ + onSubmit(){ this.setState({appear: false}, () => { requestAnimationFrame(() => this.state.fn && this.state.fn()); }); diff --git a/client/components/audio.js b/client/components/audio.js index b2446d08..11d14e55 100644 --- a/client/components/audio.js +++ b/client/components/audio.js @@ -1,21 +1,20 @@ -import React from 'react'; -import PropTypes from 'prop-types'; +import React from "react"; -import { Container, Icon, NgIf } from './'; -import './audio.scss'; +import { Container, Icon, NgIf } from "./"; +import "./audio.scss"; export class Audio extends React.Component { constructor(props){ super(props); this.state = { percent: 0, - state: 'play' + state: "play" }; } componentDidMount(){ requestAnimationFrame(() => { - if(this.state.state === 'play'){ + if(this.state.state === "play"){ if(this.state.percent < 100){ this.setState({percent: this.state.percent + 0.1}, this.componentDidMount); }else{ @@ -33,8 +32,8 @@ export class Audio extends React.Component { return (
-
- +
+ @@ -45,7 +44,7 @@ export class Audio extends React.Component { } } -const Volume = (props) => { +const Volume = () => { return (
VOLUME @@ -54,21 +53,20 @@ const Volume = (props) => {
); -} +}; const Control = (props) => { return (
- + - +
); -} - +}; const Progress = (props) => { return ( @@ -77,7 +75,7 @@ const Progress = (props) => {
); -} +}; const TrackInfo = (props) => { return ( @@ -87,4 +85,4 @@ const TrackInfo = (props) => {
); -} +}; diff --git a/client/components/button.js b/client/components/button.js index 61f75dfc..07d5e5c5 100644 --- a/client/components/button.js +++ b/client/components/button.js @@ -1,7 +1,7 @@ -import React from 'react'; -import PropTypes from 'prop-types'; +import React from "react"; +import PropTypes from "prop-types"; -import './button.scss'; +import "./button.scss"; export class Button extends React.Component { constructor(props){ @@ -12,7 +12,7 @@ export class Button extends React.Component { let props = Object.assign({}, this.props); delete props.theme; return ( - ); diff --git a/client/components/card.js b/client/components/card.js index 82438e22..5648387a 100644 --- a/client/components/card.js +++ b/client/components/card.js @@ -1,5 +1,5 @@ -import React from 'react'; -import './card.scss'; +import React from "react"; +import "./card.scss"; export class Card extends React.Component { constructor(props){ diff --git a/client/components/confirm.js b/client/components/confirm.js index 1cdc984c..cac9fd68 100644 --- a/client/components/confirm.js +++ b/client/components/confirm.js @@ -1,10 +1,9 @@ -import React from 'react'; -import PropTypes from 'prop-types'; +import React from "react"; -import { Input, Button, Modal, NgIf } from './'; -import { confirm } from '../helpers/'; -import { Popup } from './popup'; -import { t } from '../locales/'; +import { Button } from "./"; +import { confirm } from "../helpers/"; +import { Popup } from "./popup"; +import { t } from "../locales/"; export class ModalConfirm extends Popup{ constructor(props){ diff --git a/client/components/container.js b/client/components/container.js index b43c8cad..9d020807 100644 --- a/client/components/container.js +++ b/client/components/container.js @@ -1,6 +1,5 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import './container.scss'; +import React from "react"; +import "./container.scss"; export class Container extends React.Component { constructor(props){ diff --git a/client/components/decorator.js b/client/components/decorator.js index f7cec6fd..73bdeed3 100644 --- a/client/components/decorator.js +++ b/client/components/decorator.js @@ -1,22 +1,21 @@ -import React from 'react'; -import { Link } from 'react-router-dom'; -import { browserHistory, Redirect } from 'react-router'; +import React from "react"; +import { Link } from "react-router-dom"; -import { Session, Admin } from '../model/'; -import { Container, Loader, Icon, NgIf } from '../components/'; -import { memory, currentShare } from '../helpers/'; -import { t } from '../locales/'; +import { Session } from "../model/"; +import { Container, Loader, Icon } from "../components/"; +import { memory, currentShare } from "../helpers/"; +import { t } from "../locales/"; -import '../pages/error.scss'; +import "../pages/error.scss"; export function LoggedInOnly(WrappedComponent){ - memory.set('user::authenticated', false); + memory.set("user::authenticated", false); return class extends React.Component { constructor(props){ super(props); this.state = { - is_logged_in: memory.get('user::authenticated') + is_logged_in: memory.get("user::authenticated") }; } @@ -27,7 +26,7 @@ export function LoggedInOnly(WrappedComponent){ this.props.error({message: "Authentication Required"}); return; } - memory.set('user::authenticated', true); + memory.set("user::authenticated", true); this.setState({is_logged_in: true}); }).catch((err) => { if(err.code === "NO_INTERNET"){ @@ -56,7 +55,7 @@ export function ErrorPage(WrappedComponent){ error: null, has_back_button: false }; - this.unlisten = this.props.history.listen((location, action) => { + this.unlisten = this.props.history.listen(() => { this.setState({has_back_button: false}); this.unlisten(); }); @@ -101,9 +100,9 @@ export function ErrorPage(WrappedComponent){ }; } -export const LoadingPage = (props) => { +export const LoadingPage = () => { return ( -
+
); diff --git a/client/components/dropdown.js b/client/components/dropdown.js index 29cf14dd..c53b8cbf 100644 --- a/client/components/dropdown.js +++ b/client/components/dropdown.js @@ -3,12 +3,11 @@ * we replace the dirty select on desktop by something more fancy but not on ios/android * as there's just no reason for doing that. */ - -import React from 'react'; -import ReactDOM from 'react-dom'; +import React from "react"; +import ReactDOM from "react-dom"; import { Icon, NgIf } from "./"; -import './dropdown.scss'; +import "./dropdown.scss"; export class Dropdown extends React.Component { constructor(props){ @@ -44,9 +43,9 @@ export class Dropdown extends React.Component { this.setState({button: false}); } - toggleDropdown(e){ + toggleDropdown(){ if(this.props.enable === false){ - return + return; } document.body.removeEventListener("click", this.closeDropdown); this.setState({button: !this.state.button}, () => { @@ -81,7 +80,7 @@ export const DropdownButton = (props) => { { props.children }
); -} +}; export const DropdownList = (props) => { @@ -107,7 +106,7 @@ export const DropdownItem = (props) => {
{props.children} - + diff --git a/client/components/events.js b/client/components/events.js index ad40e2c2..3b5a2215 100644 --- a/client/components/events.js +++ b/client/components/events.js @@ -1,6 +1,6 @@ // cheap event system that handle subscription, unsubscriptions and event emitions -import React from 'react'; -let emitters = {} +import React from "react"; +let emitters = {}; function subscribe(key, event, fn){ if(emitters[event]){ @@ -25,12 +25,14 @@ function emit(event, payload){ // trigger events if needed if(emitters[event]){ return Promise.all(Object.keys(emitters[event]).map((key) => { - return emitters[event][key].apply(null, payload) + return emitters[event][key].apply(null, payload); })).then((res) => { - return emitters[event] ? Promise.resolve(res) : Promise.reject({message: 'do not exist', code: 'CANCELLED'}) + return emitters[event] ? + Promise.resolve(res) : + Promise.reject({message: "do not exist", code: "CANCELLED"}); }); }else{ - return Promise.reject({message: 'oups, something went wrong', code: 'NO_LISTENERS'}) + return Promise.reject({message: "oups, something went wrong", code: "NO_LISTENERS"}); } } @@ -39,17 +41,17 @@ export function EventReceiver(WrappedComponent){ return class extends React.Component { subscribe(event, callback){ - subscribe(id, event, callback) + subscribe(id, event, callback); } unsubscribe(event){ - unsubscribe(id, event) + unsubscribe(id, event); } render(){ return ; } - } + }; } export function EventEmitter(WrappedComponent) { @@ -64,12 +66,12 @@ export function EventEmitter(WrappedComponent) { if(res.then){ return res; }else{ - return Promise.resolve(res) + return Promise.resolve(res); } } render() { return ; } - } + }; } diff --git a/client/components/fab.js b/client/components/fab.js index 14fcde66..c616713d 100644 --- a/client/components/fab.js +++ b/client/components/fab.js @@ -1,8 +1,7 @@ -import React from 'react'; +import React from "react"; +import "./fab.scss"; -import './fab.scss'; - -export const Fab = (props) => { +export function Fab(props){ return (
diff --git a/client/components/formbuilder.js b/client/components/formbuilder.js index 8a6fe7dd..99378cf3 100644 --- a/client/components/formbuilder.js +++ b/client/components/formbuilder.js @@ -1,9 +1,9 @@ -import React from 'react'; -import PropTypes from 'prop-types'; +import React from "react"; +import PropTypes from "prop-types"; -import { Input, Textarea, Select, Enabler } from './'; -import { FormObjToJSON, format, autoComplete, notify } from '../helpers/'; -import { t } from '../locales/'; +import { Input, Textarea, Select, Enabler } from "./"; +import { FormObjToJSON, format, autoComplete, notify } from "../helpers/"; +import { t } from "../locales/"; import "./formbuilder.scss"; @@ -29,7 +29,7 @@ export class FormBuilder extends React.Component { let _advanced = []; for (let key in s){ const tmp = {key: key, data: s[key]}; - 'id' in s[key] ? _advanced.push(tmp) : _normal.push(tmp); + "id" in s[key] ? _advanced.push(tmp) : _normal.push(tmp); } return [_normal, _advanced]; }(struct); @@ -116,7 +116,7 @@ const FormElement = (props) => { let struct = props.params; let $input = ( props.onChange(e.target.value)} {...id} name={struct.label} type="text" defaultValue={struct.value} placeholder={ t(struct.placeholder) } /> ); switch(props.params["type"]){ - case "text": + case "text": { const onTextChange = (value) => { if(value === ""){ value = null; @@ -152,14 +152,16 @@ const FormElement = (props) => { ); } break; - case "number": + } + case "number": { const onNumberChange = (value) => { value = value === "" ? null : parseInt(value); props.onChange(value); }; $input = ( onNumberChange(e.target.value)} {...id} name={struct.label} type="number" value={struct.value === null ? "" : struct.value} placeholder={ t(struct.placeholder) } /> ); break; - case "password": + } + case "password": { const onPasswordChange = (value) => { if(value === ""){ value = null; @@ -168,7 +170,8 @@ const FormElement = (props) => { }; $input = ( onPasswordChange(e.target.value)} {...id} name={struct.label} type="password" value={struct.value || ""} placeholder={ t(struct.placeholder) } autoComplete="off" autoCorrect="off" autoCapitalize="off" spellCheck="false"/> ); break; - case "long_password": + } + case "long_password": { const onLongPasswordChange = (value) => { if(value === ""){ value = null; @@ -179,10 +182,11 @@ const FormElement = (props) => { ); } diff --git a/client/components/upload_queue.js b/client/components/upload_queue.js index 0e85ef39..4f3e37e9 100644 --- a/client/components/upload_queue.js +++ b/client/components/upload_queue.js @@ -1,28 +1,38 @@ -import React from 'react'; -import Path from 'path'; +import React from "react"; +import Path from "path"; -import { Files } from '../model/'; -import { confirm, notify, upload } from '../helpers/'; -import { Icon, NgIf } from './'; -import { t } from '../locales/'; -import './upload_queue.scss'; +import { Files } from "../model/"; +import { confirm, notify, upload } from "../helpers/"; +import { Icon, NgIf } from "./"; +import { t } from "../locales/"; +import "./upload_queue.scss"; const MAX_POOL_SIZE = 15; function humanFileSize(bytes, si) { var thresh = si ? 1000 : 1024; if (Math.abs(bytes) < thresh) { - return bytes.toFixed(1) + ' B'; + return bytes.toFixed(1) + " B"; } var units = si - ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] - : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; + ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] + : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]; var u = -1; do { bytes /= thresh; ++u; } while (Math.abs(bytes) >= thresh && u < units.length - 1); - return bytes.toFixed(1) + ' ' + units[u]; + return bytes.toFixed(1) + " " + units[u]; +} + +function waitABit() { + return new Promise((done) => { + window.setTimeout(() => { + requestAnimationFrame(() => { + done(); + }); + }, 200); + }); } export class UploadQueue extends React.Component { @@ -137,15 +147,6 @@ export class UploadQueue extends React.Component { return this.runner(id); }); } else { - function waitABit() { - return new Promise((done) => { - window.setTimeout(() => { - requestAnimationFrame(() => { - done(); - }); - }, 200); - }); - } return waitABit().then(() => this.runner(id)); } } @@ -184,13 +185,13 @@ export class UploadQueue extends React.Component { const processes = files.map((file) => { let original_path = file.path; file.path = Path.join(path, file.path); - if (file.type === 'file') { - if (files.length < 150) Files.touch(file.path, file.file, 'prepare_only'); + if (file.type === "file") { + if (files.length < 150) Files.touch(file.path, file.file, "prepare_only"); return { path: original_path, parent: file._prior || null, fn: Files.touch.bind( - Files, file.path, file.file, 'execute_only', + Files, file.path, file.file, "execute_only", { progress: (e) => this.updateProgress(original_path, e), abort: (x) => this.updateAbort(original_path, x), @@ -198,12 +199,12 @@ export class UploadQueue extends React.Component { ) }; } else { - Files.mkdir(file.path, 'prepare_only'); + Files.mkdir(file.path, "prepare_only"); return { id: file._id || null, path: original_path, parent: file._prior || null, - fn: Files.mkdir.bind(Files, file.path, 'execute_only') + fn: Files.mkdir.bind(Files, file.path, "execute_only") }; } }); @@ -231,7 +232,7 @@ export class UploadQueue extends React.Component { running: true, error: null }); - Promise.all(Array.apply(null, Array(MAX_POOL_SIZE)).map((process, index) => { + Promise.all(Array.apply(null, Array(MAX_POOL_SIZE)).map(() => { return this.runner(); })).then(() => { this.setState({ running: false }); @@ -260,7 +261,7 @@ export class UploadQueue extends React.Component { calcSpeed() { let now = Date.now(); let curSpeed = []; - for (const [key, value] of Object.entries(this.state.progress)) { + for (const [, value] of Object.entries(this.state.progress)) { if (value.prev && now - value.time < 5 * 1000) { let bytes = value.loaded - value.prev.loaded; let timeMs = value.time - value.prev.time; @@ -315,7 +316,7 @@ export class UploadQueue extends React.Component { className="file_path" onClick={() => this.emphasis(process.path)} > - {process.path.replace(/\//, '')} + {process.path.replace(/\//, "")}
{col_state(process)}
@@ -338,14 +339,14 @@ export class UploadQueue extends React.Component { {finished.length} {totalFiles}
- this.onClose()} /> + this.onClose()} />

{this.state.error ? this.state.error : this.getState()}

{this.renderRows( finished, "done", - (_) => (
{ t("Done") }
), + () => (
{ t("Done") }
), )} {this.renderRows( currents, @@ -356,13 +357,13 @@ export class UploadQueue extends React.Component {
), (p) => ( - this.abort(p)} > + this.abort(p)} > ) )} {this.renderRows( processes, "todo", - (_) => ( + () => (
{ t("Waiting") }
) )} @@ -370,14 +371,14 @@ export class UploadQueue extends React.Component { failed, "error", (p) => ( - (p.err && p.err.message == 'aborted') + (p.err && p.err.message == "aborted") ?
{ t("Aborted") }
:
{ t("Error") }
), (p) => ( - this.retryFiles(p)} > + this.retryFiles(p)} > ) )}
diff --git a/client/components/video.js b/client/components/video.js index 60019797..74e2ccd7 100644 --- a/client/components/video.js +++ b/client/components/video.js @@ -1,9 +1,6 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import { Icon, NgIf } from './'; -import './video.scss'; - +import React from "react"; +import { Icon } from "./"; +import "./video.scss"; export class Video extends React.Component { constructor(props){ @@ -20,8 +17,3 @@ export class Video extends React.Component { ); } } - - -// diff --git a/client/helpers/index.js b/client/helpers/index.js index d77a495e..4fea5ff1 100644 --- a/client/helpers/index.js +++ b/client/helpers/index.js @@ -1,4 +1,4 @@ -export { URL_HOME, goToHome, URL_FILES, goToFiles, URL_VIEWER, goToViewer, URL_LOGIN, goToLogin, URL_LOGOUT, goToLogout, urlParams } from './navigate'; +export { URL_HOME, goToHome, URL_FILES, goToFiles, URL_VIEWER, goToViewer, URL_LOGIN, goToLogin, URL_LOGOUT, goToLogout, urlParams, URL_ADMIN, URL_SHARE } from './navigate'; export { opener } from './mimetype'; export { debounce, throttle } from './backpressure'; export { event } from './events'; diff --git a/client/helpers/navigate.js b/client/helpers/navigate.js index c6eebe94..e78635b9 100644 --- a/client/helpers/navigate.js +++ b/client/helpers/navigate.js @@ -29,6 +29,10 @@ export function goToLogout(history){ return Promise.resolve("ok"); } +export const URL_ADMIN = "/admin"; + +export const URL_SHARE = "/s"; + function encode_path(path){ if(/%2F/.test(path) === false){ return encodeURIComponent(path).replace(/%2F/g, "/"); // replace slash to make url more friendly diff --git a/client/pages/viewerpage/formviewer.js b/client/pages/viewerpage/formviewer.js index 9f5bba54..fc8e81fb 100644 --- a/client/pages/viewerpage/formviewer.js +++ b/client/pages/viewerpage/formviewer.js @@ -1,10 +1,10 @@ -import React from 'react'; -import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; +import React from "react"; +import ReactCSSTransitionGroup from "react-addons-css-transition-group"; -import { MenuBar } from './menubar'; -import { Container, FormBuilder, NgIf, Icon, Fab } from '../../components/'; -import { appendShareToUrl } from '../../helpers/'; -import './formviewer.scss'; +import { MenuBar } from "./menubar"; +import { Container, FormBuilder, NgIf, Icon, Fab } from "../../components/"; +import { appendShareToUrl } from "../../helpers/"; +import "./formviewer.scss"; export class FormViewer extends React.Component { constructor(props){ @@ -29,7 +29,7 @@ export class FormViewer extends React.Component { save(){ if(this.props.needSaving === false) return; - let blob = new window.Blob([JSON.stringify(this.state.form)], {type : 'text/plain'}); + let blob = new window.Blob([JSON.stringify(this.state.form)], {type : "text/plain"}); return this.props .onSave(blob) .then(() => this.props.needSavingUpdate(false)); diff --git a/client/pages/viewerpage/index.js b/client/pages/viewerpage/index.js index 9bdc88ba..ce0598f9 100644 --- a/client/pages/viewerpage/index.js +++ b/client/pages/viewerpage/index.js @@ -1,8 +1,8 @@ -export { FileDownloader } from './filedownloader'; -export { ImageViewer } from './imageviewer'; -export { PDFViewer } from './pdfviewer'; -export { FormViewer } from './formviewer'; +export { FileDownloader } from "./filedownloader"; +export { ImageViewer } from "./imageviewer"; +export { PDFViewer } from "./pdfviewer"; +export { FormViewer } from "./formviewer"; // Those are commented because they will be delivered as a separate chunk -//export { VideoPlayer } from './videoplayer'; -//export { IDE } from './ide'; -//export { AudioPlayer } from './audioplayer'; +//export { VideoPlayer } from "./videoplayer"; +//export { IDE } from "./ide"; +//export { AudioPlayer } from "./audioplayer"; diff --git a/client/pages/viewerpage/menubar.js b/client/pages/viewerpage/menubar.js index 11f9f96a..bb739990 100644 --- a/client/pages/viewerpage/menubar.js +++ b/client/pages/viewerpage/menubar.js @@ -1,9 +1,9 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; +import React from "react"; +import PropTypes from "prop-types"; +import ReactCSSTransitionGroup from "react-addons-css-transition-group"; -import { Container, NgIf, Icon } from '../../components/'; -import './menubar.scss'; +import { Container, NgIf, Icon } from "../../components/"; +import "./menubar.scss"; export const MenuBar = (props) => { @@ -11,7 +11,7 @@ export const MenuBar = (props) => {
-
{props.title}
+
{props.title}
{props.children} @@ -37,14 +37,15 @@ class DownloadButton extends React.Component { this.setState({ loading: true }); - document.cookie = "download=yes; path=/; max-age=120;"; - this.state.id = window.setInterval(() => { - if(/download=yes/.test(document.cookie) === false){ - window.clearInterval(this.state.id); - this.setState({loading: false}); - } - }, 100); + this.setState({ + id: window.setInterval(() => { + if(/download=yes/.test(document.cookie) === false){ + window.clearInterval(this.state.id); + this.setState({loading: false}); + } + }, 100) + }); } componentWillUnmount(){ diff --git a/client/pages/viewerpage/org_viewer.js b/client/pages/viewerpage/org_viewer.js index 394f015d..9115032a 100644 --- a/client/pages/viewerpage/org_viewer.js +++ b/client/pages/viewerpage/org_viewer.js @@ -1,12 +1,12 @@ -import React from 'react'; -import { StickyContainer, Sticky } from 'react-sticky'; +import React from "react"; +import { StickyContainer, Sticky } from "react-sticky"; -import { Modal, Container, NgIf, Icon, Dropdown, DropdownButton, DropdownList, DropdownItem } from '../../components/'; -import { extractEvents, extractTodos } from '../../helpers/org'; -import { leftPad } from '../../helpers/common'; -import { debounce } from '../../helpers/'; -import { t } from '../../locales/'; -import './org_viewer.scss'; +import { Modal, NgIf, Icon, Dropdown, DropdownButton, DropdownList, DropdownItem } from "../../components/"; +import { extractEvents, extractTodos } from "../../helpers/org"; +import { leftPad } from "../../helpers/common"; +import { debounce } from "../../helpers/"; +import { t } from "../../locales/"; +import "./org_viewer.scss"; export class OrgEventsViewer extends React.Component { shouldComponentUpdate(nextProps){ @@ -47,7 +47,7 @@ class OrgViewer extends React.Component { this.state = { headlines: this.buildHeadlines(props.headlines), content: props.content, - search: '', + search: "", _: null }; this.rerender = () => {this.setState({_: Math.random()});}; @@ -64,8 +64,8 @@ class OrgViewer extends React.Component { buildHeadlines(headlines){ return headlines .reduce((acc, headline) => { - if(!acc[headline['key']]){ acc[headline['key']] = []; } - acc[headline['key']].push(headline); + if(!acc[headline["key"]]){ acc[headline["key"]] = []; } + acc[headline["key"]].push(headline); return acc; }, {}); } @@ -88,14 +88,14 @@ class OrgViewer extends React.Component { break; case "subtask": if(value === "DONE"){ - content[line] = content[line].replace(/\[.\]/, '[X]'); + content[line] = content[line].replace(/\[.\]/, "[X]"); }else{ - content[line] = content[line].replace(/\[.\]/, '[ ]'); + content[line] = content[line].replace(/\[.\]/, "[ ]"); } break; case "existing_scheduled": [head_line, head_status, item_line] = line; - content[item_line] = content[item_line].replace(/SCHEDULED\: \<.*?\>\s*/, value ? "SCHEDULED: "+orgdate(value)+" " : ""); + content[item_line] = content[item_line].replace(/SCHEDULED: <.*?>\s*/, value ? "SCHEDULED: "+orgdate(value)+" " : ""); this.state.headlines[head_status] = this.state.headlines[head_status] .map((todo) => { if(todo.line === head_line){ @@ -108,7 +108,7 @@ class OrgViewer extends React.Component { break; case "existing_deadline": [head_line, head_status, item_line] = line; - content[item_line] = content[item_line].replace(/DEADLINE\: \<.*?\>\s*/, value ? "DEADLINE: "+orgdate(value) : ""); + content[item_line] = content[item_line].replace(/DEADLINE: <.*?>\s*/, value ? "DEADLINE: "+orgdate(value) : ""); this.state.headlines[head_status] = this.state.headlines[head_status] .map((todo) => { if(todo.line === head_line){ @@ -185,7 +185,7 @@ class OrgViewer extends React.Component { this.setState({headlines: this.state.headlines}); } break; - }; + } this.setState({content: content.join("\n")}); function orgdate(_date){ @@ -194,8 +194,9 @@ class OrgViewer extends React.Component { function day(n){ switch(navigator.language.split("-")[0]){ - case "de": ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"][n]; - default: return ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][n]; + case "de": ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"][n]; + break; + default: return ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][n]; } } } @@ -212,10 +213,10 @@ class OrgViewer extends React.Component { } componentDidMount(){ - window.addEventListener('resize', this.rerender); + window.addEventListener("resize", this.rerender); } componentWillUnmount(){ - window.removeEventListener('resize', this.rerender); + window.removeEventListener("resize", this.rerender); } search(terms){ @@ -231,8 +232,8 @@ class OrgViewer extends React.Component { const keywords = terms.split(" "); const head = function(){ let str = " "; - str += headline['status'] + " "; - str += headline['title'] + " "; + str += headline["status"] + " "; + str += headline["title"] + " "; str += headline.tags.map((tag) => "#"+tag).join(" ") + " "; str += headline.scheduled ? "scheduled "+headline.scheduled.timestamp + " ": ""; str += headline.deadline ? "deadline "+headline.deadline.timestamp + " ": ""; @@ -273,7 +274,7 @@ class OrgViewer extends React.Component {
{ - ({isSticky, wasSticky, style, distanceFromTop, distanceFromBottom, calculatedHeight}) => { + ({style}) => { return (

{list} {this.state.headlines[list].length}

@@ -328,7 +329,7 @@ class Headline extends React.Component { }; } - onMenuAction(key, value){ + onMenuAction(key){ if(key === "navigate"){ this.props.goTo(); }else if(key === "properties"){ @@ -339,14 +340,14 @@ class Headline extends React.Component { onStatusToggle(){ if(!this.props.todo_status) return; - const new_status = this.state.status === 'todo' ? 'done' : 'todo'; + const new_status = this.state.status === "todo" ? "done" : "todo"; this.setState({status: new_status}); const new_status_label = function(new_status, initial_status, initial_keyword){ if(new_status === initial_status) return initial_keyword; return new_status === "todo" ? "TODO" : "DONE"; }(new_status, this.props.todo_status, this.props.status); - this.props.onTaskUpdate('status', this.props.line, new_status_label); + this.props.onTaskUpdate("status", this.props.line, new_status_label); } onTimeSet(keyword, existing, value){ @@ -417,30 +418,30 @@ class Headline extends React.Component {
- 0 && this.state.status === "todo" && this.props.type === 'todos'} className="subtask_container"> + 0 && this.state.status === "todo" && this.props.type === "todos"} className="subtask_container"> { this.props.tasks.map((task, i) => { return ( + onStatusChange={this.props.onTaskUpdate.bind(this, "subtask", task.line)} /> ); }) } diff --git a/client/pages/viewerpage/pdfviewer.js b/client/pages/viewerpage/pdfviewer.js index 956a0ab9..6696a517 100644 --- a/client/pages/viewerpage/pdfviewer.js +++ b/client/pages/viewerpage/pdfviewer.js @@ -1,5 +1,5 @@ -import React from 'react'; -import { MenuBar } from './menubar'; +import React from "react"; +import { MenuBar } from "./menubar"; import "./pdfviewer.scss"; import { Bundle } from "../../components/"; @@ -12,7 +12,7 @@ const PDFJSViewer = (props) => ( export const PDFViewer = (props) => { const ViewerComponent = "application/pdf" in navigator.mimeTypes ? - + : ; return (
diff --git a/client/pages/viewerpage/pdfviewer_lazy.js b/client/pages/viewerpage/pdfviewer_lazy.js index df8c52ca..06672b5a 100644 --- a/client/pages/viewerpage/pdfviewer_lazy.js +++ b/client/pages/viewerpage/pdfviewer_lazy.js @@ -1,7 +1,7 @@ -import React from 'react'; -import 'react-pdf/dist/Page/AnnotationLayer.css'; -import { Document, Page, pdfjs } from 'react-pdf'; -pdfjs.GlobalWorkerOptions.workerSrc = `/assets/vendor/pdfjs/build/pdf.worker.min.js`; +import React from "react"; +import "react-pdf/dist/Page/AnnotationLayer.css"; +import { Document, Page, pdfjs } from "react-pdf"; +pdfjs.GlobalWorkerOptions.workerSrc = "/assets/vendor/pdfjs/build/pdf.worker.min.js"; export class PDFJSViewer extends React.Component { state = { @@ -18,7 +18,7 @@ export class PDFJSViewer extends React.Component { file={this.props.src} onLoadSuccess={this.onDocumentLoadSuccess.bind(this)} options={{ - cMapUrl: '/assets/vendor/pdfjs/cmaps/', + cMapUrl: "/assets/vendor/pdfjs/cmaps/", cMapPacked: true, }} > diff --git a/client/pages/viewerpage/videoplayer.js b/client/pages/viewerpage/videoplayer.js index 95d8b9c8..52c51579 100644 --- a/client/pages/viewerpage/videoplayer.js +++ b/client/pages/viewerpage/videoplayer.js @@ -1,14 +1,14 @@ -import React from 'react'; -import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; +import React from "react"; +import ReactCSSTransitionGroup from "react-addons-css-transition-group"; -import { Pager } from './pager'; -import { MenuBar } from './menubar'; -import { getMimeType } from '../../helpers/'; -import videojs from 'video.js'; -import 'videojs-contrib-hls'; +import { Pager } from "./pager"; +import { MenuBar } from "./menubar"; +import { getMimeType } from "../../helpers/"; +import videojs from "video.js"; +import "videojs-contrib-hls"; -import 'video.js/dist/video-js.css'; -import './videoplayer.scss'; +import "video.js/dist/video-js.css"; +import "./videoplayer.scss"; export class VideoPlayer extends React.Component { constructor(props){ @@ -53,7 +53,7 @@ export class VideoPlayer extends React.Component {
- +
diff --git a/client/router.js b/client/router.js index 1ce63168..f428bee7 100644 --- a/client/router.js +++ b/client/router.js @@ -1,8 +1,8 @@ -import React from 'react'; -import { BrowserRouter, Route, IndexRoute, Switch } from 'react-router-dom'; -import { NotFoundPage, ConnectPage, HomePage, SharePage, LogoutPage, FilesPage, ViewerPage } from './pages/'; -import { URL_HOME, URL_FILES, URL_VIEWER, URL_LOGIN, URL_LOGOUT } from './helpers/'; -import { Bundle, ModalPrompt, ModalAlert, ModalConfirm, Notification, Audio, Video, UploadQueue } from './components/'; +import React from "react"; +import { BrowserRouter, Route, Switch } from "react-router-dom"; +import { NotFoundPage, ConnectPage, HomePage, SharePage, LogoutPage, FilesPage, ViewerPage } from "./pages/"; +import { URL_HOME, URL_FILES, URL_VIEWER, URL_LOGIN, URL_LOGOUT, URL_ADMIN, URL_SHARE } from "./helpers/"; +import { Bundle, ModalPrompt, ModalAlert, ModalConfirm, Notification, UploadQueue } from "./components/"; const AdminPage = (props) => ( @@ -13,16 +13,16 @@ const AdminPage = (props) => ( export default class AppRouter extends React.Component { render() { return ( -
+
- - - - - - - + + + + + + + diff --git a/client/worker/sw_cache.js b/client/worker/sw_cache.js index ad64998b..76dc572f 100644 --- a/client/worker/sw_cache.js +++ b/client/worker/sw_cache.js @@ -1,5 +1,4 @@ const CACHE_NAME = "v0.3"; -const DELAY_BEFORE_SENDING_CACHE = 2000; /* * Control everything going through the wire, applying different @@ -33,7 +32,7 @@ self.addEventListener("error", function(err){ * When a newly installed service worker is coming in, we want to use it * straight away (make it active). By default it would be in a "waiting state" */ -self.addEventListener("install", function(event){ +self.addEventListener("install", function(){ caches.open(CACHE_NAME).then(function(cache) { return cache.addAll([ "/", @@ -81,7 +80,8 @@ function vacuum(event){ } function _pathname(request){ - return request.url.replace(/^http[s]?:\/\/[^\/]*\//, "").split("/") + //eslint-disable-next-line no-useless-escape + return request.url.replace(/^http[s]?:\/\/[^\/]*\//, "").split("/"); } /* @@ -118,5 +118,5 @@ function cacheFirstStrategy(event){ return response; }); } - function nil(e){} + function nil(){} }