summaryrefslogtreecommitdiffstats
path: root/templates/base
diff options
context:
space:
mode:
authorkolaente <konrad@kola-entertainments.de>2018-10-23 04:57:42 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2018-10-23 10:57:42 +0800
commit6759237eda5b7ddfe9284c81900cc9deed1f6bf9 (patch)
treed6fa6ea9da9b218fcc74bcd9d9d11dc92662a349 /templates/base
parentf38fce916ec92cb9ac9fe78fb5284bc8b55a726f (diff)
downloadgitea-6759237eda5b7ddfe9284c81900cc9deed1f6bf9.tar.gz
gitea-6759237eda5b7ddfe9284c81900cc9deed1f6bf9.zip
User action heatmap (#5131)
* Added basic heatmap data * Added extra case for sqlite * Built basic heatmap into user profile * Get contribution data from api & styling * Fixed lint & added extra group by statements for all database types * generated swagger spec * generated swagger spec * generated swagger spec * fixed swagger spec * fmt * Added tests * Added setting to enable/disable user heatmap * Added locale for loading text * Removed UseTiDB * Updated librejs & moment.js * Fixed import order * Fixed heatmap in postgresql * Update docs/content/doc/advanced/config-cheat-sheet.en-us.md Co-Authored-By: kolaente <konrad@kola-entertainments.de> * Added copyright header * Fixed a bug to show the heatmap for the actual user instead of the currently logged in * Added integration test for heatmaps * Added a heatmap on the dashboard * Fixed timestamp parsing * Hide heatmap on mobile * optimized postgresql group by query * Improved sqlite group by statement
Diffstat (limited to 'templates/base')
-rw-r--r--templates/base/footer.tmpl22
-rw-r--r--templates/base/head.tmpl3
2 files changed, 25 insertions, 0 deletions
diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl
index 0dd8871525..1734d32600 100644
--- a/templates/base/footer.tmpl
+++ b/templates/base/footer.tmpl
@@ -49,6 +49,28 @@
<script src="https://www.google.com/recaptcha/api.js" async></script>
{{end}}
{{end}}
+{{if .EnableHeatmap}}
+ <script src="{{AppSubUrl}}/vendor/plugins/moment/moment.min.js" charset="utf-8"></script>
+ <script src="{{AppSubUrl}}/vendor/plugins/d3/d3.v4.min.js" charset="utf-8"></script>
+ <script src="{{AppSubUrl}}/vendor/plugins/calendar-heatmap/calendar-heatmap.js" charset="utf-8"></script>
+ <script type="text/javascript">
+ $.get( '{{AppSubUrl}}/api/v1/users/{{.HeatmapUser}}/heatmap', function( chartRawData ) {
+ var chartData = [];
+ for (var i = 0; i < chartRawData.length; i++) {
+ chartData[i] = {date: new Date(chartRawData[i].timestamp * 1000), count: chartRawData[i].contributions};
+ }
+
+ $('#loading-heatmap').removeClass('active');
+
+ var heatmap = calendarHeatmap()
+ .data(chartData)
+ .selector('#user-heatmap')
+ .colorRange(['#f4f4f4', '#459928'])
+ .tooltipEnabled(true);
+ heatmap();
+ });
+ </script>
+{{end}}
{{if .RequireTribute}}
<script src="{{AppSubUrl}}/vendor/plugins/tribute/tribute.min.js"></script>
diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl
index b6ab8141e2..130ab53755 100644
--- a/templates/base/head.tmpl
+++ b/templates/base/head.tmpl
@@ -101,6 +101,9 @@
{{if .RequireDropzone}}
<link rel="stylesheet" href="{{AppSubUrl}}/vendor/plugins/dropzone/dropzone.css">
{{end}}
+{{if .EnableHeatmap}}
+ <link rel="stylesheet" href="{{AppSubUrl}}/vendor/plugins/calendar-heatmap/calendar-heatmap.css">
+{{end}}
<style class="list-search-style"></style>
<script src="{{AppSubUrl}}/vendor/plugins/cssrelpreload/loadCSS.min.js"></script>