Skip to content

Commit

Permalink
fix: logs volume time range
Browse files Browse the repository at this point in the history
  • Loading branch information
jacovinus committed Jan 9, 2024
1 parent b10380f commit 10a7b1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ const QueryBar: React.FC<QueryBarProps> = (props) => {
const historyOpen = useSelector((store: any) => store.historyOpen);
const isEmbed = useSelector((store: any) => store.isEmbed);
const queryHistory = useSelector((store: any) => store.queryHistory);
const start = useSelector((store: any) => store.start);
const stop = useSelector((store: any) => store.stop);
const isSplit = useSelector((store: any) => store.isSplit);
const panelQuery = useSelector((store: any) => store[name]);
const isTabletOrMobile = useMediaQuery({ query: "(max-width: 1070px)" });
Expand All @@ -142,7 +140,7 @@ const QueryBar: React.FC<QueryBarProps> = (props) => {
return defaultDataSources.find((f) => f.id === dataSourceId);
}, [dataSourceId]);

const findCurrentDataSource = (dataSources: any, id: string) => {
const findCurrentDataSource = (dataSources: any) => {
return dataSources?.find((f: any) => f.id === dataSourceId);
};

Expand All @@ -155,7 +153,7 @@ const QueryBar: React.FC<QueryBarProps> = (props) => {

setLogsLevel(expr, isLogsVolume);

const dataSource: any = findCurrentDataSource(dataSources, id);
const dataSource: any = findCurrentDataSource(dataSources);

let currentDataSource: any = {};

Expand Down Expand Up @@ -416,11 +414,12 @@ const QueryBar: React.FC<QueryBarProps> = (props) => {
const { query, customStep } = setQueryTimeInterval(
queryString,
width,
start,
stop
data.start,
data.stop
);
saveLogsVolumeQuery({ query, customStep });
};

const onSubmit = (e: any) => {
e.preventDefault();
const ds: any = dataSources.find((f: any) => f.id === dataSourceId);
Expand Down Expand Up @@ -662,7 +661,7 @@ const QueryBar: React.FC<QueryBarProps> = (props) => {

if (queryExpr.includes("$__interval")) {
isMatrix = true;
const timeDiff = (stop.getTime() - start.getTime()) / 1000;
const timeDiff = (data.stop.getTime() - data.start.getTime()) / 1000;
const timeProportion = timeDiff / 30;
const screenProportion = Number(
(width / window.innerWidth).toFixed(1)
Expand Down Expand Up @@ -951,6 +950,7 @@ const QueryBar: React.FC<QueryBarProps> = (props) => {
handleLogValueChange={onLogChange}
handleLogsVolumeChange={onLogVolumeChange}
/>,

<ShowLogsButton
disabled={!queryValid}
onClick={onSubmit}
Expand Down
11 changes: 4 additions & 7 deletions packages/main/src/components/QueryTypeBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { Switch } from "@mui/material";
import { useLocation } from "react-router-dom";
import { setLeftPanel } from "@ui/store/actions/setLeftPanel";
import { setRightPanel } from "@ui/store/actions/setRightPanel";
import useTheme from "@ui/theme/useTheme"
import useTheme from "@ui/theme/useTheme";
import PluginRenderer from "@ui/plugins/PluginsRenderer";

const QueryTypeCont = styled.div`
display: flex;
padding: 4px;
// background: ${(props: any) => props.theme.shadow};
// background: ${(props: any) => props.theme.shadow};
color: ${(props: any) => props.color};
height: 26px;
`;
Expand All @@ -36,8 +36,7 @@ export const DIRECTION_SWITCH_OPTIONS = [
{ value: "backwards", label: "Backwards" },
];


// Bar with switches:
// Bar with switches:
// query type
// timestamp
// query builder
Expand Down Expand Up @@ -101,7 +100,6 @@ export default function QueryTypeBar(props: any) {
dispatch(panelAction(name, panel));
}
}

}, []);

useEffect(() => {
Expand Down Expand Up @@ -187,7 +185,6 @@ export default function QueryTypeBar(props: any) {
}
});

console.log(name, panel)
dispatch(panelAction(name, panel));
}

Expand All @@ -206,7 +203,7 @@ export default function QueryTypeBar(props: any) {
return (
<ThemeProvider theme={theme}>
<QueryTypeCont>
<PluginRenderer section={"Query Options"} localProps={props}/>
<PluginRenderer section={"Query Options"} localProps={props} />
<QueryTypeSwitch
label={"Query Type"}
options={SWITCH_OPTIONS}
Expand Down

0 comments on commit 10a7b1d

Please sign in to comment.