anoubis 1.0.1 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -0
  3. data/app/controllers/anoubis/application_controller.rb +4 -0
  4. data/app/controllers/anoubis/core/index/actions.rb +1 -1
  5. data/app/controllers/anoubis/core/index_controller.rb +3 -3
  6. data/app/controllers/anoubis/data/actions.rb +947 -0
  7. data/app/controllers/anoubis/data/callbacks.rb +66 -0
  8. data/app/controllers/anoubis/data/convert.rb +422 -0
  9. data/app/controllers/anoubis/data/defaults.rb +215 -0
  10. data/app/controllers/anoubis/data/get.rb +529 -0
  11. data/app/controllers/anoubis/data/load.rb +87 -0
  12. data/app/controllers/anoubis/data/set.rb +47 -0
  13. data/app/controllers/anoubis/data/setup.rb +102 -0
  14. data/app/controllers/anoubis/data_controller.rb +21 -0
  15. data/app/controllers/anoubis/etc/field.rb +7 -0
  16. data/app/controllers/anoubis/output/basic.rb +1 -1
  17. data/app/controllers/anoubis/sso/client/index_controller.rb +2 -2
  18. data/app/controllers/anoubis/sso/server/login_controller.rb +5 -5
  19. data/app/controllers/anoubis/sso/server/user_controller.rb +2 -2
  20. data/app/controllers/anoubis/tenant/index_controller.rb +3 -3
  21. data/app/models/anoubis/application_record.rb +141 -0
  22. data/app/services/anoubis/log_service.rb +97 -0
  23. data/app/services/anoubis/request_service.rb +134 -0
  24. data/config/locales/en.yml +20 -6
  25. data/config/locales/ru.yml +25 -13
  26. data/config/routes.rb +19 -19
  27. data/lib/anoubis/version.rb +1 -1
  28. metadata +32 -33
  29. data/app/controllers/anoubis/core/data/actions.rb +0 -962
  30. data/app/controllers/anoubis/core/data/callbacks.rb +0 -68
  31. data/app/controllers/anoubis/core/data/convert.rb +0 -407
  32. data/app/controllers/anoubis/core/data/defaults.rb +0 -217
  33. data/app/controllers/anoubis/core/data/get.rb +0 -531
  34. data/app/controllers/anoubis/core/data/load.rb +0 -89
  35. data/app/controllers/anoubis/core/data/set.rb +0 -49
  36. data/app/controllers/anoubis/core/data/setup.rb +0 -104
  37. data/app/controllers/anoubis/core/data_controller.rb +0 -28
  38. data/app/controllers/anoubis/sso/client/data/actions.rb +0 -5
  39. data/app/controllers/anoubis/sso/client/data/callbacks.rb +0 -5
  40. data/app/controllers/anoubis/sso/client/data/convert.rb +0 -5
  41. data/app/controllers/anoubis/sso/client/data/defaults.rb +0 -5
  42. data/app/controllers/anoubis/sso/client/data/get.rb +0 -5
  43. data/app/controllers/anoubis/sso/client/data/load.rb +0 -26
  44. data/app/controllers/anoubis/sso/client/data/set.rb +0 -5
  45. data/app/controllers/anoubis/sso/client/data/setup.rb +0 -5
  46. data/app/controllers/anoubis/sso/client/data_controller.rb +0 -21
  47. data/app/controllers/anoubis/tenant/data/actions.rb +0 -11
  48. data/app/controllers/anoubis/tenant/data/callbacks.rb +0 -11
  49. data/app/controllers/anoubis/tenant/data/convert.rb +0 -11
  50. data/app/controllers/anoubis/tenant/data/defaults.rb +0 -11
  51. data/app/controllers/anoubis/tenant/data/get.rb +0 -11
  52. data/app/controllers/anoubis/tenant/data/load.rb +0 -52
  53. data/app/controllers/anoubis/tenant/data/set.rb +0 -11
  54. data/app/controllers/anoubis/tenant/data/setup.rb +0 -11
  55. data/app/controllers/anoubis/tenant/data_controller.rb +0 -28
  56. data/app/controllers/anoubis/tenants_controller.rb +0 -7
  57. data/app/controllers/anoubis/users_controller.rb +0 -7
  58. data/app/mailers/anoubis/application_mailer.rb +0 -8
@@ -1,104 +0,0 @@
1
- module Anoubis
2
- ##
3
- # Module consists all procedures and functons of {DataController}
4
- module Core
5
- module Data
6
- ##
7
- # Module setups system parameters for {DataController}
8
- module Setup
9
- ##
10
- # Setups frame data information. It loads menu data, sets titles and tabs of the frame.
11
- def setup_frame
12
- self.load_menu_data
13
- if self.etc.menu
14
- self.get_parent_data
15
- if self.etc.data.parent
16
- self.output.title = self.etc.menu.page_title.sub '%{title}', self.etc.data.parent.sys_title.to_s
17
- else
18
- self.output.title = self.etc.menu.page_title
19
- end
20
- self.output.short = self.etc.menu.short_title
21
- self.output.mode = self.etc.menu.mode
22
- self.output.access = self.etc.menu.access
23
- end
24
- tabs = self.tabs
25
- tabs.each do |key, item|
26
- item = self.get_tab key, item
27
- self.output.addTab(item)
28
- end
29
- end
30
-
31
- ##
32
- # Setups order for current tab. Parameters is set into {Anoubis::Etc::TabItem#sort self.etc.tab.sort} and
33
- # {Anoubis::Etc::TabItem#order self.etc.tab.order} attributes.
34
- def setup_order
35
- sort = nil
36
- first = nil
37
- self.etc.data.fields.each do |key, field|
38
- if field.order
39
- first = key if !first
40
- first = key if field.order.default
41
- if params.key? :sort
42
- sort = key if params[:sort] == key.to_s
43
- end
44
- end
45
- end
46
- sort = first if !sort
47
- if sort
48
- self.etc.tab.sort = sort.to_s
49
- self.etc.tab.order = self.etc.data.fields[sort].order.order
50
- if params.key? :order
51
- self.etc.tab.order = :desc if params[:order] == 'desc'
52
- self.etc.tab.order = :asc if params[:order] == 'asc'
53
- end
54
- end
55
- end
56
-
57
- ##
58
- # @!group Block of fields setup functions
59
-
60
- ##
61
- # Setups defined fields and places it into attribute {Anoubis::Etc::Data#fields self.etc.data.fields}
62
- def setup_fields
63
- if !self.etc.data.fields
64
- self.etc.data.fields = {}
65
-
66
- fields = self.fields
67
-
68
- fields.each_key do |key|
69
- if fields[key].key? :edit
70
- if self.menu_access fields[key][:edit], false
71
- fields[key][:editable] = fields[key][:edit]
72
- end
73
- end
74
- self.etc.data.fields[key] = Anoubis::Etc::Field.new(key, self.get_model, fields[key].merge(action: self.etc.action))
75
- end
76
- self.setup_order if %w[index export].include? self.etc.action
77
- end
78
- end
79
-
80
- ##
81
- # Setups additional parameters for table field with type 'datetime'
82
- # Resulting data placed in {Etc::Data#fields self.etc.data.fields} (Hash)
83
- # @param key [Symbol] key of table field.
84
- def setup_fields_datetime (key)
85
- self.etc.data.fields[key][:format] = 'full' if !self.etc.data.fields[key].has_key? :format
86
- self.etc.data.fields[key][:format] = 'full' if !['full', 'month', 'date', 'datetime'].include? self.etc.data.fields[key][:format]
87
- end
88
-
89
-
90
-
91
- ##
92
- # Setups additional parameters for table field with type 'float'
93
- # Resulting data placed in {Etc::Data#fields self.etc.data.fields} (Hash)
94
- # @param key [Symbol] key of table field.
95
- def setup_fields_float (key)
96
- self.etc.data.fields[key][:precision] = 2 if !self.etc.data.fields[key][:precision]
97
- self.etc.data.fields[key][:point] = ',' if !self.etc.data.fields[key][:point]
98
- self.etc.data.fields[key][:separator] = '' if !self.etc.data.fields[key][:separator]
99
- end
100
- # @!endgroup
101
- end
102
- end
103
- end
104
- end
@@ -1,28 +0,0 @@
1
- require_dependency "anubis/core/application_controller"
2
- require_dependency "anubis/core/data/actions"
3
- require_dependency "anubis/core/data/load"
4
- require_dependency "anubis/core/data/get"
5
- require_dependency "anubis/core/data/set"
6
- require_dependency "anubis/core/data/setup"
7
- require_dependency "anubis/core/data/defaults"
8
- require_dependency "anubis/core/data/convert"
9
- require_dependency "anubis/core/data/callbacks"
10
-
11
- module Anoubis
12
- ##
13
- # Module presents all core functions for Anubis Library
14
- module Core
15
- ##
16
- # Controller consists all procedures and function for presents and modify models data.
17
- class DataController < Anoubis::Core::ApplicationController
18
- include Anoubis::Core::Data::Actions
19
- include Anoubis::Core::Data::Load
20
- include Anoubis::Core::Data::Get
21
- include Anoubis::Core::Data::Set
22
- include Anoubis::Core::Data::Setup
23
- include Anoubis::Core::Data::Defaults
24
- include Anoubis::Core::Data::Convert
25
- include Anoubis::Core::Data::Callbacks
26
- end
27
- end
28
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module presents all default actions for for {DataController}.
3
- module Anoubis::Sso::Client::Data::Actions
4
- include Anoubis::Core::Data::Actions
5
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module presents all callbacks called in actions.
3
- module Anoubis::Sso::Client::Data::Callbacks
4
- include Anoubis::Core::Data::Callbacks
5
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Data conversion moule between database and human representation
3
- module Anoubis::Sso::Client::Data::Convert
4
- include Anoubis::Core::Data::Convert
5
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module sets default parameters for {DataController}.
3
- module Anoubis::Sso::Client::Data::Defaults
4
- include Anoubis::Core::Data::Defaults
5
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module gets system data for {DataController}
3
- module Anoubis::Sso::Client::Data::Get
4
- include Anoubis::Core::Data::Get
5
- end
@@ -1,26 +0,0 @@
1
- ##
2
- # Module loads data from external sources for {Anoubis::Sso::Client::DataController}
3
- module Anoubis::Sso::Client::Data::Load
4
- include Anoubis::Core::Data::Load
5
-
6
- def load_menu_data
7
- menu_json = self.redis.get(self.redis_prefix + 'menu:' + params[:controller])
8
-
9
- unless menu_json
10
- menu = Anoubis::Sso::Client::Menu.where(mode: params[:controller], status: 'enabled').first
11
- self.redis.set(self.redis_prefix + 'menu:'+ params[:controller], menu.to_json) if menu
12
- else
13
- menu = Anoubis::Sso::Client::Menu.new(JSON.parse(menu_json, { :symbolize_names => true }))
14
- end
15
-
16
- if menu
17
- self.etc.menu = Anoubis::Etc::Menu.new menu
18
-
19
- if self.writer
20
- self.etc.menu.access = 'write'
21
- else
22
- self.etc.menu.access = 'read'
23
- end
24
- end
25
- end
26
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module sets system data for {DataController}
3
- module Anoubis::Sso::Client::Data::Set
4
- include Anoubis::Core::Data::Set
5
- end
@@ -1,5 +0,0 @@
1
- ##
2
- # Module setups system parameters for {DataController}
3
- module Anoubis::Sso::Client::Data::Setup
4
- include Anoubis::Core::Data::Setup
5
- end
@@ -1,21 +0,0 @@
1
- require_dependency "anubis/sso/client/application_controller"
2
- require_dependency "anubis/sso/client/data/actions"
3
- require_dependency "anubis/sso/client/data/load"
4
- require_dependency "anubis/sso/client/data/get"
5
- require_dependency "anubis/sso/client/data/set"
6
- require_dependency "anubis/sso/client/data/setup"
7
- require_dependency "anubis/sso/client/data/defaults"
8
- require_dependency "anubis/sso/client/data/convert"
9
- require_dependency "anubis/sso/client/data/callbacks"
10
-
11
- # Controller consists all procedures and function for presents and modify models data.
12
- class Anoubis::Sso::Client::DataController < Anoubis::Sso::Client::ApplicationController
13
- include Anoubis::Sso::Client::Data::Actions
14
- include Anoubis::Sso::Client::Data::Load
15
- include Anoubis::Sso::Client::Data::Get
16
- include Anoubis::Sso::Client::Data::Set
17
- include Anoubis::Sso::Client::Data::Setup
18
- include Anoubis::Sso::Client::Data::Defaults
19
- include Anoubis::Sso::Client::Data::Convert
20
- include Anoubis::Sso::Client::Data::Callbacks
21
- end
@@ -1,11 +0,0 @@
1
- module Anoubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module presents all default actions for for {DataController}.
6
- module Actions
7
- include Anoubis::Core::Data::Actions
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Anoubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module presents all callbacks called in actions.
6
- module Callbacks
7
- include Anoubis::Core::Data::Callbacks
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Anoubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Data conversion moule between database and human representation
6
- module Convert
7
- include Anoubis::Core::Data::Convert
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Anoubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module sets default parameters for {DataController}.
6
- module Defaults
7
- include Anoubis::Core::Data::Defaults
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Anoubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module gets system data for {DataController}
6
- module Get
7
- include Anoubis::Core::Data::Get
8
- end
9
- end
10
- end
11
- end
@@ -1,52 +0,0 @@
1
- module Anoubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module loads data from external sources for {DataController}
6
- module Load
7
- include Anoubis::Core::Data::Load
8
-
9
- ##
10
- # Loads current menu data. Procedure loads menu data from MySQL database or from Redis cache and places it in
11
- # self.etc.menu {Anoubis::Etc#menu}
12
- def load_menu_data
13
- menu_json = self.redis.get(self.redis_prefix + 'menu_' + params[:controller])
14
- menu_locale_json = self.redis.get(self.redis_prefix + 'menu_'+params[:controller]+'_'+self.locale)
15
- if !menu_json || !menu_locale_json
16
- menu = Anoubis::Tenant::MenuLocale.eager_load(menu: :menu).where(locale: Anoubis::Tenant::MenuLocale.locales[self.locale.to_sym]).where(['menus.mode = ? AND menus.status = 0', params[:controller]]).first
17
- if menu
18
- menu_json = {
19
- mode: menu.menu.mode,
20
- menu_id: menu.menu_id,
21
- parent_menu_id: menu.menu.menu_id,
22
- action: menu.menu.action,
23
- tab: menu.menu.tab,
24
- position: menu.menu.position,
25
- state: menu.menu.state
26
- }
27
- if menu.menu.menu
28
- menu_json[:parent_mode] = menu.menu.menu.mode
29
- end
30
- menu_json = menu_json.to_json
31
- self.redis.set(self.redis_prefix + 'menu_'+params[:controller], menu_json)
32
- menu_locale_json = {
33
- title: menu.title,
34
- page_title: menu.page_title,
35
- short_title: menu.short_title
36
- }.to_json
37
- self.redis.set(self.redis_prefix + 'menu_'+params[:controller]+'_'+self.locale, menu_locale_json)
38
- end
39
- end
40
- if menu_json && menu_locale_json
41
- self.etc.menu = Anoubis::Etc::Menu.new JSON.parse(menu_json, {:symbolize_names => true}).merge(JSON.parse(menu_locale_json, {:symbolize_names => true}))
42
- if self.writer
43
- self.etc.menu.access = 'write'
44
- else
45
- self.etc.menu.access = 'read'
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,11 +0,0 @@
1
- module Anoubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module sets system data for {DataController}
6
- module Set
7
- include Anoubis::Core::Data::Set
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Anoubis
2
- module Tenant
3
- module Data
4
- ##
5
- # Module setups system parameters for {DataController}
6
- module Setup
7
- include Anoubis::Core::Data::Setup
8
- end
9
- end
10
- end
11
- end
@@ -1,28 +0,0 @@
1
- require_dependency "anubis/tenant/application_controller"
2
- require_dependency "anubis/tenant/data/actions"
3
- require_dependency "anubis/tenant/data/load"
4
- require_dependency "anubis/tenant/data/get"
5
- require_dependency "anubis/tenant/data/set"
6
- require_dependency "anubis/tenant/data/setup"
7
- require_dependency "anubis/tenant/data/defaults"
8
- require_dependency "anubis/tenant/data/convert"
9
- require_dependency "anubis/tenant/data/callbacks"
10
-
11
- module Anoubis
12
- ##
13
- # Module presents all core functions for Anubis Library
14
- module Tenant
15
- ##
16
- # Controller consists all procedures and function for presents and modify models data.
17
- class DataController < Anoubis::Tenant::ApplicationController
18
- include Anoubis::Tenant::Data::Actions
19
- include Anoubis::Tenant::Data::Load
20
- include Anoubis::Tenant::Data::Get
21
- include Anoubis::Tenant::Data::Set
22
- include Anoubis::Tenant::Data::Setup
23
- include Anoubis::Tenant::Data::Defaults
24
- include Anoubis::Tenant::Data::Convert
25
- include Anoubis::Tenant::Data::Callbacks
26
- end
27
- end
28
- end
@@ -1,7 +0,0 @@
1
- module Anoubis
2
- ##
3
- # Controller that shows and proccesses {Tenant} data
4
- class TenantsController < DataController
5
-
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require_dependency "anoubis/application_controller"
2
-
3
- module Anoubis
4
- class UsersController < DataController
5
-
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- module Anoubis
2
- ##
3
- # Default mailer for Anoubis library
4
- class ApplicationMailer < ActionMailer::Base
5
- default from: 'from@example.com'
6
- layout 'mailer'
7
- end
8
- end