Mercurial > kallithea
comparison rhodecode/templates/summary/summary.html @ 2031:82a88013a3fd
merge 1.3 into stable
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 26 Feb 2012 17:25:09 +0200 |
parents | 6b25e6819753 6020e3884a58 |
children | 63e58ef80ef1 |
comparison
equal
deleted
inserted
replaced
2005:ab0e122b38a7 | 2031:82a88013a3fd |
---|---|
4 ${c.repo_name} ${_('Summary')} - ${c.rhodecode_name} | 4 ${c.repo_name} ${_('Summary')} - ${c.rhodecode_name} |
5 </%def> | 5 </%def> |
6 | 6 |
7 <%def name="breadcrumbs_links()"> | 7 <%def name="breadcrumbs_links()"> |
8 ${h.link_to(u'Home',h.url('/'))} | 8 ${h.link_to(u'Home',h.url('/'))} |
9 » | 9 » |
10 ${h.link_to(c.dbrepo.just_name,h.url('summary_home',repo_name=c.repo_name))} | 10 ${h.link_to(c.dbrepo.just_name,h.url('summary_home',repo_name=c.repo_name))} |
11 » | 11 » |
12 ${_('summary')} | 12 ${_('summary')} |
13 </%def> | 13 </%def> |
14 | 14 |
15 <%def name="page_nav()"> | 15 <%def name="page_nav()"> |
16 ${self.menu('summary')} | 16 ${self.menu('summary')} |
17 </%def> | 17 </%def> |
18 | 18 |
19 <%def name="main()"> | 19 <%def name="main()"> |
20 <div class="box box-left"> | 20 <% |
21 summary = lambda n:{False:'summary-short'}.get(n) | |
22 %> | |
23 %if c.show_stats: | |
24 <div class="box box-left"> | |
25 %else: | |
26 <div class="box"> | |
27 %endif | |
21 <!-- box / title --> | 28 <!-- box / title --> |
22 <div class="title"> | 29 <div class="title"> |
23 ${self.breadcrumbs()} | 30 ${self.breadcrumbs()} |
24 </div> | 31 </div> |
25 <!-- end box / title --> | 32 <!-- end box / title --> |
26 <div class="form"> | 33 <div class="form"> |
27 <div id="summary" class="fields"> | 34 <div id="summary" class="fields"> |
28 | 35 |
29 <div class="field"> | 36 <div class="field"> |
30 <div class="label"> | 37 <div class="label-summary"> |
31 <label>${_('Name')}:</label> | 38 <label>${_('Name')}:</label> |
32 </div> | 39 </div> |
33 <div class="input-short"> | 40 <div class="input ${summary(c.show_stats)}"> |
41 <div style="float:right;padding:5px 0px 0px 5px"> | |
42 %if c.rhodecode_user.username != 'default': | |
43 ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='rss_icon')} | |
44 ${h.link_to(_('ATOM'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='atom_icon')} | |
45 %else: | |
46 ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.dbrepo.repo_name),class_='rss_icon')} | |
47 ${h.link_to(_('ATOM'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name),class_='atom_icon')} | |
48 %endif | |
49 </div> | |
34 %if c.rhodecode_user.username != 'default': | 50 %if c.rhodecode_user.username != 'default': |
35 %if c.following: | 51 %if c.following: |
36 <span id="follow_toggle" class="following" title="${_('Stop following this repository')}" | 52 <span id="follow_toggle" class="following" title="${_('Stop following this repository')}" |
37 onclick="javascript:toggleFollowingRepo(this,${c.dbrepo.repo_id},'${str(h.get_token())}')"> | 53 onclick="javascript:toggleFollowingRepo(this,${c.dbrepo.repo_id},'${str(h.get_token())}')"> |
38 </span> | 54 </span> |
39 %else: | 55 %else: |
40 <span id="follow_toggle" class="follow" title="${_('Start following this repository')}" | 56 <span id="follow_toggle" class="follow" title="${_('Start following this repository')}" |
41 onclick="javascript:toggleFollowingRepo(this,${c.dbrepo.repo_id},'${str(h.get_token())}')"> | 57 onclick="javascript:toggleFollowingRepo(this,${c.dbrepo.repo_id},'${str(h.get_token())}')"> |
42 </span> | 58 </span> |
43 %endif | 59 %endif |
44 %endif: | 60 %endif: |
45 | |
46 ##REPO TYPE | 61 ##REPO TYPE |
47 %if c.dbrepo.repo_type =='hg': | 62 %if h.is_hg(c.dbrepo): |
48 <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/> | 63 <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/> |
49 %endif | 64 %endif |
50 %if c.dbrepo.repo_type =='git': | 65 %if h.is_git(c.dbrepo): |
51 <img style="margin-bottom:2px" class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/> | 66 <img style="margin-bottom:2px" class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/> |
52 %endif | 67 %endif |
53 | 68 |
54 ##PUBLIC/PRIVATE | 69 ##PUBLIC/PRIVATE |
55 %if c.dbrepo.private: | 70 %if c.dbrepo.private: |
56 <img style="margin-bottom:2px" class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url('/images/icons/lock.png')}"/> | 71 <img style="margin-bottom:2px" class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url('/images/icons/lock.png')}"/> |
57 %else: | 72 %else: |
58 <img style="margin-bottom:2px" class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url('/images/icons/lock_open.png')}"/> | 73 <img style="margin-bottom:2px" class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url('/images/icons/lock_open.png')}"/> |
59 %endif | 74 %endif |
60 | 75 |
61 ##REPO NAME | 76 ##REPO NAME |
62 <span class="repo_name">${h.repo_link(c.dbrepo.groups_and_repo)}</span> | 77 <span class="repo_name" title="${_('Non changable ID %s') % c.dbrepo.repo_id}">${h.repo_link(c.dbrepo.groups_and_repo)}</span> |
63 | 78 |
64 ##FORK | 79 ##FORK |
65 %if c.dbrepo.fork: | 80 %if c.dbrepo.fork: |
66 <div style="margin-top:5px;clear:both""> | 81 <div style="margin-top:5px;clear:both""> |
67 <a href="${h.url('summary_home',repo_name=c.dbrepo.fork.repo_name)}"> | 82 <a href="${h.url('summary_home',repo_name=c.dbrepo.fork.repo_name)}"><img class="icon" alt="${_('public')}" title="${_('Fork of')} ${c.dbrepo.fork.repo_name}" src="${h.url('/images/icons/arrow_divide.png')}"/> |
68 <img class="icon" alt="${_('public')}" | 83 ${_('Fork of')} ${c.dbrepo.fork.repo_name} |
69 title="${_('Fork of')} ${c.dbrepo.fork.repo_name}" | |
70 src="${h.url('/images/icons/arrow_divide.png')}"/> | |
71 ${_('Fork of')} ${c.dbrepo.fork.repo_name} | |
72 </a> | 84 </a> |
73 </div> | 85 </div> |
74 %endif | 86 %endif |
75 ##REMOTE | 87 ##REMOTE |
76 %if c.dbrepo.clone_uri: | 88 %if c.dbrepo.clone_uri: |
77 <div style="margin-top:5px;clear:both"> | 89 <div style="margin-top:5px;clear:both"> |
78 <a href="${h.url(str(h.hide_credentials(c.dbrepo.clone_uri)))}"> | 90 <a href="${h.url(str(h.hide_credentials(c.dbrepo.clone_uri)))}"><img class="icon" alt="${_('remote clone')}" title="${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}" src="${h.url('/images/icons/connect.png')}"/> |
79 <img class="icon" alt="${_('remote clone')}" | 91 ${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)} |
80 title="${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}" | |
81 src="${h.url('/images/icons/connect.png')}"/> | |
82 ${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)} | |
83 </a> | 92 </a> |
84 </div> | 93 </div> |
85 %endif | 94 %endif |
86 </div> | 95 </div> |
87 </div> | 96 </div> |
88 | 97 |
89 | |
90 <div class="field"> | 98 <div class="field"> |
91 <div class="label"> | 99 <div class="label-summary"> |
92 <label>${_('Description')}:</label> | 100 <label>${_('Description')}:</label> |
93 </div> | 101 </div> |
94 <div class="input-short desc">${h.urlify_text(c.dbrepo.description)}</div> | 102 <div class="input ${summary(c.show_stats)} desc">${h.urlify_text(c.dbrepo.description)}</div> |
95 </div> | 103 </div> |
96 | 104 |
97 | |
98 <div class="field"> | 105 <div class="field"> |
99 <div class="label"> | 106 <div class="label-summary"> |
100 <label>${_('Contact')}:</label> | 107 <label>${_('Contact')}:</label> |
101 </div> | 108 </div> |
102 <div class="input-short"> | 109 <div class="input ${summary(c.show_stats)}"> |
103 <div class="gravatar"> | 110 <div class="gravatar"> |
104 <img alt="gravatar" src="${h.gravatar_url(c.dbrepo.user.email)}"/> | 111 <img alt="gravatar" src="${h.gravatar_url(c.dbrepo.user.email)}"/> |
105 </div> | 112 </div> |
106 ${_('Username')}: ${c.dbrepo.user.username}<br/> | 113 ${_('Username')}: ${c.dbrepo.user.username}<br/> |
107 ${_('Name')}: ${c.dbrepo.user.name} ${c.dbrepo.user.lastname}<br/> | 114 ${_('Name')}: ${c.dbrepo.user.name} ${c.dbrepo.user.lastname}<br/> |
108 ${_('Email')}: <a href="mailto:${c.dbrepo.user.email}">${c.dbrepo.user.email}</a> | 115 ${_('Email')}: <a href="mailto:${c.dbrepo.user.email}">${c.dbrepo.user.email}</a> |
109 </div> | 116 </div> |
110 </div> | 117 </div> |
111 | 118 |
112 <div class="field"> | 119 <div class="field"> |
113 <div class="label"> | 120 <div class="label-summary"> |
114 <label>${_('Last change')}:</label> | 121 <label>${_('Clone url')}:</label> |
115 </div> | 122 </div> |
116 <div class="input-short"> | 123 <div class="input ${summary(c.show_stats)}"> |
117 <b>${'r%s:%s' % (h.get_changeset_safe(c.rhodecode_repo,'tip').revision, | 124 <div style="display:none" id="clone_by_name" class="ui-btn clone">${_('Show by Name')}</div> |
118 h.get_changeset_safe(c.rhodecode_repo,'tip').short_id)}</b> - | 125 <div id="clone_by_id" class="ui-btn clone">${_('Show by ID')}</div> |
119 <span class="tooltip" title="${c.rhodecode_repo.last_change}"> | 126 <input style="width:80%;margin-left:105px" type="text" id="clone_url" readonly="readonly" value="${c.clone_repo_url}"/> |
120 ${h.age(c.rhodecode_repo.last_change)}</span><br/> | 127 <input style="display:none;width:80%;margin-left:105px" type="text" id="clone_url_id" readonly="readonly" value="${c.clone_repo_url_id}"/> |
121 ${_('by')} ${h.get_changeset_safe(c.rhodecode_repo,'tip').author} | |
122 | |
123 </div> | 128 </div> |
124 </div> | 129 </div> |
125 | 130 |
126 <div class="field"> | 131 <div class="field"> |
127 <div class="label"> | 132 <div class="label-summary"> |
128 <label>${_('Clone url')}:</label> | 133 <label>${_('Trending files')}:</label> |
129 </div> | 134 </div> |
130 <div class="input-short"> | 135 <div class="input ${summary(c.show_stats)}"> |
131 <input type="text" id="clone_url" readonly="readonly" value="${c.rhodecode_repo.alias} clone ${c.clone_repo_url}" size="70"/> | 136 %if c.show_stats: |
137 <div id="lang_stats"></div> | |
138 %else: | |
139 ${_('Statistics are disabled for this repository')} | |
140 %if h.HasPermissionAll('hg.admin')('enable stats on from summary'): | |
141 ${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-btn")} | |
142 %endif | |
143 %endif | |
132 </div> | 144 </div> |
133 </div> | 145 </div> |
134 | 146 |
135 <div class="field"> | 147 <div class="field"> |
136 <div class="label"> | 148 <div class="label-summary"> |
137 <label>${_('Trending source files')}:</label> | |
138 </div> | |
139 <div class="input-short"> | |
140 <div id="lang_stats"></div> | |
141 </div> | |
142 </div> | |
143 | |
144 <div class="field"> | |
145 <div class="label"> | |
146 <label>${_('Download')}:</label> | 149 <label>${_('Download')}:</label> |
147 </div> | 150 </div> |
148 <div class="input-short"> | 151 <div class="input ${summary(c.show_stats)}"> |
149 %if len(c.rhodecode_repo.revisions) == 0: | 152 %if len(c.rhodecode_repo.revisions) == 0: |
150 ${_('There are no downloads yet')} | 153 ${_('There are no downloads yet')} |
151 %elif c.enable_downloads is False: | 154 %elif c.enable_downloads is False: |
152 ${_('Downloads are disabled for this repository')} | 155 ${_('Downloads are disabled for this repository')} |
153 %if h.HasPermissionAll('hg.admin')('enable stats on from summary'): | 156 %if h.HasPermissionAll('hg.admin')('enable downloads on from summary'): |
154 ${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-button-small")} | 157 ${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-btn")} |
155 %endif | 158 %endif |
156 %else: | 159 %else: |
157 ${h.select('download_options',c.rhodecode_repo.get_changeset().raw_id,c.download_options)} | 160 ${h.select('download_options',c.rhodecode_repo.get_changeset().raw_id,c.download_options)} |
158 %for cnt,archive in enumerate(c.rhodecode_repo._get_archives()): | 161 <span id="${'zip_link'}">${h.link_to('Download as zip',h.url('files_archive_home',repo_name=c.dbrepo.repo_name,fname='tip.zip'),class_="archive_icon ui-btn")}</span> |
159 %if cnt >=1: | |
160 | | |
161 %endif | |
162 <span class="tooltip" title="${_('Download %s as %s') %('tip',archive['type'])}" | |
163 id="${archive['type']+'_link'}">${h.link_to(archive['type'], | |
164 h.url('files_archive_home',repo_name=c.dbrepo.repo_name, | |
165 fname='tip'+archive['extension']),class_="archive_icon")}</span> | |
166 %endfor | |
167 <span style="vertical-align: bottom"> | 162 <span style="vertical-align: bottom"> |
168 <input id="archive_subrepos" type="checkbox" name="subrepos"/> <span class="tooltip" title="${_('Check this to download archive with subrepos')}" >${_('with subrepos')}</span> | 163 <input id="archive_subrepos" type="checkbox" name="subrepos" /> |
164 <label for="archive_subrepos" class="tooltip" title="${_('Check this to download archive with subrepos')}" >${_('with subrepos')}</label> | |
169 </span> | 165 </span> |
170 %endif | 166 %endif |
171 </div> | 167 </div> |
172 </div> | 168 </div> |
173 | 169 </div> |
174 <div class="field"> | |
175 <div class="label"> | |
176 <label>${_('Feeds')}:</label> | |
177 </div> | |
178 <div class="input-short"> | |
179 %if c.rhodecode_user.username != 'default': | |
180 ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='rss_icon')} | |
181 ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='atom_icon')} | |
182 %else: | |
183 ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.dbrepo.repo_name),class_='rss_icon')} | |
184 ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name),class_='atom_icon')} | |
185 %endif | |
186 </div> | |
187 </div> | |
188 </div> | |
189 </div> | 170 </div> |
190 <script type="text/javascript"> | |
191 YUE.onDOMReady(function(e){ | |
192 id = 'clone_url'; | |
193 YUE.on(id,'click',function(e){ | |
194 if(YUD.hasClass(id,'selected')){ | |
195 return | |
196 } | |
197 else{ | |
198 YUD.addClass(id,'selected'); | |
199 YUD.get(id).select(); | |
200 } | |
201 | |
202 }) | |
203 }) | |
204 var data = ${c.trending_languages|n}; | |
205 var total = 0; | |
206 var no_data = true; | |
207 var tbl = document.createElement('table'); | |
208 tbl.setAttribute('class','trending_language_tbl'); | |
209 var cnt = 0; | |
210 | |
211 for (var i=0;i<data.length;i++){ | |
212 total += data[i][1].count; | |
213 cnt += 1; | |
214 no_data = false; | |
215 | |
216 var hide = cnt>2; | |
217 var tr = document.createElement('tr'); | |
218 if (hide){ | |
219 tr.setAttribute('style','display:none'); | |
220 tr.setAttribute('class','stats_hidden'); | |
221 } | |
222 var k = data[i][0]; | |
223 var obj = data[i][1]; | |
224 var percentage = Math.round((obj.count/total*100),2); | |
225 | |
226 var td1 = document.createElement('td'); | |
227 td1.width = 150; | |
228 var trending_language_label = document.createElement('div'); | |
229 trending_language_label.innerHTML = obj.desc+" ("+k+")"; | |
230 td1.appendChild(trending_language_label); | |
231 | |
232 var td2 = document.createElement('td'); | |
233 td2.setAttribute('style','padding-right:14px !important'); | |
234 var trending_language = document.createElement('div'); | |
235 var nr_files = obj.count+" ${_('files')}"; | |
236 | |
237 trending_language.title = k+" "+nr_files; | |
238 | |
239 if (percentage>22){ | |
240 trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"% "+nr_files+ "</b>"; | |
241 } | |
242 else{ | |
243 trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"%</b>"; | |
244 } | |
245 | |
246 trending_language.setAttribute("class", 'trending_language top-right-rounded-corner bottom-right-rounded-corner'); | |
247 trending_language.style.width=percentage+"%"; | |
248 td2.appendChild(trending_language); | |
249 | |
250 tr.appendChild(td1); | |
251 tr.appendChild(td2); | |
252 tbl.appendChild(tr); | |
253 if(cnt == 3){ | |
254 var show_more = document.createElement('tr'); | |
255 var td = document.createElement('td'); | |
256 lnk = document.createElement('a'); | |
257 | |
258 lnk.href='#'; | |
259 lnk.innerHTML = "${_('show more')}"; | |
260 lnk.id='code_stats_show_more'; | |
261 td.appendChild(lnk); | |
262 | |
263 show_more.appendChild(td); | |
264 show_more.appendChild(document.createElement('td')); | |
265 tbl.appendChild(show_more); | |
266 } | |
267 | |
268 } | |
269 if(no_data){ | |
270 var tr = document.createElement('tr'); | |
271 var td1 = document.createElement('td'); | |
272 td1.innerHTML = "${c.no_data_msg}"; | |
273 tr.appendChild(td1); | |
274 tbl.appendChild(tr); | |
275 } | |
276 YUD.get('lang_stats').appendChild(tbl); | |
277 YUE.on('code_stats_show_more','click',function(){ | |
278 l = YUD.getElementsByClassName('stats_hidden') | |
279 for (e in l){ | |
280 YUD.setStyle(l[e],'display',''); | |
281 }; | |
282 YUD.setStyle(YUD.get('code_stats_show_more'), | |
283 'display','none'); | |
284 }) | |
285 | |
286 var tmpl_links = {} | |
287 %for cnt,archive in enumerate(c.rhodecode_repo._get_archives()): | |
288 tmpl_links['${archive['type']}'] = '${h.link_to(archive['type'], | |
289 h.url('files_archive_home',repo_name=c.dbrepo.repo_name, | |
290 fname='__CS__'+archive['extension'],subrepos='__SUB__'),class_="archive_icon")}'; | |
291 %endfor | |
292 | |
293 YUE.on(['download_options','archive_subrepos'],'change',function(e){ | |
294 var sm = YUD.get('download_options'); | |
295 var new_cs = sm.options[sm.selectedIndex]; | |
296 | |
297 for(k in tmpl_links){ | |
298 var s = YUD.get(k+'_link'); | |
299 title_tmpl = "${_('Download %s as %s') % ('__CS_NAME__','__CS_EXT__')}"; | |
300 s.title = title_tmpl.replace('__CS_NAME__',new_cs.text); | |
301 s.title = s.title.replace('__CS_EXT__',k); | |
302 var url = tmpl_links[k].replace('__CS__',new_cs.value); | |
303 var subrepos = YUD.get('archive_subrepos').checked | |
304 url = url.replace('__SUB__',subrepos); | |
305 s.innerHTML = url | |
306 } | |
307 }); | |
308 </script> | |
309 </div> | 171 </div> |
310 | 172 |
173 %if c.show_stats: | |
311 <div class="box box-right" style="min-height:455px"> | 174 <div class="box box-right" style="min-height:455px"> |
312 <!-- box / title --> | 175 <!-- box / title --> |
313 <div class="title"> | 176 <div class="title"> |
314 <h5>${_('Commit activity by day / author')}</h5> | 177 <h5>${_('Commit activity by day / author')}</h5> |
315 </div> | 178 </div> |
316 | 179 |
317 <div class="graph"> | 180 <div class="graph"> |
318 <div style="padding:0 10px 10px 15px;font-size: 1.2em;"> | 181 <div style="padding:0 10px 10px 17px;"> |
319 %if c.no_data: | 182 %if c.no_data: |
320 ${c.no_data_msg} | 183 ${c.no_data_msg} |
321 %if h.HasPermissionAll('hg.admin')('enable stats on from summary'): | 184 %if h.HasPermissionAll('hg.admin')('enable stats on from summary'): |
322 ${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-button-small")} | 185 ${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-btn")} |
323 %endif | 186 %endif |
324 | |
325 %else: | 187 %else: |
326 ${_('Loaded in')} ${c.stats_percentage} % | 188 ${_('Stats gathered: ')} ${c.stats_percentage}% |
327 %endif | 189 %endif |
328 </div> | 190 </div> |
329 <div id="commit_history" style="width:450px;height:300px;float:left"></div> | 191 <div id="commit_history" style="width:450px;height:300px;float:left"></div> |
330 <div style="clear: both;height: 10px"></div> | 192 <div style="clear: both;height: 10px"></div> |
331 <div id="overview" style="width:450px;height:100px;float:left"></div> | 193 <div id="overview" style="width:450px;height:100px;float:left"></div> |
332 | 194 |
333 <div id="legend_data" style="clear:both;margin-top:10px;"> | 195 <div id="legend_data" style="clear:both;margin-top:10px;"> |
334 <div id="legend_container"></div> | 196 <div id="legend_container"></div> |
335 <div id="legend_choices"> | 197 <div id="legend_choices"> |
336 <table id="legend_choices_tables" style="font-size:smaller;color:#545454"></table> | 198 <table id="legend_choices_tables" class="noborder" style="font-size:smaller;color:#545454"></table> |
337 </div> | 199 </div> |
338 </div> | 200 </div> |
339 <script type="text/javascript"> | |
340 /** | |
341 * Plots summary graph | |
342 * | |
343 * @class SummaryPlot | |
344 * @param {from} initial from for detailed graph | |
345 * @param {to} initial to for detailed graph | |
346 * @param {dataset} | |
347 * @param {overview_dataset} | |
348 */ | |
349 function SummaryPlot(from,to,dataset,overview_dataset) { | |
350 var initial_ranges = { | |
351 "xaxis":{ | |
352 "from":from, | |
353 "to":to, | |
354 }, | |
355 }; | |
356 var dataset = dataset; | |
357 var overview_dataset = [overview_dataset]; | |
358 var choiceContainer = YUD.get("legend_choices"); | |
359 var choiceContainerTable = YUD.get("legend_choices_tables"); | |
360 var plotContainer = YUD.get('commit_history'); | |
361 var overviewContainer = YUD.get('overview'); | |
362 | |
363 var plot_options = { | |
364 bars: {show:true,align:'center',lineWidth:4}, | |
365 legend: {show:true, container:"legend_container"}, | |
366 points: {show:true,radius:0,fill:false}, | |
367 yaxis: {tickDecimals:0,}, | |
368 xaxis: { | |
369 mode: "time", | |
370 timeformat: "%d/%m", | |
371 min:from, | |
372 max:to, | |
373 }, | |
374 grid: { | |
375 hoverable: true, | |
376 clickable: true, | |
377 autoHighlight:true, | |
378 color: "#999" | |
379 }, | |
380 //selection: {mode: "x"} | |
381 }; | |
382 var overview_options = { | |
383 legend:{show:false}, | |
384 bars: {show:true,barWidth: 2,}, | |
385 shadowSize: 0, | |
386 xaxis: {mode: "time", timeformat: "%d/%m/%y",}, | |
387 yaxis: {ticks: 3, min: 0,tickDecimals:0,}, | |
388 grid: {color: "#999",}, | |
389 selection: {mode: "x"} | |
390 }; | |
391 | |
392 /** | |
393 *get dummy data needed in few places | |
394 */ | |
395 function getDummyData(label){ | |
396 return {"label":label, | |
397 "data":[{"time":0, | |
398 "commits":0, | |
399 "added":0, | |
400 "changed":0, | |
401 "removed":0, | |
402 }], | |
403 "schema":["commits"], | |
404 "color":'#ffffff', | |
405 } | |
406 } | |
407 | |
408 /** | |
409 * generate checkboxes accordindly to data | |
410 * @param keys | |
411 * @returns | |
412 */ | |
413 function generateCheckboxes(data) { | |
414 //append checkboxes | |
415 var i = 0; | |
416 choiceContainerTable.innerHTML = ''; | |
417 for(var pos in data) { | |
418 | |
419 data[pos].color = i; | |
420 i++; | |
421 if(data[pos].label != ''){ | |
422 choiceContainerTable.innerHTML += '<tr><td>'+ | |
423 '<input type="checkbox" name="' + data[pos].label +'" checked="checked" />' | |
424 +data[pos].label+ | |
425 '</td></tr>'; | |
426 } | |
427 } | |
428 } | |
429 | |
430 /** | |
431 * ToolTip show | |
432 */ | |
433 function showTooltip(x, y, contents) { | |
434 var div=document.getElementById('tooltip'); | |
435 if(!div) { | |
436 div = document.createElement('div'); | |
437 div.id="tooltip"; | |
438 div.style.position="absolute"; | |
439 div.style.border='1px solid #fdd'; | |
440 div.style.padding='2px'; | |
441 div.style.backgroundColor='#fee'; | |
442 document.body.appendChild(div); | |
443 } | |
444 YUD.setStyle(div, 'opacity', 0); | |
445 div.innerHTML = contents; | |
446 div.style.top=(y + 5) + "px"; | |
447 div.style.left=(x + 5) + "px"; | |
448 | |
449 var anim = new YAHOO.util.Anim(div, {opacity: {to: 0.8}}, 0.2); | |
450 anim.animate(); | |
451 } | |
452 | |
453 /** | |
454 * This function will detect if selected period has some changesets | |
455 for this user if it does this data is then pushed for displaying | |
456 Additionally it will only display users that are selected by the checkbox | |
457 */ | |
458 function getDataAccordingToRanges(ranges) { | |
459 | |
460 var data = []; | |
461 var new_dataset = {}; | |
462 var keys = []; | |
463 var max_commits = 0; | |
464 for(var key in dataset){ | |
465 | |
466 for(var ds in dataset[key].data){ | |
467 commit_data = dataset[key].data[ds]; | |
468 if (commit_data.time >= ranges.xaxis.from && commit_data.time <= ranges.xaxis.to){ | |
469 | |
470 if(new_dataset[key] === undefined){ | |
471 new_dataset[key] = {data:[],schema:["commits"],label:key}; | |
472 } | |
473 new_dataset[key].data.push(commit_data); | |
474 } | |
475 } | |
476 if (new_dataset[key] !== undefined){ | |
477 data.push(new_dataset[key]); | |
478 } | |
479 } | |
480 | |
481 if (data.length > 0){ | |
482 return data; | |
483 } | |
484 else{ | |
485 //just return dummy data for graph to plot itself | |
486 return [getDummyData('')]; | |
487 } | |
488 } | |
489 | |
490 /** | |
491 * redraw using new checkbox data | |
492 */ | |
493 function plotchoiced(e,args){ | |
494 var cur_data = args[0]; | |
495 var cur_ranges = args[1]; | |
496 | |
497 var new_data = []; | |
498 var inputs = choiceContainer.getElementsByTagName("input"); | |
499 | |
500 //show only checked labels | |
501 for(var i=0; i<inputs.length; i++) { | |
502 var checkbox_key = inputs[i].name; | |
503 | |
504 if(inputs[i].checked){ | |
505 for(var d in cur_data){ | |
506 if(cur_data[d].label == checkbox_key){ | |
507 new_data.push(cur_data[d]); | |
508 } | |
509 } | |
510 } | |
511 else{ | |
512 //push dummy data to not hide the label | |
513 new_data.push(getDummyData(checkbox_key)); | |
514 } | |
515 } | |
516 | |
517 var new_options = YAHOO.lang.merge(plot_options, { | |
518 xaxis: { | |
519 min: cur_ranges.xaxis.from, | |
520 max: cur_ranges.xaxis.to, | |
521 mode:"time", | |
522 timeformat: "%d/%m", | |
523 }, | |
524 }); | |
525 if (!new_data){ | |
526 new_data = [[0,1]]; | |
527 } | |
528 // do the zooming | |
529 plot = YAHOO.widget.Flot(plotContainer, new_data, new_options); | |
530 | |
531 plot.subscribe("plotselected", plotselected); | |
532 | |
533 //resubscribe plothover | |
534 plot.subscribe("plothover", plothover); | |
535 | |
536 // don't fire event on the overview to prevent eternal loop | |
537 overview.setSelection(cur_ranges, true); | |
538 | |
539 } | |
540 | |
541 /** | |
542 * plot only selected items from overview | |
543 * @param ranges | |
544 * @returns | |
545 */ | |
546 function plotselected(ranges,cur_data) { | |
547 //updates the data for new plot | |
548 var data = getDataAccordingToRanges(ranges); | |
549 generateCheckboxes(data); | |
550 | |
551 var new_options = YAHOO.lang.merge(plot_options, { | |
552 xaxis: { | |
553 min: ranges.xaxis.from, | |
554 max: ranges.xaxis.to, | |
555 mode:"time", | |
556 timeformat: "%d/%m", | |
557 }, | |
558 }); | |
559 // do the zooming | |
560 plot = YAHOO.widget.Flot(plotContainer, data, new_options); | |
561 | |
562 plot.subscribe("plotselected", plotselected); | |
563 | |
564 //resubscribe plothover | |
565 plot.subscribe("plothover", plothover); | |
566 | |
567 // don't fire event on the overview to prevent eternal loop | |
568 overview.setSelection(ranges, true); | |
569 | |
570 //resubscribe choiced | |
571 YUE.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, ranges]); | |
572 } | |
573 | |
574 var previousPoint = null; | |
575 | |
576 function plothover(o) { | |
577 var pos = o.pos; | |
578 var item = o.item; | |
579 | |
580 //YUD.get("x").innerHTML = pos.x.toFixed(2); | |
581 //YUD.get("y").innerHTML = pos.y.toFixed(2); | |
582 if (item) { | |
583 if (previousPoint != item.datapoint) { | |
584 previousPoint = item.datapoint; | |
585 | |
586 var tooltip = YUD.get("tooltip"); | |
587 if(tooltip) { | |
588 tooltip.parentNode.removeChild(tooltip); | |
589 } | |
590 var x = item.datapoint.x.toFixed(2); | |
591 var y = item.datapoint.y.toFixed(2); | |
592 | |
593 if (!item.series.label){ | |
594 item.series.label = 'commits'; | |
595 } | |
596 var d = new Date(x*1000); | |
597 var fd = d.toDateString() | |
598 var nr_commits = parseInt(y); | |
599 | |
600 var cur_data = dataset[item.series.label].data[item.dataIndex]; | |
601 var added = cur_data.added; | |
602 var changed = cur_data.changed; | |
603 var removed = cur_data.removed; | |
604 | |
605 var nr_commits_suffix = " ${_('commits')} "; | |
606 var added_suffix = " ${_('files added')} "; | |
607 var changed_suffix = " ${_('files changed')} "; | |
608 var removed_suffix = " ${_('files removed')} "; | |
609 | |
610 | |
611 if(nr_commits == 1){nr_commits_suffix = " ${_('commit')} ";} | |
612 if(added==1){added_suffix=" ${_('file added')} ";} | |
613 if(changed==1){changed_suffix=" ${_('file changed')} ";} | |
614 if(removed==1){removed_suffix=" ${_('file removed')} ";} | |
615 | |
616 showTooltip(item.pageX, item.pageY, item.series.label + " on " + fd | |
617 +'<br/>'+ | |
618 nr_commits + nr_commits_suffix+'<br/>'+ | |
619 added + added_suffix +'<br/>'+ | |
620 changed + changed_suffix + '<br/>'+ | |
621 removed + removed_suffix + '<br/>'); | |
622 } | |
623 } | |
624 else { | |
625 var tooltip = YUD.get("tooltip"); | |
626 | |
627 if(tooltip) { | |
628 tooltip.parentNode.removeChild(tooltip); | |
629 } | |
630 previousPoint = null; | |
631 } | |
632 } | |
633 | |
634 /** | |
635 * MAIN EXECUTION | |
636 */ | |
637 | |
638 var data = getDataAccordingToRanges(initial_ranges); | |
639 generateCheckboxes(data); | |
640 | |
641 //main plot | |
642 var plot = YAHOO.widget.Flot(plotContainer,data,plot_options); | |
643 | |
644 //overview | |
645 var overview = YAHOO.widget.Flot(overviewContainer, | |
646 overview_dataset, overview_options); | |
647 | |
648 //show initial selection on overview | |
649 overview.setSelection(initial_ranges); | |
650 | |
651 plot.subscribe("plotselected", plotselected); | |
652 plot.subscribe("plothover", plothover) | |
653 | |
654 overview.subscribe("plotselected", function (ranges) { | |
655 plot.setSelection(ranges); | |
656 }); | |
657 | |
658 YUE.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, initial_ranges]); | |
659 } | |
660 SummaryPlot(${c.ts_min},${c.ts_max},${c.commit_data|n},${c.overview_data|n}); | |
661 </script> | |
662 | |
663 </div> | 201 </div> |
664 </div> | 202 </div> |
665 | 203 %endif |
666 <div class="box"> | 204 |
205 <div class="box"> | |
667 <div class="title"> | 206 <div class="title"> |
668 <div class="breadcrumbs">${h.link_to(_('Shortlog'),h.url('shortlog_home',repo_name=c.repo_name))}</div> | 207 <div class="breadcrumbs"> |
669 </div> | 208 %if c.repo_changesets: |
209 ${h.link_to(_('Shortlog'),h.url('shortlog_home',repo_name=c.repo_name))} | |
210 %else: | |
211 ${_('Quick start')} | |
212 %endif | |
213 </div> | |
214 </div> | |
670 <div class="table"> | 215 <div class="table"> |
671 <div id="shortlog_data"> | 216 <div id="shortlog_data"> |
672 <%include file='../shortlog/shortlog_data.html'/> | 217 <%include file='../shortlog/shortlog_data.html'/> |
673 </div> | 218 </div> |
674 ##%if c.repo_changesets: | |
675 ## ${h.link_to(_('show more'),h.url('changelog_home',repo_name=c.repo_name))} | |
676 ##%endif | |
677 </div> | 219 </div> |
678 </div> | 220 </div> |
679 <div class="box"> | 221 |
680 <div class="title"> | 222 %if c.readme_data: |
681 <div class="breadcrumbs">${h.link_to(_('Tags'),h.url('tags_home',repo_name=c.repo_name))}</div> | 223 <div class="box" style="background-color: #FAFAFA"> |
682 </div> | 224 <div id="readme" class="title"> |
683 <div class="table"> | 225 <div class="breadcrumbs"><a href="${h.url('files_home',repo_name=c.repo_name,revision='tip',f_path=c.readme_file)}">${c.readme_file}</a></div> |
684 <%include file='../tags/tags_data.html'/> | 226 </div> |
685 %if c.repo_changesets: | 227 <div class="readme"> |
686 ${h.link_to(_('show more'),h.url('tags_home',repo_name=c.repo_name))} | 228 <div class="readme_box"> |
687 %endif | 229 ${c.readme_data|n} |
230 </div> | |
688 </div> | 231 </div> |
689 </div> | 232 </div> |
690 <div class="box"> | 233 %endif |
691 <div class="title"> | 234 |
692 <div class="breadcrumbs">${h.link_to(_('Branches'),h.url('branches_home',repo_name=c.repo_name))}</div> | 235 <script type="text/javascript"> |
693 </div> | 236 var clone_url = 'clone_url'; |
694 <div class="table"> | 237 YUE.on(clone_url,'click',function(e){ |
695 <%include file='../branches/branches_data.html'/> | 238 if(YUD.hasClass(clone_url,'selected')){ |
696 %if c.repo_changesets: | 239 return |
697 ${h.link_to(_('show more'),h.url('branches_home',repo_name=c.repo_name))} | 240 } |
698 %endif | 241 else{ |
699 </div> | 242 YUD.addClass(clone_url,'selected'); |
700 </div> | 243 YUD.get(clone_url).select(); |
701 | 244 } |
702 </%def> | 245 }) |
246 | |
247 YUE.on('clone_by_name','click',function(e){ | |
248 // show url by name and hide name button | |
249 YUD.setStyle('clone_url','display',''); | |
250 YUD.setStyle('clone_by_name','display','none'); | |
251 | |
252 // hide url by id and show name button | |
253 YUD.setStyle('clone_by_id','display',''); | |
254 YUD.setStyle('clone_url_id','display','none'); | |
255 | |
256 }) | |
257 YUE.on('clone_by_id','click',function(e){ | |
258 | |
259 // show url by id and hide id button | |
260 YUD.setStyle('clone_by_id','display','none'); | |
261 YUD.setStyle('clone_url_id','display',''); | |
262 | |
263 // hide url by name and show id button | |
264 YUD.setStyle('clone_by_name','display',''); | |
265 YUD.setStyle('clone_url','display','none'); | |
266 }) | |
267 | |
268 | |
269 var tmpl_links = {}; | |
270 %for cnt,archive in enumerate(c.rhodecode_repo._get_archives()): | |
271 tmpl_links["${archive['type']}"] = '${h.link_to('__NAME__', h.url('files_archive_home',repo_name=c.dbrepo.repo_name, fname='__CS__'+archive['extension'],subrepos='__SUB__'),class_='archive_icon ui-btn')}'; | |
272 %endfor | |
273 | |
274 YUE.on(['download_options','archive_subrepos'],'change',function(e){ | |
275 var sm = YUD.get('download_options'); | |
276 var new_cs = sm.options[sm.selectedIndex]; | |
277 | |
278 for(k in tmpl_links){ | |
279 var s = YUD.get(k+'_link'); | |
280 if(s){ | |
281 var title_tmpl = "${_('Download %s as %s') % ('__CS_NAME__','__CS_EXT__')}"; | |
282 title_tmpl= title_tmpl.replace('__CS_NAME__',new_cs.text); | |
283 title_tmpl = title_tmpl.replace('__CS_EXT__',k); | |
284 | |
285 var url = tmpl_links[k].replace('__CS__',new_cs.value); | |
286 var subrepos = YUD.get('archive_subrepos').checked; | |
287 url = url.replace('__SUB__',subrepos); | |
288 url = url.replace('__NAME__',title_tmpl); | |
289 s.innerHTML = url | |
290 } | |
291 } | |
292 }); | |
293 </script> | |
294 %if c.show_stats: | |
295 <script type="text/javascript"> | |
296 var data = ${c.trending_languages|n}; | |
297 var total = 0; | |
298 var no_data = true; | |
299 var tbl = document.createElement('table'); | |
300 tbl.setAttribute('class','trending_language_tbl'); | |
301 var cnt = 0; | |
302 for (var i=0;i<data.length;i++){ | |
303 total+= data[i][1].count; | |
304 } | |
305 for (var i=0;i<data.length;i++){ | |
306 cnt += 1; | |
307 no_data = false; | |
308 | |
309 var hide = cnt>2; | |
310 var tr = document.createElement('tr'); | |
311 if (hide){ | |
312 tr.setAttribute('style','display:none'); | |
313 tr.setAttribute('class','stats_hidden'); | |
314 } | |
315 var k = data[i][0]; | |
316 var obj = data[i][1]; | |
317 var percentage = Math.round((obj.count/total*100),2); | |
318 | |
319 var td1 = document.createElement('td'); | |
320 td1.width = 150; | |
321 var trending_language_label = document.createElement('div'); | |
322 trending_language_label.innerHTML = obj.desc+" ("+k+")"; | |
323 td1.appendChild(trending_language_label); | |
324 | |
325 var td2 = document.createElement('td'); | |
326 td2.setAttribute('style','padding-right:14px !important'); | |
327 var trending_language = document.createElement('div'); | |
328 var nr_files = obj.count+" ${_('files')}"; | |
329 | |
330 trending_language.title = k+" "+nr_files; | |
331 | |
332 if (percentage>22){ | |
333 trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"% "+nr_files+ "</b>"; | |
334 } | |
335 else{ | |
336 trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"%</b>"; | |
337 } | |
338 | |
339 trending_language.setAttribute("class", 'trending_language top-right-rounded-corner bottom-right-rounded-corner'); | |
340 trending_language.style.width=percentage+"%"; | |
341 td2.appendChild(trending_language); | |
342 | |
343 tr.appendChild(td1); | |
344 tr.appendChild(td2); | |
345 tbl.appendChild(tr); | |
346 if(cnt == 3){ | |
347 var show_more = document.createElement('tr'); | |
348 var td = document.createElement('td'); | |
349 lnk = document.createElement('a'); | |
350 | |
351 lnk.href='#'; | |
352 lnk.innerHTML = "${_('show more')}"; | |
353 lnk.id='code_stats_show_more'; | |
354 td.appendChild(lnk); | |
355 | |
356 show_more.appendChild(td); | |
357 show_more.appendChild(document.createElement('td')); | |
358 tbl.appendChild(show_more); | |
359 } | |
360 | |
361 } | |
362 | |
363 YUD.get('lang_stats').appendChild(tbl); | |
364 YUE.on('code_stats_show_more','click',function(){ | |
365 l = YUD.getElementsByClassName('stats_hidden') | |
366 for (e in l){ | |
367 YUD.setStyle(l[e],'display',''); | |
368 }; | |
369 YUD.setStyle(YUD.get('code_stats_show_more'), | |
370 'display','none'); | |
371 }); | |
372 </script> | |
373 <script type="text/javascript"> | |
374 /** | |
375 * Plots summary graph | |
376 * | |
377 * @class SummaryPlot | |
378 * @param {from} initial from for detailed graph | |
379 * @param {to} initial to for detailed graph | |
380 * @param {dataset} | |
381 * @param {overview_dataset} | |
382 */ | |
383 function SummaryPlot(from,to,dataset,overview_dataset) { | |
384 var initial_ranges = { | |
385 "xaxis":{ | |
386 "from":from, | |
387 "to":to, | |
388 }, | |
389 }; | |
390 var dataset = dataset; | |
391 var overview_dataset = [overview_dataset]; | |
392 var choiceContainer = YUD.get("legend_choices"); | |
393 var choiceContainerTable = YUD.get("legend_choices_tables"); | |
394 var plotContainer = YUD.get('commit_history'); | |
395 var overviewContainer = YUD.get('overview'); | |
396 | |
397 var plot_options = { | |
398 bars: {show:true,align:'center',lineWidth:4}, | |
399 legend: {show:true, container:"legend_container"}, | |
400 points: {show:true,radius:0,fill:false}, | |
401 yaxis: {tickDecimals:0,}, | |
402 xaxis: { | |
403 mode: "time", | |
404 timeformat: "%d/%m", | |
405 min:from, | |
406 max:to, | |
407 }, | |
408 grid: { | |
409 hoverable: true, | |
410 clickable: true, | |
411 autoHighlight:true, | |
412 color: "#999" | |
413 }, | |
414 //selection: {mode: "x"} | |
415 }; | |
416 var overview_options = { | |
417 legend:{show:false}, | |
418 bars: {show:true,barWidth: 2,}, | |
419 shadowSize: 0, | |
420 xaxis: {mode: "time", timeformat: "%d/%m/%y",}, | |
421 yaxis: {ticks: 3, min: 0,tickDecimals:0,}, | |
422 grid: {color: "#999",}, | |
423 selection: {mode: "x"} | |
424 }; | |
425 | |
426 /** | |
427 *get dummy data needed in few places | |
428 */ | |
429 function getDummyData(label){ | |
430 return {"label":label, | |
431 "data":[{"time":0, | |
432 "commits":0, | |
433 "added":0, | |
434 "changed":0, | |
435 "removed":0, | |
436 }], | |
437 "schema":["commits"], | |
438 "color":'#ffffff', | |
439 } | |
440 } | |
441 | |
442 /** | |
443 * generate checkboxes accordindly to data | |
444 * @param keys | |
445 * @returns | |
446 */ | |
447 function generateCheckboxes(data) { | |
448 //append checkboxes | |
449 var i = 0; | |
450 choiceContainerTable.innerHTML = ''; | |
451 for(var pos in data) { | |
452 | |
453 data[pos].color = i; | |
454 i++; | |
455 if(data[pos].label != ''){ | |
456 choiceContainerTable.innerHTML += | |
457 '<tr><td><input type="checkbox" id="id_user_{0}" name="{0}" checked="checked" /> \ | |
458 <label for="id_user_{0}">{0}</label></td></tr>'.format(data[pos].label); | |
459 } | |
460 } | |
461 } | |
462 | |
463 /** | |
464 * ToolTip show | |
465 */ | |
466 function showTooltip(x, y, contents) { | |
467 var div=document.getElementById('tooltip'); | |
468 if(!div) { | |
469 div = document.createElement('div'); | |
470 div.id="tooltip"; | |
471 div.style.position="absolute"; | |
472 div.style.border='1px solid #fdd'; | |
473 div.style.padding='2px'; | |
474 div.style.backgroundColor='#fee'; | |
475 document.body.appendChild(div); | |
476 } | |
477 YUD.setStyle(div, 'opacity', 0); | |
478 div.innerHTML = contents; | |
479 div.style.top=(y + 5) + "px"; | |
480 div.style.left=(x + 5) + "px"; | |
481 | |
482 var anim = new YAHOO.util.Anim(div, {opacity: {to: 0.8}}, 0.2); | |
483 anim.animate(); | |
484 } | |
485 | |
486 /** | |
487 * This function will detect if selected period has some changesets | |
488 for this user if it does this data is then pushed for displaying | |
489 Additionally it will only display users that are selected by the checkbox | |
490 */ | |
491 function getDataAccordingToRanges(ranges) { | |
492 | |
493 var data = []; | |
494 var new_dataset = {}; | |
495 var keys = []; | |
496 var max_commits = 0; | |
497 for(var key in dataset){ | |
498 | |
499 for(var ds in dataset[key].data){ | |
500 commit_data = dataset[key].data[ds]; | |
501 if (commit_data.time >= ranges.xaxis.from && commit_data.time <= ranges.xaxis.to){ | |
502 | |
503 if(new_dataset[key] === undefined){ | |
504 new_dataset[key] = {data:[],schema:["commits"],label:key}; | |
505 } | |
506 new_dataset[key].data.push(commit_data); | |
507 } | |
508 } | |
509 if (new_dataset[key] !== undefined){ | |
510 data.push(new_dataset[key]); | |
511 } | |
512 } | |
513 | |
514 if (data.length > 0){ | |
515 return data; | |
516 } | |
517 else{ | |
518 //just return dummy data for graph to plot itself | |
519 return [getDummyData('')]; | |
520 } | |
521 } | |
522 | |
523 /** | |
524 * redraw using new checkbox data | |
525 */ | |
526 function plotchoiced(e,args){ | |
527 var cur_data = args[0]; | |
528 var cur_ranges = args[1]; | |
529 | |
530 var new_data = []; | |
531 var inputs = choiceContainer.getElementsByTagName("input"); | |
532 | |
533 //show only checked labels | |
534 for(var i=0; i<inputs.length; i++) { | |
535 var checkbox_key = inputs[i].name; | |
536 | |
537 if(inputs[i].checked){ | |
538 for(var d in cur_data){ | |
539 if(cur_data[d].label == checkbox_key){ | |
540 new_data.push(cur_data[d]); | |
541 } | |
542 } | |
543 } | |
544 else{ | |
545 //push dummy data to not hide the label | |
546 new_data.push(getDummyData(checkbox_key)); | |
547 } | |
548 } | |
549 | |
550 var new_options = YAHOO.lang.merge(plot_options, { | |
551 xaxis: { | |
552 min: cur_ranges.xaxis.from, | |
553 max: cur_ranges.xaxis.to, | |
554 mode:"time", | |
555 timeformat: "%d/%m", | |
556 }, | |
557 }); | |
558 if (!new_data){ | |
559 new_data = [[0,1]]; | |
560 } | |
561 // do the zooming | |
562 plot = YAHOO.widget.Flot(plotContainer, new_data, new_options); | |
563 | |
564 plot.subscribe("plotselected", plotselected); | |
565 | |
566 //resubscribe plothover | |
567 plot.subscribe("plothover", plothover); | |
568 | |
569 // don't fire event on the overview to prevent eternal loop | |
570 overview.setSelection(cur_ranges, true); | |
571 | |
572 } | |
573 | |
574 /** | |
575 * plot only selected items from overview | |
576 * @param ranges | |
577 * @returns | |
578 */ | |
579 function plotselected(ranges,cur_data) { | |
580 //updates the data for new plot | |
581 var data = getDataAccordingToRanges(ranges); | |
582 generateCheckboxes(data); | |
583 | |
584 var new_options = YAHOO.lang.merge(plot_options, { | |
585 xaxis: { | |
586 min: ranges.xaxis.from, | |
587 max: ranges.xaxis.to, | |
588 mode:"time", | |
589 timeformat: "%d/%m", | |
590 }, | |
591 }); | |
592 // do the zooming | |
593 plot = YAHOO.widget.Flot(plotContainer, data, new_options); | |
594 | |
595 plot.subscribe("plotselected", plotselected); | |
596 | |
597 //resubscribe plothover | |
598 plot.subscribe("plothover", plothover); | |
599 | |
600 // don't fire event on the overview to prevent eternal loop | |
601 overview.setSelection(ranges, true); | |
602 | |
603 //resubscribe choiced | |
604 YUE.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, ranges]); | |
605 } | |
606 | |
607 var previousPoint = null; | |
608 | |
609 function plothover(o) { | |
610 var pos = o.pos; | |
611 var item = o.item; | |
612 | |
613 //YUD.get("x").innerHTML = pos.x.toFixed(2); | |
614 //YUD.get("y").innerHTML = pos.y.toFixed(2); | |
615 if (item) { | |
616 if (previousPoint != item.datapoint) { | |
617 previousPoint = item.datapoint; | |
618 | |
619 var tooltip = YUD.get("tooltip"); | |
620 if(tooltip) { | |
621 tooltip.parentNode.removeChild(tooltip); | |
622 } | |
623 var x = item.datapoint.x.toFixed(2); | |
624 var y = item.datapoint.y.toFixed(2); | |
625 | |
626 if (!item.series.label){ | |
627 item.series.label = 'commits'; | |
628 } | |
629 var d = new Date(x*1000); | |
630 var fd = d.toDateString() | |
631 var nr_commits = parseInt(y); | |
632 | |
633 var cur_data = dataset[item.series.label].data[item.dataIndex]; | |
634 var added = cur_data.added; | |
635 var changed = cur_data.changed; | |
636 var removed = cur_data.removed; | |
637 | |
638 var nr_commits_suffix = " ${_('commits')} "; | |
639 var added_suffix = " ${_('files added')} "; | |
640 var changed_suffix = " ${_('files changed')} "; | |
641 var removed_suffix = " ${_('files removed')} "; | |
642 | |
643 | |
644 if(nr_commits == 1){nr_commits_suffix = " ${_('commit')} ";} | |
645 if(added==1){added_suffix=" ${_('file added')} ";} | |
646 if(changed==1){changed_suffix=" ${_('file changed')} ";} | |
647 if(removed==1){removed_suffix=" ${_('file removed')} ";} | |
648 | |
649 showTooltip(item.pageX, item.pageY, item.series.label + " on " + fd | |
650 +'<br/>'+ | |
651 nr_commits + nr_commits_suffix+'<br/>'+ | |
652 added + added_suffix +'<br/>'+ | |
653 changed + changed_suffix + '<br/>'+ | |
654 removed + removed_suffix + '<br/>'); | |
655 } | |
656 } | |
657 else { | |
658 var tooltip = YUD.get("tooltip"); | |
659 | |
660 if(tooltip) { | |
661 tooltip.parentNode.removeChild(tooltip); | |
662 } | |
663 previousPoint = null; | |
664 } | |
665 } | |
666 | |
667 /** | |
668 * MAIN EXECUTION | |
669 */ | |
670 | |
671 var data = getDataAccordingToRanges(initial_ranges); | |
672 generateCheckboxes(data); | |
673 | |
674 //main plot | |
675 var plot = YAHOO.widget.Flot(plotContainer,data,plot_options); | |
676 | |
677 //overview | |
678 var overview = YAHOO.widget.Flot(overviewContainer, | |
679 overview_dataset, overview_options); | |
680 | |
681 //show initial selection on overview | |
682 overview.setSelection(initial_ranges); | |
683 | |
684 plot.subscribe("plotselected", plotselected); | |
685 plot.subscribe("plothover", plothover) | |
686 | |
687 overview.subscribe("plotselected", function (ranges) { | |
688 plot.setSelection(ranges); | |
689 }); | |
690 | |
691 // user choices on overview | |
692 YUE.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, initial_ranges]); | |
693 } | |
694 SummaryPlot(${c.ts_min},${c.ts_max},${c.commit_data|n},${c.overview_data|n}); | |
695 </script> | |
696 %endif | |
697 | |
698 </%def> |