HM-62. Исправление бага при переходе между страницами (#28)
This commit is contained in:
@ -5,7 +5,7 @@ import Pagination from '../pagination';
|
||||
import LogsFilters from '../logs-filters';
|
||||
import routeService from '../../services/RouteService';
|
||||
import {prepareToNumber} from '../../utils/urlUtils';
|
||||
import {LOG_TYPE, LOG_COLS} from '../../consts';
|
||||
import {LOG_TYPE, LOG_COLS, EVENTS} from '../../consts';
|
||||
import {createElement, markText} from '../../utils/elementUtils';
|
||||
|
||||
const ELEMENTS_ON_PAGE = 15;
|
||||
@ -36,16 +36,19 @@ class LogsPage extends Component {
|
||||
|
||||
this.pagination = new Pagination(this.footer);
|
||||
|
||||
routeService.onChange(this.renderTable);
|
||||
this.logList = {
|
||||
[LOG_TYPE.SERVER]: [],
|
||||
[LOG_TYPE.CLIENT]: [],
|
||||
};
|
||||
|
||||
this.addSubscribe(routeService, EVENTS.ROUTE_SEARCH_CHANGE, this.renderTable);
|
||||
|
||||
this.initPage();
|
||||
}
|
||||
|
||||
initPage = async () => {
|
||||
this.logList = {
|
||||
[LOG_TYPE.SERVER]: await storageLogsApi.requestServerLogs(),
|
||||
[LOG_TYPE.CLIENT]: await storageLogsApi.requestClientLogs(),
|
||||
};
|
||||
this.logList[LOG_TYPE.SERVER] = await storageLogsApi.requestServerLogs();
|
||||
this.logList[LOG_TYPE.CLIENT] = await storageLogsApi.requestClientLogs();
|
||||
this.renderTable();
|
||||
}
|
||||
|
||||
@ -84,14 +87,16 @@ class LogsPage extends Component {
|
||||
}
|
||||
|
||||
renderTable = () => {
|
||||
const {query} = routeService.getUrlData();
|
||||
const {tableType, ...omitQuery} = query;
|
||||
this.table?.mainNode?.remove();
|
||||
this.table = this.tables[tableType];
|
||||
this.body.appendChild(this.table.mainNode);
|
||||
const filteredRows = this.filterRows(this.logList[tableType], omitQuery);
|
||||
const rows = this.cutPagginationPage(filteredRows, query.pageNumber);
|
||||
this.table.render(rows);
|
||||
this.render(() => {
|
||||
const {query} = routeService.getUrlData();
|
||||
const {tableType, ...omitQuery} = query;
|
||||
this.table?.mainNode?.remove();
|
||||
this.table = this.tables[tableType];
|
||||
this.body.appendChild(this.table.mainNode);
|
||||
const filteredRows = this.filterRows(this.logList[tableType], omitQuery);
|
||||
const rows = this.cutPagginationPage(filteredRows, query.pageNumber);
|
||||
this.table.render(rows);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user