Skip to content

Commit

Permalink
StatsHouse UI: fix bugs (#387)
Browse files Browse the repository at this point in the history
* StatsHouse UI: fix case-sensitive search

* StatsHouse UI: fix reload setting dash page

* StatsHouse UI: fix plot title
  • Loading branch information
vauweb authored Apr 24, 2023
1 parent 148fbb3 commit a9606a0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
24 changes: 16 additions & 8 deletions statshouse-ui/src/components/Plot/PlotHeaderTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function PlotHeaderTitle({ indexPlot, compact, dashboard }: PlotHeaderTit
: params.what.map((qw) => whatToWhatDesc(qw)).join(', '),
[params.metricName, params.what, plotData.whats]
);
const metricFullName = useMemo(() => metricName + (what ? ': ' + what : ''), [metricName, what]);
const metricFullName = useMemo(() => (metricName ? metricName + (what ? ': ' + what : '') : ''), [metricName, what]);

const editCustomName = useCallback(
(value: string) => {
Expand Down Expand Up @@ -92,12 +92,18 @@ export function PlotHeaderTitle({ indexPlot, compact, dashboard }: PlotHeaderTit
</span>
) : (
<span className="overflow-hidden d-flex flex-row w-100 justify-content-center" title={metricFullName}>
<span className="text-body text-truncate">{metricName}</span>
{!!what && (
{metricName ? (
<>
<span>: </span>
<span className="me-3 text-truncate">{what}</span>
<span className="text-body text-truncate">{metricName}</span>
{!!what && (
<>
<span>:&nbsp;</span>
<span className="me-3 text-truncate">{what}</span>
</>
)}
</>
) : (
<span>&nbsp;</span>
)}
</span>
)}
Expand All @@ -118,7 +124,8 @@ export function PlotHeaderTitle({ indexPlot, compact, dashboard }: PlotHeaderTit
<span className="text-body">{metricName}</span>
{!!what && (
<>
:<span className="me-3"> {what}</span>
<span>:&nbsp;</span>
<span className="me-3">{what}</span>
</>
)}
</>
Expand All @@ -129,7 +136,8 @@ export function PlotHeaderTitle({ indexPlot, compact, dashboard }: PlotHeaderTit
className="flex-grow-1"
defaultValue={params.customName || metricFullName}
placeholder={
params.customName || (
params.customName ||
(metricName && (
<>
<span>{metricName}</span>
{!!what && (
Expand All @@ -138,7 +146,7 @@ export function PlotHeaderTitle({ indexPlot, compact, dashboard }: PlotHeaderTit
</>
)}
</>
)
)) || <span>&nbsp;</span>
}
inputPlaceholder={metricFullName}
onSave={editCustomName}
Expand Down
10 changes: 5 additions & 5 deletions statshouse-ui/src/store/statshouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,17 +385,17 @@ export const statsHouseState: StateCreator<StatsHouseStore, [['zustand/immer', n
store.timeRange = new TimeRange(params.timeRange);
}
store.params = mergeLeft(store.params, params);
if (resetPlot) {
store.plotsData = [];
store.previews = [];
store.dashboardLayoutEdit = false;
}
if (store.params.tabNum < -1) {
store.dashboardLayoutEdit = true;
}
if (store.params.tabNum >= 0) {
store.dashboardLayoutEdit = false;
}
if (resetPlot) {
store.plotsData = [];
store.previews = [];
store.dashboardLayoutEdit = false;
}
});
getState().params.plots.forEach((plot, index) => {
if (changedTimeRange || changedTimeShifts || prevParams.plots[index] !== plot) {
Expand Down
4 changes: 2 additions & 2 deletions statshouse-ui/src/view/DashboardListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const DashboardListView: React.FC<DashboardListViewProps> = () => {
const res = listServerDashboard.filter(
(item) =>
searchInput.value === '' ||
item.name.includes(searchInput.value) ||
item.description.includes(searchInput.value)
item.name.toLowerCase().includes(searchInput.value.toLowerCase()) ||
item.description.toLowerCase().includes(searchInput.value.toLowerCase())
);
res.sort(sortByKey.bind(null, 'name'));
return res;
Expand Down

0 comments on commit a9606a0

Please sign in to comment.