В меню доски со списом задач добавлены кнопки обслуживания backend-а
This commit is contained in:
parent
888a5184c7
commit
c24a5de7dd
4 changed files with 41 additions and 19 deletions
|
|
@ -4,6 +4,7 @@ import * as IssuesListBoardStore from './store';
|
|||
import * as IssuesListBoardNs from './issues-list-board';
|
||||
import * as TopRightMenuNs from '../misc-components/top-right-menu';
|
||||
import { SetIssuesReadingTimestamp } from '../utils/unreaded-provider';
|
||||
import * as ServiceActionsButtons from '../utils/service-actions-buttons';
|
||||
|
||||
export type Props = {
|
||||
store: IssuesListBoardStore.IPageStore
|
||||
|
|
@ -31,6 +32,8 @@ export const IssuesListBoards = observer((props: Props): JSX.Element => {
|
|||
<>
|
||||
<TopRightMenuNs.TopRightMenu store={topRightMenuStore}>
|
||||
<button onClick={onAllReadItemClick}>Прочитать всё</button>
|
||||
<ServiceActionsButtons.IssuesForceRefreshButton />
|
||||
<ServiceActionsButtons.GetIssuesQueueSizeButton />
|
||||
</TopRightMenuNs.TopRightMenu>
|
||||
{list}
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { observer } from 'mobx-react-lite';
|
|||
import * as TopRightMenuNs from '../misc-components/top-right-menu';
|
||||
import { SetIssuesReadingTimestamp } from '../utils/unreaded-provider';
|
||||
import axios from 'axios';
|
||||
import * as ServiceActionsButtons from '../utils/service-actions-buttons';
|
||||
|
||||
export type Props = {
|
||||
store: IPageStore
|
||||
|
|
@ -37,30 +38,13 @@ export const KanbanBoards = observer((props: Props) => {
|
|||
}
|
||||
treeRefreshMenuItem = <button onClick={onTreeRefreshClick}>Force tree refresh</button>;
|
||||
}
|
||||
const onIssuesRefreshClick = (e: React.MouseEvent) => {
|
||||
if (e.target !== e.currentTarget) return;
|
||||
e.stopPropagation();
|
||||
const rawInput = prompt("Force issues refresh (delimiters - space, comma, semicolon, tab or new line)", "");
|
||||
if (!rawInput) return;
|
||||
const list = rawInput.split(/[ ,;\t\n\r]/).map(item => Number(item)).filter(item => (Number.isFinite(item) && item > 0));
|
||||
if (!list) return;
|
||||
axios.post(`/redmine-event-emitter/append-issues`, list);
|
||||
};
|
||||
const onGetIssuesQueueSizeClick = async (e: React.MouseEvent): Promise<void> => {
|
||||
if (e.target !== e.currentTarget) return;
|
||||
e.stopPropagation();
|
||||
const resp = await axios.get(`/redmine-event-emitter/get-issues-queue-size`);
|
||||
console.debug(`resp -`, resp); // DEBUG
|
||||
if (!resp || typeof resp.data !== 'number') return;
|
||||
alert(`Issues queue size - ${resp.data}`);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<TopRightMenuNs.TopRightMenu store={topRightMenuStore}>
|
||||
<button onClick={onAllReadClick}>Всё прочитано</button>
|
||||
{treeRefreshMenuItem}
|
||||
<button onClick={onIssuesRefreshClick}>Force issues refresh</button>
|
||||
<button onClick={onGetIssuesQueueSizeClick}>Get issues queue size</button>
|
||||
<ServiceActionsButtons.IssuesForceRefreshButton/>
|
||||
<ServiceActionsButtons.GetIssuesQueueSizeButton/>
|
||||
</TopRightMenuNs.TopRightMenu>
|
||||
{list}
|
||||
</>
|
||||
|
|
|
|||
14
frontend/src/utils/service-actions-buttons.tsx
Normal file
14
frontend/src/utils/service-actions-buttons.tsx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import React from 'react';
|
||||
import { onGetIssuesQueueSizeClick, onIssuesRefreshClick } from './service-actions';
|
||||
|
||||
export const IssuesForceRefreshButton = (): JSX.Element => {
|
||||
return (
|
||||
<button onClick={onIssuesRefreshClick}>Force issues refresh</button>
|
||||
);
|
||||
};
|
||||
|
||||
export const GetIssuesQueueSizeButton = (): JSX.Element => {
|
||||
return (
|
||||
<button onClick={onGetIssuesQueueSizeClick}>Get issues queue size</button>
|
||||
);
|
||||
};
|
||||
21
frontend/src/utils/service-actions.ts
Normal file
21
frontend/src/utils/service-actions.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import axios from "axios";
|
||||
import React from 'react';
|
||||
|
||||
export const onIssuesRefreshClick = (e: React.MouseEvent) => {
|
||||
if (e.target !== e.currentTarget) return;
|
||||
e.stopPropagation();
|
||||
const rawInput = prompt("Force issues refresh (delimiters - space, comma, semicolon or tab)", "");
|
||||
if (!rawInput) return;
|
||||
const list = rawInput.split(" ,;\t").map(item => Number(item)).filter(item => Number.isFinite(item));
|
||||
if (!list) return;
|
||||
axios.post(`/redmine-event-emitter/append-issues`, list);
|
||||
};
|
||||
|
||||
export const onGetIssuesQueueSizeClick = async (e: React.MouseEvent): Promise<void> => {
|
||||
if (e.target !== e.currentTarget) return;
|
||||
e.stopPropagation();
|
||||
const resp = await axios.get(`/redmine-event-emitter/get-issues-queue-size`);
|
||||
console.debug(`resp -`, resp); // DEBUG
|
||||
if (!resp || typeof resp.data !== 'number') return;
|
||||
alert(`Issues queue size - ${resp.data}`);
|
||||
};
|
||||
Loading…
Reference in a new issue