Moved to assets for sla, overview and jobs.
This commit is contained in:
parent
30e28e71f6
commit
d4ec678238
8 changed files with 121 additions and 134 deletions
|
@ -542,7 +542,7 @@ class App.Controller extends Spine.Controller
|
|||
el.html App.view('generic/page_loading')()
|
||||
else
|
||||
@html App.view('generic/page_loading')()
|
||||
@initLoadingDoneDelay = @delay(later, 2800)
|
||||
@initLoadingDoneDelay = @delay(later, 1800)
|
||||
|
||||
stopLoading: =>
|
||||
return if !@initLoadingDoneDelay
|
||||
|
|
|
@ -124,7 +124,10 @@ class App.ControllerGenericIndex extends App.Controller
|
|||
|
||||
# fetch all
|
||||
if !@disableInitFetch
|
||||
App[ @genericObject ].fetch()
|
||||
App[ @genericObject ].fetchFull(
|
||||
->
|
||||
clear: true
|
||||
)
|
||||
|
||||
release: =>
|
||||
if @subscribeId
|
||||
|
|
|
@ -12,26 +12,17 @@ class Index extends App.ControllerContent
|
|||
# check authentication
|
||||
return if !@authenticate(false, 'Admin')
|
||||
|
||||
@interval(@load, 60000)
|
||||
#@load()
|
||||
|
||||
load: =>
|
||||
@startLoading()
|
||||
@ajax(
|
||||
id: 'calendar_index'
|
||||
type: 'GET'
|
||||
url: @apiPath + '/calendars'
|
||||
processData: true
|
||||
success: (data, status, xhr) =>
|
||||
@subscribeId = App.Calendar.subscribe(@render)
|
||||
|
||||
callback = (data) =>
|
||||
App.Config.set('ical_feeds', data.ical_feeds)
|
||||
App.Config.set('timezones', data.timezones)
|
||||
|
||||
# load assets
|
||||
App.Collection.loadAssets(data.assets)
|
||||
|
||||
@stopLoading()
|
||||
@render(data)
|
||||
@render()
|
||||
@startLoading()
|
||||
App.Calendar.fetchFull(
|
||||
callback
|
||||
clear: true
|
||||
)
|
||||
|
||||
render: =>
|
||||
|
|
|
@ -463,8 +463,8 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|||
@Config.set('NavBarRight', NavBarRight)
|
||||
|
||||
fetchRecentView: =>
|
||||
load = (items) =>
|
||||
App.RecentView.refresh( items, { clear: true } )
|
||||
load = (data) =>
|
||||
App.RecentView.refresh(data.stream, clear: true)
|
||||
@renderPersonal()
|
||||
App.RecentView.fetchFull(load)
|
||||
|
||||
|
|
|
@ -11,20 +11,16 @@ class Index extends App.ControllerContent
|
|||
# check authentication
|
||||
return if !@authenticate(false, 'Admin')
|
||||
|
||||
@interval(@load, 60000)
|
||||
#@load()
|
||||
@subscribeCalendarId = App.Calendar.subscribe(@render)
|
||||
@subscribeSlaId = App.Sla.subscribe(@render)
|
||||
|
||||
load: =>
|
||||
@startLoading()
|
||||
@ajax(
|
||||
id: 'sla_index'
|
||||
type: 'GET'
|
||||
url: @apiPath + '/slas'
|
||||
processData: true
|
||||
success: (data, status, xhr) =>
|
||||
App.Collection.loadAssets(data.assets)
|
||||
callback = =>
|
||||
@stopLoading()
|
||||
@render(data)
|
||||
@render()
|
||||
@startLoading()
|
||||
App.Sla.fetchFull(
|
||||
callback
|
||||
clear: true
|
||||
)
|
||||
|
||||
render: =>
|
||||
|
@ -56,8 +52,10 @@ class Index extends App.ControllerContent
|
|||
)
|
||||
|
||||
release: =>
|
||||
if @subscribeId
|
||||
App.Calendar.unsubscribe(@subscribeId)
|
||||
if @subscribeCalendarId
|
||||
App.Calendar.unsubscribe(@subscribeCalendarId)
|
||||
if @subscribeSlaId
|
||||
App.Sla.unsubscribe(@subscribeSlaId)
|
||||
|
||||
new: (e) ->
|
||||
e.preventDefault()
|
||||
|
|
|
@ -153,9 +153,9 @@ class App.OnlineNotificationWidget extends App.Controller
|
|||
@toggle.popover('hide')
|
||||
|
||||
fetch: =>
|
||||
load = (items) =>
|
||||
load = (data) =>
|
||||
@fetchedData = true
|
||||
App.OnlineNotification.refresh(items, { clear: true })
|
||||
App.OnlineNotification.refresh(data.stream, clear: true)
|
||||
@updateContent()
|
||||
App.OnlineNotification.fetchFull(load)
|
||||
|
||||
|
|
|
@ -302,6 +302,8 @@ class App.Model extends Spine.Model
|
|||
###
|
||||
|
||||
@subscribe: (callback, param = {}) ->
|
||||
|
||||
# global bind to changes
|
||||
if !@SUBSCRIPTION_COLLECTION
|
||||
@SUBSCRIPTION_COLLECTION = {}
|
||||
|
||||
|
@ -320,7 +322,10 @@ class App.Model extends Spine.Model
|
|||
events
|
||||
=>
|
||||
App.Log.debug('Model', "server notify collection change #{@className}")
|
||||
@fetch( {}, { clear: true } )
|
||||
@fetchFull(
|
||||
->
|
||||
clear: true
|
||||
)
|
||||
|
||||
'Collection::Subscribe::' + @className
|
||||
)
|
||||
|
@ -334,7 +339,10 @@ class App.Model extends Spine.Model
|
|||
@one 'refresh', (collection) =>
|
||||
@initFetchActive = true
|
||||
callback(collection)
|
||||
@fetch( {}, { clear: true } )
|
||||
@fetchFull(
|
||||
->
|
||||
clear: true
|
||||
)
|
||||
else
|
||||
callback(@all())
|
||||
|
||||
|
@ -423,7 +431,6 @@ class App.Model extends Spine.Model
|
|||
if !genericObject || new Date(item.updated_at) >= new Date(genericObject.updated_at)
|
||||
App.Log.debug('Model', "request #{@className}.find(#{item.id}) from server")
|
||||
@full(item.id, false, true)
|
||||
|
||||
App.Delay.set(callback, 500, item.id, "full-#{@className}")
|
||||
|
||||
'Item::Subscribe::' + @className
|
||||
|
@ -462,8 +469,14 @@ class App.Model extends Spine.Model
|
|||
|
||||
App.Model.fetchFull(@callback)
|
||||
|
||||
App.Model.fetchFull(
|
||||
@callback
|
||||
clear: true
|
||||
)
|
||||
|
||||
|
||||
###
|
||||
@fetchFull: (callback) ->
|
||||
@fetchFull: (callback, params = {}) ->
|
||||
url = "#{@url}/?full=true"
|
||||
App.Log.debug('Model', "fetchFull collection #{@className}", url)
|
||||
App.Ajax.request(
|
||||
|
@ -474,6 +487,10 @@ class App.Model extends Spine.Model
|
|||
|
||||
App.Log.debug('Model', "got fetchFull collection #{@className}", data)
|
||||
|
||||
# clear collection
|
||||
if params.clear
|
||||
App[@className].deleteAll()
|
||||
|
||||
# full / load assets
|
||||
if data.assets
|
||||
App.Collection.loadAssets(data.assets)
|
||||
|
@ -482,8 +499,8 @@ class App.Model extends Spine.Model
|
|||
else
|
||||
App[@className].refresh(data)
|
||||
|
||||
# execute callbacks
|
||||
callback(data.stream)
|
||||
if callback
|
||||
callback(data)
|
||||
|
||||
error: (xhr, statusText, error) ->
|
||||
App.Log.error('Model', statusText, error, url)
|
||||
|
|
|
@ -49,51 +49,29 @@ curl http://localhost/api/v1/slas.json -v -u #{login}:#{password}
|
|||
def index
|
||||
return if deny_if_not_role(Z_ROLENAME_ADMIN)
|
||||
|
||||
assets = {}
|
||||
if params[:full]
|
||||
|
||||
# calendars
|
||||
assets = {}
|
||||
calendar_ids = []
|
||||
Calendar.all.order(:name, :created_at).each {|calendar|
|
||||
calendar_ids.push calendar.id
|
||||
Calendar.all.each {|calendar|
|
||||
assets = calendar.assets(assets)
|
||||
}
|
||||
|
||||
# slas
|
||||
sla_ids = []
|
||||
models = Models.all
|
||||
Sla.all.order(:name, :created_at).each {|sla|
|
||||
sla_ids.push sla.id
|
||||
assets = sla.assets(assets)
|
||||
|
||||
# get assets of condition
|
||||
sla.condition.each {|item, content|
|
||||
attribute = item.split(/\./)
|
||||
next if !attribute[1]
|
||||
attribute_class = attribute[0].to_classname.constantize
|
||||
reflection = attribute[1].sub(/_id$/, '')
|
||||
reflection = reflection.to_sym
|
||||
next if !models[attribute_class]
|
||||
next if !models[attribute_class][:reflections]
|
||||
next if !models[attribute_class][:reflections][reflection]
|
||||
next if !models[attribute_class][:reflections][reflection].klass
|
||||
attribute_ref_class = models[attribute_class][:reflections][reflection].klass
|
||||
if content['value'].class == Array
|
||||
content['value'].each {|item_id|
|
||||
attribute_object = attribute_ref_class.find_by(id: item_id)
|
||||
assets = attribute_object.assets(assets)
|
||||
Sla.all.each {|item|
|
||||
sla_ids.push item.id
|
||||
assets = item.assets(assets)
|
||||
}
|
||||
else
|
||||
attribute_object = attribute_ref_class.find_by(id: content['value'])
|
||||
assets = attribute_object.assets(assets)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
render json: {
|
||||
calendar_ids: calendar_ids,
|
||||
sla_ids: sla_ids,
|
||||
record_ids: sla_ids,
|
||||
assets: assets,
|
||||
}, status: :ok
|
||||
return
|
||||
end
|
||||
|
||||
model_index_render(Sla, params)
|
||||
end
|
||||
|
||||
=begin
|
||||
|
|
Loading…
Reference in a new issue