diff --git a/src/short-urls/ShortUrlVisits.js b/src/short-urls/ShortUrlVisits.js
index c59e35ce..4ce6ad8f 100644
--- a/src/short-urls/ShortUrlVisits.js
+++ b/src/short-urls/ShortUrlVisits.js
@@ -5,6 +5,8 @@ import { pick } from 'ramda';
import { Card, CardBody, CardHeader } from 'reactstrap';
import { getShortUrlVisits } from './reducers/shortUrlVisits';
import VisitsParser from '../visits/services/VisitsParser';
+import preloader from '@fortawesome/fontawesome-free-solid/faCircleNotch';
+import FontAwesomeIcon from '@fortawesome/react-fontawesome';
export class ShortUrlsVisits extends React.Component {
state = { startDate: '', endDate: '' };
@@ -15,14 +17,73 @@ export class ShortUrlsVisits extends React.Component {
}
render() {
- const { match: { params }, selectedServer, visitsParser, shortUrlVisits } = this.props;
+ const { match: { params }, selectedServer, visitsParser, shortUrlVisits: { visits, loading, error } } = this.props;
const serverUrl = selectedServer ? selectedServer.url : '';
const shortUrl = `${serverUrl}/${params.shortCode}`;
const generateGraphData = stats => ({
labels: Object.keys(stats),
- datasets: Object.values(stats)
+ data: Object.values(stats)
});
+ const renderContent = () => {
+ if (loading) {
+ return (
+
+
+
+ Loading...
+
+
+
+ );
+ }
+
+ if (error) {
+ return (
+
+ An error occurred while loading visits :(
+
+ );
+ }
+
+ return (
+
+
+
+ Operating systems
+
+
+
+
+
+
+
+ Browsers
+
+
+
+
+
+
+
+ Countries
+
+
+
+
+
+
+
+ Referrers
+
+
+
+
+
+
+ );
+ };
+
return (
@@ -31,40 +92,7 @@ export class ShortUrlsVisits extends React.Component {
-
-
-
- Operating systems
-
-
-
-
-
-
-
- Browsers
-
-
-
-
-
-
-
- Countries
-
-
-
-
-
-
-
- Referrers
-
-
-
-
-
-
+ {renderContent()}
);
}
diff --git a/src/short-urls/helpers/CreateShortUrlResult.js b/src/short-urls/helpers/CreateShortUrlResult.js
index 7ef07c2c..32eb67fd 100644
--- a/src/short-urls/helpers/CreateShortUrlResult.js
+++ b/src/short-urls/helpers/CreateShortUrlResult.js
@@ -4,7 +4,7 @@ import { isNil } from 'ramda';
import React from 'react';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import './CreateShortUrlResult.scss'
-import { Tooltip } from 'reactstrap';
+import { Card, CardBody, Tooltip } from 'reactstrap';
export default class CreateShortUrlResult extends React.Component {
state = { showCopyTooltip: false };
@@ -17,7 +17,11 @@ export default class CreateShortUrlResult extends React.Component {
const { error, result } = this.props;
if (error) {
- return An error occurred while creating the URL :(
+ return (
+
+ An error occurred while creating the URL :(
+
+ );
}
if (isNil(result)) {
return null;
@@ -30,19 +34,21 @@ export default class CreateShortUrlResult extends React.Component {
};
return (
-
- Great! The short URL is {shortUrl}
+
+
+ Great! The short URL is {shortUrl}
-
-
-
+
+
+
-
- Copied!
-
-
+
+ Copied!
+
+
+
);
}
};