@ -204,15 +204,19 @@ const sfc = {
} ;
} ,
mounted ( ) {
async mounted ( ) {
/ / l o a d j o b d a t a a n d t h e n a u t o - r e l o a d p e r i o d i c a l l y
this . loadJob ( ) ;
/ / n e e d t o a w a i t f i r s t l o a d J o b s o t h i s . c u r r e n t J o b S t e p s S t a t e s i s i n i t i a l i z e d a n d c a n b e u s e d i n h a s h C h a n g e L i s t e n e r
await this . loadJob ( ) ;
this . intervalID = setInterval ( this . loadJob , 1000 ) ;
document . body . addEventListener ( 'click' , this . closeDropdown ) ;
this . hashChangeListener ( ) ;
window . addEventListener ( 'hashchange' , this . hashChangeListener ) ;
} ,
beforeUnmount ( ) {
document . body . removeEventListener ( 'click' , this . closeDropdown ) ;
window . removeEventListener ( 'hashchange' , this . hashChangeListener ) ;
} ,
unmounted ( ) {
@ -280,14 +284,16 @@ const sfc = {
this . fetchPost ( ` ${ this . run . link } /approve ` ) ;
} ,
createLogLine ( line , startTime ) {
createLogLine ( line , startTime , stepIndex ) {
const div = document . createElement ( 'div' ) ;
div . classList . add ( 'job-log-line' ) ;
div . setAttribute ( 'id' , ` jobstep- ${ stepIndex } - ${ line . index } ` ) ;
div . _jobLogTime = line . timestamp ;
const lineNumber = document . createElement ( 'div ' ) ;
lineNumber . className = 'line-num' ;
const lineNumber = document . createElement ( 'a ' ) ;
lineNumber . classList . add ( 'line-num' , 'muted' ) ;
lineNumber . textContent = line . index ;
lineNumber . setAttribute ( 'href' , ` #jobstep- ${ stepIndex } - ${ line . index } ` ) ;
div . append ( lineNumber ) ;
/ / f o r " S h o w t i m e s t a m p s "
@ -318,7 +324,7 @@ const sfc = {
for ( const line of logLines ) {
/ / T O D O : g r o u p s u p p o r t : # # [ g r o u p ] G r o u p T i t l e , # # [ e n d g r o u p ]
const el = this . getLogsContainer ( stepIndex ) ;
el . append ( this . createLogLine ( line , startTime ) ) ;
el . append ( this . createLogLine ( line , startTime , stepIndex ) ) ;
}
} ,
@ -429,6 +435,21 @@ const sfc = {
} else {
actionBodyEl . append ( fullScreenEl ) ;
}
} ,
async hashChangeListener ( ) {
const selectedLogStep = window . location . hash ;
if ( ! selectedLogStep ) return ;
const [ _ , step , _line ] = selectedLogStep . split ( '-' ) ;
if ( ! this . currentJobStepsStates [ step ] ) return ;
if ( ! this . currentJobStepsStates [ step ] . expanded && this . currentJobStepsStates [ step ] . cursor === null ) {
this . currentJobStepsStates [ step ] . expanded = true ;
/ / n e e d t o a w a i t f o r l o a d j o b i f t h e s t e p l o g i s l o a d e d f o r t h e f i r s t t i m e
/ / s o l o g l i n e c a n b e s e l e c t e d b y q u e r y S e l e c t o r
await this . loadJob ( ) ;
}
const logLine = this . $refs . steps . querySelector ( selectedLogStep ) ;
if ( ! logLine ) return ;
logLine . querySelector ( '.line-num' ) . click ( ) ;
}
} ,
} ;
@ -802,10 +823,15 @@ export function initRepositoryActionView() {
display : flex ;
}
. job - step - section . job - step - logs . job - log - line : hover {
. job - log - line : hover ,
. job - log - line : target {
background - color : var ( -- color - console - hover - bg ) ;
}
. job - log - line : target {
scroll - margin - top : 95 px ;
}
/* class names 'log-time-seconds' and 'log-time-stamp' are used in the method toggleTimeDisplay */
. job - log - line . line - num , . log - time - seconds {
width : 48 px ;
@ -814,6 +840,11 @@ export function initRepositoryActionView() {
user - select : none ;
}
. job - log - line : target > . line - num {
color : var ( -- color - primary ) ;
text - decoration : underline ;
}
. log - time - seconds {
padding - right : 2 px ;
}