import { ServiceRepository } from 'services/services';
import { Dispatch } from 'redux';
import { groupBy } from 'lodash';
-import { loadProcess } from 'store/processes/processes-actions';
import { LogResource } from 'models/log';
import { LogService } from 'services/log-service/log-service';
import { ResourceEventMessage } from 'websocket/resource-event-message';
export const initProcessLogsPanel = (processUuid: string) =>
async (dispatch: Dispatch, getState: () => RootState, { logService }: ServiceRepository) => {
dispatch(processLogsPanelActions.RESET_PROCESS_LOGS_PANEL());
- const process = await dispatch<any>(loadProcess(processUuid));
- if (process.container) {
+ const process = getProcess(processUuid)(getState().resources);
+ if (process && process.container) {
const logResources = await loadContainerLogs(process.container.uuid, logService);
const initialState = createInitialLogPanelState(logResources);
dispatch(processLogsPanelActions.INIT_PROCESS_LOGS_PANEL(initialState));
export const addProcessLogsPanelItem = (message: ResourceEventMessage<{ text: string }>) =>
async (dispatch: Dispatch, getState: () => RootState, { logService }: ServiceRepository) => {
if (PROCESS_PANEL_LOG_EVENT_TYPES.indexOf(message.eventType) > -1) {
- const uuid = getProcessLogsPanelCurrentUuid(getState());
- if (uuid) {
- const process = getProcess(uuid)(getState().resources);
- if (process) {
- const { containerRequest, container } = process;
- if (message.objectUuid === containerRequest.uuid
- || (container && message.objectUuid === container.uuid)) {
- dispatch(processLogsPanelActions.ADD_PROCESS_LOGS_PANEL_ITEM({
- logType: SUMMARIZED_FILTER_TYPE,
- log: message.properties.text
- }));
- dispatch(processLogsPanelActions.ADD_PROCESS_LOGS_PANEL_ITEM({
- logType: message.eventType,
- log: message.properties.text
- }));
- }
+ const uuid = getProcessLogsPanelCurrentUuid(getState().router);
+ if (!uuid) { return }
+ const process = getProcess(uuid)(getState().resources);
+ if (!process) { return }
+ const { containerRequest, container } = process;
+ if (message.objectUuid === containerRequest.uuid
+ || (container && message.objectUuid === container.uuid)) {
+ dispatch(processLogsPanelActions.ADD_PROCESS_LOGS_PANEL_ITEM({
+ logType: ALL_FILTER_TYPE,
+ log: message.properties.text
+ }));
+ dispatch(processLogsPanelActions.ADD_PROCESS_LOGS_PANEL_ITEM({
+ logType: message.eventType,
+ log: message.properties.text
+ }));
+ if (MAIN_EVENT_TYPES.indexOf(message.eventType) > -1) {
+ dispatch(processLogsPanelActions.ADD_PROCESS_LOGS_PANEL_ITEM({
+ logType: MAIN_FILTER_TYPE,
+ log: message.properties.text
+ }));
}
}
}
const createInitialLogPanelState = (logResources: LogResource[]) => {
const allLogs = logsToLines(logResources);
+ const mainLogs = logsToLines(logResources.filter(
+ e => MAIN_EVENT_TYPES.indexOf(e.eventType) > -1
+ ));
const groupedLogResources = groupBy(logResources, log => log.eventType);
const groupedLogs = Object
.keys(groupedLogResources)
...grouped,
[key]: logsToLines(groupedLogResources[key])
}), {});
- const filters = [SUMMARIZED_FILTER_TYPE, ...Object.keys(groupedLogs)];
- const logs = { [SUMMARIZED_FILTER_TYPE]: allLogs, ...groupedLogs };
+ const filters = [MAIN_FILTER_TYPE, ALL_FILTER_TYPE, ...Object.keys(groupedLogs)];
+ const logs = {
+ [MAIN_FILTER_TYPE]: mainLogs,
+ [ALL_FILTER_TYPE]: allLogs,
+ ...groupedLogs
+ };
return { filters, logs };
};
await services.collectionService.get(uuid);
dispatch<any>(navigateTo(uuid));
} catch {
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'This collection does not exists!', hideDuration: 2000, kind: SnackbarKind.ERROR }));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not request collection', hideDuration: 2000, kind: SnackbarKind.ERROR }));
}
};
const MAX_AMOUNT_OF_LOGS = 10000;
-const SUMMARIZED_FILTER_TYPE = 'Summarized';
+const ALL_FILTER_TYPE = 'All logs';
+
+const MAIN_FILTER_TYPE = 'Main logs';
+const MAIN_EVENT_TYPES = [
+ LogEventType.CRUNCH_RUN,
+ LogEventType.STDERR,
+ LogEventType.STDOUT,
+];
const PROCESS_PANEL_LOG_EVENT_TYPES = [
LogEventType.ARV_MOUNT,
LogEventType.NODE_INFO,
LogEventType.STDERR,
LogEventType.STDOUT,
+ LogEventType.CONTAINER,
+ LogEventType.KEEPSTORE,
];