Skip to content

Commit 80149eb

Browse files
authored
fix(front): add expand button for job commands that are too big (#321)
1 parent 33c4990 commit 80149eb

File tree

4 files changed

+67
-3
lines changed

4 files changed

+67
-3
lines changed

front/assets/css/app-semaphore-min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front/assets/css/app-semaphore.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,26 @@ li.projects-menu-item-special:hover {
13801380
position: sticky;
13811381
top: 0;
13821382
z-index: 1;
1383+
max-height: 250px;
1384+
overflow-y: hidden;
13831385
}
1386+
1387+
.job-log-line-expand {
1388+
width: 100%;
1389+
text-align: center;
1390+
background: white;
1391+
border-bottom: 1px solid #D3DADE;
1392+
text-decoration: underline;
1393+
1394+
position: sticky;
1395+
z-index: 1;
1396+
cursor: pointer;
1397+
}
1398+
1399+
.job-log-line-expand:hover {
1400+
background-color: #D3DADE;
1401+
}
1402+
13841403
.job-log-line:hover {
13851404
background-color: #c7edff;
13861405
}

front/assets/js/job_logs/logs.js

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,61 @@ export class JobLogs {
101101
this.update()
102102

103103
this.on("click", ".job-log-line.command", (e) => {
104-
let fold = e.target.closest(".job-log-fold")
104+
const fold = e.target.closest(".job-log-fold")
105105

106106
if (FoldToggle.isTogglable(fold)) {
107107
FoldToggle.toggle(fold)
108108
}
109109
})
110110

111111
this.on("click", ".job-log-line-number", (e) => {
112-
let line = e.target.closest('.job-log-line');
112+
const line = e.target.closest('.job-log-line');
113113
Highlight.highlightLine(line, event.shiftKey)
114114

115115
e.stopPropagation()
116116
})
117117
}
118118

119+
setupFoldExpandButtons() {
120+
document.querySelectorAll('.job-log-line.command').forEach((element) => {
121+
const fold = element.closest(".job-log-fold");
122+
const expandButton = fold?.querySelector(".job-log-line-expand");
123+
124+
if (element.offsetHeight >= 250) {
125+
expandButton.style.top = element.offsetHeight.toString() + "px"
126+
expandButton?.classList.remove("dn");
127+
} else {
128+
expandButton?.classList.add("dn");
129+
}
130+
});
131+
132+
this.on("click", ".job-log-line-expand", (e) => {
133+
const fold = e.target.closest(".job-log-fold");
134+
const jobCommand = fold.querySelector('.job-log-line.command')
135+
this.toggleExpandCommand(e.target, jobCommand)
136+
})
137+
}
138+
139+
toggleExpandCommand(expandButton, jobCommand) {
140+
if (jobCommand.style.maxHeight) {
141+
this.collapseCommand(expandButton, jobCommand)
142+
} else {
143+
this.expandCommand(expandButton, jobCommand)
144+
}
145+
}
146+
147+
expandCommand(expandButton, jobCommand) {
148+
jobCommand.style.maxHeight = "none"
149+
expandButton.innerText = "↑ Collapse ↑"
150+
expandButton.style.top = jobCommand.offsetHeight.toString() + "px"
151+
}
152+
153+
collapseCommand(expandButton, jobCommand) {
154+
jobCommand.style.maxHeight = ""
155+
expandButton.innerText = "↓ Expand ↓"
156+
expandButton.style.top = jobCommand.offsetHeight.toString() + "px"
157+
}
158+
119159
update() {
120160
_.forIn(this.components, (component) => component.update())
121161
}
@@ -155,6 +195,7 @@ export class JobLogs {
155195
if(this.config.isJobFinished === true) {
156196
this.logRenderDuration(this.startTime, performance.now(), "v2");
157197
this.scrollToLastOpenFold();
198+
this.setupFoldExpandButtons()
158199
}
159200
})
160201
}

front/assets/js/job_logs/templates/command.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export class CommandTemplate {
2222
<span class="job-log-line-time ${this.statusBackground(command, isJobFinished)}">
2323
${this.renderSpinnerIfNotFullyFetched(command)}${this.status(command, isJobFinished)}${this.duration(command, isJobFinished)}
2424
</span>
25+
26+
</div>
27+
<div class="job-log-line-expand dn">
28+
↓ Expand ↓
2529
</div>
2630
2731
<div cmd-lines-container ${this.logLinesVisibility(command, isJobFinished)}>

0 commit comments

Comments
 (0)