Track and display build authors
This commit is contained in:
@@ -4,14 +4,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const buildStatusTxt = this.getElementById('buildStatus');
|
const buildStatusTxt = this.getElementById('buildStatus');
|
||||||
let started = logContainer.childElementCount > 0;
|
let started = logContainer.childElementCount > 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the correct path to establish a ws connection
|
|
||||||
* @param {Location} loc
|
|
||||||
*/
|
|
||||||
function wsPath(loc) {
|
|
||||||
return loc.pathname.replace(/\/$/, '') + '/ws';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add log line to the DOM
|
* Add log line to the DOM
|
||||||
* @param {string[]} str
|
* @param {string[]} str
|
||||||
@@ -52,7 +44,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const loc = window.location;
|
const loc = window.location;
|
||||||
let new_uri = loc.protocol === 'https:' ? 'wss:' : 'ws:';
|
let new_uri = loc.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
new_uri += "//" + loc.host;
|
new_uri += "//" + loc.host;
|
||||||
new_uri += wsPath(loc);
|
new_uri += loc.pathname + 'ws';
|
||||||
var ws = new WebSocket(new_uri);
|
var ws = new WebSocket(new_uri);
|
||||||
|
|
||||||
ws.onmessage = function (message) {
|
ws.onmessage = function (message) {
|
||||||
|
37
src/DB.ts
37
src/DB.ts
@@ -149,13 +149,24 @@ class DB {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.build.belongsTo(this.user);
|
||||||
|
this.user.hasMany(this.build);
|
||||||
|
|
||||||
this.sync();
|
this.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async sync(): Promise<void> {
|
private async sync(): Promise<void> {
|
||||||
|
await this.user.sync();
|
||||||
await this.build.sync();
|
await this.build.sync();
|
||||||
await this.logChunk.sync();
|
await this.logChunk.sync();
|
||||||
await this.user.sync();
|
|
||||||
|
if (!(await this.getUser('-1'))) {
|
||||||
|
await this.createUser({
|
||||||
|
id: '-1',
|
||||||
|
username: '???',
|
||||||
|
displayName: 'Anonymous User'
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getUser(id: string): Promise<User> {
|
public async getUser(id: string): Promise<User> {
|
||||||
@@ -171,13 +182,14 @@ class DB {
|
|||||||
return user.id;
|
return user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createBuild(repo: string, commit: string, patch: string, distro: string, dependencies: string): Promise<number> {
|
public async createBuild(repo: string, commit: string, patch: string, distro: string, dependencies: string, author: string): Promise<number> {
|
||||||
const buildRec = await this.build.create({
|
const buildRec = await this.build.create({
|
||||||
repo,
|
repo,
|
||||||
commit: commit || null,
|
commit: commit || null,
|
||||||
patch: patch || null,
|
patch: patch || null,
|
||||||
distro,
|
distro,
|
||||||
dependencies
|
dependencies,
|
||||||
|
userId: author || '-1'
|
||||||
});
|
});
|
||||||
return buildRec.id;
|
return buildRec.id;
|
||||||
}
|
}
|
||||||
@@ -224,14 +236,17 @@ class DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getBuild(id: number): Promise<Build> {
|
public async getBuild(id: number): Promise<Build> {
|
||||||
return await this.build.findByPk(id);
|
return await this.build.findByPk(id, {
|
||||||
|
include: this.user
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getBuilds(): Promise<Build[]> {
|
public async getBuilds(): Promise<Build[]> {
|
||||||
return await this.build.findAll({
|
return await this.build.findAll({
|
||||||
attributes: SELECT,
|
attributes: SELECT,
|
||||||
order: [['id', 'DESC']],
|
order: [['id', 'DESC']],
|
||||||
where: FRESH
|
where: FRESH,
|
||||||
|
include: this.user
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +257,8 @@ class DB {
|
|||||||
where: {
|
where: {
|
||||||
...FRESH,
|
...FRESH,
|
||||||
status
|
status
|
||||||
}
|
},
|
||||||
|
include: this.user
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +269,8 @@ class DB {
|
|||||||
where: {
|
where: {
|
||||||
...FRESH,
|
...FRESH,
|
||||||
distro
|
distro
|
||||||
}
|
},
|
||||||
|
include: this.user
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +281,8 @@ class DB {
|
|||||||
where: {
|
where: {
|
||||||
...FRESH,
|
...FRESH,
|
||||||
...filterable
|
...filterable
|
||||||
}
|
},
|
||||||
|
include: this.user
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +305,8 @@ class DB {
|
|||||||
{ repo: { [Op.iLike]: `%${query}%` } }
|
{ repo: { [Op.iLike]: `%${query}%` } }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
limit: 100
|
limit: 100,
|
||||||
|
include: this.user
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -215,13 +215,14 @@ class Web {
|
|||||||
req.body.commit || null,
|
req.body.commit || null,
|
||||||
req.body.patch || null,
|
req.body.patch || null,
|
||||||
req.body.distro || 'arch',
|
req.body.distro || 'arch',
|
||||||
req.body.dependencies || 'stable'
|
req.body.dependencies || 'stable',
|
||||||
|
req?.user?.['id']
|
||||||
);
|
);
|
||||||
res.redirect(`/build/${sqids.encode([buildId])}`);
|
res.redirect(`/build/${sqids.encode([buildId])}/`);
|
||||||
this.buildController.triggerBuild();
|
this.buildController.triggerBuild();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/build/:id{/}', async (req, res) => {
|
app.get('/build/:id/', async (req, res) => {
|
||||||
const build = await this.db.getBuild(sqids.decode(req.params.id)?.[0]);
|
const build = await this.db.getBuild(sqids.decode(req.params.id)?.[0]);
|
||||||
showBuild(req, res, build);
|
showBuild(req, res, build);
|
||||||
});
|
});
|
||||||
|
@@ -18,17 +18,22 @@
|
|||||||
<label>Distro</label> <span><%= build.distro %></span>
|
<label>Distro</label> <span><%= build.distro %></span>
|
||||||
<label>Dependencies</label> <span><%= build.dependencies %></span>
|
<label>Dependencies</label> <span><%= build.dependencies %></span>
|
||||||
<label>Start time</label> <span class="to-local-time"><%= build.startTime %></span>
|
<label>Start time</label> <span class="to-local-time"><%= build.startTime %></span>
|
||||||
|
<% if (build.userId !== '-1') { %>
|
||||||
|
<label>Triggered by</label> <span><%= build.user.displayName %> (<%= build.user.username %>)</span>
|
||||||
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% if (build.sqid) { %>
|
||||||
<div>
|
<div>
|
||||||
<a href="/build?id=<%= build.sqid %>" class="button">Clone</a>
|
<a href="/build?id=<%= build.sqid %>" class="button">Clone</a>
|
||||||
</div>
|
</div>
|
||||||
|
<% } %>
|
||||||
<% if (!ended) { %>
|
<% if (!ended) { %>
|
||||||
<div id="cancelRow">
|
<div id="cancelRow">
|
||||||
<a href="/build/<%= build.sqid %>/cancel" class="button">Cancel build</a>
|
<a href="cancel" class="button">Cancel build</a>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<p><a href="/build/<%= build.sqid %>/logs">Full logs</a></p>
|
<p><a href="logs">Full logs</a></p>
|
||||||
<pre class="overflow-x"><div class="logs" id="logs"><% (log || []).forEach(line => { %><p><%= line %></p><% }) %></div></pre>
|
<pre class="overflow-x"><div class="logs" id="logs"><% (log || []).forEach(line => { %><p><%= line %></p><% }) %></div></pre>
|
||||||
|
|
||||||
<% if (!ended) { %>
|
<% if (!ended) { %>
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% builds.forEach(build => { %>
|
<% builds.forEach(build => { %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="/build/<%= build.sqid %>"><%= build.repo %></a></td>
|
<td><a href="/build/<%= build.sqid %>/"><%= build.repo %></a></td>
|
||||||
<td><%= build.distro %></td>
|
<td><%= build.distro %></td>
|
||||||
<td class="to-local-time"><%= build.startTime %></td>
|
<td class="to-local-time"><%= build.startTime %></td>
|
||||||
<td><%= timeElapsed(build.startTime, build.endTime) %></td>
|
<td><%= timeElapsed(build.startTime, build.endTime) %></td>
|
||||||
|
Reference in New Issue
Block a user