Improved visualisation of errors.
This commit is contained in:
parent
8ff2318539
commit
a3daad2917
5 changed files with 44 additions and 26 deletions
|
@ -12,7 +12,8 @@ class Index extends App.ControllerContent
|
|||
# check authentication
|
||||
return if !@authenticate()
|
||||
|
||||
@load()
|
||||
@interval(@load, 60000)
|
||||
#@load()
|
||||
|
||||
load: =>
|
||||
@ajax(
|
||||
|
|
|
@ -11,7 +11,8 @@ class Index extends App.ControllerContent
|
|||
# check authentication
|
||||
return if !@authenticate()
|
||||
|
||||
@load()
|
||||
@interval(@load, 60000)
|
||||
#@load()
|
||||
|
||||
load: =>
|
||||
@ajax(
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% if calendar.last_log: %><div class="action-row"><div class="alert alert--danger"><%= calendar.last_log %></div></div><% end %>
|
||||
<div class="action-row">
|
||||
<div class="label"><%- @T('Timezone') %></div> <%= calendar.timezone %>
|
||||
</div>
|
||||
|
|
|
@ -52,8 +52,7 @@
|
|||
</a>
|
||||
|
||||
<% if !_.isEmpty(channel.last_log_in): %>
|
||||
<div>
|
||||
<%- @T('Notice') %>:<br>
|
||||
<div class="alert alert--danger">
|
||||
<%= channel.last_log_in %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -76,8 +75,7 @@
|
|||
<%- @T('Protocol') %>: <%= channel.options.outbound.adapter %>
|
||||
</a>
|
||||
<% if !_.isEmpty(channel.last_log_out): %>
|
||||
<div>
|
||||
<%- @T('Notice') %>:<br>
|
||||
<div class="alert alert--danger">
|
||||
<%= channel.last_log_out %>
|
||||
<div>
|
||||
<% end %>
|
||||
|
@ -132,10 +130,10 @@
|
|||
</a>
|
||||
|
||||
<% if channel.status_in is 'error': %>
|
||||
<div><%= channel.last_log_in %></div>
|
||||
<div class="alert alert--danger"><%= channel.last_log_in %></div>
|
||||
<% end %>
|
||||
<% if channel.status_out is 'error': %>
|
||||
<div><%= channel.last_log_out %></div>
|
||||
<div class="alert alert--danger"><%= channel.last_log_out %></div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -4,6 +4,8 @@ class Calendar < ApplicationModel
|
|||
store :business_hours
|
||||
store :public_holidays
|
||||
|
||||
before_create :fetch_ical
|
||||
before_update :fetch_ical
|
||||
after_create :sync_default, :min_one_check
|
||||
after_update :sync_default, :min_one_check
|
||||
after_destroy :min_one_check
|
||||
|
@ -207,37 +209,47 @@ returns
|
|||
|
||||
=end
|
||||
|
||||
def sync
|
||||
def sync(without_save = nil)
|
||||
return if !ical_url
|
||||
events = Calendar.parse(ical_url)
|
||||
begin
|
||||
events = Calendar.parse(ical_url)
|
||||
|
||||
# sync with public_holidays
|
||||
if !public_holidays
|
||||
self.public_holidays = {}
|
||||
end
|
||||
events.each {|day, summary|
|
||||
if !public_holidays[day]
|
||||
public_holidays[day] = {}
|
||||
# sync with public_holidays
|
||||
if !public_holidays
|
||||
self.public_holidays = {}
|
||||
end
|
||||
events.each {|day, summary|
|
||||
if !public_holidays[day]
|
||||
public_holidays[day] = {}
|
||||
end
|
||||
|
||||
# ignore if already added or changed
|
||||
next if public_holidays[day].key?('active')
|
||||
# ignore if already added or changed
|
||||
next if public_holidays[day].key?('active')
|
||||
|
||||
# create new entry
|
||||
public_holidays[day] = {
|
||||
active: true,
|
||||
summary: summary,
|
||||
# create new entry
|
||||
public_holidays[day] = {
|
||||
active: true,
|
||||
summary: summary,
|
||||
}
|
||||
}
|
||||
}
|
||||
self.last_log = ''
|
||||
self.last_log = nil
|
||||
rescue => e
|
||||
self.last_log = e.inspect
|
||||
end
|
||||
|
||||
self.last_sync = Time.zone.now
|
||||
save
|
||||
if !without_save
|
||||
save
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
def self.parse(location)
|
||||
if location =~ /^http/i
|
||||
result = UserAgent.get(location)
|
||||
if !result.success?
|
||||
fail result.error
|
||||
end
|
||||
cal_file = result.body
|
||||
else
|
||||
cal_file = File.open(location)
|
||||
|
@ -298,4 +310,9 @@ returns
|
|||
end
|
||||
}
|
||||
end
|
||||
|
||||
# fetch ical feed
|
||||
def fetch_ical
|
||||
sync(true)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue