diff options
author | Lauris BH <lauris@nix.lv> | 2018-11-27 11:36:54 +0200 |
---|---|---|
committer | Jonas Franz <info@jonasfranz.software> | 2018-11-27 10:36:54 +0100 |
commit | e09fe487734238708c2f9fc7c47dbb2132250400 (patch) | |
tree | bd302a98f3badfe9e2b74283e2d068bfd92bb5f8 /templates | |
parent | c03a9b3e422ded9d8200a83b94ab56ddb4740d94 (diff) | |
download | gitea-e09fe487734238708c2f9fc7c47dbb2132250400.tar.gz gitea-e09fe487734238708c2f9fc7c47dbb2132250400.zip |
Refactor heatmap to vue component (#5401)
Diffstat (limited to 'templates')
-rw-r--r-- | templates/base/footer.tmpl | 29 | ||||
-rw-r--r-- | templates/base/head.tmpl | 2 | ||||
-rw-r--r-- | templates/user/dashboard/dashboard.tmpl | 9 | ||||
-rw-r--r-- | templates/user/profile.tmpl | 9 |
4 files changed, 22 insertions, 27 deletions
diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index 320b4fa1db..dff23f12f7 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -49,28 +49,6 @@ <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({{SafeJS HeatmapColorRange}}) - .tooltipEnabled(true); - heatmap(); - }); - </script> -{{end}} {{if .RequireTribute}} <script src="{{AppSubUrl}}/vendor/plugins/tribute/tribute.min.js"></script> @@ -136,6 +114,13 @@ <!-- JavaScript --> <script src="{{AppSubUrl}}/vendor/plugins/semantic/semantic.min.js"></script> <script src="{{AppSubUrl}}/js/index.js?v={{MD5 AppVer}}"></script> +{{if .EnableHeatmap}} + <script src="{{AppSubUrl}}/vendor/plugins/moment/moment.min.js" charset="utf-8"></script> + <script src="{{AppSubUrl}}/vendor/plugins/vue-calendar-heatmap/vue-calendar-heatmap.browser.js" charset="utf-8"></script> + <script type="text/javascript"> + initHeatmap('user-heatmap', '{{.HeatmapUser}}'); + </script> +{{end}} {{template "custom/footer" .}} </body> </html> diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 130ab53755..bb6a8a981b 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -102,7 +102,7 @@ <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"> + <link rel="stylesheet" href="{{AppSubUrl}}/vendor/plugins/vue-calendar-heatmap/vue-calendar-heatmap.css"> {{end}} <style class="list-search-style"></style> diff --git a/templates/user/dashboard/dashboard.tmpl b/templates/user/dashboard/dashboard.tmpl index ac094f24c7..e7b378e364 100644 --- a/templates/user/dashboard/dashboard.tmpl +++ b/templates/user/dashboard/dashboard.tmpl @@ -6,8 +6,13 @@ <div class="ui mobile reversed stackable grid"> <div class="ten wide column"> {{if .EnableHeatmap}} - <div class="ui active centered inline indeterminate text loader" id="loading-heatmap">{{.i18n.Tr "user.heatmap.loading"}}</div> - <div id="user-heatmap"></div> + <div id="user-heatmap" style="padding-right: 40px"> + <activity-heatmap :locale="locale" :suburl="suburl" :user="heatmapUser"> + <div slot="loading"> + <div class="ui active centered inline indeterminate text loader" id="loading-heatmap">{{.i18n.Tr "user.heatmap.loading"}}</div> + </div> + </activity-heatmap> + </div> <div class="ui divider"></div> {{end}} {{template "user/dashboard/feeds" .}} diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 3f535ba140..350032e564 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -96,8 +96,13 @@ {{if eq .TabName "activity"}} {{if .EnableHeatmap}} - <div class="ui active centered inline indeterminate text loader" id="loading-heatmap">{{.i18n.Tr "user.heatmap.loading"}}</div> - <div id="user-heatmap"></div> + <div id="user-heatmap" style="padding-right: 40px"> + <activity-heatmap :locale="locale" :suburl="suburl" :user="heatmapUser"> + <div slot="loading"> + <div class="ui active centered inline indeterminate text loader" id="loading-heatmap">{{.i18n.Tr "user.heatmap.loading"}}</div> + </div> + </activity-heatmap> + </div> <div class="ui divider"></div> {{end}} <div class="feeds"> |