📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
(improvmetns) viewProject
kruzhambus96c9391b5980
diff --git a/src/pages/Project/View/ViewProject.container.tsx b/src/pages/Project/View/ViewProject.container.tsxindex acb6d610a..538b53052 100644--- a/src/pages/Project/View/ViewProject.container.tsx+++ b/src/pages/Project/View/ViewProject.container.tsx@@ -25,6 +25,7 @@ const mapStateToProps = (state: StateType) => {projectTab: state.ui.projects.projectTab,customEventsPrefs: state.ui.cache.customEventsPrefs,liveStats: state.ui.projects.liveStats,+ passwordHash: state.ui.projects.passwordHash,}}@@ -42,6 +43,7 @@ const mapStateToProps = (state: StateType) => {projectTab: state.ui.projects.projectTab,customEventsPrefs: state.ui.cache.customEventsPrefs,liveStats: state.ui.projects.liveStats,+ passwordHash: state.ui.projects.passwordHash,}}diff --git a/src/pages/Project/View/ViewProject.tsx b/src/pages/Project/View/ViewProject.tsxindex 32515b7fb..cb7f6a647 100644--- a/src/pages/Project/View/ViewProject.tsx+++ b/src/pages/Project/View/ViewProject.tsx@@ -43,6 +43,7 @@ import {tbPeriodPairs, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL, DEFAULT_TIMEZONE, CDN_URL, isDevelopment,timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, PROJECT_TABS,TimeFormat, getProjectForcastCacheKey, chartTypes, roleAdmin, TRAFFIC_PANELS_ORDER, PERFORMANCE_PANELS_ORDER, isSelfhosted,+ PROJECTS_PROTECTED_PASSWORD,} from 'redux/constants'import { IUser } from 'redux/models/IUser'import { IProject, ILiveStats } from 'redux/models/IProject'@@ -84,7 +85,7 @@ interface IProjectView extends IProject {const ViewProject = ({projects, isLoading: _isLoading, showError, cache, cachePerf, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject,setLiveStatsForProject, authenticated, timezone, user, sharedProjects, extensions, generateAlert, setProjectCachePerf,- projectTab, setProjectTab, setProjects, setProjectForcastCache, customEventsPrefs, setCustomEventsPrefs, liveStats,+ projectTab, setProjectTab, setProjects, setProjectForcastCache, customEventsPrefs, setCustomEventsPrefs, liveStats, passwordHash,}: {projects: IProjectView[],extensions: any,@@ -117,6 +118,9 @@ const ViewProject = ({customEventsPrefs: any,setCustomEventsPrefs: (pid: string, data: any) => void,liveStats: ILiveStats,+ passwordHash: {+ [key: string]: string,+ },}) => {const { t, i18n: { language } }: {t: (key: string, options?: {@@ -143,6 +147,7 @@ const ViewProject = ({} = useParams()const history = useHistory()const project: IProjectForShared = useMemo(() => _find([...projects, ..._map(sharedProjects, (item) => ({ ...item.project, role: item.role }))], p => p.id === id) || {} as IProjectForShared, [projects, id, sharedProjects])+ const projectPassword: string = useMemo(() => passwordHash[id] || getItem(PROJECTS_PROTECTED_PASSWORD)?.[id] || '', [id, passwordHash])const isSharedProject = useMemo(() => {const foundProject = _find([..._map(sharedProjects, (item) => item.project)], p => p.id === id)return !_isEmpty(foundProject)@@ -1393,6 +1398,11 @@ const ViewProject = ({// eslint-disable-next-line react-hooks/exhaustive-deps}, [chartType])+ if (project.isPasswordProtected && _isEmpty(passwordHash)) {+ // write password modal+ return ''+ }+if (!isLoading) {return (<Title title={name}>diff --git a/src/utils/localstorage.ts b/src/utils/localstorage.tsindex e65785d3a..296c2cd5f 100644--- a/src/utils/localstorage.ts+++ b/src/utils/localstorage.ts@@ -15,7 +15,7 @@ export const setItem: setItemType = (key, value) => {localStorage.setItem(key, value)}-type getItemType = (key: string) => string | null | {}+type getItemType = (key: string) => anyexport const getItem: getItemType = (key) => {if (currentLocalStorage[key]) {