Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code changes to handle front end logic of apply stopwords to the widgets in dashboard #151

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "2.0.0",
"private": true,
"scripts": {
"dev": "./env.sh next dev -p 3000",
"build": "./env.sh next build",
"dev": "next dev -p 3000",
"build": "next build",
"start": "next start"
},
"dependencies": {
Expand Down Expand Up @@ -39,6 +39,7 @@
"d3-legend": "^1.0.0",
"date-fns": "^2.29.3",
"file-saver": "^2.0.5",
"formidable": "^3.5.2",
"formik": "^2.2.9",
"framer-motion": "^7.5.3",
"gray-matter": "^4.0.3",
Expand All @@ -48,8 +49,8 @@
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
"match-sorter": "^6.3.1",
"next-auth": "^4.24.5",
"next": "^13.5.6",
"next-auth": "^4.24.5",
"next-transpile-modules": "^9.0.0",
"notistack": "^2.0.8",
"qs": "^6.11.2",
Expand Down Expand Up @@ -83,6 +84,7 @@
},
"devDependencies": {
"@types/chance": "^1.1.3",
"@types/formidable": "^3.4.5",
"@types/lodash": "^4.14.186",
"@types/node": "^18.7.23",
"@types/react": "^18.2.56",
Expand Down
19 changes: 14 additions & 5 deletions src/contexts/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useRouter } from 'next/router';
import qs from 'qs';

// types
import { DashboardContextProps, DashboardState, DashboardStatePatch, WorksetList } from 'types/torchlite';
import { DashboardContextProps, DashboardState, DashboardStatePatch, DataCleaningSettings, WorksetList } from 'types/torchlite';
import { useSession } from 'next-auth/react';
import { getAvailableDashboards, getAvailableWorksets, getDashboardState, updateDashboardState } from 'services';
import CustomBackdrop from 'components/Backdrop';
Expand Down Expand Up @@ -38,8 +38,10 @@ function AppProvider({ children }: AppProviderProps) {
// Get workset and filter from router query
const { worksetId } = router.query;
const filters: any = qs.parse(router.query.filters as string, { comma: true });
const dataClean = router.query.datacleaning as DataCleaningSettings;
let selectedWorksetId: string,
appliedFilters: any = {};
appliedFilters: any = {},
dataCleaning: DataCleaningSettings;

// Get worksets
let worksets: WorksetList = await getAvailableWorksets();
Expand Down Expand Up @@ -88,20 +90,25 @@ function AppProvider({ children }: AppProviderProps) {
}
}
}
dataCleaning = dataClean

await updateDashboardState(dashboardState.id, {
importedId: selectedWorksetId,
filters: appliedFilters
filters: appliedFilters,
datacleaning: dataCleaning
});
dashboardState = await getDashboardState(dashboardState.id);
} else {
selectedWorksetId = dashboardState.importedId;
appliedFilters = dashboardState.filters;
dataCleaning = dashboardState.datacleaning;
router.push({
pathname: router.pathname,
query: {
...router.query,
worksetId: selectedWorksetId,
filters: qs.stringify(appliedFilters, { arrayFormat: 'comma', encode: false })
filters: qs.stringify(appliedFilters, { arrayFormat: 'comma', encode: false }),
datacleaning: qs.stringify(dataCleaning, { arrayFormat: 'comma', encode: false })
}
});
}
Expand All @@ -123,12 +130,14 @@ function AppProvider({ children }: AppProviderProps) {
if (dashboardState) {
const selectedWorksetId = dashboardState.worksetId;
const appliedFilters = dashboardState.filters;
const dataCleaning = dashboardState.datacleaning;
router.push({
pathname: router.pathname,
query: {
...router.query,
worksetId: selectedWorksetId,
filters: qs.stringify(appliedFilters, { arrayFormat: 'comma', encode: false })
filters: qs.stringify(appliedFilters, { arrayFormat: 'comma', encode: false }),
datacleaning: qs.stringify(dataCleaning, { arrayFormat: 'comma', encode: false })
}
});
}
Expand Down
Loading