From 822e4484e9b9bf4cb3b9ef9e709a1c9332a1b0c0 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 5 Dec 2017 19:23:48 +0100 Subject: [PATCH] revised frontend (auto completion, util helper module) --- handlers/tmpls/protected.html | 2 +- static/src/Card/Card.js | 9 +++------ static/src/Home/Home.js | 2 +- static/src/Lookup/Lookup.js | 11 +++++++---- static/src/Recent/Recent.js | 11 ++++------- static/src/util/util.js | 10 ++++++++++ 6 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 static/src/util/util.js diff --git a/handlers/tmpls/protected.html b/handlers/tmpls/protected.html index f24e8c7..1070447 100644 --- a/handlers/tmpls/protected.html +++ b/handlers/tmpls/protected.html @@ -40,7 +40,7 @@
- +
diff --git a/static/src/Card/Card.js b/static/src/Card/Card.js index a789b0f..85a641e 100644 --- a/static/src/Card/Card.js +++ b/static/src/Card/Card.js @@ -25,12 +25,12 @@ export default class CardComponent extends Component { {this.props.metaHeader} - {this.props.description} + {this.props.description} {this.props.deletionURL && } - {!this.props.showInfoURL ?
+ {!this.props.customExtraContent ?
}> {this.props.description} @@ -43,10 +43,7 @@ export default class CardComponent extends Component { Copy to Clipboard
-
:
-
} + : this.props.customExtraContent}
) } diff --git a/static/src/Home/Home.js b/static/src/Home/Home.js index 90afec5..5eaf998 100644 --- a/static/src/Home/Home.js +++ b/static/src/Home/Home.js @@ -116,7 +116,7 @@ export default class HomeComponent extends Component { minDate={moment()} /> } {setOptions.includes("protected") && - } + } diff --git a/static/src/Lookup/Lookup.js b/static/src/Lookup/Lookup.js index c2a4abe..ce3b7de 100644 --- a/static/src/Lookup/Lookup.js +++ b/static/src/Lookup/Lookup.js @@ -1,5 +1,5 @@ import React, { Component } from 'react' -import { Segment, Header, Form, Input, Card } from 'semantic-ui-react' +import { Segment, Header, Form, Input, Card, Button } from 'semantic-ui-react' import toastr from 'toastr' import CustomCard from '../Card/Card' @@ -40,14 +40,17 @@ export default class LookupComponent extends Component {
URL Lookup
-
+ - this.urlInput = input} action={{ icon: 'arrow right', labelPosition: 'right', content: 'Lookup' }} type='url' onChange={this.handleURLChange} name='url' placeholder={window.location.origin + "/..."} /> + this.urlInput = input} action={{ icon: 'arrow right', labelPosition: 'right', content: 'Lookup' }} type='url' onChange={this.handleURLChange} name='url' placeholder={window.location.origin + "/..."} autoComplete="off"/>
- {links.map((link, i) => )} + {links.map((link, i) => +
} />)} ) diff --git a/static/src/Recent/Recent.js b/static/src/Recent/Recent.js index 490cf0b..fca1ef1 100644 --- a/static/src/Recent/Recent.js +++ b/static/src/Recent/Recent.js @@ -2,7 +2,7 @@ import React, { Component } from 'react' import { Container, Table, Button, Icon } from 'semantic-ui-react' import toastr from 'toastr' import Moment from 'react-moment'; - +import util from '../util/util' export default class RecentComponent extends Component { state = { recent: null @@ -28,11 +28,8 @@ export default class RecentComponent extends Component { this.props.history.push(`/visitors/${id}`) } - onEntryDeletion(visit) { - fetch(visit.DeletionURL) - .then(res => res.ok ? res.json() : Promise.reject(res.json())) - .then(() => this.loadRecentURLs()) - .catch(e => e instanceof Promise ? e.then(error => toastr.error(`Could not delete: ${error.error}`)) : null) + onEntryDeletion(entry) { + util.deleteEntry(entry.DeletionURL) } render() { @@ -53,7 +50,7 @@ export default class RecentComponent extends Component { {recent && Object.keys(recent).map(key => {recent[key].Public.URL} {recent[key].Public.CreatedOn} - {`${window.location.origin}/${key}`} + {`${window.location.origin}/${key}`} {recent[key].Public.VisitCount}