This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from skroutz/web-view
Add a Web view
- Loading branch information
Showing
18 changed files
with
862 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,10 @@ | |
*.prof | ||
*.pyc | ||
|
||
config.json | ||
fabfile.py | ||
|
||
/mistry | ||
/mistryd | ||
|
||
cmd/mistryd/statik | ||
config.json | ||
fabfile.py | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ services: | |
- docker | ||
install: | ||
- make deps | ||
- go get github.com/rakyll/statik | ||
script: | ||
- make | ||
addons: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>The mistry jobs</title> | ||
<link rel="stylesheet" href="css/foundation.min.css"> | ||
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script> | ||
<script src="https://unpkg.com/react@16/umd/react.production.min.js"></script> | ||
<script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script> | ||
<script type="text/babel" src="js/index.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div class="top-bar"> | ||
<div class="top-bar-left"> | ||
<h1><a href="/">mistry</a></h1> | ||
</div> | ||
</div> | ||
|
||
<div class="grid-container"> | ||
<div class="grid-x grid-padding-x"> | ||
|
||
<div class="large-12 cell"> | ||
<h1>Jobs</h1> | ||
</div> | ||
|
||
<div class="large-12 cell" id="js-jobs"> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const JobsRoot = document.getElementById('js-jobs') | ||
|
||
class Jobs extends React.Component { | ||
constructor(props) { | ||
super(props) | ||
this.every = props.every | ||
this.state = {} | ||
}; | ||
|
||
fetchJobs() { | ||
fetch("/index"). | ||
then(response => response.json()). | ||
then(data => this.setState({ jobs: data })); | ||
}; | ||
|
||
componentDidMount() { | ||
this.fetchJobs(); | ||
this.interval = setInterval(() => this.fetchJobs(), this.every); | ||
}; | ||
|
||
componentWillUnmount() { | ||
clearInterval(this.interval); | ||
}; | ||
|
||
render() { | ||
if (this.state.jobs == undefined) { | ||
return ( | ||
<div class="jumbotron"> | ||
<h3>No jobs...</h3> | ||
</div> | ||
); | ||
} | ||
|
||
let jobs = this.state.jobs; | ||
return ( | ||
<table class="hover unstriped"> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>Project</th> | ||
<th>Started At</th> | ||
<th>State</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{jobs.map(function(j, idx){ | ||
return ( | ||
<tr key={idx}> | ||
<td><a href={`/job/${j.project}/${j.id}`} > {j.id} </a></td> | ||
<td>{j.project}</td> | ||
<td>{j.startedAt}</td> | ||
<td>{j.state}</td> | ||
</tr> | ||
) | ||
})} | ||
</tbody> | ||
</table> | ||
); | ||
} | ||
} | ||
|
||
ReactDOM.render(<Jobs every={3000} />, JobsRoot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Job Logs</title> | ||
<link rel="stylesheet" href="../../css/foundation.min.css"> | ||
</head> | ||
|
||
<body> | ||
<div class="top-bar"> | ||
<div class="top-bar-left"> | ||
<h1><a href="/">mistry</a></h1> | ||
</div> | ||
</div> | ||
|
||
<div class="grid-container"> | ||
<div class="grid"> | ||
<div class="cell"> | ||
<h4>Job: {{.ID}}</h4> | ||
</div> | ||
<div class="cell"> | ||
<div class="card"> | ||
<div class="card-section"> | ||
<div class="card-divider"> | ||
<h4> Details </h4> | ||
</div> | ||
<p id="js-job-info"></p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="cell"> | ||
<div class="card"> | ||
<div class="card-section"> | ||
<div class="card-divider"> | ||
<h4> Logs </h4> | ||
</div> | ||
<p id="js-job-log">{{.Log}}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
const jobInfo = document.getElementById('js-job-info'); | ||
const state = {{.State}} | ||
|
||
jobInfo.innerHTML += "Project: ".big() + {{.Project}} + "<br>"; | ||
jobInfo.innerHTML += "State: ".big() + {{.State}} + "<br>"; | ||
jobInfo.innerHTML += "Started at: ".big() + {{.StartedAt}} + "<br>"; | ||
|
||
if (state == "ready") { | ||
const output = {{.Output}} | ||
const jobJSON = JSON.parse(output); | ||
jobInfo.innerHTML += "Path: ".big() + jobJSON["Path"] + "<br>"; | ||
jobInfo.innerHTML += "Params: ".big() + JSON.stringify(jobJSON.Params) + "<br>"; | ||
jobInfo.innerHTML += "Cached: ".big() + jobJSON["Cached"] + "<br>"; | ||
jobInfo.innerHTML += "Coalesced: ".big() + jobJSON["Coalesced"] + "<br>"; | ||
jobInfo.innerHTML += "Error: ".big() + jobJSON["Err"] + "<br>"; | ||
jobInfo.innerHTML += "ExitCode: ".big() + jobJSON["ExitCode"] + "<br>"; | ||
jobInfo.innerHTML += "Transport method: ".big() + jobJSON["TransportMethod"] + "<br>"; | ||
} | ||
|
||
if (state == "pending") { | ||
setInterval(checkState, 3000); | ||
|
||
function checkState() { | ||
let jHeaders = new Headers(); | ||
jHeaders.append('Content-Type', 'application/json'); | ||
const jobRequest = new Request('/job/{{.Project}}/{{.ID}}', {headers: jHeaders}); | ||
fetch(jobRequest) | ||
.then(function(response) { return response.json(); }) | ||
.then(function(data) { | ||
if (data["State"] == "ready"){ | ||
location.reload(); | ||
} | ||
}) | ||
} | ||
|
||
const source = new EventSource('/log/{{.Project}}/{{.ID}}'); | ||
const jobLog = document.getElementById('js-job-log') | ||
source.onmessage = function(e) { | ||
jobLog.innerHTML += e.data + "</br>" | ||
}; | ||
|
||
source.onerror = function(e) { | ||
document.body.innerHTML += "Web tail failed."; | ||
source.close(); | ||
}; | ||
} | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.