diff --git a/app/assets/javascripts/app/controllers/_application_controller_table.coffee b/app/assets/javascripts/app/controllers/_application_controller_table.coffee
index b1e9cbee8..41bd1b3f8 100644
--- a/app/assets/javascripts/app/controllers/_application_controller_table.coffee
+++ b/app/assets/javascripts/app/controllers/_application_controller_table.coffee
@@ -76,14 +76,15 @@ class App.ControllerTable extends App.Controller
e.preventDefault()
console.log('checkboxClick', e.target)
- callbackHeader = (header) ->
- console.log('current header is', header)
+ callbackHeader = (headers) ->
+ console.log('current header is', headers)
# add new header item
attribute =
name: 'some name'
display: 'Some Name'
- header.push attribute
- console.log('new header is', header)
+ headers.push attribute
+ console.log('new header is', headers)
+ headers
callbackAttributes = (value, object, attribute, header, refObject) ->
console.log('data of item col', value, object, attribute, header, refObject)
diff --git a/app/assets/javascripts/app/controllers/api.coffee b/app/assets/javascripts/app/controllers/api.coffee
index 50cd78ce1..bcc0ab6fc 100644
--- a/app/assets/javascripts/app/controllers/api.coffee
+++ b/app/assets/javascripts/app/controllers/api.coffee
@@ -34,20 +34,47 @@ class Index extends App.ControllerSubContent
App.Setting.unsubscribe(@subscribeApplicationId)
table = =>
+
+ callbackHeader = (headers) ->
+ attribute =
+ name: 'view'
+ display: 'View'
+ headers.splice(3, 0, attribute)
+ attribute =
+ name: 'token'
+ display: 'Token'
+ headers.splice(4, 0, attribute)
+ headers
+
+ callbackViewAttributes = (value, object, attribute, header, refObject) ->
+ value = 'X'
+ value
+
+ callbackTokenAttributes = (value, object, attribute, header, refObject) ->
+ value = 'X'
+ value
+
new App.ControllerTable(
- el: @$('.js-appList')
- model: App.Application
- table_id: 'applications'
- objects: App.Application.all()
+ el: @$('.js-appList')
+ model: App.Application
+ table_id: 'applications'
+ objects: App.Application.all()
bindRow:
events:
'click': @appEdit
+ bindCol:
+ view:
+ events:
+ 'click': @appView
+ token:
+ events:
+ 'click': @appToken
+ callbackHeader: [callbackHeader]
+ callbackAttributes:
+ view: [callbackViewAttributes]
+ token: [callbackTokenAttributes]
)
table()
- #App.Application.fetchFull(
- # table
- # clear: true
- #)
@subscribeApplicationId = App.Application.subscribe(table, initFetch: true, clear: true)
@@ -82,6 +109,18 @@ class Index extends App.ControllerSubContent
value = @PasswordAccess.prop('checked')
App.Setting.set('api_password_access', value)
+ appToken: (id, e) ->
+ e.preventDefault()
+ new ViewAppTokenModal(
+ app: App.Application.find(id)
+ )
+
+ appView: (id, e) ->
+ e.preventDefault()
+ new ViewAppModal(
+ app: App.Application.find(id)
+ )
+
appNew: (e) ->
e.preventDefault()
new App.ControllerGenericNew(
@@ -107,4 +146,51 @@ class Index extends App.ControllerSubContent
container: @el.closest('.content')
)
+class ViewAppModal extends App.ControllerModal
+ headPrefix: 'App'
+ buttonSubmit: false
+ buttonCancel: true
+ shown: true
+ small: true
+ events:
+ 'click .js-select': 'selectAll'
+
+ constructor: (params) ->
+ @head = params.app.name
+ super
+
+ content: ->
+ "AppID:
+
+ Secret: "
+
+class ViewAppTokenModal extends App.ControllerModal
+ headPrefix: 'Generate Token'
+ buttonSubmit: 'Generate Token'
+ buttonCancel: true
+ shown: true
+ small: true
+ events:
+ 'click .js-select': 'selectAll'
+
+ constructor: (params) ->
+ @head = params.app.name
+ super
+
+ content: ->
+ "#{App.i18n.translateContent('Generate Access Token for |%s|', App.Session.get().displayNameLong())}"
+
+ onSubmit: =>
+ @ajax(
+ id: 'application_token'
+ type: 'POST'
+ url: "#{@apiPath}/applications/token"
+ processData: true
+ data: JSON.stringify(id: @app.id)
+ success: (data, status, xhr) =>
+ @contentInline = "#{App.i18n.translateContent('New Access Token is')}: "
+ @update()
+ @$('.js-submit').remove()
+ )
+
App.Config.set('API', { prio: 1200, name: 'API', parent: '#system', target: '#system/api', controller: Index, permission: ['admin.api'] }, 'NavBarAdmin')
diff --git a/app/assets/javascripts/app/models/application.coffee b/app/assets/javascripts/app/models/application.coffee
index 4bad86d8b..e31faa35e 100644
--- a/app/assets/javascripts/app/models/application.coffee
+++ b/app/assets/javascripts/app/models/application.coffee
@@ -1,17 +1,16 @@
class App.Application extends App.Model
- @configure 'Application', 'name', 'redirect_uri', 'uid', 'secret'
+ @configure 'Application', 'name', 'redirect_uri'
@extend Spine.Model.Ajax
@url: @apiPath + '/applications'
@configure_attributes = [
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
- { name: 'redirect_uri', display: 'Redirect URI', tag: 'textarea', limit: 250, null: false, note: 'Use one line per URI' },
- { name: 'uid', display: 'Application ID', tag: 'input', type: 'text', null: true, readonly: 1 },
- { name: 'secret', display: 'Application secret', tag: 'input', type: 'text', null: true },
+ { name: 'redirect_uri', display: 'Callback URL', tag: 'textarea', limit: 250, null: false, note: 'Use one line per URI' },
+ { name: 'clients', display: 'Clients', tag: 'input', readonly: 1 },
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
]
@configure_overview = [
- 'name', 'uid'
+ 'name', 'redirect_uri', 'clients'
]
@configure_delete = true
diff --git a/app/assets/javascripts/app/views/api.jst.eco b/app/assets/javascripts/app/views/api.jst.eco
index 86f412824..de29d157c 100644
--- a/app/assets/javascripts/app/views/api.jst.eco
+++ b/app/assets/javascripts/app/views/api.jst.eco
@@ -51,6 +51,7 @@ curl -u <%= @S('email') %>:some_password <%= @C('http_type') %>://<%= @C('fqdn')
+