Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Commit

Permalink
add-in displayURL support to new admin.js file and address codacy issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Billimek committed Jun 14, 2019
1 parent 5492db4 commit 23c7998
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions web/src/Admin/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@ import util from '../util/util'

export default class AllEntriesComponent extends Component {
state = {
allEntries: []
allEntries: [],
displayURL: window.location.origin
}

componentDidMount() {
this.getAllURLs()
fetch("/displayurl")
.then(response => response.json())
.then(data => this.setState({displayURL: data}));
}

getAllURLs = () => {
util.getAllURLs(allEntries => {
let parsed = [];
for (let key in allEntries) {
allEntries[key].ID = key;
parsed.push(allEntries[key]);
if ({}.hasOwnProperty.call(allEntries, key)) {
allEntries[key].ID = key;
parsed.push(allEntries[key]);
}
}
this.setState({ allEntries: parsed })
})
Expand All @@ -47,7 +53,7 @@ export default class AllEntriesComponent extends Component {
}, {
Header: 'Short URL',
accessor: "ID",
Cell: props => `${window.location.origin}/${props.value}`
Cell: props => `${this.state.displayURL}/${props.value}`
}, {
Header: 'Visitor count',
accessor: "Public.VisitCount"
Expand Down

0 comments on commit 23c7998

Please sign in to comment.