Skip to content

Commit

Permalink
Fix job update (#214)
Browse files Browse the repository at this point in the history
* fix job update

* Update prebuild
  • Loading branch information
ChristopherHX authored Sep 12, 2023
1 parent a265a69 commit 679ef11
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 37 deletions.
12 changes: 12 additions & 0 deletions src/Runner.Server/actions-service-webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Runner.Server/actions-service-webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@primer/octicons-react": "^19.7.0",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
Expand Down
40 changes: 21 additions & 19 deletions src/Runner.Server/actions-service-webapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,18 @@ function List() {
setLoading(false);
}
})()
var source = new EventSource(`${ghHostApiUrl}/_apis/v1/Message/event2?filter=${encodeURIComponent(params.owner + "/" + params.repo)}&runid=${encodeURIComponent(params.runid || "null")}`);
if(page === 0) {
var source = new EventSource(`${ghHostApiUrl}/_apis/v1/Message/event2?filter=${encodeURIComponent(params.owner + "/" + params.repo)}&runid=${encodeURIComponent(params.runid || "null")}`);
source.addEventListener("job", ev => {
var x = JSON.parse((ev as MessageEvent).data) as IJob;
setJobs(_jobs => {
var jobs = [..._jobs];
var insertp = jobs.findIndex(j => j.runid > x.runid && j.attempt > x.attempt && j.requestId > x.requestId);
var sp = insertp > 0 ? jobs.splice(insertp) : jobs.splice(0);
if(sp.length > 0 && sp[0].jobId === x.jobId) {
sp.shift();
}
var final = [...jobs, x, ...sp];
// Remove elements from the first page
if(final.length > 30) {
final.length = 30;
for(var i in _jobs) {
if(_jobs[i].jobId === x.jobId) {
var final = [..._jobs];
final[i] = x;
return final;
}
}
return final;
});
});
source.addEventListener("jobupdate", ev => {
console.log("jobupdate: " + JSON.stringify(ev));
var x = JSON.parse((ev as MessageEvent).data) as IJob;
setJobs(_jobs => {
var jobs = [..._jobs];
var insertp = jobs.findIndex(j => j.runid > x.runid && j.attempt > x.attempt && j.requestId > x.requestId);
var sp = insertp > 0 ? jobs.splice(insertp) : jobs.splice(0);
Expand All @@ -81,8 +70,21 @@ function List() {
return final;
});
});
return () => source.close();
}
source.addEventListener("jobupdate", ev => {
var x = JSON.parse((ev as MessageEvent).data) as IJob;
setJobs(_jobs => {
for(var i in _jobs) {
if(_jobs[i].jobId === x.jobId) {
var final = [..._jobs];
final[i] = x;
return final;
}
}
return _jobs;
});
});
return () => source.close();
}
}, [page, params.page, params.owner, params.repo, params.runid]);
return (<span style={{
Expand Down
6 changes: 3 additions & 3 deletions src/Runner.Server/wwwroot/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"files": {
"main.css": "/static/css/main.4758f308.css",
"main.js": "/static/js/main.31e4af4c.js",
"main.js": "/static/js/main.ac168a61.js",
"static/js/787.0500ceb2.chunk.js": "/static/js/787.0500ceb2.chunk.js",
"index.html": "/index.html",
"main.4758f308.css.map": "/static/css/main.4758f308.css.map",
"main.31e4af4c.js.map": "/static/js/main.31e4af4c.js.map",
"main.ac168a61.js.map": "/static/js/main.ac168a61.js.map",
"787.0500ceb2.chunk.js.map": "/static/js/787.0500ceb2.chunk.js.map"
},
"entrypoints": [
"static/css/main.4758f308.css",
"static/js/main.31e4af4c.js"
"static/js/main.ac168a61.js"
]
}
2 changes: 1 addition & 1 deletion src/Runner.Server/wwwroot/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.1.0/github-markdown.css"><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="View workflow runs, jobs and download artifacts"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Actions Service</title><script defer="defer" src="/static/js/main.31e4af4c.js"></script><link href="/static/css/main.4758f308.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.1.0/github-markdown.css"><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="View workflow runs, jobs and download artifacts"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Actions Service</title><script defer="defer" src="/static/js/main.ac168a61.js"></script><link href="/static/css/main.4758f308.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
3 changes: 0 additions & 3 deletions src/Runner.Server/wwwroot/static/js/main.31e4af4c.js

This file was deleted.

1 change: 0 additions & 1 deletion src/Runner.Server/wwwroot/static/js/main.31e4af4c.js.map

This file was deleted.

3 changes: 3 additions & 0 deletions src/Runner.Server/wwwroot/static/js/main.ac168a61.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ object-assign
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @remix-run/router v1.8.0
*
Expand Down
1 change: 1 addition & 0 deletions src/Runner.Server/wwwroot/static/js/main.ac168a61.js.map

Large diffs are not rendered by default.

0 comments on commit 679ef11

Please sign in to comment.