Commit 034d56fbc9a8660e36b70edb3e7d3c60da9fd03a
Committed by
Alessandro Palmeira
1 parent
0473aeda
Exists in
master
and in
29 other branches
[Mezuro] Drafts to repository controller and view
Showing
2 changed files
with
167 additions
and
0 deletions
Show diff stats
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
0 → 100644
... | ... | @@ -0,0 +1,43 @@ |
1 | + def processing(repository_id) | |
2 | + begin | |
3 | + if Kalibro::Processing.has_ready_processing(repository_id) | |
4 | + @processing ||= Kalibro::Processing.last_ready_processing_of(repository_id) | |
5 | + else | |
6 | + @processing = Kalibro::Processing.last_processing_of(repository_id) | |
7 | + end | |
8 | + rescue Exception => error | |
9 | + errors.add_to_base(error.message) | |
10 | + end | |
11 | + @processing | |
12 | + end | |
13 | + | |
14 | + def processing_with_date(repository_id, date) | |
15 | + begin | |
16 | + if Kalibro::Processing.has_processing_after(repository_id, date) | |
17 | + @processing ||= Kalibro::Processing.first_processing_after(repository_id, date) | |
18 | + elsif Kalibro::Processing.has_processing_before(repository_id, date) | |
19 | + @processing ||= Kalibro::Processing.last_processing_before(repository_id, date) | |
20 | + end | |
21 | + rescue Exception => error | |
22 | + errors.add_to_base(error.message) | |
23 | + end | |
24 | + @processing | |
25 | + end | |
26 | + | |
27 | + def module_result(repository_id, date = nil) | |
28 | + @processing ||= date.nil? ? processing(repository_id) : processing_with_date(repository_id, date) | |
29 | + begin | |
30 | + @module_result ||= Kalibro::ModuleResult.find(@processing.results_root_id) | |
31 | + rescue Exception => error | |
32 | + errors.add_to_base(error.message) | |
33 | + end | |
34 | + @module_result | |
35 | + end | |
36 | + | |
37 | + def result_history(module_result_id) | |
38 | + begin | |
39 | + @result_history ||= Kalibro::MetricResult.history_of(module_result_id) | |
40 | + rescue Exception => error | |
41 | + errors.add_to_base(error.message) | |
42 | + end | |
43 | + end | ... | ... |
plugins/mezuro/views/mezuro_plugin_repository/show_repository.html.erb
0 → 100644
... | ... | @@ -0,0 +1,124 @@ |
1 | +<h1> <%= _(MezuroPlugin::ProjectContent.short_description) %> </h1> | |
2 | + | |
3 | +<% | |
4 | + @project = @article.title.nil? ? nil : @article.project | |
5 | + begin | |
6 | + @repository_types = Kalibro::Repository.repository_types.sort | |
7 | + @configuration_names = Kalibro::Configuration.all_names.sort | |
8 | + rescue Exception => exception | |
9 | + @article.errors.add_to_base(exception.message) | |
10 | + @repository_types = [] | |
11 | + @configuration_names = [] | |
12 | + end | |
13 | +%> | |
14 | + | |
15 | +<%= error_messages_for 'project_content' %> | |
16 | + | |
17 | +<%= hidden_field_tag 'project_content[profile_id]', profile.id %> | |
18 | +<%= hidden_field_tag 'id', @article.id %> | |
19 | + | |
20 | +<%= required_fields_message %> | |
21 | +<% if !@project.nil? && !@article.id.nil? %> | |
22 | + <%= required f.text_field(:name, :disabled => 'true') %> | |
23 | +<% else %> | |
24 | + <%= required f.text_field(:name) %> | |
25 | +<% end %> | |
26 | + | |
27 | +<% selected = (@project.nil? ? "" : @project.license) %> | |
28 | +<%= required labelled_form_field _('License'), | |
29 | + f.select(:project_license, MezuroPlugin::Helpers::ContentViewerHelper.create_license_options ,{:selected => selected}) %><br/> | |
30 | + | |
31 | +<%= f.text_field :description %><br/> | |
32 | + | |
33 | +<% @selected = (@project.nil? ? @repository_types : @project.repository.type) %> | |
34 | +<%= required labelled_form_field _('Repository type'), | |
35 | + f.select(:repository_type, @repository_types, {:selected => @selected}) %><br/> | |
36 | + | |
37 | +<%= required f.text_field(:repository_url) %><br/> | |
38 | + | |
39 | +<% @selected = (@project.nil? ? @configuration_names[0] : @project.configuration_name) %> | |
40 | + | |
41 | +<% if !@project.nil? && !@article.id.nil? %> | |
42 | + <%= required labelled_form_field _('Configuration') + " (Changing the configuration will erase your saved periodic avaliations)", | |
43 | + f.select(:configuration_name, @configuration_names, {:selected => @selected}) %> | |
44 | +<% else %> | |
45 | + <%= required labelled_form_field _('Configuration'), | |
46 | + f.select(:configuration_name, @configuration_names, {:selected => @selected}) %><br/> | |
47 | +<% end %> | |
48 | + | |
49 | +<% selected = (@project.nil? ? 0 : @project.process_period.to_i) %> | |
50 | +<%= required labelled_form_field _('Periodic Avaliation'), | |
51 | + f.select(:periodicity_in_days, MezuroPlugin::Helpers::ContentViewerHelper.create_periodicity_options ,{:selected => selected}) %><br/> | |
52 | + | |
53 | + | |
54 | + | |
55 | + | |
56 | + | |
57 | + | |
58 | + | |
59 | + | |
60 | + ************************************* | |
61 | + | |
62 | + | |
63 | + | |
64 | + | |
65 | + <script src="/plugins/mezuro/javascripts/project_content.js" type="text/javascript"></script> | |
66 | + | |
67 | +<% @project = @page.project %> | |
68 | +<% unless @page.errors[:base].nil? %> | |
69 | + <% if @page.errors[:base] =~ /There is no project named/ %> | |
70 | + <h3>Warning:</h3> | |
71 | + <p>This project doesn't exist on the Web Service. Do you want to <%= link_to 'delete', :action => 'destroy', :controller => 'cms', :profile => @page.profile.identifier, :id => @page.id %> or <%= link_to 'save it again', :action => 'edit', :controller => 'cms', :profile => @page.profile.identifier, :id => @page.id %>?</p> | |
72 | + <% else %> | |
73 | + <%= @page.errors[:base] %> | |
74 | + <% end %> | |
75 | +<% else %> | |
76 | + | |
77 | + <table> | |
78 | + <tr> | |
79 | + <td><%= _('Name') %></td> | |
80 | + <td><%= @project.name %></td> | |
81 | + </tr> | |
82 | + <tr> | |
83 | + <td><%= _('License') %></td> | |
84 | + <td><%= @project.license %></td> | |
85 | + </tr> | |
86 | + <tr> | |
87 | + <td><%= _('Description') %></td> | |
88 | + <td><%= @project.description %></td> | |
89 | + </tr> | |
90 | + <tr> | |
91 | + <td><%= _('Repository type') %></td> | |
92 | + <td><%= @project.repository.type %></td> | |
93 | + </tr> | |
94 | + <tr> | |
95 | + <td><%= _('Repository address') %></td> | |
96 | + <td><%= @project.repository.address %></td> | |
97 | + </tr> | |
98 | + <tr> | |
99 | + <td><%= _('Configuration') %></td> | |
100 | + <td><%= @project.configuration_name %></td> | |
101 | + </tr> | |
102 | + <tr> | |
103 | + <td><%= _('Periodicity') %></td> | |
104 | + <td><%= MezuroPlugin::Helpers::ContentViewerHelper.get_periodicity_option(@page.periodicity_in_days) %></td> | |
105 | + </tr> | |
106 | + <tr> | |
107 | + <td><%= _('Status')%></td> | |
108 | + <td> | |
109 | + <div id="project-state" style="color:DarkGoldenRod"><%= @project.state %></div> | |
110 | + <div id="msg-time"></div> | |
111 | + </td> | |
112 | + </tr> | |
113 | + </table> | |
114 | + | |
115 | + <br /> | |
116 | + | |
117 | + <div id="project-result" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>" | |
118 | + data-project-name="<%= @project.name %>"> | |
119 | + </div> | |
120 | + <div id="project-tree"></div> | |
121 | + <div id="module-result"> | |
122 | + </div> | |
123 | +<% end %> | |
124 | + | ... | ... |