diff options
Diffstat (limited to 'app/assets/javascripts/jobs/store')
-rw-r--r-- | app/assets/javascripts/jobs/store/actions.js | 12 | ||||
-rw-r--r-- | app/assets/javascripts/jobs/store/mutations.js | 10 | ||||
-rw-r--r-- | app/assets/javascripts/jobs/store/utils.js | 40 |
3 files changed, 34 insertions, 28 deletions
diff --git a/app/assets/javascripts/jobs/store/actions.js b/app/assets/javascripts/jobs/store/actions.js index 41cc5a181dc..5e23eeb08b7 100644 --- a/app/assets/javascripts/jobs/store/actions.js +++ b/app/assets/javascripts/jobs/store/actions.js @@ -157,13 +157,13 @@ export const fetchTrace = ({ dispatch, state }) => dispatch('toggleScrollisInBottom', isScrolledToBottom()); dispatch('receiveTraceSuccess', data); - if (!data.complete) { - traceTimeout = setTimeout(() => { - dispatch('fetchTrace'); - }, 4000); - } else { + // if (!data.complete) { + // traceTimeout = setTimeout(() => { + // dispatch('fetchTrace'); + // }, 4000); + // } else { dispatch('stopPollingTrace'); - } + // } }) .catch(() => dispatch('receiveTraceError')); diff --git a/app/assets/javascripts/jobs/store/mutations.js b/app/assets/javascripts/jobs/store/mutations.js index 074143acf70..d5d5cebb057 100644 --- a/app/assets/javascripts/jobs/store/mutations.js +++ b/app/assets/javascripts/jobs/store/mutations.js @@ -29,21 +29,21 @@ export default { } if (log.append) { - state.originalTrace = state.originalTrace.concat(log.trace); - state.trace = updateIncrementalTrace(state.originalTrace, state.trace, log.lines) + // state.originalTrace = state.originalTrace.concat(log.trace); + // state.trace = updateIncrementalTrace(state.originalTrace, state.trace, log.lines) state.traceSize += log.size; } else { // When the job still does not have a trace // the trace response will not have a defined // html or size. We keep the old value otherwise these // will be set to `undefined` - state.originalTrace = log.lines || state.trace; - state.trace = logLinesParser(log.lines) || state.trace; + // state.originalTrace = log.lines || state.trace; + // state.trace = logLinesParser(log.lines) || state.trace; state.traceSize = log.size || state.traceSize; } state.originalTrace = oldLog.lines; - state.trace = updateIncrementalTrace(state.originalTrace, logLinesParser(oldLog.lines), newLog.lines) + state.trace = logLinesParser(oldLog.lines); if (state.traceSize < log.total) { state.isTraceSizeVisible = true; diff --git a/app/assets/javascripts/jobs/store/utils.js b/app/assets/javascripts/jobs/store/utils.js index 26ef13cc4fc..bb8cf5b80de 100644 --- a/app/assets/javascripts/jobs/store/utils.js +++ b/app/assets/javascripts/jobs/store/utils.js @@ -1,4 +1,10 @@ import _ from 'underscore'; + +export const parseLine = (line = {}, lineNumber) => ({ + ...line, + lineNumber, +}); + /** * Parses the job log content into a structure usable by the template * @@ -6,10 +12,10 @@ import _ from 'underscore'; * - creates a new array to hold the lines that are collpasible, * - adds a isClosed property to handle toggle * - adds a isHeader property to handle template logic - * For each line: - * - adds the index as lineNumber + * - adds the section_duration * - * TODO: Check if line has content before adding it to the array + * For each line: + * - adds the index as lineNumber * * @param {Array} lines * @returns {Array} @@ -21,22 +27,20 @@ export const logLinesParser = (lines = [], lineNumberStart) => acc.push({ isClosed: true, isHeader: true, - line: { - ...line, - lineNumber, - }, + line: parseLine(line, lineNumber), lines: [], }); - } else if (acc.length && acc[acc.length - 1].isHeader) { - acc[acc.length - 1].lines.push({ - ...line, - lineNumber, - }); - } else { - acc.push({ - ...line, - lineNumber, - }); + } else if ( + acc.length && + acc[acc.length - 1].isHeader && + !line.section_duration && + line.content.length + ) { + acc[acc.length - 1].lines.push(parseLine(line, lineNumber)); + } else if (acc.length && acc[acc.length - 1].isHeader && line.section_duration) { + acc[acc.length - 1].section_duration = line.section_duration; + } else if (line.content.length) { + acc.push(parseLine(line, lineNumber)); } return acc; @@ -65,6 +69,8 @@ export const updateIncrementalTrace = (originalTrace = [], oldLog = [], newLog = const lastIndex = cloneOldLog.length - 1; const lastLine = cloneOldLog[lastIndex]; + // TODO: Keep the isClosed state!!! + // The last line may be inside a collpasible section // If it is, we use the not parsed saved log, remove the last element // and parse the first received part togheter with the incremental log |