feat: rerun jobs

This commit is contained in:
Jason Song
2022-11-07 14:16:51 +08:00
parent 37224e2441
commit 0b62e1da74
4 changed files with 66 additions and 7 deletions

View File

@ -18,6 +18,9 @@
<SvgIcon name="octicon-meter" class="ui text yellow" class-name="job-status-rotate" v-else-if="job.status === 'running'"/>
<SvgIcon name="octicon-x-circle-fill" class="red" v-else/>
{{ job.name }}
<button class="job-brief-rerun" @click="rerunJob(index)" v-if="job.status !== 'waiting' && job.status !== 'blocked' && job.status !== 'running'">
<SvgIcon name="octicon-sync"/>
</button>
</a>
</div>
</div>
@ -146,6 +149,17 @@ const sfc = {
this.loadJobData(); // try to load the data immediately instead of waiting for next timer interval
}
},
// rerun a job
rerunJob(idx) {
fetch(this.buildInfo.htmlurl+'/jobs/'+idx+'/rerun', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Csrf-Token': csrfToken,
},
body: {},
});
},
formatDuration(d) {
d = Math.round(d);
@ -359,6 +373,12 @@ export function initRepositoryBuildView() {
background: #f8f8f8;
border-radius: 5px;
text-decoration: none;
button.job-brief-rerun {
float: right;
border: none;
background-color: transparent;
outline: none
};
}
}
}

View File

@ -29,6 +29,7 @@ import octiconXCircleFill from '../../public/img/svg/octicon-x-circle-fill.svg';
import octiconSkip from '../../public/img/svg/octicon-skip.svg';
import octiconMeter from '../../public/img/svg/octicon-meter.svg';
import octiconBlocked from '../../public/img/svg/octicon-blocked.svg';
import octiconSync from '../../public/img/svg/octicon-sync.svg';
export const svgs = {
@ -63,6 +64,7 @@ export const svgs = {
'octicon-skip': octiconSkip,
'octicon-meter': octiconMeter,
'octicon-blocked': octiconBlocked,
'octicon-sync': octiconSync,
};