Skip to content

Commit b232462

Browse files
committed
Merge branch 'main' of https://github.com/TRACE-Digital/TRACE into main
2 parents bcef93c + 3c95a17 commit b232462

File tree

8 files changed

+207
-85
lines changed

8 files changed

+207
-85
lines changed

src/assets/scss/black-dashboard-react/custom/_alerts.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
}
6262

6363
&.alert-with-icon{
64-
padding-left: 65px;
64+
padding-left: 15px;
6565
}
6666
}
6767

src/components/AccountCardList/AccountCardList.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import AccountCard from 'components/AccountCard/AccountCard';
22
import { rejectAccount } from 'components/AccountCard/AccountCard';
33
import { claimAccount } from 'components/AccountCard/AccountCard';
4-
import React, { useState, useEffect } from 'react';
4+
import React, { useState, useEffect, useRef } from 'react';
55
import { Dropdown, DropdownItem, DropdownMenu, DropdownToggle, Row } from 'reactstrap';
66
import { tags } from 'trace-search';
7+
import NotificationAlert from "react-notification-alert";
78

89
function AccountCardList(props) {
910
const [sortMethod, setSortMethod] = useState("new");
@@ -18,6 +19,18 @@ function AccountCardList(props) {
1819
const selectAll = () => setSelection(props.accounts.map(account => account.id));
1920
const deselectAll = () => setSelection([]);
2021

22+
const notificationAlertRef = useRef(null);
23+
const toast = (message, type) => {
24+
var options = {};
25+
options = {
26+
place: "bc",
27+
message: (<span>{message}</span>),
28+
type: type,
29+
autoDismiss: 7,
30+
};
31+
notificationAlertRef.current.notificationAlert(options);
32+
}
33+
2134
const claimSelected = async () => {
2235
let count = 0;
2336
const selectedAccounts = props.accounts.filter(account => selection.includes(account.id));
@@ -27,7 +40,7 @@ function AccountCardList(props) {
2740
count++;
2841
}
2942
}
30-
alert(`Claimed ${count} accounts.`);
43+
toast(`Claimed ${count} accounts.`, "success");
3144
return count;
3245
};
3346

@@ -40,7 +53,7 @@ function AccountCardList(props) {
4053
count++;
4154
}
4255
}
43-
alert(`Rejected ${count} accounts.`);
56+
toast(`Rejected ${count} accounts.`, "danger");
4457
return count;
4558
};
4659

@@ -132,6 +145,9 @@ function AccountCardList(props) {
132145

133146
return (
134147
<>
148+
<div className="react-notification-alert-container">
149+
<NotificationAlert ref={notificationAlertRef} />
150+
</div>
135151
<span style={{display: "inline", float: "right"}}>
136152
{/* SORT DROPDOWN */}
137153
<Dropdown isOpen={sortDropdownOpen} toggle={toggleSortDropdown} style={{display: "inline", marginRight: "10px"}}>

src/components/Graph/Graph.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function Graph(props) {
77

88
const [data, setData] = useState([]);
99
const [labels, setLabels] = useState([]);
10+
const [totalData, setTotalData] = useState(0);
1011

1112
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
1213
var days = ["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"];
@@ -65,6 +66,7 @@ function Graph(props) {
6566
// Add label logic in here
6667
const tempLabels = [];
6768
let count = 0;
69+
let total = 0;
6870
for (const key in analyticsData) {
6971

7072
if (analyticsData.hasOwnProperty(key)) {
@@ -87,7 +89,9 @@ function Graph(props) {
8789

8890

8991
if (analyticsData[key].length !== 0) {
90-
data.push(analyticsData[key][0].nb_hits);
92+
let hits = analyticsData[key][0].nb_hits;
93+
data.push(hits);
94+
total += hits;
9195
}
9296
else {
9397
data.push(0);
@@ -97,6 +101,7 @@ function Graph(props) {
97101
}
98102

99103
setLabels(tempLabels);
104+
setTotalData(total);
100105
return data;
101106
}
102107

@@ -152,6 +157,16 @@ function Graph(props) {
152157

153158
return (
154159
<>
160+
{props.dataLabel === "Visitors" && (
161+
<h2 style={{position: "absolute", fontWeight: "100", transform: "translate(10px, -57px)"}}>
162+
{totalData} Visitors
163+
</h2>
164+
)}
165+
{props.dataLabel === "Clicks" && (
166+
<h4 style={{position: "absolute", fontWeight: "100", transform: "translate(10px, -50px)"}}>
167+
{totalData} Clicks
168+
</h4>
169+
)}
155170
<Line
156171
data={chart.visitorData}
157172
options={chart.options}
@@ -195,7 +210,7 @@ let defaultOptions = {
195210
},
196211
ticks: {
197212
suggestedMin: 0,
198-
suggestedMax: 5,
213+
suggestedMax: 6,
199214
padding: 20,
200215
fontColor: "#9a9a9a",
201216
},

src/components/SiteCard/SiteCard.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import PrivacyBadge from "components/PrivacyBadge/PrivacyBadge";
2-
import React, { useState } from "react";
2+
import React, { useState, useRef } from "react";
33
import ReactCardFlip from "react-card-flip";
44
import { Card, CardBody, Button } from "reactstrap";
55
import { IconButton } from "@material-ui/core";
66
import { AccountType } from "trace-search";
7+
import NotificationAlert from "react-notification-alert";
78

89
/**
910
* Displays a Card with information about the account passed in
@@ -24,7 +25,18 @@ const SiteCard = (props) => {
2425
const editorColor = props.editorColor;
2526
const iconColor = props.iconColor;
2627

27-
28+
const notificationAlertRef = useRef(null);
29+
const toast = (message, type) => {
30+
var options = {};
31+
options = {
32+
place: "bc",
33+
message: (<span>{message}</span>),
34+
type: type,
35+
autoDismiss: 7,
36+
};
37+
notificationAlertRef.current.notificationAlert(options);
38+
}
39+
2840
if (!search && !dashboard && !editor) {
2941
console.warn(
3042
'WARNING - invalid type passed to SiteCard component. Needs to be "search", "dashboard", or "editor"'
@@ -52,9 +64,9 @@ const SiteCard = (props) => {
5264
// async function claimAccount(account) {
5365
try {
5466
await account.claim();
55-
alert("Account successfully claimed!");
67+
toast("Account successfully claimed!", "success");
5668
} catch (e) {
57-
alert("Account has already been claimed!");
69+
toast("Account has already been claimed!", "warning");
5870
console.error(e);
5971
}
6072
};
@@ -66,14 +78,18 @@ const SiteCard = (props) => {
6678
// async function deleteAccount(account) {
6779
try {
6880
await account.reject();
69-
alert("Account successfully removed!");
81+
toast("Account successfully removed!");
7082
} catch (e) {
7183
console.error(e);
7284
}
7385
};
7486

7587
return (
7688
//<Col lg="3" key={account.id}>
89+
<>
90+
<div className="react-notification-alert-container">
91+
<NotificationAlert ref={notificationAlertRef} />
92+
</div>
7793
<ReactCardFlip
7894
isFlipped={flipped}
7995
flipSpeedBackToFront=".8"
@@ -86,7 +102,7 @@ const SiteCard = (props) => {
86102
{/* ICON */}
87103
<div className="editor">
88104
{" "}
89-
105+
90106
<i
91107
className={account.site.logoClass || 'fas fa-question fa-sm'}
92108
style={{ color: (iconColor === "Default") ? account.site.logoColor || null : iconColor }}
@@ -201,6 +217,7 @@ const SiteCard = (props) => {
201217
<div />
202218
)}
203219
</ReactCardFlip>
220+
</>
204221
//</Col>
205222
);
206223
};

src/components/SyncToggle/SyncToggle.js

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
import { useEffect, useState } from 'react';
1+
import { useEffect, useState, useRef } from 'react';
22
import ToggleButton from 'react-toggle-button';
33
import { setRemoteUser, setupReplication, teardownReplication } from 'trace-search';
44
import Auth from "@aws-amplify/auth";
5+
import NotificationAlert from "react-notification-alert";
56

67
function SyncToggle() {
78
const [replicate, setReplicate] = useState(false);
89
const [isLoggedIn, setIsLoggedIn] = useState(false);
910

11+
const notificationAlertRef = useRef(null);
12+
const toast = (message, type) => {
13+
var options = {};
14+
options = {
15+
place: "bc",
16+
message: (<span>{message}</span>),
17+
type: type,
18+
autoDismiss: 7,
19+
};
20+
notificationAlertRef.current.notificationAlert(options);
21+
}
22+
1023
useEffect(() => {
1124
(async () => {
1225
try {
@@ -23,7 +36,7 @@ function SyncToggle() {
2336
useEffect(() => {
2437
async function handleReplication() {
2538
if (!isLoggedIn && replicate) {
26-
alert('You must sign in to use sync!');
39+
toast('You must sign in to use sync!', "danger");
2740
setReplicate(false);
2841
return;
2942
}
@@ -36,12 +49,12 @@ function SyncToggle() {
3649
const replicator = obj.TODO_replication;
3750

3851
replicator.on('error', (e) => {
39-
alert(`Replication error: ${e.message || e}`);
52+
toast(`Replication error: ${e.message || e}`, "danger");
4053
console.error(e);
4154
setReplicate(false);
4255
});
4356
} catch(e) {
44-
alert(`Replication error: ${e.message || e}`);
57+
toast(`Replication error: ${e.message || e}`, "danger");
4558
console.error(e);
4659
setReplicate(false);
4760
return;
@@ -59,15 +72,20 @@ function SyncToggle() {
5972
}, [replicate, isLoggedIn]);
6073

6174
return(
62-
<div style={{ textAlign: 'center' }}>
63-
Sync
64-
<ToggleButton
65-
inactiveLabel={<span>Off</span>}
66-
activeLabel={<span>On</span>}
67-
value={replicate || false}
68-
onToggle={() => setReplicate(prev => !prev) }
69-
/>
70-
</div>
75+
<>
76+
<div className="react-notification-alert-container">
77+
<NotificationAlert ref={notificationAlertRef} />
78+
</div>
79+
<div style={{ textAlign: 'center' }}>
80+
Sync
81+
<ToggleButton
82+
inactiveLabel={<span>Off</span>}
83+
activeLabel={<span>On</span>}
84+
value={replicate || false}
85+
onToggle={() => setReplicate(prev => !prev) }
86+
/>
87+
</div>
88+
</>
7189
);
7290
}
7391

src/views/Analytics.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function Analytics(props) {
5858
<Row>
5959
<Col className="text-left" sm="6">
6060
<h5 className="card-category">Public Profile</h5>
61-
<CardTitle tag="h2">[Data] Visitors</CardTitle>
61+
<CardTitle tag="h2" style={{opacity: "0"}}>placeholder</CardTitle>
6262
</Col>
6363
</Row>
6464
</CardHeader>
@@ -78,12 +78,12 @@ function Analytics(props) {
7878
<Col lg="4" key={account.id}>
7979
<Card className="card-chart">
8080
<CardHeader>
81-
{/* <h5 className="card-category">[Data] Interactions</h5> */}
8281
<CardTitle tag="h3">
8382
<i className="tim-icons icon-single-02" style={{paddingRight: "5px"}}/>
84-
{account.site.name}
85-
<br/>
83+
{account.site.name} -
8684
<a href={account.url}> @{account.userName}</a>
85+
<br/>
86+
<h4 style={{opacity: "0"}}>placeholder</h4>
8787
</CardTitle>
8888
</CardHeader>
8989
<CardBody>

0 commit comments

Comments
 (0)