blob: ecb46bf7ab740aa2152deca540ab45d513b53b1a [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001{% extends "basebuildpage.html" %}
Patrick Williamsf1e5d692016-03-30 15:21:19 -05002{% block title %} Directory structure - {{ target.target }} {{ build.machine }} - {{ build.project.name }} - Toaster {% endblock %}
Patrick Williamsc124f4f2015-09-15 14:41:29 -05003{% block extraheadcontent %}
4{% load static %}
5<link rel="stylesheet" href="{% static 'css/jquery.treetable.css' %}" type="text/css">
6<link rel="stylesheet" href="{% static 'css/jquery.treetable.theme.toaster.css' %}" type="text/css">
7{% endblock extraheadcontent %}
8
9{% block localbreadcrumb %}
10<li>{{target.target}}</li>
11{% endblock localbreadcrumb%}
12
13{% block buildinfomain %}
14
15{% load static %}
16<script src="{% static 'js/jquery.treetable.js' %}">
17</script>
18{% load projecttags %}
19
20<script type='text/javascript'>
21 function setupTreetable() {
22 $("#dirtable").treetable({
23 expandable: true,
24 branchAttr: "ttBranch",
25 clickableNodeNames: true,
26 onNodeCollapse: function() {
27 /* Do nothing, keep cached */
28 },
29 onNodeExpand: function() {
30 var start = this.id;
31 var n = $("#dirtable").treetable("node", start);
32 if (this.children.length > 0) {
33 /* already was expanded once */
34 $("#dirtable").treetable("reveal", start);
35 }
36 else {
37 var url = "{% url "dirinfo_ajax" build.id target.id %}";
38 $.ajax({
39 async: false,
40 type : "GET",
41 url : url,
42 data : "start=" + start,
43 success : function(response) {
44 addRows(n, response)
45 },
46 error : function(jqXHR, textStatus, errorThrown ) {alert(textStatus + ":" + errorThrown)},
47 });
48 }
49 },
50 });
51 }
52 function td(data) {
53 if (data == null) {
54 data = '';
55 }
56 return '<td>' + data + '</td>'
57 }
58
59 function formatRow(o) {
60 /* setup tr-wide formatting */
61 var tr = '<tr class="';
62 if (o.link_to != null) {
63 tr += 'muted ';
64 }
65 if (o.isdir && o.childcount) {
66 tr += 'branch" data-tt-branch="true" ';
67 }
68 else {
69 tr += 'leaf" data-tt-branch="false" ';
70 }
71 tr += ' data-tt-id="' + o.fullpath +'" ';
72 if (o.parent != "/") {
73 tr += ' data-tt-parent-id="' + o.parent +'" ';
74 }
75 tr += '>';
76
77 /* setup td specific formatting */
78 var link_to = td(o.link_to);
79 var size = '<td class = "sizecol">' + o.size + '</td>'
80 var permission = td(o.permission);
81 var owner = td(o.owner);
82 var group = td(o.group);
83
84 /* handle the name column */
85 var name = null;;
86 var namespan=1;
87 if (o.isdir) {
88 if (o.link_to == null) {
89 namespan = 2;
90 if (o.package == null) {
91 namespan = 3;
92 }
93 }
94 var colspan = 'colspan="' + namespan + '"';
95 name = '<td class="content-directory"' + colspan + '>';
96 if (o.childcount) {
97 name += '<a href="">';
98 }
99 name += '<i class="icon-folder-close"></i>';
100 name += '&nbsp;' + o.name;
101 if (o.childcount) {
102 name += '</a>';
103 }
104 name += '</td>';
105 }
106 else {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107 if (o.link_to == null) {
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500108 namespan = 2;
109 if (o.package == null) {
110 namespan = 3;
111 }
112 var colspan = 'colspan="' + namespan + '"';
113 name = '<td ' + colspan + '><i class="icon-file"></i>';
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114 }
115 else {
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500116 name = '<td><i class="icon-hand-right"></i>';
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117 }
118 name += '&nbsp;' + o.name;
119 name += '</td>';
120 }
121
122 /* handle the package column */
123 var package = null;
124 if (o.package != null) {
125 /* add link to included package page */
126 build_id = {{ build.id }};
127 target_id = {{ target.id }};
128 /* Create a url for a dummy package id of 0 */
129 dummy = "{% url 'package_included_detail' build.id target.id 0 %}"
130 /* fill in the package id */
131 url = dummy.substr(0, dummy.length-1) + o.package_id;
132 package = '<a href=' + url + '>' ;
133 package += o.package;
134 package += '</a>';
135 if (o.installed_package != o.package) {
136 /* make class muted and add hover help */
137 package += '<span class="muted"> as ' + o.installed_package + ' </span>';
138 package += '<i class="icon-question-sign get-help hover-help" ';
139 package += 'title="' + o.package + ' was renamed at packaging time and was installed in your image as ' + o.installed_package + '">';
140 package += '</i>';
141 }
142 }
143 package = td(package);
144
145 var cols1to3;
146 switch (namespan) {
147 case 3:
148 cols1to3 = name;
149 break;
150 case 2:
151 cols1to3 = name + package;
152 break;
153 default:
154 cols1to3 = name + link_to + package;
155 }
156 r = tr + cols1to3 + size + permission + owner + group + "</tr>"
157 return r;
158 }
159
160 function addRows(n, objs) {
161 rows = "";
162 for (i=0; i<objs.length; i++) {
163 rows += formatRow(objs[i]);
164 }
165 $("#dirtable").treetable("loadBranch", n, rows);
166 }
167
168 $.fn.isOffScreen = function(){
169 var win = $(window);
170 viewportBottom = win.scrollTop() + win.height();
171
172 var bounds = this.offset();
173 bounds.bottom = bounds.top + this.outerHeight();
174
175 return (bounds.bottom > viewportBottom);
176 };
177
178 function selectRow(path) {
179 var row = $('tr[data-tt-id="' + path + '"]');
180 row.addClass(" highlight");
181 if (row.isOffScreen()) {
182 $('html, body').animate({ scrollTop: row.offset().top - 150}, 2000);
183 }
184 }
185</script>
186
187<div class="span10">
188
189 <div class="page-header">
190 <h1> {{target.target}} </h1>
191 </div>
192
193 <ul class="nav nav-pills">
194 <li class="">
195 <a href="{% url 'target' build.id target.id %}">
196 <i class="icon-question-sign get-help" title="Of all the packages built, the subset installed in the root file system of this image"></i>
197 Packages included ({{target.package_count}} - {{packages_sum|filtered_filesizeformat}})
198 </a>
199 </li>
200 <li class="active">
201 <a href="{% url 'dirinfo' build.id target.id %}">
202 <i class="icon-question-sign get-help" title="The directories and files in the root file system of this image"></i>
203 Directory structure
204 </a>
205 </li>
206 </ul>
207
208 <div id="directory-structure" class="tab-pane active">
209 <table id="dirtable" class="table table-bordered table-hover treetable">
210 <thead>
211 <tr>
212 <th>Directory / File</th>
213 <th>Symbolic link to</th>
214 <th>Source package</th>
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500215 <th class="narrow-col">Size</th>
216 <th class="medium-col">Permissions</th>
217 <th class="narrow-col">Owner</th>
218 <th class="narrow-col">Group</th>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500219 </tr>
220 </thead>
221 <tbody>
222 <script type='text/javascript'>
223 setupTreetable();
224 addRows(null, {{ objects|safe }} );
225 {% if file_path %}
226 {% comment %}
227 link from package_included_detail specifies file path
228 {% endcomment %}
229 {% for dir_elem in dir_list %}
230 $("#dirtable").treetable("expandNode", "{{dir_elem}}");
231 {% endfor %}
232 selectRow("{{file_path}}");
233 {% endif %}
234 </script>
235 </tbody>
236 </table>
237 </div> <!-- directory-structure -->
238</div> <!-- span10 -->
239
240{% endblock buildinfomain %}
241