summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/templates/dirinfo.html
blob: 7819894b6516321bad41423bf7f0f3119e3a9ade (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
{% extends "basebuildpage.html" %}
{% block extraheadcontent %}
{% load static %}
<link rel="stylesheet" href="{% static 'css/jquery.treetable.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'css/jquery.treetable.theme.toaster.css' %}" type="text/css">
{% endblock extraheadcontent %}

{% block localbreadcrumb %}
<li>{{target.target}}</li>
{% endblock localbreadcrumb%}

{% block buildinfomain %}

{% load static %}
<script src="{% static 'js/jquery.treetable.js' %}">
</script>
{% load projecttags %}

<script type='text/javascript'>
    function setupTreetable() {
        $("#dirtable").treetable({
            expandable: true,
            branchAttr: "ttBranch",
            clickableNodeNames: true,
            onNodeCollapse: function() {
                /* Do nothing, keep cached */
            },
            onNodeExpand: function() {
                var start = this.id;
                var n = $("#dirtable").treetable("node", start);
                if (this.children.length > 0) {
                    /* already was expanded once */
                    $("#dirtable").treetable("reveal", start);
                }
                else {
                    var url = "{% url "dirinfo_ajax" build.id target.id  %}";
                    $.ajax({
                        async: false,
                        type    : "GET",
                        url     : url,
                        data    : "start=" + start,
                        success : function(response) {
                            addRows(n, response)
                        },
                        error   : function(jqXHR, textStatus, errorThrown ) {alert(textStatus + ":" + errorThrown)},
                     });
                }
             },
       });
    }
    function td(data) {
        if (data == null) {
            data = '';
        }
        return '<td>' + data + '</td>'
    }

    function formatRow(o) {
        /* setup tr-wide formatting */
        var tr = '<tr class="';
        if (o.link_to != null) {
            tr += 'muted ';
        }
        if (o.isdir && o.childcount) {
            tr += 'branch" data-tt-branch="true" ';
        }
        else {
            tr += 'leaf" data-tt-branch="false" ';
        }
        tr +=    ' data-tt-id="' + o.fullpath +'" ';
        if (o.parent != "/") {
            tr +=    ' data-tt-parent-id="' + o.parent +'" ';
        }
        tr += '>';

        /* setup td specific formatting */
        var link_to = td(o.link_to);
        var size = '<td class = "sizecol">' + o.size + '</td>'
        var permission = td(o.permission);
        var owner = td(o.owner);
        var group = td(o.group);

        /* handle the name column */
        var name = null;;
        var namespan=1;
        if (o.isdir) {
            if (o.link_to == null) {
                namespan = 2;
                if (o.package == null) {
                    namespan = 3;
                }
            }
            var colspan = 'colspan="' + namespan + '"';
            name = '<td class="content-directory"' + colspan + '>';
            if (o.childcount) {
                name += '<a href="">';
            }
            name += '<i class="icon-folder-close"></i>';
            name += '&nbsp;' + o.name;
            if (o.childcount) {
                name += '</a>';
            }
            name += '</td>';
        }
        else {
            if (o.link_to == null) {
                namespan = 2;
                if (o.package == null) {
                  namespan = 3;
                }
                var colspan = 'colspan="' + namespan + '"';
                name = '<td ' + colspan + '><i class="icon-file"></i>';
            }
            else {
                name = '<td><i class="icon-hand-right"></i>';
            }
            name += '&nbsp;' + o.name;
            name += '</td>';
        }

        /* handle the package column */
        var package = null;
        if (o.package != null) {
            /* add link to included package page */
            build_id = {{ build.id }};
            target_id = {{ target.id }};
            /* Create a url for a dummy package id of 0 */
            dummy = "{% url 'package_included_detail' build.id target.id 0 %}"
            /* fill in the package id */
            url = dummy.substr(0, dummy.length-1) + o.package_id;
            package = '<a href=' + url + '>' ;
            package += o.package;
            package += '</a>';
            if (o.installed_package != o.package) {
                /* make class muted and add hover help */
                package += '<span class="muted"> as ' + o.installed_package + ' </span>';
                package += '<i class="icon-question-sign get-help hover-help" ';
                package += 'title="' + o.package + ' was renamed at packaging time and was installed in your image as ' + o.installed_package + '">';
                package += '</i>';
            }
        }
        package = td(package);

        var cols1to3;
        switch (namespan) {
            case 3:
                cols1to3 = name;
                break;
            case  2:
                cols1to3 = name + package;
                break;
            default:
                cols1to3 = name + link_to + package;
        }
        r = tr + cols1to3 + size + permission + owner + group + "</tr>"
        return r;
    }

    function addRows(n, objs) {
        rows = "";
        for (i=0; i<objs.length; i++) {
            rows += formatRow(objs[i]);
        }
        $("#dirtable").treetable("loadBranch", n, rows);
    }

    $.fn.isOffScreen = function(){
        var win = $(window);
        viewportBottom = win.scrollTop() + win.height();
        
        var bounds = this.offset();
        bounds.bottom = bounds.top + this.outerHeight();
        
        return (bounds.bottom > viewportBottom);
    };

    function selectRow(path) {
        var row  = $('tr[data-tt-id="' + path + '"]');
        row.addClass(" highlight");
        if (row.isOffScreen()) {
            $('html, body').animate({ scrollTop: row.offset().top - 150}, 2000);
        }
    }
</script>

<div class="span10">

    <div class="page-header">
        <h1> {{target.target}} </h1>
    </div>

    <ul class="nav nav-pills">
        <li class="">
            <a href="{% url 'target' build.id target.id %}">
            <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>
                Packages included ({{target.package_count}} - {{packages_sum|filtered_filesizeformat}})
            </a>
        </li>
        <li class="active">
            <a href="{% url 'dirinfo' build.id target.id %}">
                <i class="icon-question-sign get-help" title="The directories and files in the root file system of this image"></i>
                Directory structure
            </a>
        </li>
    </ul>

    <div id="directory-structure" class="tab-pane active">
        <table id="dirtable" class="table table-bordered table-hover treetable">
            <thead>
                <tr>
                    <th>Directory / File</th>
                    <th>Symbolic link to</th>
                    <th>Source package</th>
                    <th class="narrow-col">Size</th>
                    <th class="medium-col">Permissions</th>
                    <th class="narrow-col">Owner</th>
                    <th class="narrow-col">Group</th>
                </tr>
            </thead>
            <tbody>
            <script type='text/javascript'>
                setupTreetable();
                addRows(null, {{ objects|safe }} );
                {% if file_path %}
                    {% comment %}
                        link from package_included_detail specifies file path
                    {% endcomment %}
                    {% for dir_elem in dir_list %}
                        $("#dirtable").treetable("expandNode", "{{dir_elem}}");
                    {% endfor %}
                    selectRow("{{file_path}}");
                {% endif %}
            </script>
            </tbody>
        </table>
    </div> <!-- directory-structure -->
</div> <!-- span10 -->

{% endblock buildinfomain %}