Skip to content

Commit

Permalink
Merge branch 'develop' into feat/updates-and-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Oct 24, 2023
2 parents 203fb3a + bed827b commit 0004d41
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 43 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"initialise": "yarn link '@rawgraphs/rawgraphs-charts' && yarn install --network-timeout 100000",
"docker-staging": "cp -r /app/client/build /app/client/staging && tail -f /dev/null",
"docker-test": "cp -r /app/client/build /app/client/test && tail -f /dev/null",
"docker-prod": "cp -r /app/client/build /app/client/prod"
"docker-prod": "cp -r /app/client/build /app/client/prod && tail -f /dev/null"
},
"browserslist": {
"production": [
Expand Down
38 changes: 31 additions & 7 deletions src/app/components/Dialogs/logOutDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useAuth0 } from "@auth0/auth0-react";
import { useStyles } from "./deleteChartDialog";
import { CloseOutlined } from "@material-ui/icons";
import { IconButton, Modal } from "@material-ui/core";
import { useStoreActions } from "app/state/store/hooks";
import useSessionStorage from "react-use/lib/useSessionStorage";

interface Props {
modalDisplay: boolean;
Expand All @@ -13,6 +15,34 @@ export default function LogOutDialog(props: Props) {
const classes = useStyles();
const { logout } = useAuth0();

const setToken = useSessionStorage("authToken", "")[1];

const clearDatasets = useStoreActions(
(actions) => actions.dataThemes.DatasetGetList.clear
);
const clearCharts = useStoreActions(
(actions) => actions.charts.ChartGetList.clear
);
const clearReports = useStoreActions(
(actions) => actions.reports.ReportGetList.clear
);

function clearAssets() {
setToken("");
clearDatasets();
clearCharts();
clearReports();
}

function onLogout() {
clearAssets();
logout({
logoutParams: {
returnTo: window.location.origin,
},
});
}

return (
<div>
<Modal
Expand Down Expand Up @@ -98,13 +128,7 @@ export default function LogOutDialog(props: Props) {
</button>
<button
type="button"
onClick={() =>
logout({
logoutParams: {
returnTo: window.location.origin,
},
})
}
onClick={onLogout}
css={`
background: #231d2c;
border-radius: 30px;
Expand Down
24 changes: 20 additions & 4 deletions src/app/modules/common/subheader-toolbar/SubheaderToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
report: false,
});
axios
.delete(`${process.env.REACT_APP_API}/report/${page}`)
.delete(`${process.env.REACT_APP_API}/report/${page}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(async () => {
loadReports({
token,
Expand All @@ -295,7 +299,11 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
chart: false,
});
axios
.delete(`${process.env.REACT_APP_API}/chart/${page}`)
.delete(`${process.env.REACT_APP_API}/chart/${page}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(async () => {
loadCharts({
token,
Expand All @@ -312,7 +320,11 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
const handleDuplicate = () => {
if (props.pageType === "report") {
axios
.get(`${process.env.REACT_APP_API}/report/duplicate/${page}`)
.get(`${process.env.REACT_APP_API}/report/duplicate/${page}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((response) => {
loadReports({
token,
Expand All @@ -329,7 +341,11 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
.catch((error) => console.log(error));
} else {
axios
.get(`${process.env.REACT_APP_API}/chart/duplicate/${page}`)
.get(`${process.env.REACT_APP_API}/chart/duplicate/${page}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(async (response) => {
loadCharts({
token,
Expand Down
24 changes: 20 additions & 4 deletions src/app/modules/common/subheader-toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,11 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
report: false,
});
axios
.delete(`${process.env.REACT_APP_API}/report/${page}`)
.delete(`${process.env.REACT_APP_API}/report/${page}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(async () => {
loadReports({
token,
Expand All @@ -342,7 +346,11 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
chart: false,
});
axios
.delete(`${process.env.REACT_APP_API}/chart/${page}`)
.delete(`${process.env.REACT_APP_API}/chart/${page}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(async () => {
loadCharts({
token,
Expand All @@ -359,7 +367,11 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
const handleDuplicate = () => {
if (props.pageType === "report") {
axios
.get(`${process.env.REACT_APP_API}/report/duplicate/${page}`)
.get(`${process.env.REACT_APP_API}/report/duplicate/${page}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((response) => {
loadReports({
token,
Expand All @@ -375,7 +387,11 @@ export function SubheaderToolbar(props: SubheaderToolbarProps) {
.catch((error) => console.log(error));
} else {
axios
.get(`${process.env.REACT_APP_API}/chart/duplicate/${page}`)
.get(`${process.env.REACT_APP_API}/chart/duplicate/${page}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(async (response) => {
loadCharts({
token,
Expand Down
35 changes: 27 additions & 8 deletions src/app/modules/home-module/components/Charts/chartsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ export default function ChartsGrid(props: Props) {

const loadData = async () => {
//refrain from loading data if all the data is loaded

await loadCharts({
token,
storeInCrudData: true,
filterString: getFilterString(),
});
// if (loadedCharts.length !== ChartsCount) {
if (token) {
await loadCharts({
token,
storeInCrudData: true,
filterString: getFilterString(),
});
}
// }
};

const reloadData = async () => {
Expand All @@ -90,6 +93,14 @@ export default function ChartsGrid(props: Props) {
loadData();
};

React.useEffect(() => {
if (token) {
loadChartsCount({
token,
});
}
}, [token]);

React.useEffect(() => {
//load data if intersection observer is triggered
if (isObserved) {
Expand Down Expand Up @@ -118,7 +129,11 @@ export default function ChartsGrid(props: Props) {
return;
}
axios
.delete(`${process.env.REACT_APP_API}/chart/${id}`)
.delete(`${process.env.REACT_APP_API}/chart/${id}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(() => {
reloadData();
})
Expand All @@ -131,7 +146,11 @@ export default function ChartsGrid(props: Props) {
return;
}
axios
.get(`${process.env.REACT_APP_API}/chart/duplicate/${id}`)
.get(`${process.env.REACT_APP_API}/chart/duplicate/${id}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(() => {
reloadData();
})
Expand Down
25 changes: 17 additions & 8 deletions src/app/modules/home-module/components/Reports/reportsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ export default function ReportsGrid(props: Props) {

const loadData = async () => {
//refrain from loading data if all the data is loaded

await loadReports({
token,
storeInCrudData: true,
filterString: getFilterString(),
});
if (loadedReports.length !== reportsCount && token) {
await loadReports({
token,
storeInCrudData: true,
filterString: getFilterString(),
});
}
};

const reloadData = async () => {
Expand Down Expand Up @@ -113,7 +114,11 @@ export default function ReportsGrid(props: Props) {
return;
}
axios
.delete(`${process.env.REACT_APP_API}/report/${id}`)
.delete(`${process.env.REACT_APP_API}/report/${id}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(() => {
reloadData();
})
Expand All @@ -126,7 +131,11 @@ export default function ReportsGrid(props: Props) {
return;
}
axios
.get(`${process.env.REACT_APP_API}/report/duplicate/${id}`)
.get(`${process.env.REACT_APP_API}/report/duplicate/${id}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(() => {
reloadData();
})
Expand Down
20 changes: 9 additions & 11 deletions src/app/modules/home-module/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,12 @@ export default function HomeModule() {
max-width: 450px;
`}
>
<h1>Turns data into impact</h1>
<h1>Turn data into impact with DataXplorer</h1>
<Box height={34} />
<p>
<b>
Dx drives better business outcomes and intelligent customer
experiences with insights everywhere,
<br /> for everyone.
DataXplorer simplifies and empowers visual data reporting
for all.
</b>
</p>
<Box height={52} />
Expand Down Expand Up @@ -209,19 +208,18 @@ export default function HomeModule() {
{!isAuthenticated && (
<div
css={`
gap: 32px;
gap: 20px;
width: 100%;
display: flex;
margin-left: -90px;
flex-direction: row;
justify-content: space-between;
justify-content: center;
> button {
gap: 10px;
color: #fff;
display: flex;
min-width: 285px;
background: #231d2c;
padding: 9px 18px;
background: #a1a2ff;
align-items: center;
justify-content: center;
text-transform: uppercase;
Expand All @@ -233,10 +231,10 @@ export default function HomeModule() {
`}
>
<button onClick={handleLogin}>
start free with google <GoogleIcon />
<GoogleIcon /> sign in for free
</button>
<button onClick={handleLogin}>
start free with linkedin <LinkedInIcon />
<LinkedInIcon /> sign in for free
</button>
</div>
)}
Expand Down
1 change: 1 addition & 0 deletions src/app/state/api/action-reducers/charts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const ChartDuplicate: ApiCallModel = {
export const ChartGetList: ApiCallModel = {
...APIModel(`${process.env.REACT_APP_API}/charts`),
};

export const ChartsCount: ApiCallModel = {
...APIModel(`${process.env.REACT_APP_API}/charts/count`),
};
1 change: 1 addition & 0 deletions src/app/state/api/action-reducers/reports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const ReportDuplicate: ApiCallModel = {
export const ReportGetList: ApiCallModel = {
...APIModel(`${process.env.REACT_APP_API}/reports`),
};

export const ReportsCount: ApiCallModel = {
...APIModel(`${process.env.REACT_APP_API}/reports/count`),
};

0 comments on commit 0004d41

Please sign in to comment.