Improved default route for ui controller.
This commit is contained in:
parent
bcd9395b5f
commit
cddcbf3957
7 changed files with 81 additions and 11 deletions
|
@ -1,5 +1,3 @@
|
||||||
$ = jQuery.sub()
|
|
||||||
|
|
||||||
class Index extends App.Controller
|
class Index extends App.Controller
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
@ -8,14 +6,13 @@ class Index extends App.Controller
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate()
|
||||||
|
|
||||||
# check role
|
|
||||||
if @isRole('Customer')
|
if @isRole('Customer')
|
||||||
@navigate '#ticket_view/my_tickets'
|
@navigate '#'
|
||||||
return
|
return
|
||||||
|
|
||||||
# set title
|
# set title
|
||||||
@title 'Dashboard'
|
@title 'Dashboard'
|
||||||
@navupdate '#/'
|
@navupdate '#dashboard'
|
||||||
|
|
||||||
@plugins = {
|
@plugins = {
|
||||||
main: {
|
main: {
|
||||||
|
@ -91,5 +88,4 @@ class Index extends App.Controller
|
||||||
@el.find( '#sortable' ).sortable( dndOptions )
|
@el.find( '#sortable' ).sortable( dndOptions )
|
||||||
@el.find( '#sortable-sidebar' ).sortable( dndOptions )
|
@el.find( '#sortable-sidebar' ).sortable( dndOptions )
|
||||||
|
|
||||||
App.Config.set( '', Index, 'Routes' )
|
App.Config.set( 'dashboard', Index, 'Routes' )
|
||||||
App.Config.set( '/', Index, 'Routes' )
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
class Index extends App.Controller
|
||||||
|
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
|
||||||
|
if !@Config.get('system_init_done')
|
||||||
|
@navigate '#getting_started'
|
||||||
|
return
|
||||||
|
|
||||||
|
# check role
|
||||||
|
if @isRole('Customer')
|
||||||
|
@navigate '#ticket_view/my_tickets'
|
||||||
|
return
|
||||||
|
|
||||||
|
if @Config.get('default_controller')
|
||||||
|
@navigate @Config.get('default_controller')
|
||||||
|
return
|
||||||
|
|
||||||
|
@navigate '#dashboard'
|
||||||
|
|
||||||
|
App.Config.set( '', Index, 'Routes' )
|
||||||
|
App.Config.set( '/', Index, 'Routes' )
|
|
@ -4,6 +4,12 @@ class Index extends App.Controller
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
|
||||||
|
# navigate to # if sesstion if exists
|
||||||
|
if @Session.get( 'id' )
|
||||||
|
@navigate '#'
|
||||||
|
return
|
||||||
|
|
||||||
@title 'Sign in'
|
@title 'Sign in'
|
||||||
@render()
|
@render()
|
||||||
@navupdate '#login'
|
@navupdate '#login'
|
||||||
|
|
|
@ -172,6 +172,19 @@ curl http://localhost/api/users.json -v -u #{login}:#{password} -H "Content-Type
|
||||||
|
|
||||||
user.save
|
user.save
|
||||||
|
|
||||||
|
# if first user set init done
|
||||||
|
if count <= 2
|
||||||
|
Setting.create_or_update(
|
||||||
|
:title => 'System Init Done',
|
||||||
|
:name => 'system_init_done',
|
||||||
|
:area => 'Core',
|
||||||
|
:description => 'Defines if application is in init mode.',
|
||||||
|
:options => {},
|
||||||
|
:state => true,
|
||||||
|
:frontend => true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
# send inviteation if needed / only if session exists
|
# send inviteation if needed / only if session exists
|
||||||
if params[:invite] && current_user
|
if params[:invite] && current_user
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,12 @@ class Setting < ApplicationModel
|
||||||
after_create :delete_cache
|
after_create :delete_cache
|
||||||
after_update :delete_cache
|
after_update :delete_cache
|
||||||
|
|
||||||
|
@@current = {}
|
||||||
|
|
||||||
def self.load
|
def self.load
|
||||||
|
|
||||||
# check if config is already generated
|
# check if config is already generated
|
||||||
return Thread.current[:settings_config] if Thread.current[:settings_config]
|
return @@current[:settings_config] if @@current[:settings_config]
|
||||||
|
|
||||||
# read all config settings
|
# read all config settings
|
||||||
config = {}
|
config = {}
|
||||||
|
@ -27,7 +29,7 @@ class Setting < ApplicationModel
|
||||||
}
|
}
|
||||||
|
|
||||||
# store for class requests
|
# store for class requests
|
||||||
Thread.current[:settings_config] = config
|
@@current[:settings_config] = config
|
||||||
return config
|
return config
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,12 +44,12 @@ class Setting < ApplicationModel
|
||||||
|
|
||||||
def self.get(name)
|
def self.get(name)
|
||||||
self.load
|
self.load
|
||||||
return Thread.current[:settings_config][name]
|
return @@current[:settings_config][name]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def delete_cache
|
def delete_cache
|
||||||
Thread.current[:settings_config] = nil
|
@@current[:settings_config] = nil
|
||||||
end
|
end
|
||||||
def set_initial
|
def set_initial
|
||||||
self.state_initial = self.state
|
self.state_initial = self.state
|
||||||
|
|
21
db/migrate/20130319003833_setting_update.rb
Normal file
21
db/migrate/20130319003833_setting_update.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
require 'user'
|
||||||
|
require 'setting'
|
||||||
|
class SettingUpdate < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
count = User.all.count()
|
||||||
|
if count <= 2
|
||||||
|
Setting.create_or_update(
|
||||||
|
:title => 'System Init Done',
|
||||||
|
:name => 'system_init_done',
|
||||||
|
:area => 'Core',
|
||||||
|
:description => 'Defines if application is in init mode.',
|
||||||
|
:options => {},
|
||||||
|
:state => true,
|
||||||
|
:frontend => true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
10
db/seeds.rb
10
db/seeds.rb
|
@ -995,6 +995,16 @@ Setting.create_if_not_exists(
|
||||||
:frontend => true
|
:frontend => true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
:title => 'Default Screen',
|
||||||
|
:name => 'default_controller',
|
||||||
|
:area => 'Core',
|
||||||
|
:description => 'Defines the default controller.',
|
||||||
|
:options => {},
|
||||||
|
:state => '#dashboard',
|
||||||
|
:frontend => true
|
||||||
|
)
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
:title => 'Import Mode',
|
:title => 'Import Mode',
|
||||||
:name => 'import_mode',
|
:name => 'import_mode',
|
||||||
|
|
Loading…
Reference in a new issue