mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
Track query times. Updated refresh button.
This commit is contained in:
parent
f17be19110
commit
c984f4c6ae
5 changed files with 48 additions and 19 deletions
17
redux/actions/queries.js
Normal file
17
redux/actions/queries.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
const queries = createSlice({
|
||||
name: 'queries',
|
||||
initialState: {},
|
||||
reducers: {
|
||||
updateQuery(state, action) {
|
||||
const { url, ...data } = action.payload;
|
||||
state[url] = data;
|
||||
return state;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { updateQuery } = queries.actions;
|
||||
|
||||
export default queries.reducer;
|
||||
|
|
@ -1,33 +1,29 @@
|
|||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import produce from 'immer';
|
||||
|
||||
const websites = createSlice({
|
||||
name: 'user',
|
||||
name: 'websites',
|
||||
initialState: {},
|
||||
reducers: {
|
||||
updateWebsites(state, action) {
|
||||
state = action.payload;
|
||||
return state;
|
||||
},
|
||||
updateWebsite(state, action) {
|
||||
const { websiteId, ...data } = action.payload;
|
||||
state[websiteId] = data;
|
||||
return state;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { updateWebsites } = websites.actions;
|
||||
export const { updateWebsites, updateWebsite } = websites.actions;
|
||||
|
||||
export default websites.reducer;
|
||||
|
||||
export function setDateRange(websiteId, dateRange) {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
let { websites = {} } = state;
|
||||
|
||||
websites = produce(websites, draft => {
|
||||
if (!draft[websiteId]) {
|
||||
draft[websiteId] = {};
|
||||
}
|
||||
draft[websiteId].dateRange = { ...dateRange, modified: Date.now() };
|
||||
});
|
||||
|
||||
return dispatch(updateWebsites(websites));
|
||||
return dispatch => {
|
||||
return dispatch(
|
||||
updateWebsite({ websiteId, dateRange: { ...dateRange, modified: Date.now() } }),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { combineReducers } from 'redux';
|
||||
import user from './actions/user';
|
||||
import websites from './actions/websites';
|
||||
import queries from './actions/queries';
|
||||
|
||||
export default combineReducers({ user, websites });
|
||||
export default combineReducers({ user, websites, queries });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue