Added config option for browser tracking and browser storage.

This commit is contained in:
Martin Edenhofer 2014-07-28 09:36:05 +02:00
parent a937196a49
commit 202269bb58
7 changed files with 114 additions and 12 deletions

View file

@ -311,7 +311,6 @@ class App.ControllerNavSidbar extends App.ControllerContent
group.items = _.sortBy( itemsUnsorted, (item) -> return item.prio ) group.items = _.sortBy( itemsUnsorted, (item) -> return item.prio )
# set active item # set active item
selectedItem = undefined selectedItem = undefined
for group in @groupsSorted for group in @groupsSorted
@ -328,11 +327,6 @@ class App.ControllerNavSidbar extends App.ControllerContent
@render(selectedItem) @render(selectedItem)
if selectedItem
new selectedItem.controller(
el: @el.find('.main')
)
@bind( @bind(
'ui:rerender' 'ui:rerender'
=> =>
@ -349,6 +343,10 @@ class App.ControllerNavSidbar extends App.ControllerContent
@el.find('li').removeClass('active') @el.find('li').removeClass('active')
@el.find('a[href="' + selectedItem.target + '"]').parent().addClass('active') @el.find('a[href="' + selectedItem.target + '"]').parent().addClass('active')
new selectedItem.controller(
el: @el.find('.main')
)
class App.GenericHistory extends App.ControllerModal class App.GenericHistory extends App.ControllerModal
events: events:
'click [data-type=sortorder]': 'sortorder', 'click [data-type=sortorder]': 'sortorder',

View file

@ -10,11 +10,11 @@ class App.SettingsArea extends App.Controller
render: => render: =>
settings = App.Setting.all() settings = App.Setting.all()
html = $('<div></div>') html = $('<div></div>')
for setting in settings for setting in settings
if setting.area is @area if setting.area is @area
item = new App.SettingsAreaItem( setting: setting ) item = new App.SettingsAreaItem( setting: setting )
html.append( item.el ) html.append( item.el )
@html html @html html
@ -67,10 +67,12 @@ class App.SettingsAreaItem extends App.Controller
state = { state = {
value: params value: params
} }
#App.Config.set((@setting.name, params)
else else
state = { state = {
value: directData value: directData
} }
#App.Config.set(@setting.name, directData)
@setting['state'] = state @setting['state'] = state
ui = @ ui = @
@ -83,6 +85,7 @@ class App.SettingsAreaItem extends App.Controller
timeout: 1500 timeout: 1500
} }
ui.render() ui.render()
#App.Event.trigger( 'ui:rerender' )
# login check # login check
# App.Auth.loginCheck() App.Auth.loginCheck()
) )

View file

@ -10,6 +10,7 @@ class System extends App.ControllerTabs
# { name: 'Log', 'target': 'log', controller: App.SettingsSystem, params: { area: 'System::Log' } }, # { name: 'Log', 'target': 'log', controller: App.SettingsSystem, params: { area: 'System::Log' } },
{ name: 'Storage', 'target': 'storage', controller: App.SettingsArea, params: { area: 'System::Storage' } }, { name: 'Storage', 'target': 'storage', controller: App.SettingsArea, params: { area: 'System::Storage' } },
{ name: 'Geo Services', 'target': 'geo', controller: App.SettingsArea, params: { area: 'System::Geo' } }, { name: 'Geo Services', 'target': 'geo', controller: App.SettingsArea, params: { area: 'System::Geo' } },
{ name: 'Frontend', 'target': 'ui', controller: App.SettingsArea, params: { area: 'System::UI' } },
] ]
# render page # render page

View file

@ -89,8 +89,8 @@ class _trackSingleton
return return
) )
log: ( area, level, args ) -> log: ( area, level, args ) ->
return if !App.Config.get('ui_send_client_stats')
info = info =
time: Math.round( new Date().getTime() / 1000 ) time: Math.round( new Date().getTime() / 1000 )
area: area area: area
@ -100,10 +100,11 @@ class _trackSingleton
@data.push info @data.push info
send: (async = true) => send: (async = true) =>
return if !App.Config.get('ui_send_client_stats')
return if _.isEmpty @data return if _.isEmpty @data
newData = _.clone( @data ) newData = _.clone( @data )
@data = [] @data = []
newDataNew = [] newDataNew = []
for item in newData for item in newData
try try
itemNew = _.clone( item ) itemNew = _.clone( item )

View file

@ -46,6 +46,7 @@ class _storeSingleton
write: (key, value) -> write: (key, value) ->
@store[key] = value @store[key] = value
return if !@support return if !@support
return if !App.Config.get('ui_client_storage')
try try
sessionStorage.setItem( key, JSON.stringify( value ) ) sessionStorage.setItem( key, JSON.stringify( value ) )
catch e catch e
@ -56,6 +57,7 @@ class _storeSingleton
# get item # get item
get: (key) -> get: (key) ->
return @store[key] if !@support return @store[key] if !@support
return @store[key] if !App.Config.get('ui_client_storage')
value = sessionStorage.getItem( key ) value = sessionStorage.getItem( key )
return if !value return if !value
object = JSON.parse( value ) object = JSON.parse( value )
@ -65,6 +67,7 @@ class _storeSingleton
delete: (key) -> delete: (key) ->
delete @store[key] delete @store[key]
return if !@support return if !@support
return if !App.Config.get('ui_client_storage')
sessionStorage.removeItem( key ) sessionStorage.removeItem( key )
# clear local storage # clear local storage
@ -75,7 +78,7 @@ class _storeSingleton
# return list of all keys # return list of all keys
list: -> list: ->
list = [] list = []
if !@support if !@support || !App.Config.get('ui_client_storage')
for key of @store for key of @store
list.push key list.push key
return list return list

View file

@ -0,0 +1,51 @@
class UpdateSetting1 < ActiveRecord::Migration
def up
Setting.create_if_not_exists(
:title => 'Send client stats.',
:name => 'ui_send_client_stats',
:area => 'System::UI',
:description => 'Send client stats to central server.',
:options => {
:form => [
{
:display => '',
:null => true,
:name => 'ui_send_client_stats',
:tag => 'boolean',
:options => {
true => 'yes',
false => 'no',
},
},
],
},
:state => true,
:frontend => true
)
Setting.create_if_not_exists(
:title => 'Client storage.',
:name => 'ui_client_storage',
:area => 'System::UI',
:description => 'Use client storage to cache data to perform speed of application.',
:options => {
:form => [
{
:display => '',
:null => true,
:name => 'ui_client_storage',
:tag => 'boolean',
:options => {
true => 'yes',
false => 'no',
},
},
],
},
:state => false,
:frontend => true
)
end
def down
end
end

View file

@ -178,6 +178,51 @@ Setting.create_if_not_exists(
:frontend => false :frontend => false
) )
Setting.create_if_not_exists(
:title => 'Send client stats.',
:name => 'ui_send_client_stats',
:area => 'System::UI',
:description => 'Send client stats to central server.',
:options => {
:form => [
{
:display => '',
:null => true,
:name => 'ui_send_client_stats',
:tag => 'boolean',
:options => {
true => 'yes',
false => 'no',
},
},
],
},
:state => true,
:frontend => true
)
Setting.create_if_not_exists(
:title => 'Client storage.',
:name => 'ui_client_storage',
:area => 'System::UI',
:description => 'Use client storage to cache data to perform speed of application.',
:options => {
:form => [
{
:display => '',
:null => true,
:name => 'ui_client_storage',
:tag => 'boolean',
:options => {
true => 'yes',
false => 'no',
},
},
],
},
:state => false,
:frontend => true
)
Setting.create_if_not_exists( Setting.create_if_not_exists(
:title => 'New User Accounts', :title => 'New User Accounts',
:name => 'user_create_account', :name => 'user_create_account',