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

Commit 81f111d

Browse files
author
Jeff Billimek
committed
add-in displayURL support to new admin.js file and address codacy issue
1 parent f8de2ea commit 81f111d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

web/src/Admin/Admin.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,25 @@ import util from '../util/util'
88

99
export default class AllEntriesComponent extends Component {
1010
state = {
11-
allEntries: []
11+
allEntries: [],
12+
displayURL: window.location.origin
1213
}
1314

1415
componentDidMount() {
1516
this.getAllURLs()
17+
fetch("/displayurl")
18+
.then(response => response.json())
19+
.then(data => this.setState({displayURL: data}));
1620
}
1721

1822
getAllURLs = () => {
1923
util.getAllURLs(allEntries => {
2024
let parsed = [];
2125
for (let key in allEntries) {
22-
allEntries[key].ID = key;
23-
parsed.push(allEntries[key]);
26+
if ({}.hasOwnProperty.call(allEntries, key)) {
27+
allEntries[key].ID = key;
28+
parsed.push(allEntries[key]);
29+
}
2430
}
2531
this.setState({ allEntries: parsed })
2632
})
@@ -47,7 +53,7 @@ export default class AllEntriesComponent extends Component {
4753
}, {
4854
Header: 'Short URL',
4955
accessor: "ID",
50-
Cell: props => `${window.location.origin}/${props.value}`
56+
Cell: props => `${this.state.displayURL}/${props.value}`
5157
}, {
5258
Header: 'Visitor count',
5359
accessor: "Public.VisitCount"

0 commit comments

Comments
 (0)