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

[Feature Request] Refresh button #166 #277

Merged
merged 12 commits into from
Jan 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: neodash
version: 2.2
title: NeoDash Documentation
title: NeoDash
start_page: ROOT:index.adoc
nav:
- modules/ROOT/nav.adoc
Expand Down
2 changes: 1 addition & 1 deletion docs/preview.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
site:
title: NeoDash Documentation
title: NeoDash

content:
sources:
Expand Down
8 changes: 0 additions & 8 deletions src/card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
updateSelectionThunk,
updateReportQueryThunk,
toggleCardSettingsThunk,
updateReportRefreshRateThunk,
updateReportSettingThunk,
updateReportTitleThunk,
updateReportTypeThunk,
Expand Down Expand Up @@ -47,7 +46,6 @@ const NeoCard = ({
onTypeUpdate, // action to take when the card report type is updated.
onFieldsUpdate, // action to take when the set of returned query fields is updated.
onQueryUpdate, // action to take when the card query is updated.
onRefreshRateUpdate, // action to take when the card refresh rate is updated.
onReportSettingUpdate, // action to take when an advanced report setting is updated.
onSelectionUpdate, // action to take when the selected visualization fields are updated.
onGlobalParameterUpdate, // action to take when a report updates a dashboard parameter.
Expand Down Expand Up @@ -138,7 +136,6 @@ const NeoCard = ({
query={report.query}
globalParameters={globalParameters}
fields={report.fields ? report.fields : []}
refreshRate={report.refreshRate}
selection={report.selection}
widthPx={width}
heightPx={height}
Expand Down Expand Up @@ -170,7 +167,6 @@ const NeoCard = ({
heightPx={height}
fields={report.fields}
type={report.type}
refreshRate={report.refreshRate}
expanded={expanded}
extensions={extensions}
dashboardSettings={dashboardSettings}
Expand All @@ -179,7 +175,6 @@ const NeoCard = ({
reportSettings={report.settings}
reportSettingsOpen={report.advancedSettingsOpen}
onQueryUpdate={(query) => onQueryUpdate(index, query)}
onRefreshRateUpdate={(rate) => onRefreshRateUpdate(index, rate)}
onDatabaseChanged={(database) => onDatabaseChanged(index, database)}
onReportSettingUpdate={(setting, value) => onReportSettingUpdate(index, setting, value)}
onTypeUpdate={(type) => onTypeUpdate(index, type)}
Expand Down Expand Up @@ -237,9 +232,6 @@ const mapDispatchToProps = (dispatch) => ({
onQueryUpdate: (index: any, query: any) => {
dispatch(updateReportQueryThunk(index, query));
},
onRefreshRateUpdate: (index: any, rate: any) => {
dispatch(updateReportRefreshRateThunk(index, rate));
},
onTypeUpdate: (index: any, type: any) => {
dispatch(updateReportTypeThunk(index, type));
},
Expand Down
6 changes: 0 additions & 6 deletions src/card/CardActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ export const updateReportQuery = (pagenumber: number, index: number, query: any)
payload: { pagenumber, index, query },
});

export const UPDATE_REPORT_REFRESH_RATE = 'PAGE/CARD/UPDATE_REPORT_REFRESH_RATE';
export const updateReportRefreshRate = (pagenumber: number, index: number, rate: any) => ({
type: UPDATE_REPORT_REFRESH_RATE,
payload: { pagenumber, index, rate },
});

export const UPDATE_CYPHER_PARAMETERS = 'PAGE/CARD/UPDATE_CYPHER_PARAMETERS';
export const updateCypherParameters = (pagenumber: number, index: number, parameters: any) => ({
type: UPDATE_CYPHER_PARAMETERS,
Expand Down
7 changes: 0 additions & 7 deletions src/card/CardReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
UPDATE_CYPHER_PARAMETERS,
UPDATE_FIELDS,
UPDATE_REPORT_QUERY,
UPDATE_REPORT_REFRESH_RATE,
UPDATE_REPORT_SETTING,
UPDATE_REPORT_SIZE,
UPDATE_REPORT_TITLE,
Expand Down Expand Up @@ -61,12 +60,6 @@ export const cardReducer = (state = CARD_INITIAL_STATE, action: { type: any; pay
state = update(state, { query: query });
return state;
}
case UPDATE_REPORT_REFRESH_RATE: {
const { rate } = payload;

state = update(state, { refreshRate: rate });
return state;
}
case UPDATE_CYPHER_PARAMETERS: {
const { parameters } = payload;
state = update(state, { parameters: parameters });
Expand Down
13 changes: 0 additions & 13 deletions src/card/CardThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {
updateReportTitle,
updateReportQuery,
updateSelection,
updateReportSize,
updateReportRefreshRate,
updateCypherParameters,
updateFields,
updateReportType,
Expand Down Expand Up @@ -52,17 +50,6 @@ export const updateReportQueryThunk = (index, query) => (dispatch: any, getState
}
};

// TODO: make refresh rate an advanced setting
export const updateReportRefreshRateThunk = (index, rate) => (dispatch: any, getState: any) => {
try {
const state = getState();
const { pagenumber } = state.dashboard.settings;
dispatch(updateReportRefreshRate(pagenumber, index, rate));
} catch (e) {
dispatch(createNotificationThunk('Cannot update refresh rate', e));
}
};

export const updateCypherParametersThunk = (index, parameters) => (dispatch: any, getState: any) => {
try {
const state = getState();
Expand Down
4 changes: 0 additions & 4 deletions src/card/settings/CardSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const NeoCardSettings = ({
query,
database, // Current database related to the report
databaseList, // List of databases the user can choose from ('system' is filtered out)
refreshRate,
width,
height,
type,
Expand All @@ -21,7 +20,6 @@ const NeoCardSettings = ({
heightPx,
extensions, // A set of enabled extensions.
onQueryUpdate,
onRefreshRateUpdate,
onDatabaseChanged, // When the database related to a report is changed it must be stored in the report state
onRemovePressed,
onClonePressed,
Expand Down Expand Up @@ -57,7 +55,6 @@ const NeoCardSettings = ({
<NeoCardSettingsContent
query={query}
database={database}
refreshRate={refreshRate}
reportSettings={reportSettings}
width={width}
height={height}
Expand All @@ -67,7 +64,6 @@ const NeoCardSettings = ({
onDatabaseChanged={onDatabaseChanged}
onQueryUpdate={onQueryUpdate}
onReportSettingUpdate={onReportSettingUpdate}
onRefreshRateUpdate={onRefreshRateUpdate}
onTypeUpdate={onTypeUpdate}
></NeoCardSettingsContent>
) : (
Expand Down
32 changes: 2 additions & 30 deletions src/card/settings/CardSettingsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ const NeoCardSettingsContent = ({
database, // Current report database
databaseList, // List of databases the user can choose from ('system' is filtered out)
reportSettings,
refreshRate,
type,
extensions,
onQueryUpdate,
onRefreshRateUpdate,
onReportSettingUpdate,
onTypeUpdate,
onDatabaseChanged, // When the database related to a report is changed it must be stored in the report state
Expand All @@ -25,9 +23,6 @@ const NeoCardSettingsContent = ({
const [queryText, setQueryText] = React.useState(query);
const debouncedQueryUpdate = useCallback(debounce(onQueryUpdate, 250), []);

const [refreshRateText, setRefreshRateText] = React.useState(refreshRate);
const debouncedRefreshRateUpdate = useCallback(debounce(onRefreshRateUpdate, 250), []);

// State to manage the current database entry inside the form
const [databaseText, setDatabaseText] = React.useState(database);
const debouncedDatabaseUpdate = useCallback(debounce(onDatabaseChanged, 250), []);
Expand All @@ -39,13 +34,6 @@ const NeoCardSettingsContent = ({
}
}, [query]);

useEffect(() => {
// Reset text to the dashboard state when the page gets reorganized.
if (refreshRate !== refreshRateText) {
setRefreshRateText(refreshRate !== undefined ? refreshRate : '');
}
}, [refreshRate]);

const reportTypes = getReportTypes(extensions);
const SettingsComponent = reportTypes[type] && reportTypes[type].settingsComponent;

Expand All @@ -64,13 +52,13 @@ const NeoCardSettingsContent = ({
))}
/>

{reportTypes[type] && reportTypes[type].disableRefreshRate == undefined ? (
{reportTypes[type] && reportTypes[type].disableDatabaseSelector == undefined ? (
<NeoField
select
placeholder='neo4j'
label='Database'
value={databaseText}
style={{ width: '47%', maxWidth: '200px', marginRight: '10px' }}
style={{ width: '47%', maxWidth: '200px' }}
choices={databaseList.map((database) => (
<MenuItem key={database} value={database}>
{database}
Expand All @@ -85,22 +73,6 @@ const NeoCardSettingsContent = ({
<></>
)}

{reportTypes[type] && reportTypes[type].disableRefreshRate == undefined ? (
<NeoField
placeholder='0 (No Refresh)'
label='Refresh Rate (sec)'
numeric={true}
value={refreshRateText}
style={{ width: '47%', maxWidth: '200px' }}
onChange={(value) => {
setRefreshRateText(value);
debouncedRefreshRateUpdate(value);
}}
/>
) : (
<></>
)}

<br />
<br />
{/* Allow for overriding the code box with a custom component */}
Expand Down
26 changes: 17 additions & 9 deletions src/card/view/CardView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { ReportItemContainer } from '../CardStyle';
import NeoCardViewHeader from './CardViewHeader';
import NeoCardViewFooter from './CardViewFooter';
Expand All @@ -8,7 +8,6 @@ import NeoCodeEditorComponent from '../../component/editor/CodeEditorComponent';
import PlayCircleFilledIcon from '@material-ui/icons/PlayCircleFilled';

import { CARD_FOOTER_HEIGHT, CARD_HEADER_HEIGHT } from '../../config/CardConfig';
import { downloadComponentAsImage } from '../../chart/ChartUtils';
import { getReportTypes } from '../../extensions/ExtensionUtils';
import NeoCodeViewerComponent from '../../component/editor/CodeViewerComponent';

Expand All @@ -29,7 +28,6 @@ const NeoCardView = ({
dashboardSettings,
settings,
settingsOpen,
refreshRate,
editable,
onGlobalParameterUpdate,
onSelectionUpdate,
Expand All @@ -42,11 +40,12 @@ const NeoCardView = ({
const reportHeight = heightPx - CARD_FOOTER_HEIGHT - CARD_HEADER_HEIGHT + 13;
const cardHeight = heightPx - CARD_FOOTER_HEIGHT;
const ref = React.useRef();
const [lastRunTimestamp, setLastRunTimestamp] = useState(Date.now());

const getLocalParameters = (parse_string): any => {
let re = /(?:^|\W)\$(\w+)(?!\w)/g;
let match;
let localQueryVariables: string[] = [];
let match;
let localQueryVariables: string[] = [];
while ((match = re.exec(parse_string))) {
localQueryVariables.push(match[1]);
}
Expand All @@ -65,10 +64,12 @@ const NeoCardView = ({
title={title}
editable={editable}
description={settings.description}
fullscreenEnabled={dashboardSettings.fullscreenEnabled}
downloadImageEnabled={dashboardSettings.downloadImageEnabled}
fullscreenEnabled={settings.fullscreenEnabled}
downloadImageEnabled={settings.downloadImageEnabled}
refreshButtonEnabled={settings.refreshButtonEnabled}
onTitleUpdate={onTitleUpdate}
onToggleCardSettings={onToggleCardSettings}
onManualRefreshCard={() => setLastRunTimestamp(Date.now())}
settings={settings}
onDownloadImage={onDownloadImage}
onToggleCardExpand={onToggleCardExpand}
Expand Down Expand Up @@ -115,6 +116,13 @@ const NeoCardView = ({
)
);

const localParameters = getLocalParameters(query);
useEffect(() => {
if (!settingsOpen) {
setLastRunTimestamp(Date.now());
}
}, [settingsOpen, query, JSON.stringify(localParameters)]);

// TODO - understand why CardContent is throwing a warning based on this style config.
const cardContentStyle = {
paddingBottom: '0px',
Expand All @@ -139,15 +147,15 @@ const NeoCardView = ({
<NeoReport
query={query}
database={database}
parameters={getLocalParameters(query)}
parameters={localParameters}
lastRunTimestamp={lastRunTimestamp}
extensions={extensions}
disabled={settingsOpen}
selection={selection}
fields={fields}
settings={settings}
expanded={expanded}
rowLimit={dashboardSettings.disableRowLimiting ? 1000000 : reportTypes[type] && reportTypes[type].maxRecords}
refreshRate={refreshRate}
dimensions={{ width: widthPx, height: heightPx }}
type={type}
ChartType={reportTypes[type] && reportTypes[type].component}
Expand Down
12 changes: 12 additions & 0 deletions src/card/view/CardViewHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect } from 'react';
import CardHeader from '@material-ui/core/CardHeader';
import IconButton from '@material-ui/core/IconButton';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import RefreshIcon from '@material-ui/icons/Refresh';
import FullscreenIcon from '@material-ui/icons/Fullscreen';
import FullscreenExit from '@material-ui/icons/FullscreenExit';
import { Badge, Dialog, DialogContent, DialogTitle, TextField } from '@material-ui/core';
Expand All @@ -22,7 +23,9 @@ const NeoCardViewHeader = ({
onTitleUpdate,
fullscreenEnabled,
downloadImageEnabled,
refreshButtonEnabled,
onToggleCardSettings,
onManualRefreshCard,
onDownloadImage,
onToggleCardExpand,
expanded,
Expand Down Expand Up @@ -115,6 +118,14 @@ const NeoCardViewHeader = ({
</Tooltip>
);

const refreshButton = (
<Tooltip title='Refresh' aria-label='refresh'>
<IconButton aria-label='refresh' onClick={onManualRefreshCard}>
<RefreshIcon />
</IconButton>
</Tooltip>
);

const maximizeButton = (
<Tooltip title='Maximize' aria-label='maximize'>
<IconButton aria-label='maximize' onClick={onToggleCardExpand}>
Expand Down Expand Up @@ -174,6 +185,7 @@ const NeoCardViewHeader = ({
{downloadImageEnabled ? downloadImageButton : <></>}
{fullscreenEnabled ? expanded ? unMaximizeButton : maximizeButton : <></>}
{descriptionEnabled ? descriptionButton : <></>}
{refreshButtonEnabled ? refreshButton : <></>}
{editable ? settingsButton : <></>}
</>
}
Expand Down
4 changes: 0 additions & 4 deletions src/chart/line/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { NoDrawableDataErrorMessage } from '../../component/editor/CodeViewerCom
import { evaluateRulesOnDict } from '../../extensions/styling/StyleRuleEvaluator';
import { ChartProps } from '../Chart';
import { convertRecordObjectToString, recordToNative } from '../ChartUtils';
import { ResponsiveSunburst } from '@nivo/sunburst';
import { useState } from 'react';
import { Tooltip } from '@material-ui/core';
import RefreshIcon from '@material-ui/icons/Refresh';

interface LineChartData {
id: string;
Expand Down
Loading