Skip to content

Commit

Permalink
Added translations for servers
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilien Bausson committed Oct 10, 2023
1 parent eb73e2c commit 45f9137
Show file tree
Hide file tree
Showing 16 changed files with 280 additions and 112 deletions.
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ GEM
letter_opener (1.8.1)
launchy (>= 2.2, < 3)
libv8-node (18.16.0.0-arm64-darwin)
libv8-node (18.16.0.0-x86_64-darwin)
libv8-node (18.16.0.0-x86_64-linux)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
Expand Down Expand Up @@ -237,6 +238,8 @@ GEM
nio4r (2.5.9)
nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
omniauth (2.1.1)
Expand Down Expand Up @@ -480,6 +483,7 @@ GEM

PLATFORMS
arm64-darwin-22
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand Down
10 changes: 5 additions & 5 deletions app/views/servers/_card_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<%= f.text_field :name %>
</div>
<div class="col-sm-2">
<%= f.select :orientation, [["Horizontal, de gauche à droite", "lr-td"],
["Horizontal, de droite à gauche", "rl-td"],
["Vertical, de bas en haut", "dt-lr"],
["Vertical, de haut en bas", "td-lr"]], class: "form-control" %>
<%= f.select :orientation, [[t(".orientations.horizontal.lr"), "lr-td"],
[t(".orientations.horizontal.rl"), "rl-td"],
[t(".orientations.vertical.dt"), "dt-lr"],
[t(".orientations.vertical.td"), "td-lr"]], class: "form-control" %>
</div>
<div class="col-sm-1">
<%= f.select :first_position, 0..100, { include_blank: true } %>
Expand All @@ -42,7 +42,7 @@

<span>
<%= f.hidden_field :_destroy %>
<%= link_to "Supprimer", '#', class: "remove_fields pull-right" %>
<%= link_to t("actions.delete"), '#', class: "remove_fields pull-right" %>
</span>
</fieldset>
</li>
Expand Down
4 changes: 2 additions & 2 deletions app/views/servers/_disk_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<li class="list-group-item">
<fieldset>
<div class="col-sm-4">
<%= f.number_field :quantity, class: "form-control", placeholder: 'quantité' %>
<%= f.number_field :quantity, class: "form-control", placeholder: t(".quantity") %>
</div>
<div class="col-sm-4">
<%= f.collection_select :disk_type_id, DiskType.order(:quantity), :id, :to_s, class: "form-control" %>
</div>
<span>
<%= f.hidden_field :_destroy %>
<%= link_to "Supprimer", '#', class: "remove_fields pull-right" %>
<%= link_to t("actions.delete"), '#', class: "remove_fields pull-right" %>
</span>
</fieldset>
</li>
2 changes: 1 addition & 1 deletion app/views/servers/_document_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<span>
<%= f.hidden_field :_destroy %>
<%= link_to "Supprimer", '#', class: "remove_fields pull-right btn btn-default" %>
<%= link_to t("actions.delete"), '#', class: "remove_fields pull-right btn btn-default" %>
</span>

<span class="pull-left"><%= f.object.document.metadata['filename'] if f.object.document.present? %></span>
Expand Down
38 changes: 20 additions & 18 deletions app/views/servers/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<div class="alert alert-danger alert-dismissable" role="alert">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4><%= pluralize(@server.errors.count, "erreur", "erreurs") %> lors de la sauvegarde :</h4>
<h4>
<%= t("errors.title", count: @server.errors.count) %>
</h4>

<ul>
<% @server.errors.full_messages.each do |msg| %>
Expand All @@ -18,15 +20,15 @@
<div class="col-sm-10">
<%= f.text_field :name, class: "form-control" %>
</div>
<%= f.label 'Baie', class: "col-sm-2 control-label" %>
<%= f.label :bay, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.collection_select(:frame_id, Frame.all_sorted, :id, :name_with_room_and_islet, {:prompt => true, :include_blank => false}, {class: "form-control"}) %>
</div>
<%= f.label :position, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.number_field :position, class: "form-control" %>
</div>
<%= f.label 'Etat', class: "col-sm-2 control-label" %>
<%= f.label :state, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.collection_select(:server_state_id, ServerState.sorted, :id, :name, {:prompt => false, :include_blank => true}, {class: "form-control"}) %>
</div>
Expand All @@ -40,7 +42,7 @@
</div>
</div>
<div class="form-group col-md-6">
<%= f.label 'Service Tag', class: "col-sm-2 control-label" %>
<%= f.label :numero, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :numero, class: "form-control" %>
</div>
Expand All @@ -52,15 +54,15 @@
<div class="col-sm-10">
<%= f.collection_select(:domaine_id, Domaine.sorted, :id, :name, {:prompt => true, :include_blank => true}, {class: "form-control"}) %>
</div>
<%= f.label 'Gestionnaire', class: "col-sm-2 control-label" %>
<%= f.label :gestion_id, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.collection_select(:gestion_id, Gestion.sorted, :id, :name, {:prompt => true, :include_blank => true}, {class: "form-control"}) %>
</div>
<%= f.label 'Réseau Gb/10Gb', class: "col-sm-2 control-label text-nowrap" %>
<%= f.label :network_id, class: "col-sm-2 control-label text-nowrap" %>
<div class="col-sm-10">
<%= f.select(:network_id, [["Réseau Gb", 1], ["Réseau 10Gb", 2]], {:prompt => true, :include_blank => true}, {class: "form-control"}) %>
<%= f.select(:network_id, [[t(".network_type", type: "Gb"), 1], [t(".network_type", type: "10Gb"), 2]], {:prompt => true, :include_blank => true}, {class: "form-control"}) %>
</div>
<%= f.label 'Stack', class: "col-sm-2 control-label" %>
<%= f.label :stack, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.collection_select(:stack_id, Stack.order(:id), :id, :name, {:prompt => true, :include_blank => true}, {class: "form-control"}) %>
</div>
Expand All @@ -75,22 +77,22 @@
<li class="list-group-item">
<fieldset class="header">
<div class="col-sm-2">
Composant du modèle
<%= t(".enclosure.component") %>
</div>
<div class="col-sm-2">
Type de carte
<%= t(".enclosure.card_type") %>
</div>
<div class="col-sm-2">
Libellé
<%= t(".enclosure.label") %>
</div>
<div class="col-sm-2">
Orientation
<%= t(".enclosure.orientation") %>
</div>
<div class="col-sm-1">
Numéro du premier port
<%= t(".enclosure.first_port_name") %>
</div>
<div class="col-sm-2">
Carte jumèle
<%= t(".enclosure.twin_card") %>
</div>
</fieldset>
</li>
Expand Down Expand Up @@ -133,12 +135,12 @@
-->

<div class="form-group" style="clear:both;">
<%= f.label 'Commentaire', class: "col-sm-1 control-label" %>
<%= f.label :comment, class: "col-sm-1 control-label" %>
<div class="col-sm-11">
<%= f.text_area :comment, :style => 'width: 98%', class: "form-control" %>
</div>

<%= f.label 'Documents', class: "col-sm-1 control-label" %>
<%= f.label :documents, class: "col-sm-1 control-label" %>
<div class="col-sm-11">
<div class="panel panel-default">
<div class="col-sm-12">
Expand All @@ -152,7 +154,7 @@
</div>
</div>

<%= f.label 'Photo', class: "col-sm-1 control-label" %>
<%= f.label :photo, class: "col-sm-1 control-label" %>
<div class="col-sm-11">
<%= f.file_field :photo %>
<% if @server.photo.attached? %>
Expand All @@ -165,7 +167,7 @@

<div class="form-group" style="clear:both;">
<div class="col-sm-offset-1 col-sm-11">
<%= f.submit "Modifier ce matériel", class: "btn btn-primary" %>
<%= f.submit t(".edit_confirmation"), class: "btn btn-primary" %>
</div>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/servers/_memory_component_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<li class="list-group-item">
<fieldset>
<div class="col-sm-4">
<%= f.number_field :quantity, class: "form-control", placeholder: 'quantité' %>
<%= f.number_field :quantity, class: "form-control", placeholder: t(".quantity") %>
</div>
<div class="col-sm-4">
<%= f.collection_select :memory_type_id, MemoryType.order(:quantity), :id, :to_s, class: "form-control" %>
</div>
<span>
<%= f.hidden_field :_destroy %>
<%= link_to "Supprimer", '#', class: "remove_fields pull-right" %>
<%= link_to t("actions.delete"), '#', class: "remove_fields pull-right" %>
</span>
</fieldset>
</li>
18 changes: 12 additions & 6 deletions app/views/servers/_modal_add_element_in_frame.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Ajouter un élément</h4>
<h4 class="modal-title" id="myModalLabel">
<%= t(".title") %>
</h4>
</div>
<div class="modal-body">
<%= form_for(Server.new(:name => "PatchPanel", :modele => Modele.where("name LIKE ?", '%Panel%').first, frame: (@frame ? @frame : nil)), html: { class: "form-horizontal", role: "form" }) do |f| %>
<% if @server.try(:errors).try(:any?) %>
<div class="alert alert-danger alert-dismissable" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4><%= pluralize(@server.errors.count, "erreur", "erreurs") %> lors de la sauvegarde :</h4>
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only"><%= t("actions.close") %></span></button>
<h4>
<%= t("errors.title", count: @server.errors.count) %>
</h4>

<ul>
<% @server.errors.full_messages.each do |msg| %>
Expand All @@ -21,7 +25,7 @@
<% end %>

<div class="form-group">
<%= f.label :nom, class: "col-sm-2 control-label" %>
<%= f.label :name, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :name, class: "form-control" %>
</div>
Expand Down Expand Up @@ -63,8 +67,10 @@

<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<%= f.submit 'Confirmer',class: "btn btn-primary" %>
<button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
<%= f.submit t("actions.confirm"),class: "btn btn-primary" %>
<button type="button" class="btn btn-default" data-dismiss="modal">
<%= t("actions.cancel") %>
</button>
</div>
</div>
<% end %>
Expand Down
4 changes: 3 additions & 1 deletion app/views/servers/_room.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<% if local_assigns[:title].present? %>
<div><h3><%= title %></h3></div>
<% elsif room.present? %>
<div><h3>Salle <%= room %> - Ilot <%= islet %></h3></div>
<div><h3>
<%= t(".title", room: room, islet:) %>
</h3></div>
<% end %>

<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion app/views/servers/_slot_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<li class="list-group-item">
<fieldset>
<% label = (f.object.position ? "#{f.object.valeur} #{f.object.position}" : "Nouveau port" ) %>
<% label = (f.object.position ? "#{f.object.valeur} #{f.object.position}" : t(".new_port") ) %>
<%= f.hidden_field :_destroy %>
<%= link_to "X", '#', class: "remove_fields pull-right" %>
Expand Down
20 changes: 11 additions & 9 deletions app/views/servers/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<% provide(:title, "#{@server.modele.try(:category).try(:name)} #{@server.name} - Edition") %>
<% provide(:title, t(".page_title", modele: @server.modele.try(:category).try(:name), name: @server.name)) %>
<%= render 'layouts/breadcrumb', breadcrumb_variables: { "Salles" => overview_rooms_path,
<%= render 'layouts/breadcrumb', breadcrumb_variables: { t("breadcrumbs.rooms") => overview_rooms_path,
@server.frame.room.name => room_path(@server.frame.room, view: params[:view]),
"Ilot #{@server.frame.islet.name}" => room_path(@server.frame.room, islet: @server.frame.islet.name, :view => params[:view], bg: params[:bg]),
"Double baie #{@server.frame.bay}" => room_path(@server.frame.room, islet: @server.frame.islet.name, 'bay-id': @server.frame.bay_id, view: params[:view]),
"Baie #{@server.frame.name}" => frame_path(@server.frame, view: params[:view]),
t("breadcrumbs.islet", name: @server.frame.islet.name) => room_path(@server.frame.room, islet: @server.frame.islet.name, :view => params[:view], bg: params[:bg]),
t("breadcrumbs.bays.double", name: @server.frame.bay) => room_path(@server.frame.room, islet: @server.frame.islet.name, 'bay-id': @server.frame.bay_id, view: params[:view]),
t("breadcrumbs.bays.simple", name: @server.frame.name) => frame_path(@server.frame, view: params[:view]),
@server.name => server_path(@server),
'Edition' => '' } %>
t("breadcrumbs.editing") => '' } %>
<div class="page-header">
<%= link_to(server_path(@server.slug),
method: :delete,
data: { confirm: 'Toutes les données concernant ce matériel seront supprimées, ainsi que toutes les connexions associées. Souhaitez-vous confirmer ?' },
data: { confirm: t(".delete_confirmation") },
class: 'btn btn-danger') do %>
<span class="glyphicon glyphicon-alert"></span>
Supprimer
<%= t("actions.delete") %>
<% end %>
<h1>Matériel : <%= @server.name %></h1>
<h1>
<%= t(".title", name: @server.name) %>
</h1>
</div>

<%= render 'form' %>
8 changes: 6 additions & 2 deletions app/views/servers/grid.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<h3>Users Report</h3>
<h3>
<%= t(".title") %>
</h3>

<%= datagrid_form_for @servers %>


<div class='total'>Total: <%= @servers.assets.total_count %></div>
<div class='total'>
<%= t(".total", count: @servers.assets.total_count) %>
</div>
<%= datagrid_table(@servers) %>
<%= paginate @servers.assets %>
24 changes: 15 additions & 9 deletions app/views/servers/import_csv.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<% provide(:title, "Importation de matériel par fichier CSV") %>
<%= render 'layouts/breadcrumb', breadcrumb_variables: {
'Paramètres' => servers_url, 'Matériels' => servers_path, 'Importation de matériel par fichier CSV' => ''
t("breadcrumbs.settings") => servers_url,
t("breadcrumbs.servers.label") => servers_path,
t(".title") => ''
}
%>
<% if @import_error %>
<div class="alert alert-danger alert-dismissable" role="alert">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<span aria-hidden="true">&times;</span><span class="sr-only"><%= t("actions.close") %></span></button>
<h4><%= @import_error %></h4>
</div>
<% end %>
Expand All @@ -20,35 +22,39 @@
<div class="panel panel-primary">
<%= form_for :import, url: import_servers_path, multipart: true do |f| %>
<div class="panel-heading">
<h4 class="panel-title text-center">Importation de matériel par fichier CSV</h4>
<h4 class="panel-title text-center">
<%= t(".title") %>
</h4>
</div>

<div class="panel-body">
<p>
<%= f.label "Salle où importer les serveurs :" %>
<%= f.label t(".room_import.label") %>
<%= f.select :room_id, Room.order('id').all.collect {|p| [p.name, p.id]}, include_blank: false, selected: Room.find_by_name('Atelier').try(:id) %>
<br>
<span class="hint">(utilisé seulement si la baie n'est pas précisée dans le fichier CSV)</span>
<span class="hint">
<%= t(".room_import.hint") %>
</span>
</p>

<p>
<%= f.label "Etat des serveurs importés :" %>
<%= f.label t(".servers_states") %>
<%= f.select :server_state_id, ServerState.all.collect {|p| [t(p.name.parameterize), p.id]}, include_blank: true %>
</p>
<p>
<%= f.label "Fichier CSV :" %>
<%= f.label t(".csv_file") %>
<%= f.file_field :file %>
</p>

</div>

<div class="panel-footer">
<%= f.submit "Importer ce CSV", class: 'btn btn-primary', style: "width:100%;" %>
<%= f.submit t(".import_this"), class: 'btn btn-primary', style: "width:100%;" %>
</div>
<% end %>
</div>

Télécharger un exemple de fichier CSV compatible : <%= link_to 'fichier_exemple.csv', root_url + 'files/format_exemple.csv' %>
<%= t(".download_example") %> <%= link_to 'fichier_exemple.csv', root_url + 'files/format_exemple.csv' %>

</div>
</p>
Loading

0 comments on commit 45f9137

Please sign in to comment.