-
Notifications
You must be signed in to change notification settings - Fork 10
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 #14 from xebialabs-community/dashboard-tiles
Add a contributions pie chart tile and a contributions timeline tile
- Loading branch information
Showing
12 changed files
with
547 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# | ||
# Copyright 2019 XEBIALABS | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
|
||
from stash.Stash import StashClient | ||
import datetime | ||
|
||
def convertMillisEpoch(millis): | ||
return datetime.datetime.fromtimestamp(float(millis)/1000).strftime('%Y-%m-%d %H:%M:%S %Z') | ||
|
||
stash = StashClient.get_client(server, username, password) | ||
method = "stash_querycommits" | ||
call = getattr(stash, method) | ||
response = call(locals()) | ||
|
||
commits = response["output"] | ||
|
||
# Compile data for detail and summary views | ||
authors = {} | ||
committers = {} | ||
people = [] | ||
for commit in commits: | ||
if commit["author"]["name"] in authors.keys(): | ||
authors[commit["author"]["name"]] += 1 | ||
else: | ||
authors[commit["author"]["name"]] = 1 | ||
if commit["author"]["name"] not in people: | ||
people.append(commit["author"]["name"]) | ||
|
||
if commit["committer"]["name"] in committers.keys(): | ||
committers[commit["committer"]["name"]] += 1 | ||
else: | ||
committers[commit["committer"]["name"]] = 1 | ||
if commit["committer"]["name"] not in people: | ||
people.append(commit["committer"]["name"]) | ||
|
||
# Convert timestamps to a user-friendly format | ||
for i in range(len(commits)): | ||
commits[i]["authorTimestamp"] = convertMillisEpoch(commits[i]["authorTimestamp"]) | ||
commits[i]["committerTimestamp"] = convertMillisEpoch(commits[i]["committerTimestamp"]) | ||
|
||
data = { | ||
"commits": commits, | ||
"authors": [{"name":author,"value":authors[author]} for author in authors.keys()], | ||
"committers": [{"name":committer,"value":committers[committer]} for committer in committers.keys()], | ||
"people": people | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# | ||
# Copyright 2019 XEBIALABS | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
|
||
from stash.Stash import StashClient | ||
import datetime | ||
from java.time import LocalDate | ||
|
||
def convertMillisEpochDateComponents(millis): | ||
isodate = datetime.datetime.fromtimestamp(float(millis)/1000).strftime('%Y-%m-%d').split('-') | ||
isodate = [int(dateComponent) for dateComponent in isodate] | ||
return LocalDate.of(isodate[0], isodate[1], isodate[2]) | ||
|
||
def convertMillisEpoch(millis): | ||
return datetime.datetime.fromtimestamp(float(millis)/1000).strftime('%Y-%m-%d %H:%M:%S %Z') | ||
|
||
stash = StashClient.get_client(server, username, password) | ||
method = "stash_querycommits" | ||
call = getattr(stash, method) | ||
response = call(locals()) | ||
|
||
commits = response["output"] | ||
|
||
# Compile data for summary view | ||
commitsByDay = {} | ||
for commit in commits: | ||
commitDate = convertMillisEpochDateComponents(commit["committerTimestamp"]) | ||
if commitDate in commitsByDay.keys(): | ||
commitsByDay[commitDate] += 1 | ||
else: | ||
commitsByDay[commitDate] = 1 | ||
|
||
dates = [date for date in commitsByDay.keys()] | ||
dates.sort() | ||
startDate = dates[0] | ||
endDate = dates[-1] | ||
days = [] | ||
commitsEachDay = [] | ||
daysWithCommits = [dayCommits.toString() for dayCommits in commitsByDay.keys()] | ||
while startDate.isBefore(endDate.plusDays(1)): | ||
days.append(startDate.toString()) | ||
if startDate.toString() in daysWithCommits: | ||
commitsEachDay.append(commitsByDay[startDate]) | ||
else: | ||
commitsEachDay.append(0) | ||
startDate = startDate.plusDays(1) | ||
|
||
# Convert timestamps to a user-friendly format for the detail view | ||
for i in range(len(commits)): | ||
commits[i]["authorTimestamp"] = convertMillisEpoch(commits[i]["authorTimestamp"]) | ||
commits[i]["committerTimestamp"] = convertMillisEpoch(commits[i]["committerTimestamp"]) | ||
|
||
data = { | ||
"dates": days, | ||
"commitsEachDay": commitsEachDay, | ||
"commits": commits | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/resources/web/stash/ContributionsTile/echarts.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
src/main/resources/web/stash/ContributionsTile/stash-contributions-tile-details-view.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,65 @@ | ||
<!-- | ||
Copyright 2019 XEBIALABS | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
--> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<!-- Bootstrap CSS dependency --> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" | ||
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | ||
<script | ||
src="https://code.jquery.com/jquery-3.2.1.min.js" | ||
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" | ||
crossorigin="anonymous"> | ||
</script> | ||
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet"> | ||
</head> | ||
<script> | ||
window.addEventListener("xlrelease.load", function () { | ||
window.xlrelease.queryTileData(function (response) { | ||
var commits = response.data.data.commits; | ||
commits.forEach(function (commit) { | ||
if(commit.message.length > 64) { | ||
var message = commit.message.substring(0, 61).concat('...'); | ||
} else { | ||
var message = commit.message; | ||
} | ||
$("#commits").append( | ||
'<tr>' + | ||
'<td>' + commit.displayId + '</td>' + | ||
'<td>' + commit.authorTimestamp + '</td>' + | ||
'<td>' + commit.author.name + | ||
' (<a href="mailto:' + commit.author.emailAddress + '">' + commit.author.emailAddress + '</a>)</td>' + | ||
'<td>' + commit.committerTimestamp + '</td>' + | ||
'<td>' + commit.committer.name + | ||
' (<a href="mailto:' + commit.committer.emailAddress + '">' + commit.committer.emailAddress + '</a>)</td>' + | ||
'<td>' + message + '</td>' + | ||
'</tr>' | ||
); | ||
}) | ||
}); | ||
}); | ||
</script> | ||
<body> | ||
<table class="table table-rounded table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Commit ID</th> | ||
<th>Authored Date</th> | ||
<th>Author</th> | ||
<th>Committed Date</th> | ||
<th>Committer</th> | ||
<th>Message</th> | ||
</tr> | ||
</thead> | ||
<tbody id="commits"> | ||
</tbody> | ||
</table> | ||
</body> | ||
</html> |
78 changes: 78 additions & 0 deletions
78
src/main/resources/web/stash/ContributionsTile/stash-contributions-tile-summary-view.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,78 @@ | ||
<!-- | ||
Copyright 2019 XEBIALABS | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
--> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="echarts.min.js"></script> | ||
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet"> | ||
<script | ||
src="https://code.jquery.com/jquery-3.2.1.min.js" | ||
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" | ||
crossorigin="anonymous"> | ||
</script> | ||
</head> | ||
<script> | ||
window.addEventListener("xlrelease.load", function () { | ||
window.xlrelease.queryTileData(function (response) { | ||
var authors = response.data.data.authors; | ||
var committers = response.data.data.committers; | ||
var people = response.data.data.people; | ||
var dom = document.getElementById("main"); | ||
var myChart = echarts.init(dom); | ||
var app = {}; | ||
option = null; | ||
app.title = 'Authors and Committers'; | ||
option = { | ||
tooltip: { | ||
trigger: 'item', | ||
formatter: "{a} <br/>{b}: {c} Commit(s) ({d}%)" | ||
}, | ||
legend: { | ||
orient: 'vertical', | ||
type: 'scroll', | ||
x: 'left', | ||
data: people | ||
}, | ||
series: [ | ||
{ | ||
name:'Authors', | ||
type:'pie', | ||
selectedMode: 'single', | ||
radius: [0, '45%'], | ||
label: { | ||
normal: { | ||
show: false | ||
} | ||
}, | ||
data: authors | ||
}, | ||
{ | ||
name:'Committers', | ||
type:'pie', | ||
radius: ['60%', '82.5%'], | ||
label: { | ||
normal: { | ||
show: false | ||
} | ||
}, | ||
data: committers | ||
} | ||
] | ||
};; | ||
if (option && typeof option === "object") { | ||
myChart.setOption(option, true); | ||
} | ||
}); | ||
}); | ||
</script> | ||
<body> | ||
<div id="main" style="width:100%;height:calc(100vh - 16px);"></div> | ||
</body> | ||
</html> |
Oops, something went wrong.