34 lines
1.3 KiB
CoffeeScript
34 lines
1.3 KiB
CoffeeScript
import Ember from 'ember'
|
|
|
|
export default Ember.Component.extend
|
|
panda_prefix: '/panda/api/v1'
|
|
loading_html: "<i class='notched circle loading icon green'></i>"
|
|
session: Ember.inject.service('session')
|
|
identifier: ''
|
|
actions:
|
|
on_show: (element, popup) ->
|
|
return unless identifier = @get('identifier')
|
|
session = @get('session')
|
|
url = "#{@get('panda_prefix')}/workflow_action_definitions/#{identifier}/action_info"
|
|
start_time = new Date()
|
|
request =
|
|
url: url
|
|
contentType: "application/json"
|
|
dataType: "json"
|
|
success: (response) ->
|
|
#debugger
|
|
#console.log response
|
|
finish_time = new Date()
|
|
action_info_load_time = finish_time - start_time
|
|
console.log "Action info for action #{identifier} loaded (#{Math.round(action_info_load_time / 100) / 10}s)"
|
|
if action_info_load_time < 500 # too fast response will not be shown due to fade in effect (I think)
|
|
setTimeout((-> popup.setSemanticAttr('html', response)), 500)
|
|
else
|
|
popup.setSemanticAttr('html', response)
|
|
if Ember.get(session, 'isAuthenticated')
|
|
session.authorize 'authorizer:devise', (key, authorization) ->
|
|
request.crossDomain = true
|
|
request.headers = {"#{key}": authorization}
|
|
Ember.$.ajax(request)
|
|
true
|