Skip to content

Add log line anchor for action logs #25532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Jul 3, 2023
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
42ad4ca
save
HesterG Jun 21, 2023
43ba3e1
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 21, 2023
01f7f85
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 21, 2023
3018a10
save
HesterG Jun 21, 2023
49fde14
save
HesterG Jun 21, 2023
d0b360d
save
HesterG Jun 21, 2023
d72a9e8
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 21, 2023
b6de1ab
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 21, 2023
7591b69
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 26, 2023
4aec5d8
save
HesterG Jun 26, 2023
9ec632e
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 26, 2023
b547ee6
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 26, 2023
f080463
update
HesterG Jun 26, 2023
379ed9c
scroll
HesterG Jun 26, 2023
6928dc1
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 26, 2023
64b4c1f
click log
HesterG Jun 26, 2023
5cc5b7c
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 26, 2023
cca4ce8
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 26, 2023
1983cc3
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 27, 2023
9ac54fa
remove one async
HesterG Jun 27, 2023
f396711
adjust styles
HesterG Jun 27, 2023
7b3f625
change position
HesterG Jun 27, 2023
3524e8d
Merge branch 'go-gitea:main' into log-hash
HesterG Jun 27, 2023
be531b8
fix lint
HesterG Jun 27, 2023
31086ae
update
HesterG Jun 27, 2023
469f546
clean up
HesterG Jun 27, 2023
79d06cb
Merge branch 'main' into log-hash
HesterG Jun 28, 2023
f2c9c52
Update web_src/js/components/RepoActionView.vue
HesterG Jun 28, 2023
c037bf4
Update web_src/js/components/RepoActionView.vue
HesterG Jun 28, 2023
77c550a
updates
HesterG Jun 28, 2023
987f29c
use block
HesterG Jun 28, 2023
f019ff1
Merge branch 'main' into log-hash
HesterG Jun 28, 2023
bf3b567
Merge branch 'main' into log-hash
HesterG Jun 29, 2023
f350d38
Merge branch 'main' into log-hash
HesterG Jun 29, 2023
f4dc02e
fix href
HesterG Jun 29, 2023
d9dea1b
fix scroll
HesterG Jun 29, 2023
e42fb25
fix css
HesterG Jun 29, 2023
a94351d
Merge branch 'main' into log-hash
HesterG Jun 29, 2023
55b6aea
Update web_src/js/components/RepoActionView.vue
silverwind Jun 29, 2023
313e809
Merge branch 'main' into log-hash
HesterG Jun 30, 2023
faf49ba
Merge branch 'main' into log-hash
GiteaBot Jul 1, 2023
293f26d
Merge branch 'main' into log-hash
GiteaBot Jul 1, 2023
bc3405c
Merge branch 'main' into log-hash
GiteaBot Jul 2, 2023
d8b73ae
Merge branch 'main' into log-hash
GiteaBot Jul 3, 2023
1e9c646
Update web_src/js/components/RepoActionView.vue
HesterG Jul 3, 2023
a229c68
Merge branch 'main' into log-hash
GiteaBot Jul 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions web_src/js/components/RepoActionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,19 @@ const sfc = {
};
},

mounted() {
async mounted() {
// load job data and then auto-reload periodically
this.loadJob();
// need to await first loadJob so this.currentJobStepsStates is initialized and can be used in hashChangeListener
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() {
Expand Down Expand Up @@ -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);

// for "Show timestamps"
Expand Down Expand Up @@ -318,7 +324,7 @@ const sfc = {
for (const line of logLines) {
// TODO: group support: ##[group]GroupTitle , ##[endgroup]
const el = this.getLogsContainer(stepIndex);
el.append(this.createLogLine(line, startTime));
el.append(this.createLogLine(line, startTime, stepIndex));
}
},

Expand Down Expand Up @@ -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;
// need to await for load job if the step log is loaded for the first time
// so logline can be selected by querySelector
await this.loadJob();
}
const logLine = this.$refs.steps.querySelector(selectedLogStep);
if (!logLine) return;
logLine.querySelector('.line-num').click();
}
},
};
Expand Down Expand Up @@ -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: 95px;
}

/* class names 'log-time-seconds' and 'log-time-stamp' are used in the method toggleTimeDisplay */
.job-log-line .line-num, .log-time-seconds {
width: 48px;
Expand All @@ -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: 2px;
}
Expand Down