diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2019-09-12 16:49:37 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2019-09-12 17:10:11 +0100 |
commit | ef8c0f933c035229ee08afa031b3a36d32da61d4 (patch) | |
tree | dc2c90618d8d770d1988e372afa199b7dbdd6465 /app/assets/javascripts | |
parent | 7fab004639c3768462581c6bcff5669b3058da54 (diff) | |
download | gitlab-ce-ef8c0f933c035229ee08afa031b3a36d32da61d4.tar.gz |
Adds badge for duration and CSS66454-frontend-parser
Diffstat (limited to 'app/assets/javascripts')
10 files changed, 97 insertions, 61 deletions
diff --git a/app/assets/javascripts/jobs/components/log/duration_badge.vue b/app/assets/javascripts/jobs/components/log/duration_badge.vue new file mode 100644 index 00000000000..39643f4594f --- /dev/null +++ b/app/assets/javascripts/jobs/components/log/duration_badge.vue @@ -0,0 +1,13 @@ +<script> +export default { + props: { + duration: { + type: String, + required: true, + }, + }, +}; +</script> +<template> + <div class="duration rounded align-self-start pr-2 pl-2 ml-2 flex-shrink-0">{{duration}}</div> +</template>
\ No newline at end of file diff --git a/app/assets/javascripts/jobs/components/log/line.vue b/app/assets/javascripts/jobs/components/log/line.vue index 86d0fcc3b74..336ae623f0f 100644 --- a/app/assets/javascripts/jobs/components/log/line.vue +++ b/app/assets/javascripts/jobs/components/log/line.vue @@ -21,7 +21,7 @@ export default { <template> <div class="line"> <line-number :line-number="line.lineNumber" :path="path" /> - <span v-for="(content, i) in line.content" :key="i" class="line-text" :class="content.style">{{ + <span v-for="(content, i) in line.content" :key="i" :class="content.style">{{ content.text }}</span> </div> diff --git a/app/assets/javascripts/jobs/components/log/line_header.vue b/app/assets/javascripts/jobs/components/log/line_header.vue index 4ec212d2333..5886b7d03bf 100644 --- a/app/assets/javascripts/jobs/components/log/line_header.vue +++ b/app/assets/javascripts/jobs/components/log/line_header.vue @@ -1,11 +1,13 @@ <script> import Icon from '~/vue_shared/components/icon.vue'; import LineNumber from './line_number.vue'; +import DurationBadge from './duration_badge.vue'; export default { components: { Icon, LineNumber, + DurationBadge, }, props: { line: { @@ -20,6 +22,11 @@ export default { type: String, required: true, }, + duration: { + type: String, + required: false, + default: '', + }, }, computed: { iconName() { @@ -35,11 +42,14 @@ export default { </script> <template> - <div class="line collapsible-line" role="button" @click="handleOnClick"> - <icon :name="iconName" class="arrow" /> + <div class="line collapsible-line d-flex justify-content-between" role="button" @click="handleOnClick"> + <icon :name="iconName" class="arrow position-absolute" /> <line-number :line-number="line.lineNumber" :path="path" /> - <span v-for="(content, i) in line.content" :key="i" class="line-text" :class="content.style">{{ + <span v-for="(content, i) in line.content" :key="i" class="line-text" :class="content.style"> + {{ content.text - }}</span> + }} + </span> + <duration-badge v-if="duration" :duration="duration" /> </div> </template> diff --git a/app/assets/javascripts/jobs/components/log/line_number.vue b/app/assets/javascripts/jobs/components/log/line_number.vue index e06836e2e97..a0e27028e25 100644 --- a/app/assets/javascripts/jobs/components/log/line_number.vue +++ b/app/assets/javascripts/jobs/components/log/line_number.vue @@ -46,7 +46,7 @@ export default { }; </script> <template> - <gl-link :id="lineNumberId" class="line-number" :href="buildLineNumber">{{ + <gl-link :id="lineNumberId" class="d-inline-block text-right position-absolute line-number" :href="buildLineNumber">{{ parsedLineNumber }}</gl-link> </template> diff --git a/app/assets/javascripts/jobs/components/log/log.vue b/app/assets/javascripts/jobs/components/log/log.vue index 5db866afe5a..92a72c932c3 100644 --- a/app/assets/javascripts/jobs/components/log/log.vue +++ b/app/assets/javascripts/jobs/components/log/log.vue @@ -9,7 +9,7 @@ export default { LogLineHeader, }, computed: { - ...mapState(['traceEndpoint', 'trace']), + ...mapState(['traceEndpoint', 'trace', 'isTraceComplete']), }, methods: { ...mapActions(['toggleCollapsibleLine']), @@ -26,6 +26,7 @@ export default { <log-line-header :key="`collapsible-${index}`" :line="section.line" + :duration="section.section_duration" :path="traceEndpoint" :is-closed="section.isClosed" @toggleLine="handleOnClickCollapsibleLine(section)" @@ -41,5 +42,11 @@ export default { </template> <log-line v-else :key="section.offset" :line="section" :path="traceEndpoint" /> </template> + + <div v-if="!isTraceComplete" class="js-log-animation loader-animation pt-3 pl-3"> + <div class="dot"></div> + <div class="dot"></div> + <div class="dot"></div> + </div> </code> </template> diff --git a/app/assets/javascripts/jobs/mock_data/trace.js b/app/assets/javascripts/jobs/mock_data/trace.js index 8bacfded051..b8505e4185a 100644 --- a/app/assets/javascripts/jobs/mock_data/trace.js +++ b/app/assets/javascripts/jobs/mock_data/trace.js @@ -15,11 +15,11 @@ export default { lines: [ { offset: 1000, - content: [{ text: __('Running with gitlab-runner 12.1.0 (de7731dd)') }], + content: [{ text: 'Running with gitlab-runner 12.1.0 (de7731dd)' }], }, { offset: 1001, - content: [{ text: __(' on docker-auto-scale-com 8a6210b8') }], + content: [{ text: ' on docker-auto-scale-com 8a6210b8' }], }, { offset: 1002, @@ -34,12 +34,12 @@ export default { }, { offset: 1003, - content: [{ text: __('Starting service postgres:9.6.14 ...') }], + content: [{ text: 'Starting service postgres:9.6.14 ...' }], sections: ['prepare-executor'], }, { offset: 1004, - content: [{ text: __('Pulling docker image postgres:9.6.14 ...') }], + content: [{ text: 'Pulling docker image postgres:9.6.14 ...' }], sections: ['prepare-executor'], }, { @@ -74,7 +74,7 @@ export default { }, { offset: 1009, - content: [{ text: __('Waiting for services to be up and running...') }], + content: [{ text: 'Waiting for services to be up and running...' }], sections: ['prepare-executor'], }, { @@ -110,8 +110,8 @@ export default { offset: 1013, content: [ { - text: __(`Running on runner-8a6210b8-project-13083-concurrent-0 via - runner-8a6210b8-gsrm-1566561403-37c881a0...`), + text: `Running on runner-8a6210b8-project-13083-concurrent-0 via + runner-8a6210b8-gsrm-1566561403-37c881a0...`, }, ], sections: ['prepare-script'], @@ -121,7 +121,7 @@ export default { { offset: 1014, content: [ - { text: __('Fetching changes with git depth set to 20..'), style: 'term-fg-l-green term-bold' }, + { text: 'Fetching changes with git depth set to 20..', style: 'term-fg-l-green term-bold' }, ], sections: ['get-sources'], section_header: true, @@ -130,7 +130,7 @@ export default { offset: 1015, content: [ { - text: __('Reinitialized existing Git repository in /builds/gitlab-org/gitlab-ce/.git/ '), + text: 'Reinitialized existing Git repository in /builds/gitlab-org/gitlab-ce/.git/ ', }, ], sections: ['get-sources'], @@ -157,7 +157,7 @@ export default { offset: 1018, content: [ { - text: __('Checking out 061606b4 as 66454-create-feature-flag...'), + text: 'Checking out 061606b4 as 66454-create-feature-flag...', style: 'term-fg-l-green term-bold', }, ], @@ -212,7 +212,7 @@ export default { offset: 1024, content: [ { - text: __('Skipping Git submodules setup'), + text: 'Skipping Git submodules setup', style: 'term-fg-l-green term-bold', }, ], @@ -234,7 +234,7 @@ export default { offset: 1027, content: [ { - text: __('Checking cache for debian-stretch-ruby-2.6.3-node-12.x-3...'), + text: 'Checking cache for debian-stretch-ruby-2.6.3-node-12.x-3...', style: 'term-fg-l-green term-bold', }, ], @@ -265,7 +265,7 @@ export default { offset: 1031, content: [ { - text: __('Successfully extracted cache'), + text: 'Successfully extracted cache', style: 'term-fg-l-green term-bold ', }, ], @@ -282,7 +282,7 @@ export default { offset: 1033, content: [ { - text: __('Downloading artifacts for compile-assets pull-cache (278912482)...'), + text: 'Downloading artifacts for compile-assets pull-cache (278912482)...', style: 'term-fg-l-green term-bold', }, ], @@ -298,20 +298,20 @@ export default { offset: 1035, content: [ { - text: __('Downloading artifacts from coordinator... ok '), + text: 'Downloading artifacts from coordinator... ok ', style: 'term-fg-l-green term-bold', }, { - text: __(' id'), + text: ' id', }, { text: '=278912482 responseStatus', }, { - text: __('=200 OK token'), + text: '=200 OK token', }, { - text: __('=DUNW1asp'), + text: '=DUNW1asp', }, ], sections: ['download-artifacts'], @@ -320,7 +320,7 @@ export default { offset: 1036, content: [ { - text: __('Downloading artifacts for setup-test-env (278912484)...'), + text: 'Downloading artifacts for setup-test-env (278912484)...', style: 'term-fg-l-green term-bold', }, ], @@ -351,7 +351,7 @@ export default { offset: 1039, content: [ { - text: __('Downloading artifacts for retrieve-tests-metadata (278912485)...'), + text: 'Downloading artifacts for retrieve-tests-metadata (278912485)...', style: 'term-fg-l-green term-bold', }, ], @@ -377,10 +377,10 @@ export default { offset: 1042, content: [ { - text: __('Downloading artifacts from coordinator... ok '), + text: 'Downloading artifacts from coordinator... ok ', }, { - text: __(' id'), + text: ' id', style: 'term-fg-l-green term-bold', }, { diff --git a/app/assets/javascripts/jobs/mock_data/trace_incremental.js b/app/assets/javascripts/jobs/mock_data/trace_incremental.js index 56ff3c14321..a32ddedf956 100644 --- a/app/assets/javascripts/jobs/mock_data/trace_incremental.js +++ b/app/assets/javascripts/jobs/mock_data/trace_incremental.js @@ -17,10 +17,10 @@ export default { offset: 1042, content: [ { - text: __('Not downloading anything '), + text:'Not downloading anything ', }, { - text: __(' id'), + text: ' id', style: 'term-fg-l-green term-bold', }, { @@ -34,10 +34,10 @@ export default { offset: 1043, content: [ { - text: __('A filipa é fixe e o resto que se lixe '), + text: 'A filipa é fixe e o resto que se lixe ', }, { - text: __(' id'), + text: ' id', style: 'term-fg-l-green term-bold', }, { 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 |