@@ -6,6 +6,7 @@ import {toggleElem} from '../utils/dom.ts';
66import {formatDatetime } from ' ../utils/time.ts' ;
77import {renderAnsi } from ' ../render/ansi.ts' ;
88import {GET , POST , DELETE } from ' ../modules/fetch.ts' ;
9+ import type {ActionsStepLogLine , ActionsStatus } from ' ../types.ts' ;
910
1011const sfc = {
1112 name: ' RepoActionView' ,
@@ -113,12 +114,12 @@ const sfc = {
113114
114115 methods: {
115116 // get the active container element, either the `job-step-logs` or the `job-log-list` in the `job-log-group`
116- getLogsContainer(idx ) {
117+ getLogsContainer(idx : number ) {
117118 const el = this .$refs .logs [idx ];
118119 return el ._stepLogsActiveContainer ?? el ;
119120 },
120121 // begin a log group
121- beginLogGroup(idx ) {
122+ beginLogGroup(idx : number ) {
122123 const el = this .$refs .logs [idx ];
123124
124125 const elJobLogGroup = document .createElement (' div' );
@@ -135,13 +136,13 @@ const sfc = {
135136 el ._stepLogsActiveContainer = elJobLogList ;
136137 },
137138 // end a log group
138- endLogGroup(idx ) {
139+ endLogGroup(idx : number ) {
139140 const el = this .$refs .logs [idx ];
140141 el ._stepLogsActiveContainer = null ;
141142 },
142143
143144 // show/hide the step logs for a step
144- toggleStepLogs(idx ) {
145+ toggleStepLogs(idx : number ) {
145146 this .currentJobStepsStates [idx ].expanded = ! this .currentJobStepsStates [idx ].expanded ;
146147 if (this .currentJobStepsStates [idx ].expanded ) {
147148 this .loadJob (); // try to load the data immediately instead of waiting for next timer interval
@@ -156,29 +157,29 @@ const sfc = {
156157 POST (` ${this .run .link }/approve ` );
157158 },
158159
159- createLogLine(line , startTime , stepIndex ) {
160+ createLogLine(line : ActionsStepLogLine , startTime : number , stepIndex : number ) {
160161 const div = document .createElement (' div' );
161162 div .classList .add (' job-log-line' );
162163 div .setAttribute (' id' , ` jobstep-${stepIndex }-${line .index } ` );
163164 div ._jobLogTime = line .timestamp ;
164165
165166 const lineNumber = document .createElement (' a' );
166167 lineNumber .classList .add (' line-num' , ' muted' );
167- lineNumber .textContent = line .index ;
168+ lineNumber .textContent = String ( line .index ) ;
168169 lineNumber .setAttribute (' href' , ` #jobstep-${stepIndex }-${line .index } ` );
169170 div .append (lineNumber );
170171
171172 // for "Show timestamps"
172173 const logTimeStamp = document .createElement (' span' );
173174 logTimeStamp .className = ' log-time-stamp' ;
174- const date = new Date (parseFloat ( line .timestamp * 1000 ) );
175+ const date = new Date (line .timestamp * 1000 );
175176 const timeStamp = formatDatetime (date );
176177 logTimeStamp .textContent = timeStamp ;
177178 toggleElem (logTimeStamp , this .timeVisible [' log-time-stamp' ]);
178179 // for "Show seconds"
179180 const logTimeSeconds = document .createElement (' span' );
180181 logTimeSeconds .className = ' log-time-seconds' ;
181- const seconds = Math .floor (parseFloat ( line .timestamp ) - parseFloat ( startTime ) );
182+ const seconds = Math .floor (line .timestamp - startTime );
182183 logTimeSeconds .textContent = ` ${seconds }s ` ;
183184 toggleElem (logTimeSeconds , this .timeVisible [' log-time-seconds' ]);
184185
@@ -192,7 +193,7 @@ const sfc = {
192193 return div ;
193194 },
194195
195- appendLogs(stepIndex , logLines , startTime ) {
196+ appendLogs(stepIndex : number , logLines : Array < ActionsStepLogLine > , startTime : number ) {
196197 for (const line of logLines ) {
197198 // TODO: group support: ##[group]GroupTitle , ##[endgroup]
198199 const el = this .getLogsContainer (stepIndex );
@@ -205,7 +206,7 @@ const sfc = {
205206 return await resp .json ();
206207 },
207208
208- async deleteArtifact(name ) {
209+ async deleteArtifact(name : string ) {
209210 if (! window .confirm (this .locale .confirmDeleteArtifact .replace (' %s' , name ))) return ;
210211 await DELETE (` ${this .run .link }/artifacts/${name } ` );
211212 await this .loadJob ();
@@ -269,19 +270,19 @@ const sfc = {
269270 }
270271 },
271272
272- isDone(status ) {
273+ isDone(status : ActionsStatus ) {
273274 return [' success' , ' skipped' , ' failure' , ' cancelled' ].includes (status );
274275 },
275276
276- isExpandable(status ) {
277+ isExpandable(status : ActionsStatus ) {
277278 return [' success' , ' running' , ' failure' , ' cancelled' ].includes (status );
278279 },
279280
280281 closeDropdown() {
281282 if (this .menuVisible ) this .menuVisible = false ;
282283 },
283284
284- toggleTimeDisplay(type ) {
285+ toggleTimeDisplay(type : ' seconds ' | ' stamp ' ) {
285286 this .timeVisible [` log-time-${type } ` ] = ! this .timeVisible [` log-time-${type } ` ];
286287 for (const el of this .$refs .steps .querySelectorAll (` .log-time-${type } ` )) {
287288 toggleElem (el , this .timeVisible [` log-time-${type } ` ]);
@@ -332,7 +333,7 @@ export function initRepositoryActionView() {
332333
333334 // TODO: the parent element's full height doesn't work well now,
334335 // but we can not pollute the global style at the moment, only fix the height problem for pages with this component
335- const parentFullHeight = document .querySelector (' body > div.full.height' );
336+ const parentFullHeight = document .querySelector < HTMLDivElement > (' body > div.full.height' );
336337 if (parentFullHeight ) parentFullHeight .style .paddingBottom = ' 0' ;
337338
338339 const view = createApp (sfc , {
0 commit comments