[webui] improve the services ui
[opensuse:build-service.git] / src / webui / app / views / package / _files_view.html.erb
1 <% # locals:
2 #   file_list: list of source files in package
3 -%>
4
5 <div id="files_view">
6
7   <% unless @files.empty? %>
8     <table cellspacing='1' id="file_table" class="tablesorter">
9
10       <!-- table header -->
11       <thead>
12         <tr>
13           <th class="header" style="min-width: 100px;">Filename</th>
14           <th class="header">Size</th>
15           <th class="header" style="min-width: 90px;">Changed</th>
16           <th>Actions</th>
17         </tr>
18       </thead>
19
20       <!-- files -->
21       <tbody>
22         <% @files.each do |file| %>
23           <tr><td>
24               <% if file[:viewable] %>
25                 <%= link_to(h(file[:name]), :action => :view_file, :project => @project, :package => @package, :file => file[:name], :srcmd5 => file[:srcmd5], :expand => params[:expand] ) %>
26               <% else %>
27                 <%= h file[:name] %>
28               <% end %>
29               <% if @link && @link.has_add_patch?( file[:name] ) %>
30                 (Added Patch)
31               <% elsif @link && @link.has_patch?( file[:name] ) %>
32                 (Global Patch)
33               <% end %>
34             </td>
35             <td><!-- <%= file[:size].rjust(10, '0') %> --><%=h human_readable_fsize( file[:size] )%></td>
36             <td><!-- <%= file[:mtime] %> --><%= fuzzy_time_string( Time.at(file[:mtime].to_i).to_s ) %></td>
37             <td><%= link_to image_tag('icons/page_white_get.png', :alt => "Download", :title => "Download File"), file_url( @project, @package, file[:name], file[:srcmd5] ) %>
38               <% unless file[:name].match(/^_service:/) %>
39                 <% if @package.can_edit?( session[:login] ) %>
40                   <%= link_to image_tag('icons/page_white_delete.png', :alt => "Remove", :title => "Remove File"), {:action => :remove_file, :project => @project,
41                     :package => @package, :filename => file[:name]},
42                     {:confirm => "Really remove file '#{file[:name]}'?", :method => :post }%>
43                 <% end %>
44               <% end %>
45             </td>
46           </tr>
47         <% end %>
48       </tbody>
49     </table>
50
51     <% if @package.can_edit?( session[:login] ) %>
52       <p><%= link_to image_tag('icons/page_white_add.png', :alt => "Add", :title => "Add File"),
53           :action => :add_file, :project => @project, :package => @package %>
54         <%= link_to 'Add File', :action => :add_file, :project => @project, :package => @package %>
55       </p>
56     <% end %>
57
58     <% if @revision && !(@revision == @current_rev)%>
59       <h3>Showing revision <%= @revision %> (current revision is <%=  @current_rev %>)</h3>
60     <% else %>
61       <h3>Showing current revision</h3>
62     <% end %>
63     <div style="margin-left: 1em">
64       Last commit: <br/>
65       <%= render :partial => 'commit_item', :locals => {:rev => @revision } %>
66     </div>
67
68     <!-- Simplified for now.
69         <p>
70         Source MD5: <%= text_field_tag :srcmd5, @files[0][:srcmd5], { :size => 33, :disabled => true } %>
71         </p>
72     -->
73   <% else %>
74     <p><i>This package has no files yet</i></p>
75
76     <% if @package.can_edit?( session[:login] ) %>
77       <p><%= link_to image_tag('icons/page_white_add.png', :alt => "Add", :title => "Add File"),
78           :action => :add_file, :project => @project, :package => @package %>
79         <%= link_to 'Add File', :action => :add_file, :project => @project, :package => @package %>
80       </p>
81     <% end %>
82   <% end %>
83
84 </div>
85