Notify code cleanup.
This commit is contained in:
parent
6f8d3ee1b6
commit
09531e7a4d
|
@ -1,6 +1,6 @@
|
||||||
class Index extends App.ControllerContent
|
class Index extends App.ControllerContent
|
||||||
events:
|
events:
|
||||||
'submit #login': 'login',
|
'submit #login': 'login'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
@ -47,7 +47,7 @@ class Index extends App.ControllerContent
|
||||||
auth_providers: auth_providers
|
auth_providers: auth_providers
|
||||||
)
|
)
|
||||||
|
|
||||||
# set focus
|
# set focus to username or password
|
||||||
if !$(@el).find('[name="username"]').val()
|
if !$(@el).find('[name="username"]').val()
|
||||||
$(@el).find('[name="username"]').focus()
|
$(@el).find('[name="username"]').focus()
|
||||||
else
|
else
|
||||||
|
@ -68,9 +68,9 @@ class Index extends App.ControllerContent
|
||||||
|
|
||||||
# session create with login/password
|
# session create with login/password
|
||||||
App.Auth.login(
|
App.Auth.login(
|
||||||
data: params,
|
data: params
|
||||||
success: @success
|
success: @success
|
||||||
error: @error,
|
error: @error
|
||||||
)
|
)
|
||||||
|
|
||||||
success: (data, status, xhr) =>
|
success: (data, status, xhr) =>
|
||||||
|
@ -80,15 +80,14 @@ class Index extends App.ControllerContent
|
||||||
App.WebSocket.send( event: 'navupdate_ticket_overview' )
|
App.WebSocket.send( event: 'navupdate_ticket_overview' )
|
||||||
|
|
||||||
# add notify
|
# add notify
|
||||||
App.Event.trigger 'notify:removeall'
|
@notify
|
||||||
App.Event.trigger 'notify', {
|
type: 'success'
|
||||||
type: 'success',
|
msg: App.i18n.translateContent('Login successfully! Have a nice day!')
|
||||||
msg: App.i18n.translateContent('Login successfully! Have a nice day!'),
|
removeAll: true
|
||||||
}
|
|
||||||
|
|
||||||
# redirect to #
|
# redirect to #
|
||||||
requested_url = @Config.get( 'requested_url' )
|
requested_url = @Config.get( 'requested_url' )
|
||||||
if requested_url isnt ''
|
if requested_url && requested_url isnt '#login'
|
||||||
console.log("REDIRECT to '#{requested_url}'")
|
console.log("REDIRECT to '#{requested_url}'")
|
||||||
@navigate requested_url
|
@navigate requested_url
|
||||||
|
|
||||||
|
@ -101,11 +100,10 @@ class Index extends App.ControllerContent
|
||||||
error: (xhr, statusText, error) =>
|
error: (xhr, statusText, error) =>
|
||||||
|
|
||||||
# add notify
|
# add notify
|
||||||
App.Event.trigger 'notify:removeall'
|
@notify
|
||||||
App.Event.trigger 'notify', {
|
type: 'error'
|
||||||
type: 'error',
|
msg: App.i18n.translateContent('Wrong Username and Password combination.')
|
||||||
msg: App.i18n.translateContent('Wrong Username and Password combination.'),
|
removeAll: true
|
||||||
}
|
|
||||||
|
|
||||||
# rerender login page
|
# rerender login page
|
||||||
@render(
|
@render(
|
||||||
|
@ -115,7 +113,7 @@ class Index extends App.ControllerContent
|
||||||
# login shake
|
# login shake
|
||||||
@delay(
|
@delay(
|
||||||
=> @shake( @el.find('#login') ),
|
=> @shake( @el.find('#login') ),
|
||||||
700
|
600
|
||||||
)
|
)
|
||||||
|
|
||||||
App.Config.set( 'login', Index, 'Routes' )
|
App.Config.set( 'login', Index, 'Routes' )
|
||||||
|
|
|
@ -24,27 +24,29 @@ class App.Notify extends Spine.Controller
|
||||||
if data['type'] is 'warning'
|
if data['type'] is 'warning'
|
||||||
data['type'] = 'alert'
|
data['type'] = 'alert'
|
||||||
|
|
||||||
$.noty.closeAll()
|
if data['removeAll']
|
||||||
|
$.noty.closeAll()
|
||||||
if data.link
|
if data.link
|
||||||
data.msg = '<a href="' + data.link + '">' + data.msg + '</a>'
|
data.msg = '<a href="' + data.link + '">' + data.msg + '</a>'
|
||||||
$('#notify').noty(
|
$('#notify').noty(
|
||||||
{
|
{
|
||||||
text: data.msg,
|
dismissQueue: true
|
||||||
layout: 'top',
|
text: data.msg
|
||||||
type: data.type,
|
layout: 'top'
|
||||||
theme: 'noty_theme_twitter',
|
type: data.type
|
||||||
|
theme: 'noty_theme_twitter'
|
||||||
animateOpen: {
|
animateOpen: {
|
||||||
height: 'toggle'
|
height: 'toggle'
|
||||||
opacity: 0.85,
|
opacity: 0.85,
|
||||||
},
|
},
|
||||||
animateClose: {
|
animateClose: {
|
||||||
opacity: 0.25,
|
opacity: 0.25
|
||||||
},
|
},
|
||||||
speed: 450,
|
speed: 450
|
||||||
timeout: data.timeout || 3800,
|
timeout: data.timeout || 3800
|
||||||
closeButton: false,
|
closeButton: false
|
||||||
closeOnSelfClick: true,
|
closeOnSelfClick: true
|
||||||
closeOnSelfOver: false,
|
closeOnSelfOver: false
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -140,10 +140,10 @@ class Verify extends App.ControllerContent
|
||||||
App.Auth.loginCheck()
|
App.Auth.loginCheck()
|
||||||
|
|
||||||
# add notify
|
# add notify
|
||||||
App.Event.trigger 'notify:removeall'
|
|
||||||
@notify
|
@notify
|
||||||
type: 'success',
|
type: 'success'
|
||||||
msg: 'Woo hoo! Your password has been changed!'
|
msg: 'Woo hoo! Your password has been changed!'
|
||||||
|
removeAll: true
|
||||||
|
|
||||||
# redirect to #
|
# redirect to #
|
||||||
@navigate '#'
|
@navigate '#'
|
||||||
|
@ -151,10 +151,10 @@ class Verify extends App.ControllerContent
|
||||||
error: =>
|
error: =>
|
||||||
|
|
||||||
# add notify
|
# add notify
|
||||||
App.Event.trigger 'notify:removeall'
|
|
||||||
@notify
|
@notify
|
||||||
type: 'error',
|
type: 'error'
|
||||||
msg: 'Something went wrong. Please contact your administrator.'
|
msg: 'Something went wrong. Please contact your administrator.'
|
||||||
|
removeAll: true
|
||||||
)
|
)
|
||||||
|
|
||||||
render_changed_failed: =>
|
render_changed_failed: =>
|
||||||
|
|
|
@ -2,9 +2,9 @@ class Index extends App.ControllerContent
|
||||||
className: 'container signup'
|
className: 'container signup'
|
||||||
|
|
||||||
events:
|
events:
|
||||||
'submit form': 'submit',
|
'submit form': 'submit'
|
||||||
'click .submit': 'submit',
|
'click .submit': 'submit'
|
||||||
'click .cancel': 'cancel',
|
'click .cancel': 'cancel'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
@ -37,7 +37,7 @@ class Index extends App.ControllerContent
|
||||||
)
|
)
|
||||||
|
|
||||||
cancel: ->
|
cancel: ->
|
||||||
@navigate 'login'
|
@navigate '#login'
|
||||||
|
|
||||||
submit: (e) ->
|
submit: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
@ -80,10 +80,10 @@ class Index extends App.ControllerContent
|
||||||
App.Auth.loginCheck()
|
App.Auth.loginCheck()
|
||||||
|
|
||||||
# add notify
|
# add notify
|
||||||
App.Event.trigger 'notify:removeall'
|
|
||||||
@notify
|
@notify
|
||||||
type: 'success',
|
type: 'success'
|
||||||
msg: 'Thanks for joining. Email sent to "' + @params.email + '". Please verify your email address.'
|
msg: 'Thanks for joining. Email sent to "' + @params.email + '". Please verify your email address.'
|
||||||
|
removeAll: true
|
||||||
|
|
||||||
# redirect to #
|
# redirect to #
|
||||||
@navigate '#'
|
@navigate '#'
|
||||||
|
@ -91,16 +91,9 @@ class Index extends App.ControllerContent
|
||||||
error: (xhr, statusText, error) =>
|
error: (xhr, statusText, error) =>
|
||||||
|
|
||||||
# add notify
|
# add notify
|
||||||
App.Event.trigger 'notify:removeall'
|
@notify
|
||||||
App.Event.trigger 'notify', {
|
type: 'warning'
|
||||||
type: 'warning'
|
msg: 'Wrong Username and Password combination.'
|
||||||
msg: 'Wrong Username and Password combination.'
|
removeAll: true
|
||||||
}
|
|
||||||
|
|
||||||
# rerender login page
|
|
||||||
@render(
|
|
||||||
msg: 'Wrong Username and Password combination.'
|
|
||||||
username: @username
|
|
||||||
)
|
|
||||||
|
|
||||||
App.Config.set( 'signup', Index, 'Routes' )
|
App.Config.set( 'signup', Index, 'Routes' )
|
Loading…
Reference in a new issue