|
1 | 1 | [[ define "commitsPage" ]]
|
2 | 2 | <!doctype html>
|
3 |
| -<html ng-app="DBHub" ng-controller="commitsView"> |
| 3 | +<html> |
4 | 4 | [[ template "head" . ]]
|
5 | 5 | <body>
|
6 | 6 | [[ template "header" . ]]
|
7 | 7 | <div>
|
8 | 8 | <div id="db-header-root"></div>
|
9 |
| - <div class="row"> |
10 |
| - <div class="col-md-12"> |
11 |
| - <div style="text-align: center; margin: 1% 0"> |
12 |
| - <span data-cy="commithist">Commit history for branch</span> |
13 |
| - <span class="dropdown"> |
14 |
| - <span class="btn-group" uib-dropdown keyboard-nav="true"> |
15 |
| - <button id="branchname" type="button" class="btn" data-cy="branchdropdown">{{ meta.Branch }}</button> |
16 |
| - |
17 |
| - <button type="button" uib-dropdown-toggle class="btn btn-default"> |
18 |
| - <span class="caret"></span> |
19 |
| - </button> |
20 |
| - <ul uib-dropdown-menu class="dropdown-menu" role="menu"> |
21 |
| - <li ng-repeat="row in meta.Branches" role="menuitem" ng-click="changeBranch(row)" data-cy="commit-{{ row }}"> |
22 |
| - <a href="">{{ row }}</a> |
23 |
| - </li> |
24 |
| - </ul> |
25 |
| - </span> |
26 |
| - </span> |
27 |
| - </div> |
28 |
| - </div> |
29 |
| - </div> |
30 |
| - <div class="row" ng-if="statusMessage != ''"> |
31 |
| - <div class="col-md-12"> |
32 |
| - <div style="text-align: center; padding-bottom: 8px;"> |
33 |
| - <h4 style="color: red;"> {{ statusMessage }}</h4> |
34 |
| - </div> |
35 |
| - </div> |
36 |
| - </div> |
37 |
| - <div class="row"> |
38 |
| - <div class="col-md-12"> |
39 |
| - <div style="border: 1px solid #DDD; border-radius: 7px; margin-bottom: 10px; padding: 0;"> |
40 |
| - <table id="contents" class="table table-striped table-responsive" style="margin: 0;"> |
41 |
| - <thead> |
42 |
| - <tr> |
43 |
| - [[ if eq .DB.Info.Owner .PageMeta.LoggedInUser ]] |
44 |
| - <th>Actions</th> |
45 |
| - [[ end ]] |
46 |
| - <th width="25%" colspan="2">Author</th><th>Date</th><th>Commit ID</th> |
47 |
| - </tr> |
48 |
| - </thead> |
49 |
| - <tbody> |
50 |
| - <tr ng-repeat-start="row in meta.History"> |
51 |
| - [[ if eq .DB.Info.Owner .PageMeta.LoggedInUser ]] |
52 |
| - <td style="border-style: none;"> |
53 |
| - <button class="btn btn-primary" ng-click="createBranch(row.id)" data-cy="createbranchbtn">Create Branch</button> |
54 |
| - </td> |
55 |
| - [[ end ]] |
56 |
| - <td width="15%" style="border-style: none;"> |
57 |
| - <img ng-if="row.avatar_url != ''" ng-attr-src="{{ decodeAmp(row.avatar_url) }}" height="30" width="30" style="border: 1px solid #8c8c8c;"/> |
58 |
| - <a class="blackLink" href="/{{ row.author_user_name }}">{{ row.author_name }}</a> |
59 |
| - </td> |
60 |
| - <td width="10%" style="border-style: none;"> </td> |
61 |
| - <td style="border-style: none;"> |
62 |
| - <span title="{{ row.timestamp | date : 'medium' }}">{{ getTimePeriodTxt(row.timestamp, false) }}</span> |
63 |
| - </td> |
64 |
| - <td style="border-style: none; font-family: Monospace; font-size: large; text-align: left; vertical-align: text-bottom;"> |
65 |
| - <a class="blackLink" href="/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?branch={{ meta.Branch }}&commit={{ row.id }}">{{ row.id }}</a> |
66 |
| - </td> |
67 |
| - </tr> |
68 |
| - <tr ng-repeat-end class="tableRow"> |
69 |
| - <td style="border-style: none;"> |
70 |
| - <span ng-if="row.id != lastCommit"> |
71 |
| - <button class="btn btn-primary" ng-click="viewChanges(meta.History[$index + 1].id, row.id)">View Changes</button> |
72 |
| - <br /><br /> |
73 |
| - </span> |
74 |
| - [[ if eq .DB.Info.Owner .PageMeta.LoggedInUser ]] |
75 |
| - <button class="btn btn-primary" ng-click="createTag(row.id)" data-cy="createtagrelbtn">Create Tag or Release</button> |
76 |
| - <span ng-if="(row.id == headCommit) && (row.id != lastCommit)"> |
77 |
| - <br /><br /> |
78 |
| - <button class="btn btn-danger" ng-click="deleteCommit(row.id)" data-cy="delcommitbtn">Delete Commit</button> |
79 |
| - </span> |
80 |
| - [[ end ]] |
81 |
| - </td> |
82 |
| - <td width="15%" style="border-style: none;"> </td> |
83 |
| - <td colspan="3" style="border-style: none; vertical-align: top;"> |
84 |
| - <span ng-bind-html="row.message"></span> |
85 |
| - </td> |
86 |
| - </tr> |
87 |
| - </tbody> |
88 |
| - </table> |
89 |
| - </div> |
90 |
| - </div> |
91 |
| - </div> |
| 9 | + <div id="database-commits"></div> |
92 | 10 | </div>
|
93 | 11 | [[ template "script_db_header" . ]]
|
94 |
| -[[ template "footer" . ]] |
95 | 12 | <script>
|
96 |
| - let app = angular.module('DBHub', ['ui.bootstrap', 'ngSanitize']); |
97 |
| - app.controller('commitsView', function($scope, $http, $httpParamSerializerJQLike) { |
98 |
| - $scope.meta = { |
99 |
| - Branch: "[[ .Branch ]]", |
100 |
| - Branches: [[ .Branches ]], |
101 |
| - History: [[ .History ]] |
102 |
| - } |
103 |
| - |
104 |
| - // Take note of the first and last commit IDs, so we can compare against them |
105 |
| - let numCommits = $scope.meta.History.length; |
106 |
| - $scope.headCommit = $scope.meta.History[0].id; |
107 |
| - $scope.lastCommit = $scope.meta.History[numCommits - 1].id; |
108 |
| - |
109 |
| - // Change the branch being viewed |
110 |
| - $scope.changeBranch = function(branchName){ |
111 |
| - window.location = "/commits/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?branch=" + branchName; |
112 |
| - }; |
113 |
| - |
114 |
| - // Bounce to the page for creating branches |
115 |
| - $scope.createBranch = function(commit){ |
116 |
| - window.location = "/createbranch/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?commit=" + commit; |
117 |
| - }; |
118 |
| - |
119 |
| - // Bounce to the page for creating tags |
120 |
| - $scope.createTag = function(commit){ |
121 |
| - window.location = "/createtag/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?commit=" + commit; |
122 |
| - }; |
123 |
| - |
124 |
| - // Bounce to the page for viewing changes |
125 |
| - $scope.viewChanges = function(commit_a, commit_b){ |
126 |
| - window.location = "/diffs/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?commit_a=" + commit_a + "&commit_b=" + commit_b; |
127 |
| - }; |
128 |
| - |
129 |
| - // Change \u0026 to & |
130 |
| - $scope.decodeAmp = function(str) { |
131 |
| - return decodeURIComponent(str); |
132 |
| - }; |
133 |
| - |
134 |
| - // Delete a commit from the viewed branch |
135 |
| - $scope.statusMessage = ""; |
136 |
| - $scope.deleteCommit = function(commit) { |
137 |
| - $http({ |
138 |
| - method: "POST", |
139 |
| - url: "/x/deletecommit/", |
140 |
| - data: $httpParamSerializerJQLike({ |
141 |
| - "branch": $scope.meta.Branch, |
142 |
| - "commit": commit, |
143 |
| - "dbname": [[ .DB.Info.Database ]], |
144 |
| - "username": [[ .DB.Info.Owner ]] |
145 |
| - }), |
146 |
| - headers: { "Content-Type": "application/x-www-form-urlencoded" } |
147 |
| - }).then(function success(response) { |
148 |
| - // The delete was successful, so reload the page |
149 |
| - let status = response.status; |
150 |
| - if (status === 200) { |
151 |
| - window.location = '/commits/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?branch=' + $scope.meta.Branch; |
152 |
| - } |
153 |
| - }, function failure(response) { |
154 |
| - // The delete failed, so display the returned error message |
155 |
| - $scope.statusMessage = "Error: " + response.data; |
156 |
| - }); |
157 |
| - }; |
158 |
| - |
159 |
| - // Returns a nicely presented "time elapsed" string |
160 |
| - $scope.getTimePeriodTxt = function(date1, includeOn) { |
161 |
| - return getTimePeriod(date1, includeOn) |
162 |
| - }; |
163 |
| - }); |
| 13 | + const commitData = [[ .History ]]; |
| 14 | + const branchData = [[ .Branches ]]; |
164 | 15 | </script>
|
| 16 | +[[ template "footer" . ]] |
165 | 17 | </body>
|
166 | 18 | </html>
|
167 | 19 | [[ end ]]
|
0 commit comments