Added App.Wizard controller to reduce lines of code.
This commit is contained in:
parent
71c774cb99
commit
cd799f0d74
6 changed files with 97 additions and 177 deletions
|
@ -596,4 +596,45 @@ class App.Sidebar extends App.Controller
|
||||||
@currentTab = name
|
@currentTab = name
|
||||||
|
|
||||||
# show sidebar if not shown
|
# show sidebar if not shown
|
||||||
@showSidebar()
|
@showSidebar()
|
||||||
|
|
||||||
|
class App.Wizard extends App.Controller
|
||||||
|
goToSlide: (e) =>
|
||||||
|
e.preventDefault()
|
||||||
|
slide = $(e.target).data('slide')
|
||||||
|
@showSlide(slide)
|
||||||
|
|
||||||
|
showSlide: (name) =>
|
||||||
|
@hideAlert(name)
|
||||||
|
@$('.setup.wizard').addClass('hide')
|
||||||
|
@$(".setup.wizard.#{name}").removeClass('hide')
|
||||||
|
@$(".setup.wizard.#{name} input, .setup.wizard.#{name} select").first().focus()
|
||||||
|
|
||||||
|
showAlert: (screen, message) =>
|
||||||
|
@$(".#{screen}").find('.alert').removeClass('hide').text( App.i18n.translateInline( message ) )
|
||||||
|
|
||||||
|
hideAlert: (screen) =>
|
||||||
|
@$(".#{screen}").find('.alert').addClass('hide')
|
||||||
|
|
||||||
|
hideAlerts: =>
|
||||||
|
@$('.form-group').removeClass('has-error')
|
||||||
|
@$('.alert').addClass('hide')
|
||||||
|
|
||||||
|
disable: (e) =>
|
||||||
|
@formDisable(e)
|
||||||
|
@$('.wizard-controls .btn').attr('disabled', true)
|
||||||
|
|
||||||
|
enable: (e) =>
|
||||||
|
@formEnable(e)
|
||||||
|
@$('.wizard-controls .btn').attr('disabled', false)
|
||||||
|
|
||||||
|
hide: (e) =>
|
||||||
|
e.preventDefault()
|
||||||
|
@el.modal('hide')
|
||||||
|
|
||||||
|
showInvalidField: (screen, fields) =>
|
||||||
|
@$(".#{screen}").find('.form-group').removeClass('has-error')
|
||||||
|
return if !fields
|
||||||
|
for field, type of fields
|
||||||
|
if type
|
||||||
|
@$(".#{screen}").find("[name=\"options::#{field}\"]").closest('.form-group').addClass('has-error')
|
||||||
|
|
|
@ -342,7 +342,7 @@ class App.ChannelEmailAccountOverview extends App.Controller
|
||||||
callback: @load
|
callback: @load
|
||||||
)
|
)
|
||||||
|
|
||||||
class App.ChannelEmailAccountWizard extends App.Controller
|
class App.ChannelEmailAccountWizard extends App.Wizard
|
||||||
elements:
|
elements:
|
||||||
'.modal-body': 'body'
|
'.modal-body': 'body'
|
||||||
|
|
||||||
|
@ -637,43 +637,11 @@ class App.ChannelEmailAccountWizard extends App.Controller
|
||||||
@showAlert('js-intro', 'Unable to verify sending and receiving. Please check your settings.')
|
@showAlert('js-intro', 'Unable to verify sending and receiving. Please check your settings.')
|
||||||
)
|
)
|
||||||
|
|
||||||
goToSlide: (e) =>
|
|
||||||
e.preventDefault()
|
|
||||||
slide = $(e.target).data('slide')
|
|
||||||
@showSlide(slide)
|
|
||||||
|
|
||||||
showSlide: (name) =>
|
|
||||||
@hideAlert(name)
|
|
||||||
@$('.setup.wizard').addClass('hide')
|
|
||||||
@$(".setup.wizard.#{name}").removeClass('hide')
|
|
||||||
@$(".setup.wizard.#{name} input, .setup.wizard.#{name} select").first().focus()
|
|
||||||
|
|
||||||
showAlert: (screen, message) =>
|
|
||||||
@$(".#{screen}").find('.alert').removeClass('hide').text( App.i18n.translateInline( message ) )
|
|
||||||
|
|
||||||
hideAlert: (screen) =>
|
|
||||||
@$(".#{screen}").find('.alert').addClass('hide')
|
|
||||||
|
|
||||||
disable: (e) =>
|
|
||||||
@formDisable(e)
|
|
||||||
@$('.wizard-controls .btn').attr('disabled', true)
|
|
||||||
|
|
||||||
enable: (e) =>
|
|
||||||
@formEnable(e)
|
|
||||||
@$('.wizard-controls .btn').attr('disabled', false)
|
|
||||||
|
|
||||||
showInvalidField: (screen, fields) =>
|
|
||||||
@$(".#{screen}").find('.form-group').removeClass('has-error')
|
|
||||||
return if !fields
|
|
||||||
for field, type of fields
|
|
||||||
if type
|
|
||||||
@$(".#{screen}").find("[name=\"options::#{field}\"]").closest('.form-group').addClass('has-error')
|
|
||||||
|
|
||||||
hide: (e) =>
|
hide: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@el.modal('hide')
|
@el.modal('hide')
|
||||||
|
|
||||||
class App.ChannelEmailNotificationWizard extends App.Controller
|
class App.ChannelEmailNotificationWizard extends App.Wizard
|
||||||
elements:
|
elements:
|
||||||
'.modal-body': 'body'
|
'.modal-body': 'body'
|
||||||
|
|
||||||
|
@ -788,33 +756,11 @@ class App.ChannelEmailNotificationWizard extends App.Controller
|
||||||
else
|
else
|
||||||
@showSlide('js-outbound')
|
@showSlide('js-outbound')
|
||||||
@showAlert('js-outbound', data.message_human || data.message )
|
@showAlert('js-outbound', data.message_human || data.message )
|
||||||
|
@showInvalidField('js-outbound', data.invalid_field)
|
||||||
@enable(e)
|
@enable(e)
|
||||||
fail: =>
|
fail: =>
|
||||||
@showSlide('js-outbound')
|
@showSlide('js-outbound')
|
||||||
@showAlert('js-outbound', data.message_human || data.message )
|
@showAlert('js-outbound', data.message_human || data.message )
|
||||||
|
@showInvalidField('js-outbound', data.invalid_field)
|
||||||
@enable(e)
|
@enable(e)
|
||||||
)
|
)
|
||||||
|
|
||||||
showSlide: (name) =>
|
|
||||||
@hideAlert(name)
|
|
||||||
@$('.setup.wizard').addClass('hide')
|
|
||||||
@$(".setup.wizard.#{name}").removeClass('hide')
|
|
||||||
@$(".setup.wizard.#{name} input, .setup.wizard.#{name} select").first().focus()
|
|
||||||
|
|
||||||
showAlert: (screen, message) =>
|
|
||||||
@$(".#{screen}").find('.alert').removeClass('hide').text( App.i18n.translateInline( message ) )
|
|
||||||
|
|
||||||
hideAlert: (screen) =>
|
|
||||||
@$(".#{screen}").find('.alert').addClass('hide')
|
|
||||||
|
|
||||||
disable: (e) =>
|
|
||||||
@formDisable(e)
|
|
||||||
@$('.wizard-controls .btn').attr('disabled', true)
|
|
||||||
|
|
||||||
enable: (e) =>
|
|
||||||
@formEnable(e)
|
|
||||||
@$('.wizard-controls .btn').attr('disabled', false)
|
|
||||||
|
|
||||||
hide: (e) =>
|
|
||||||
e.preventDefault()
|
|
||||||
@el.modal('hide')
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Index extends App.ControllerContent
|
class Index extends App.Controller
|
||||||
className: 'getstarted fit'
|
className: 'getstarted fit'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
@ -61,7 +61,7 @@ class Index extends App.ControllerContent
|
||||||
App.Config.set( 'getting_started', Index, 'Routes' )
|
App.Config.set( 'getting_started', Index, 'Routes' )
|
||||||
|
|
||||||
|
|
||||||
class AutoWizard extends App.ControllerContent
|
class AutoWizard extends App.Controller
|
||||||
className: 'getstarted fit'
|
className: 'getstarted fit'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
@ -130,7 +130,7 @@ App.Config.set( 'getting_started/auto_wizard', AutoWizard, 'Routes' )
|
||||||
App.Config.set( 'getting_started/auto_wizard/:token', AutoWizard, 'Routes' )
|
App.Config.set( 'getting_started/auto_wizard/:token', AutoWizard, 'Routes' )
|
||||||
|
|
||||||
|
|
||||||
class Admin extends App.ControllerContent
|
class Admin extends App.Controller
|
||||||
className: 'getstarted fit'
|
className: 'getstarted fit'
|
||||||
events:
|
events:
|
||||||
'submit form': 'submit'
|
'submit form': 'submit'
|
||||||
|
@ -247,7 +247,7 @@ class Admin extends App.ControllerContent
|
||||||
App.Config.set( 'getting_started/admin', Admin, 'Routes' )
|
App.Config.set( 'getting_started/admin', Admin, 'Routes' )
|
||||||
|
|
||||||
|
|
||||||
class Base extends App.ControllerContent
|
class Base extends App.Wizard
|
||||||
className: 'getstarted fit'
|
className: 'getstarted fit'
|
||||||
elements:
|
elements:
|
||||||
'.logo-preview': 'logoPreview'
|
'.logo-preview': 'logoPreview'
|
||||||
|
@ -376,25 +376,10 @@ class Base extends App.ControllerContent
|
||||||
# add resized image
|
# add resized image
|
||||||
App.ImageService.resizeForApp( @params.logo, @logoPreview.width(), @logoPreview.height(), store )
|
App.ImageService.resizeForApp( @params.logo, @logoPreview.width(), @logoPreview.height(), store )
|
||||||
|
|
||||||
hideAlerts: =>
|
|
||||||
@$('.form-group').removeClass('has-error')
|
|
||||||
@$('.alert').addClass('hide')
|
|
||||||
|
|
||||||
showAlert: (field, message) =>
|
|
||||||
@$("[name=#{field}]").closest('.form-group').addClass('has-error')
|
|
||||||
@$("[name=#{field}]").closest('.form-group').find('.alert').removeClass('hide').text( App.i18n.translateInline( message ) )
|
|
||||||
|
|
||||||
disable: (e) =>
|
|
||||||
@formDisable(e)
|
|
||||||
@$('.wizard-controls .btn').attr('disabled', true)
|
|
||||||
|
|
||||||
enable: (e) =>
|
|
||||||
@formEnable(e)
|
|
||||||
@$('.wizard-controls .btn').attr('disabled', false)
|
|
||||||
|
|
||||||
App.Config.set( 'getting_started/base', Base, 'Routes' )
|
App.Config.set( 'getting_started/base', Base, 'Routes' )
|
||||||
|
|
||||||
class EmailNotification extends App.ControllerContent
|
|
||||||
|
class EmailNotification extends App.Wizard
|
||||||
className: 'getstarted fit'
|
className: 'getstarted fit'
|
||||||
events:
|
events:
|
||||||
'change .js-outbound [name=adapter]': 'toggleOutboundAdapter'
|
'change .js-outbound [name=adapter]': 'toggleOutboundAdapter'
|
||||||
|
@ -504,42 +489,20 @@ class EmailNotification extends App.ControllerContent
|
||||||
else
|
else
|
||||||
@showSlide('js-outbound')
|
@showSlide('js-outbound')
|
||||||
@showAlert('js-outbound', data.message_human || data.message )
|
@showAlert('js-outbound', data.message_human || data.message )
|
||||||
|
@showInvalidField('js-outbound', data.invalid_field)
|
||||||
@enable(e)
|
@enable(e)
|
||||||
|
|
||||||
fail: =>
|
fail: =>
|
||||||
@showSlide('js-outbound')
|
@showSlide('js-outbound')
|
||||||
@showAlert('js-outbound', data.message_human || data.message )
|
@showAlert('js-outbound', data.message_human || data.message )
|
||||||
|
@showInvalidField('js-outbound', data.invalid_field)
|
||||||
@enable(e)
|
@enable(e)
|
||||||
)
|
)
|
||||||
|
|
||||||
goToSlide: (e) =>
|
|
||||||
e.preventDefault()
|
|
||||||
slide = $(e.target).data('slide')
|
|
||||||
@showSlide(slide)
|
|
||||||
|
|
||||||
showSlide: (name) =>
|
|
||||||
@hideAlert(name)
|
|
||||||
@$('.setup.wizard').addClass('hide')
|
|
||||||
@$(".setup.wizard.#{name}").removeClass('hide')
|
|
||||||
@$(".setup.wizard.#{name} input, .setup.wizard.#{name} select").first().focus()
|
|
||||||
|
|
||||||
showAlert: (screen, message) =>
|
|
||||||
@$(".#{screen}").find('.alert').removeClass('hide').text( App.i18n.translateInline( message ) )
|
|
||||||
|
|
||||||
hideAlert: (screen) =>
|
|
||||||
@$(".#{screen}").find('.alert').addClass('hide')
|
|
||||||
|
|
||||||
disable: (e) =>
|
|
||||||
@formDisable(e)
|
|
||||||
@$('.wizard-controls .btn').attr('disabled', true)
|
|
||||||
|
|
||||||
enable: (e) =>
|
|
||||||
@formEnable(e)
|
|
||||||
@$('.wizard-controls .btn').attr('disabled', false)
|
|
||||||
|
|
||||||
App.Config.set( 'getting_started/email_notification', EmailNotification, 'Routes' )
|
App.Config.set( 'getting_started/email_notification', EmailNotification, 'Routes' )
|
||||||
|
|
||||||
class Channel extends App.ControllerContent
|
|
||||||
|
class Channel extends App.Controller
|
||||||
className: 'getstarted fit'
|
className: 'getstarted fit'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
@ -592,7 +555,7 @@ class Channel extends App.ControllerContent
|
||||||
|
|
||||||
App.Config.set( 'getting_started/channel', Channel, 'Routes' )
|
App.Config.set( 'getting_started/channel', Channel, 'Routes' )
|
||||||
|
|
||||||
class ChannelEmailPreConfigured extends App.ControllerContent
|
class ChannelEmailPreConfigured extends App.Controller
|
||||||
className: 'getstarted fit'
|
className: 'getstarted fit'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
@ -637,7 +600,7 @@ class ChannelEmailPreConfigured extends App.ControllerContent
|
||||||
|
|
||||||
App.Config.set( 'getting_started/channel/email_pre_configured', ChannelEmailPreConfigured, 'Routes' )
|
App.Config.set( 'getting_started/channel/email_pre_configured', ChannelEmailPreConfigured, 'Routes' )
|
||||||
|
|
||||||
class ChannelEmail extends App.ControllerContent
|
class ChannelEmail extends App.Wizard
|
||||||
className: 'getstarted fit'
|
className: 'getstarted fit'
|
||||||
events:
|
events:
|
||||||
'submit .js-intro': 'probeBasedOnIntro'
|
'submit .js-intro': 'probeBasedOnIntro'
|
||||||
|
@ -896,42 +859,9 @@ class ChannelEmail extends App.ControllerContent
|
||||||
@showAlert('js-intro', 'Unable to verify sending and receiving. Please check your settings.' )
|
@showAlert('js-intro', 'Unable to verify sending and receiving. Please check your settings.' )
|
||||||
)
|
)
|
||||||
|
|
||||||
goToSlide: (e) =>
|
|
||||||
e.preventDefault()
|
|
||||||
slide = $(e.target).data('slide')
|
|
||||||
@showSlide(slide)
|
|
||||||
|
|
||||||
showSlide: (name) =>
|
|
||||||
@hideAlert(name)
|
|
||||||
@$('.setup.wizard').addClass('hide')
|
|
||||||
@$(".setup.wizard.#{name}").removeClass('hide')
|
|
||||||
@$(".setup.wizard.#{name} input, .setup.wizard.#{name} select").first().focus()
|
|
||||||
|
|
||||||
showAlert: (screen, message) =>
|
|
||||||
@$(".#{screen}").find('.alert').removeClass('hide').text( App.i18n.translateInline( message ) )
|
|
||||||
|
|
||||||
hideAlert: (screen) =>
|
|
||||||
@$(".#{screen}").find('.alert').addClass('hide')
|
|
||||||
|
|
||||||
disable: (e) =>
|
|
||||||
@formDisable(e)
|
|
||||||
@$('.wizard-controls .btn').attr('disabled', true)
|
|
||||||
|
|
||||||
enable: (e) =>
|
|
||||||
@formEnable(e)
|
|
||||||
@$('.wizard-controls .btn').attr('disabled', false)
|
|
||||||
|
|
||||||
showInvalidField: (screen, fields) =>
|
|
||||||
@$(".#{screen}").find('.form-group').removeClass('has-error')
|
|
||||||
return if !fields
|
|
||||||
for field, type of fields
|
|
||||||
if type
|
|
||||||
@$(".#{screen}").find("[name=\"options::#{field}\"]").closest('.form-group').addClass('has-error')
|
|
||||||
|
|
||||||
App.Config.set( 'getting_started/channel/email', ChannelEmail, 'Routes' )
|
App.Config.set( 'getting_started/channel/email', ChannelEmail, 'Routes' )
|
||||||
|
|
||||||
|
class Agent extends App.Controller
|
||||||
class Agent extends App.ControllerContent
|
|
||||||
className: 'getstarted fit'
|
className: 'getstarted fit'
|
||||||
events:
|
events:
|
||||||
'submit form': 'submit'
|
'submit form': 'submit'
|
||||||
|
@ -1031,7 +961,7 @@ class Agent extends App.ControllerContent
|
||||||
|
|
||||||
App.Config.set( 'getting_started/agents', Agent, 'Routes' )
|
App.Config.set( 'getting_started/agents', Agent, 'Routes' )
|
||||||
|
|
||||||
class Channel extends App.ControllerContent
|
class Channel extends App.Controller
|
||||||
className: 'getstarted fit'
|
className: 'getstarted fit'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
|
|
@ -69,35 +69,37 @@
|
||||||
|
|
||||||
<a data-type="new" class="btn btn--success"><%- @T('New') %></a>
|
<a data-type="new" class="btn btn--success"><%- @T('New') %></a>
|
||||||
|
|
||||||
<h1><%- @T('Notification Account') %></h1>
|
<% if @channel && !App.Config.get('system_online_service'): %>
|
||||||
|
<h1><%- @T('Notification Account') %></h1>
|
||||||
|
|
||||||
<table class="table table-hover user-list">
|
<table class="table table-hover user-list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%- @T('Outbound') %></th>
|
<th><%- @T('Outbound') %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr data-id="<%- @channel.id %>">
|
<tr data-id="<%- @channel.id %>">
|
||||||
<td class="<% if @channel.status_out is 'ok': %>success<% else if @channel.status_out is 'error': %>danger<% else: %>warning<% end %>">
|
<td class="<% if @channel.status_out is 'ok': %>success<% else if @channel.status_out is 'error': %>danger<% else: %>warning<% end %>">
|
||||||
<%- @T('State') %>: <%- @T(@channel.status_out || 'unknown') %><br>
|
<%- @T('State') %>: <%- @T(@channel.status_out || 'unknown') %><br>
|
||||||
<a href="#" data-type="edit-notification-outbound">
|
<a href="#" data-type="edit-notification-outbound">
|
||||||
<% if @channel.options.outbound && @channel.options.outbound.options: %>
|
<% if @channel.options.outbound && @channel.options.outbound.options: %>
|
||||||
<%= @channel.options.outbound.options.user %><br>
|
<%= @channel.options.outbound.options.user %><br>
|
||||||
<%= @channel.options.outbound.options.host %>
|
<%= @channel.options.outbound.options.host %>
|
||||||
<% end %>
|
<% end %>
|
||||||
(<%= @channel.options.outbound.adapter %>)</a>
|
(<%= @channel.options.outbound.adapter %>)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% if @channel.status_in is 'error': %>
|
<% if @channel.status_in is 'error': %>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1"><%= @channel.last_log_in %></td>
|
<td colspan="1"><%= @channel.last_log_in %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @channel.status_out is 'error': %>
|
<% if @channel.status_out is 'error': %>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1"><%= @channel.last_log_out %></td>
|
<td colspan="1"><%= @channel.last_log_out %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<svg class="wizard-logo icon-full-logo"><use xlink:href="#icon-full-logo" /></svg>
|
<svg class="wizard-logo icon-full-logo"><use xlink:href="#icon-full-logo" /></svg>
|
||||||
|
|
||||||
<form class="setup wizard js-outbound">
|
<form class="setup wizard js-outbound">
|
||||||
|
<input type="password" style="display:none"/><!-- dummy to prevent chrome to ask for password save -->
|
||||||
<div class="wizard-slide">
|
<div class="wizard-slide">
|
||||||
<h2><%- @T('Email Notification') %></h2>
|
<h2><%- @T('Email Notification') %></h2>
|
||||||
<div class="wizard-body vertical justified">
|
<div class="wizard-body vertical justified">
|
||||||
|
|
|
@ -216,14 +216,14 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
|
||||||
|
|
||||||
def email_index
|
def email_index
|
||||||
return if deny_if_not_role(Z_ROLENAME_ADMIN)
|
return if deny_if_not_role(Z_ROLENAME_ADMIN)
|
||||||
|
system_online_service = Setting.get('system_online_service')
|
||||||
assets = {}
|
assets = {}
|
||||||
Channel.all.each {|channel|
|
Channel.all.each {|channel|
|
||||||
next if channel.preferences && channel.preferences[:online_service_disable]
|
next if system_online_service && channel.preferences && channel.preferences[:online_service_disable]
|
||||||
assets = channel.assets(assets)
|
assets = channel.assets(assets)
|
||||||
}
|
}
|
||||||
EmailAddress.all.each {|email_address|
|
EmailAddress.all.each {|email_address|
|
||||||
next if email_address.preferences && email_address.preferences[:online_service_disable]
|
next if system_online_service && email_address.preferences && email_address.preferences[:online_service_disable]
|
||||||
assets = email_address.assets(assets)
|
assets = email_address.assets(assets)
|
||||||
}
|
}
|
||||||
render json: {
|
render json: {
|
||||||
|
|
Loading…
Reference in a new issue