[ARVADOS-WORKBENCH2] updated: 1.2.0-237-g4076b27

Git user git at public.curoverse.com
Mon Sep 3 06:53:12 EDT 2018


Summary of changes:
 .../process-logs-panel-actions.ts                  | 34 ++++++++++++++++++++--
 .../process-logs-panel-reducer.ts                  |  4 ++-
 src/store/process-logs-panel/process-logs-panel.ts |  8 +++++
 src/store/workbench/workbench-actions.ts           |  2 +-
 src/views/process-log-panel/process-log-panel.tsx  |  8 ++---
 src/websocket/resource-event-message.ts            |  4 +--
 src/websocket/websocket.ts                         |  4 ++-
 7 files changed, 52 insertions(+), 12 deletions(-)

       via  4076b2736c50e6122d3d840f9c1f6f7d2cf81c28 (commit)
      from  a56225865734e581714833201bd1448ba34e0e9d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 4076b2736c50e6122d3d840f9c1f6f7d2cf81c28
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Mon Sep 3 12:52:57 2018 +0200

    Enable process log live updates
    
    Feature #14100
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/process-logs-panel/process-logs-panel-actions.ts b/src/store/process-logs-panel/process-logs-panel-actions.ts
index 395d26f..62c9a25 100644
--- a/src/store/process-logs-panel/process-logs-panel-actions.ts
+++ b/src/store/process-logs-panel/process-logs-panel-actions.ts
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { unionize, ofType, UnionOf } from "~/common/unionize";
-import { ProcessLogs } from './process-logs-panel';
+import { ProcessLogs, getProcessLogsPanelCurrentUuid } from './process-logs-panel';
 import { LogEventType } from '~/models/log';
 import { RootState } from '~/store/store';
 import { ServiceRepository } from '~/services/services';
@@ -14,8 +14,11 @@ import { loadProcess } from '~/store/processes/processes-actions';
 import { OrderBuilder } from '~/common/api/order-builder';
 import { LogResource } from '~/models/log';
 import { LogService } from '~/services/log-service/log-service';
+import { ResourceEventMessage } from '../../websocket/resource-event-message';
+import { getProcess } from '~/store/processes/process';
 
 export const processLogsPanelActions = unionize({
+    RESET_PROCESS_LOGS_PANEL: ofType<{}>(),
     INIT_PROCESS_LOGS_PANEL: ofType<{ filters: string[], logs: ProcessLogs }>(),
     SET_PROCESS_LOGS_PANEL_FILTER: ofType<string>(),
     ADD_PROCESS_LOGS_PANEL_ITEM: ofType<{ logType: string, log: string }>(),
@@ -28,6 +31,7 @@ export const setProcessLogsPanelFilter = (filter: string) =>
 
 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 logResources = await loadContainerLogs(process.container.uuid, logService);
@@ -36,6 +40,30 @@ export const initProcessLogsPanel = (processUuid: string) =>
         }
     };
 
+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 loadContainerLogs = async (containerUuid: string, logService: LogService) => {
     const requestFilters = new FilterBuilder()
         .addEqual('objectUuid', containerUuid)
@@ -67,8 +95,8 @@ const createInitialLogPanelState = (logResources: LogResource[]) => {
     return { filters, logs };
 };
 
-const logsToLines = (logs: LogResource[]) => 
-    logs.map(({properties}) => properties.text);
+const logsToLines = (logs: LogResource[]) =>
+    logs.map(({ properties }) => properties.text);
 
 const MAX_AMOUNT_OF_LOGS = 10000;
 
diff --git a/src/store/process-logs-panel/process-logs-panel-reducer.ts b/src/store/process-logs-panel/process-logs-panel-reducer.ts
index 39a448b..38a3136 100644
--- a/src/store/process-logs-panel/process-logs-panel-reducer.ts
+++ b/src/store/process-logs-panel/process-logs-panel-reducer.ts
@@ -14,6 +14,7 @@ const initialState: ProcessLogsPanel = {
 
 export const processLogsPanelReducer = (state = initialState, action: ProcessLogsPanelAction): ProcessLogsPanel =>
     processLogsPanelActions.match(action, {
+        RESET_PROCESS_LOGS_PANEL: () => initialState,
         INIT_PROCESS_LOGS_PANEL: ({ filters, logs }) => ({
             filters,
             logs,
@@ -24,7 +25,8 @@ export const processLogsPanelReducer = (state = initialState, action: ProcessLog
             selectedFilter
         }),
         ADD_PROCESS_LOGS_PANEL_ITEM: ({ logType, log }) => {
-            const logsOfType = [...state.logs[logType], log];
+            const currentLogs = state.logs[logType] || [];
+            const logsOfType = [...currentLogs, log];
             const logs = { ...state.logs, [logType]: logsOfType };
             return { ...state, logs };
         },
diff --git a/src/store/process-logs-panel/process-logs-panel.ts b/src/store/process-logs-panel/process-logs-panel.ts
index 65ed78d..e0753cd 100644
--- a/src/store/process-logs-panel/process-logs-panel.ts
+++ b/src/store/process-logs-panel/process-logs-panel.ts
@@ -1,3 +1,5 @@
+import { RootState } from '../store';
+import { matchProcessLogRoute } from '~/routes/routes';
 // Copyright (C) The Arvados Authors. All rights reserved.
 //
 // SPDX-License-Identifier: AGPL-3.0
@@ -15,3 +17,9 @@ export interface ProcessLogs {
 export const getProcessPanelLogs = ({ selectedFilter, logs }: ProcessLogsPanel) => {
     return logs[selectedFilter];
 };
+
+export const getProcessLogsPanelCurrentUuid = ({ router }: RootState) => {
+    const pathname = router.location ? router.location.pathname : '';
+    const match = matchProcessLogRoute(pathname);
+    return match ? match.params.id : undefined;
+};
diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts
index cbe91c3..8c7ec9a 100644
--- a/src/store/workbench/workbench-actions.ts
+++ b/src/store/workbench/workbench-actions.ts
@@ -187,7 +187,7 @@ export const loadProcess = (uuid: string) =>
     };
 
 export const loadProcessLog = (uuid: string) =>
-    async (dispatch: Dispatch, getState: () => RootState) => {
+    async (dispatch: Dispatch) => {
         dispatch<any>(initProcessLogsPanel(uuid));
     };
 
diff --git a/src/views/process-log-panel/process-log-panel.tsx b/src/views/process-log-panel/process-log-panel.tsx
index e4ceae3..2b2d684 100644
--- a/src/views/process-log-panel/process-log-panel.tsx
+++ b/src/views/process-log-panel/process-log-panel.tsx
@@ -12,6 +12,7 @@ import { matchProcessLogRoute } from '~/routes/routes';
 import { ProcessLogPanelRootDataProps, ProcessLogPanelRootActionProps, ProcessLogPanelRoot } from './process-log-panel-root';
 import { getProcessPanelLogs } from '~/store/process-logs-panel/process-logs-panel';
 import { setProcessLogsPanelFilter } from '~/store/process-logs-panel/process-logs-panel-actions';
+import { getProcessLogsPanelCurrentUuid } from '../../store/process-logs-panel/process-logs-panel';
 
 export interface Log {
     object_uuid: string;
@@ -26,10 +27,9 @@ export interface FilterOption {
     value: string;
 }
 
-const mapStateToProps = ({ router, resources, processLogsPanel }: RootState): ProcessLogPanelRootDataProps => {
-    const pathname = router.location ? router.location.pathname : '';
-    const match = matchProcessLogRoute(pathname);
-    const uuid = match ? match.params.id : '';
+const mapStateToProps = (state: RootState): ProcessLogPanelRootDataProps => {
+    const { resources, processLogsPanel } = state;
+    const uuid = getProcessLogsPanelCurrentUuid(state) || '';
     return {
         process: getProcess(uuid)(resources),
         selectedFilter: { label: processLogsPanel.selectedFilter, value: processLogsPanel.selectedFilter },
diff --git a/src/websocket/resource-event-message.ts b/src/websocket/resource-event-message.ts
index 05553bd..420f25a 100644
--- a/src/websocket/resource-event-message.ts
+++ b/src/websocket/resource-event-message.ts
@@ -3,7 +3,7 @@ import { LogEventType } from '../models/log';
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-export interface ResourceEventMessage {
+export interface ResourceEventMessage<Properties = {}> {
     eventAt: string;
     eventType: LogEventType;
     id: string;
@@ -11,6 +11,6 @@ export interface ResourceEventMessage {
     objectKind: string;
     objectOwnerUuid: string;
     objectUuid: string;
-    properties: {};
+    properties: Properties;
     uuid: string;
 }
diff --git a/src/websocket/websocket.ts b/src/websocket/websocket.ts
index 9ee2d17..634fa8f 100644
--- a/src/websocket/websocket.ts
+++ b/src/websocket/websocket.ts
@@ -12,6 +12,7 @@ import { loadProcess } from '~/store/processes/processes-actions';
 import { loadContainers } from '../store/processes/processes-actions';
 import { FilterBuilder } from '~/common/api/filter-builder';
 import { LogEventType } from '../models/log';
+import { addProcessLogsPanelItem } from '../store/process-logs-panel/process-logs-panel-actions';
 
 export const initWebSocket = (config: Config, authService: AuthService, store: RootStore) => {
     const webSocketService = new WebSocketService(config.websocketUrl, authService);
@@ -31,6 +32,7 @@ const messageListener = (store: RootStore) => (message: ResourceEventMessage) =>
             default:
                 return;
         }
+    } else {
+        return store.dispatch(addProcessLogsPanelItem(message as ResourceEventMessage<{text: string}>));
     }
-    return ;
 };

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list