Skip to content

Commit c1b5d6c

Browse files
committed
Merge branch 'main' into alexey-header-fixes
2 parents d34ed64 + c2a9014 commit c1b5d6c

18 files changed

+494
-186
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"url": "git+ssh://[email protected]/metrico/cloki-view.git"
77
},
88
"author": "[email protected]",
9-
"version": "0.8.0",
9+
"version": "0.8.1",
1010
"private": false,
1111
"dependencies": {
1212
"@emotion/react": "^11.7.1",

src/actions/LoadLabels.js

-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ export default function loadLabels(apiUrl) {
3232
const labels = response?.data?.data.sort().map((label) => ({
3333
name: label,
3434
selected: false,
35-
loading: false,
3635
values: [],
37-
hidden: false,
38-
facets: 0,
3936
}));
4037
dispatch(setLabels(labels || []));
4138
}

src/actions/loadLabelValues.js

-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ export default function loadLabelValues(label, labelList, apiUrl) {
3737
const values = response?.data?.data?.map?.((value) => ({
3838
name: value,
3939
selected: false,
40-
loading: false,
41-
hidden: false,
4240
inverted: false
4341
}));
4442

@@ -55,8 +53,6 @@ export default function loadLabelValues(label, labelList, apiUrl) {
5553
dispatch(setApiError(''))
5654
dispatch(setLabelValues(response?.data?.data));
5755

58-
59-
6056
}).catch(error => {
6157
dispatch(setLoading(false))
6258
const { message } = errorHandler(url, error)

src/actions/loadLogs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function loadLogs() {
1717
// const step = 120
1818
// const direction = 'backward'
1919
const localStore = store.getState();
20-
const { query: label, limit, step, apiUrl, label: rangeLabel } = localStore;
20+
const { query, limit, step, apiUrl, label: rangeLabel } = localStore;
2121
let { start: startTs, stop: stopTs } = localStore;
2222

2323
if (findRangeByLabel(rangeLabel)) {
@@ -39,9 +39,9 @@ export default function loadLogs() {
3939

4040
const queryStep = `&step=${step || 120}`;
4141

42-
const query = `${encodeURIComponent(label)}`;
42+
const encodedQuery = `${encodeURIComponent(query)}`;
4343

44-
const getUrl = `${url}/loki/api/v1/query_range?query=${query}&limit=${limit}${parsedTime}${queryStep}`;
44+
const getUrl = `${url}/loki/api/v1/query_range?query=${encodedQuery}&limit=${limit}${parsedTime}${queryStep}`;
4545

4646
const options = {
4747
method: "GET",

src/components/LabelBrowser/QueryBar.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import HistoryIcon from "@mui/icons-material/History";
1010
import styled from "@emotion/styled";
1111
import setHistoryOpen from "../../actions/setHistoryOpen";
1212
import { Tooltip } from "@mui/material";
13-
import Badge from '@mui/material/Badge';
13+
import { decodeQuery } from "../UpdateStateFromQueryParams";
14+
import localUrl from "../../services/localUrl";
15+
1416

1517
const HistoryButton = styled.button`
1618
background: none;
@@ -27,6 +29,7 @@ export const QueryBar = () => {
2729
const labelsBrowserOpen = useSelector((store) => store.labelsBrowserOpen);
2830
const debug = useSelector((store) => store.debug);
2931
const query = useSelector((store) => store.query);
32+
const apiUrl = useSelector((store) => store.apiUrl)
3033
const isSubmit = useSelector((store) => store.isSubmit);
3134
const historyOpen = useSelector((store) => store.historyOpen)
3235
const [queryInput, setQueryInput] = useState(query);
@@ -36,7 +39,7 @@ export const QueryBar = () => {
3639
const LOG_BROWSER = "Log Browser";
3740
const queryHistory = useSelector((store) => store.queryHistory)
3841
const [historyItems, setHistoryItems] = useState(queryHistory.length>0)
39-
42+
const saveUrl = localUrl()
4043
useEffect(()=>{
4144
setHistoryItems(queryHistory.length>0)
4245
},[queryHistory])
@@ -60,7 +63,6 @@ export const QueryBar = () => {
6063
);
6164
// here
6265
dispatch(setLoading(true));
63-
6466
dispatch(loadLogs());
6567

6668
setTimeout(() => {
@@ -107,15 +109,17 @@ export const QueryBar = () => {
107109

108110
dispatch(setQuery(queryInput));
109111

110-
if (onQueryValid(query)) {
112+
if (onQueryValid(queryInput)) {
111113
try {
112114
const historyUpdated = historyService.add({
113-
data: query,
115+
data: queryInput,
114116
url: window.location.hash,
115117
});
116118
dispatch(setQueryHistory(historyUpdated));
117119
dispatch(setLabelsBrowserOpen(false));
120+
decodeQuery(query,apiUrl)
118121
dispatch(loadLogs());
122+
saveUrl.add({data: window.location.href, description:'From Query Submit'})
119123
} catch (e) {
120124
console.log(e);
121125
}

src/components/LabelBrowser/ValuesList.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const ValuesList = (props) => {
3232
const [labelsSelected, setLabelsSelected] = useState([]);
3333
const labels = useSelector(state => {
3434
const selected = state.labels.filter((f) => f.selected);
35-
console.log(JSON.stringify(selected) !== JSON.stringify(labelsSelected))
3635
if (JSON.stringify(selected) !== JSON.stringify(labelsSelected)) {
3736
setLabelsSelected(selected);
3837
}
@@ -47,7 +46,7 @@ export const ValuesList = (props) => {
4746
if(debug) console.log('🚧 LOGIC/LabelBrowser/ValuesList', apiUrl)
4847
const labelsBrowserOpen = useSelector((store) => store.labelsBrowserOpen)
4948

50-
const CLOSE = "close"
49+
const CLEAR = "clear"
5150
/**
5251
* TODO: FILTER VALUES INSIDE LABELS
5352
*/
@@ -191,7 +190,7 @@ export const ValuesList = (props) => {
191190
onClick={(e) =>
192191
onLabelOpen(e, labelSelected)
193192
}
194-
>{CLOSE}</span>
193+
>{CLEAR}</span>
195194
</div>
196195
<div className={"valuelist-content column"}>
197196
{labelSelected?.values?.map(

src/components/LabelBrowser/helpers/querybuilder.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { setQuery } from "../../../actions";
22
import store from "../../../store/store";
33

44
export function queryBuilder(labels) {
5+
console.log(labels)
56
const selectedLabels = [];
67
for (const label of labels) {
78
if (label.selected && label.values && label.values.length > 0) {
@@ -30,6 +31,6 @@ export function queryBuilder(labels) {
3031
export function queryBuilderWithLabels() {
3132
const labels = store.getState().labels;
3233
console.log(labels)
33-
const query = queryBuilder(labels)
34-
store.dispatch(setQuery(query));
35-
}
34+
const query = queryBuilder(labels)
35+
store.dispatch(setQuery(query));
36+
}

0 commit comments

Comments
 (0)