aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorLuc Donnet2017-09-11 17:27:10 +0200
committerLuc Donnet2017-09-11 17:27:10 +0200
commit5ee3a180de710d23ceb7660b1bcc454701b42d87 (patch)
treec5a6fa4d304306bb53dfcea93037f3ac10b46624 /app
parent1b2976d7a63cc140304bd94b88b5ddc93e0aceb0 (diff)
downloadchouette-core-5ee3a180de710d23ceb7660b1bcc454701b42d87.tar.bz2
Fix views and access for api keys generation Refs #4276 @8
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api_keys_controller.rb22
-rw-r--r--app/views/api_keys/_api_key.html.slim18
-rw-r--r--app/views/api_keys/_form.html.slim14
-rw-r--r--app/views/api_keys/edit.html.slim20
-rw-r--r--app/views/api_keys/index.html.slim27
-rw-r--r--app/views/api_keys/new.html.slim14
-rw-r--r--app/views/api_keys/show.html.slim17
-rw-r--r--app/views/workbenches/index.html.slim20
8 files changed, 73 insertions, 79 deletions
diff --git a/app/controllers/api_keys_controller.rb b/app/controllers/api_keys_controller.rb
index 7059cf52e..03e5ef237 100644
--- a/app/controllers/api_keys_controller.rb
+++ b/app/controllers/api_keys_controller.rb
@@ -3,19 +3,27 @@ class ApiKeysController < BreadcrumbController
def create
@api_key = Api::V1::ApiKey.new(api_key_params.merge(organisation: current_organisation))
- create! { organisation_api_keys_path }
- end
-
- def index
- @api_keys = decorate_api_keys(current_organisation.api_keys.paginate(page: params[:page]))
+ create! do |format|
+ format.html {
+ redirect_to workbenches_path
+ }
+ end
end
def update
- update! { organisation_api_key_path(resource) }
+ update! do |format|
+ format.html {
+ redirect_to workbenches_path
+ }
+ end
end
def destroy
- destroy! { organisation_api_keys_path }
+ destroy! do |format|
+ format.html {
+ redirect_to workbenches_path
+ }
+ end
end
private
diff --git a/app/views/api_keys/_api_key.html.slim b/app/views/api_keys/_api_key.html.slim
deleted file mode 100644
index 4cb07ef83..000000000
--- a/app/views/api_keys/_api_key.html.slim
+++ /dev/null
@@ -1,18 +0,0 @@
-#index_item.panel.panel-default.api_key
- .panel-heading
- .panel-title.clearfix
- span.pull-right
- = link_to edit_referential_api_key_path(@referential, api_key), class: "btn btn-default btn-sm" do
- span.fa.fa-pencil
-
- = link_to referential_api_key_path(@referential, api_key), :method => :delete, :data => {:confirm => t('api_keys.actions.destroy_confirm')}, class: "btn btn-danger btn-sm" do
- span.fa.fa-trash-o
-
- h5
- = link_to([@referential, api_key], class: "preview", :title => "#{Chouette::StopArea.model_name.human.capitalize} #{api_key.name}") do
- span.name = truncate(api_key.name, :length => 20)
-
- .panel-body
- p = "#{api_key.class.human_attribute_name('token')} #{truncate(api_key.token, :length => 20)}"
-
- p = "#{api_key.class.human_attribute_name('updated_at')} #{l(api_key.updated_at)}" \ No newline at end of file
diff --git a/app/views/api_keys/_form.html.slim b/app/views/api_keys/_form.html.slim
index f3ebf3fe1..94a3ae57e 100644
--- a/app/views/api_keys/_form.html.slim
+++ b/app/views/api_keys/_form.html.slim
@@ -1,7 +1,9 @@
-= simple_form_for @api_key, url: action_url do |f|
- = f.input :name
- - unless @api_key.new_record?
- = f.input :token, :input_html => { readonly: true }
+= simple_form_for @api_key, html: {class: 'form-horizontal', id: 'api_key_form'}, wrapper: :horizontal_form do |f|
+ .row
+ .col-lg-12
+ = f.input :name
+ - unless @api_key.new_record?
+ = f.input :token, :input_html => { readonly: true }
- = f.association :referential
- = f.button :submit, 'submit', class: 'btn-primary'
+ / = f.association :referential
+ = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'api_key_form'
diff --git a/app/views/api_keys/edit.html.slim b/app/views/api_keys/edit.html.slim
index e47deddf7..b1bd1858d 100644
--- a/app/views/api_keys/edit.html.slim
+++ b/app/views/api_keys/edit.html.slim
@@ -1,2 +1,18 @@
-= title_tag t('api_keys.edit.title')
-== render partial: 'form', locals: {action_url: organisation_api_key_path}
+/ PageHeader
+= pageheader 'Clé d\'API',
+ t('api_keys.edit.title'),
+ 'Lorem ipsum dolor sit amet',
+ t('last_update', time: l(@api_key.updated_at, format: :short)),
+ ''
+
+ / Below is secundary actions & optional contents (filters, ...)
+ .row.mb-sm
+ .col-lg-12.text-right
+ = ( policy(@api_key).destroy? ? link_to(t('actions.destroy'), api_key_path(@api_key), :method => :delete, class: 'btn btn-default') : '' )
+
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1
+ == render 'form'
diff --git a/app/views/api_keys/index.html.slim b/app/views/api_keys/index.html.slim
deleted file mode 100644
index 9757b8955..000000000
--- a/app/views/api_keys/index.html.slim
+++ /dev/null
@@ -1,27 +0,0 @@
-- header_params = ['map-marker',
- t('.title'),
- '']
-- header_params << link_to(t('actions.add'), new_organisation_api_key_path, class: 'btn btn-default') if policy(Api::V1::ApiKey).create?
-= pageheader(*header_params) do
-
-
-- if @api_keys.any?
- .row
- .col-lg-12
- = table_builder_2 @api_keys,
- [ \
- TableBuilderHelper::Column.new( \
- key: :name, \
- attribute: 'name', \
- link_to: lambda do |api_key| \
- organisation_api_key_path(api_key) \
- end \
- ), \
- TableBuilderHelper::Column.new( \
- key: :token, \
- attribute: 'token' \
- ), \
- ],
- cls: 'table has-search'
-
- = new_pagination @api_keys, 'pull-right'
diff --git a/app/views/api_keys/new.html.slim b/app/views/api_keys/new.html.slim
index 291c9f8a6..9acb08a94 100644
--- a/app/views/api_keys/new.html.slim
+++ b/app/views/api_keys/new.html.slim
@@ -1,2 +1,12 @@
-= title_tag t('api_keys.new.title')
-== render partial: 'form', locals: {action_url: organisation_api_keys_path}
+/ PageHeader
+= pageheader 'Clé d\'API',
+ t('api_keys.new.title'),
+ 'Lorem ipsum dolor sit amet',
+ ''
+
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1
+ == render 'form'
diff --git a/app/views/api_keys/show.html.slim b/app/views/api_keys/show.html.slim
deleted file mode 100644
index de30ac125..000000000
--- a/app/views/api_keys/show.html.slim
+++ /dev/null
@@ -1,17 +0,0 @@
-= title_tag t('api_keys.show.title')
-
-.api_keys_show
- .summary
- p
- label = "#{@api_key.class.human_attribute_name('name')} : "
- = @api_key.name
-
- p
- label = "#{@api_key.class.human_attribute_name('token')} : "
- = @api_key.token
-
-- content_for :sidebar do
- ul.actions
- li = link_to t('api_keys.actions.edit'), edit_organisation_api_key_path(@api_key), class: "edit"
- li = link_to t('api_keys.actions.destroy'), organisation_api_key_path(@api_key), :method => :delete, :data => {:confirm => t('api_keys.actions.destroy_confirm')}, class: "remove"
- br
diff --git a/app/views/workbenches/index.html.slim b/app/views/workbenches/index.html.slim
index eece51bca..2ea1f0fe4 100644
--- a/app/views/workbenches/index.html.slim
+++ b/app/views/workbenches/index.html.slim
@@ -2,6 +2,13 @@
= pageheader 'tableau-de-bord',
t('.title', organisation: current_organisation.name)
+ / Below is secundary actions & optional contents (filters, ...)
+ .row.mb-sm
+ .col-lg-12.text-right
+ - if policy(Api::V1::ApiKey).create?
+ = link_to t('actions.create_api_key'), new_api_key_path, class: 'btn btn-primary'
+
+
/ PageContent
.page_content
.container-fluid
@@ -27,6 +34,19 @@
.panel-body
em.small.text-muted = t('.offers.no_content')
+ .panel.panel-default
+ .panel-heading
+ h3.panel-title
+ = t('.offers.api_keys')
+ span.badge.ml-xs = current_organisation.api_keys.count if current_organisation.api_keys.any?
+ - if current_organisation.api_keys.any?
+ - current_organisation.api_keys.each do |api_key|
+ .list-group
+ = policy(api_key).edit? ? link_to( "#{api_key.name} : #{api_key.token}", edit_api_key_path(api_key), class: 'list-group-item') : "#{api_key.name} : #{api_key.token}"
+ - else
+ .panel-body
+ em.small.text-muted = t('.offers.no_content')
+
.col-lg-6.col-md-6.col-sm-6.col-xs-12
.panel.panel-default
.panel-heading