Skip to content

Commit

Permalink
chore: refactor web
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Oct 17, 2018
1 parent 0dbf7b6 commit eddb42b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.DS_Store
*~
*#
.#*
depviz.db
/vendor/
6 changes: 6 additions & 0 deletions cmd_web.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ func webListIssues(w http.ResponseWriter, r *http.Request) {
return
}

targets := strings.Split(r.URL.Query().Get("targets"), ",")
issues.filterByTargets(targets)

list := []render.Renderer{}
for _, issue := range issues {
if issue.Hidden {
continue
}
list = append(list, issue)
}

Expand Down
17 changes: 17 additions & 0 deletions web/depviz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$(document).ready(function() {
$("#submit").click(function() {
$("#result").html("loading JSON...");
$.ajax({
url: "/api/issues.json?targets=" + $("#targets").attr("value"),
success: function(result, status, xhr) {
console.dir(result);
$("#result").html(JSON.stringify(result));
$("#image-link").attr("href", "/api/graph/image?targets=" + $("#targets").attr("value"));
},
error: function(xhr, status, error) {
console.error("failed", xhr, status, error);
alert("failed: " + error);
},
})
});
});
16 changes: 15 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
<a href="/api/graph/image?targets=berty/berty">berty/berty</a>
<!doctype html>
<html lang="en">
<head>
<title>DepViz</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="/depviz.js"></script>
<input type="text" id="targets" placeholder="user/project" value="moul/depviz" />
<input type="button" id="submit" value="generate" />
<hr />
<a id="image-link">download image</a>
<textarea id="result" style="width: 100%; height: 500px;"></textarea>
</body>
</html>

0 comments on commit eddb42b

Please sign in to comment.