atome 0.5.6.2.3 → 0.5.6.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/atome/genesis/generators/communication.rb +2 -2
- data/lib/atome/genesis/generators/identity.rb +3 -1
- data/lib/atome/genesis/generators/utility.rb +9 -2
- data/lib/atome/genesis/sparkle.rb +26 -8
- data/lib/atome/version.rb +1 -1
- data/lib/renderers/html/property.rb +0 -8
- data/vendor/assets/application/examples/database_handling.rb +39 -39
- data/vendor/assets/server/atome_server_wasm.rb +37 -37
- data/vendor/assets/server/database.rb +19 -201
- data/vendor/assets/server/eDen.rb +91 -44
- data/vendor/assets/src/js/atome/atome_helpers/communication.js +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a31a51c4b23141c27202a017b8eda058b7fc25fb7d9bc0b2efd13ddb7eaf252
|
4
|
+
data.tar.gz: 30b7d9e1d5fcfbd1bdfa358df8a1c122be32c7fb10825f7bfc470ab8742077cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b85398a923c15fa0ee33f1e96eb56df3938d38c3c938631e9d97f34ff3c0c8628d185573817da9d25474ab3edddb51c76879a91865414d1b1eec31b506f60f9
|
7
|
+
data.tar.gz: d84a2f1c53c250e01c70b80b50fef4bcb0ab73687e924715b2d42b27bde2aa18c7d92f8434b5d5d7810fdacf9d5538d04c14f6d15137ab8aee64a29c8f43acd3
|
@@ -8,8 +8,8 @@ end
|
|
8
8
|
|
9
9
|
new({ particle: :message, category: :communication, type: :hash }) do |params, bloc|
|
10
10
|
params = { data: params } unless params.instance_of? Hash
|
11
|
-
params[:user] = 'dfghg4df5gdfgh654'
|
12
|
-
params[:pass] = 'gfhkzrhgzr4h98948'
|
11
|
+
# params[:user] = 'dfghg4df5gdfgh654'
|
12
|
+
# params[:pass] = 'gfhkzrhgzr4h98948'
|
13
13
|
# instance_variable_set('@message_code', {}) unless instance_variable_get('@message_code')
|
14
14
|
# store_proc= instance_variable_get('@message_code')
|
15
15
|
message_id= "msg_#{Universe.messages.length}"
|
@@ -61,4 +61,6 @@ new(particle: :selected, category: :identity, type: :boolean) do |params|
|
|
61
61
|
end
|
62
62
|
|
63
63
|
new({ particle: :format, category: :identity, type: :string })
|
64
|
-
new({ particle: :alien, category: :identity, type: :string }) #special particel that old alien object
|
64
|
+
new({ particle: :alien, category: :identity, type: :string }) #special particel that old alien object
|
65
|
+
|
66
|
+
new({ particle: :email, category: :identity, type: :string })
|
@@ -115,7 +115,14 @@ new({ particle: :web, category: :utility, type: :string })
|
|
115
115
|
# new({ particle: :metrics, type: :hash })
|
116
116
|
# do not change the line below initialise is a special method
|
117
117
|
new({ initialize: :unit, value: {} })
|
118
|
-
|
118
|
+
new({ particle: :unit, store: false, type: :string, category: :utility }) do |params|
|
119
|
+
params.each do |k, v|
|
120
|
+
@unit[k] = v
|
121
|
+
# now we refresh the particle
|
122
|
+
send(k, send(k))
|
123
|
+
end
|
124
|
+
@unit
|
125
|
+
end
|
119
126
|
new({ particle: :login, category: :utility, type: :string }) do |params|
|
120
127
|
set_current_user(id) if params
|
121
128
|
end
|
@@ -124,7 +131,7 @@ new({ particle: :hyperedit, category: :utility, type: :string })
|
|
124
131
|
new({ particle: :terminal, category: :utility, type: :string })
|
125
132
|
new({ particle: :read, category: :utility, type: :string })
|
126
133
|
new({ particle: :browse, category: :utility, type: :string })
|
127
|
-
new({ particle: :copies, category: :utility, type: :string})
|
134
|
+
new({ particle: :copies, category: :utility, type: :string })
|
128
135
|
new({ particle: :temporary, category: :utility, type: :int })
|
129
136
|
new({ particle: :atomes, category: :utility, type: :string })
|
130
137
|
|
@@ -147,15 +147,33 @@ def atome_genesis
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def init_database # this method is call from JS (atome/communication)
|
150
|
+
# we init the db file eDen
|
151
|
+
A.message({ action: :init_db, data: { database: :eDen } }) do |db_state|
|
152
|
+
puts db_state
|
153
|
+
end
|
150
154
|
|
151
155
|
particles = Universe.particle_list
|
152
156
|
categories = Universe.categories
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
157
|
+
categories.each do |category|
|
158
|
+
A.message({ action: :crate_db_table, data: { table: category } }) do |db_state|
|
159
|
+
puts db_state
|
160
|
+
end
|
161
|
+
end
|
162
|
+
particles_length=particles.length
|
163
|
+
particles.each_with_index do |(particle, infos), index|
|
164
|
+
type = infos[:type]
|
165
|
+
table = infos[:category]
|
166
|
+
@i=1
|
167
|
+
A.message({ action: :create_db_column, data: { table: table, column: particle, type: type } }) do |db_state|
|
168
|
+
@i+=1
|
169
|
+
if @i==particles_length
|
170
|
+
user_login
|
171
|
+
end
|
172
|
+
puts db_state
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
159
177
|
end
|
160
178
|
|
161
179
|
def user_login
|
@@ -164,7 +182,7 @@ def user_login
|
|
164
182
|
message({ action: :authentication, data: { email: 'jeezs@atome.one' } }) do |email|
|
165
183
|
puts "email received : #{email}"
|
166
184
|
end
|
167
|
-
message({ action: :authorization, data: { password: password } }) do |
|
168
|
-
puts "
|
185
|
+
message({ action: :authorization, data: { password: password } }) do |pass|
|
186
|
+
puts "password recieved : #{pass}"
|
169
187
|
end
|
170
188
|
end
|
data/lib/atome/version.rb
CHANGED
@@ -51,11 +51,3 @@ new({ method: :sort, renderer: :html, type: :hash }) do |params|
|
|
51
51
|
html.refresh_table(params)
|
52
52
|
end
|
53
53
|
|
54
|
-
new({ particle: :unit, store: false }) do |params|
|
55
|
-
params.each do |k, v|
|
56
|
-
@unit[k] = v
|
57
|
-
# now we refresh the particle
|
58
|
-
send(k, send(k))
|
59
|
-
end
|
60
|
-
@unit
|
61
|
-
end
|
@@ -1,39 +1,39 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
A.message({ action: :insert, data: { table: :security, particle: :password, data: 'my_pass'} }) do |datas|
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs' } }) do |data_received_from_server|
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs2' } })
|
12
|
-
|
13
|
-
A.message({ action: :query, data: { table: :identity } }) do |data_received_from_server|
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
A.message({ action: :query, data: { table: :identity } }) do |data_received|
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs3' } }) do |result|
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs4' } }) do |result|
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
A.message({ action: :insert, data: { table: :security, particle: :name, data: 'john doe' } }) do |data_received_from_server|
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
A.message({ action: :insert, data: { table: :identity, particle: :tit, data: 'dummy' } }) do |data_received_from_server|
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
A.message({ action: :insert, data: { table: :unknown, particle: :name, data: 'dummy2' } }) do |data_received_from_server|
|
38
|
-
|
39
|
-
end
|
1
|
+
# # frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# A.message({ action: :insert, data: { table: :security, particle: :password, data: 'my_pass'} }) do |datas|
|
4
|
+
# puts "0 data received: #{datas}"
|
5
|
+
# end
|
6
|
+
#
|
7
|
+
# A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs' } }) do |data_received_from_server|
|
8
|
+
# puts "1 my first insert #{data_received_from_server}"
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs2' } })
|
12
|
+
#
|
13
|
+
# A.message({ action: :query, data: { table: :identity } }) do |data_received_from_server|
|
14
|
+
# puts "2 another insert : #{data_received_from_server}"
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# A.message({ action: :query, data: { table: :identity } }) do |data_received|
|
18
|
+
# puts "3 received : #{data_received}"
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs3' } }) do |result|
|
22
|
+
# puts "4 insert done : #{result}"
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# A.message({ action: :insert, data: { table: :identity, particle: :name, data: 'jeezs4' } }) do |result|
|
26
|
+
# puts "5 last message received: #{result}"
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# A.message({ action: :insert, data: { table: :security, particle: :name, data: 'john doe' } }) do |data_received_from_server|
|
30
|
+
# puts "6 test 1 : #{data_received_from_server}"
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# A.message({ action: :insert, data: { table: :identity, particle: :tit, data: 'dummy' } }) do |data_received_from_server|
|
34
|
+
# puts "7 test 2 : #{data_received_from_server}"
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# A.message({ action: :insert, data: { table: :unknown, particle: :name, data: 'dummy2' } }) do |data_received_from_server|
|
38
|
+
# puts "test 3 : #{data_received_from_server}"
|
39
|
+
# end
|
@@ -26,43 +26,43 @@ class String
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
class Database
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
29
|
+
# class Database
|
30
|
+
# def self.connect_database
|
31
|
+
# if File.exist?("eden.sqlite3")
|
32
|
+
# eden = Sequel.connect("sqlite://eden.sqlite3")
|
33
|
+
# else
|
34
|
+
# eden = Sequel.connect("sqlite://eden.sqlite3")
|
35
|
+
# eden.create_table :atome do
|
36
|
+
# primary_key :atome_id
|
37
|
+
# String :aui
|
38
|
+
# String :id
|
39
|
+
# String :type
|
40
|
+
# String :name
|
41
|
+
# String :content
|
42
|
+
# String :position
|
43
|
+
# String :dimension
|
44
|
+
# String :color
|
45
|
+
# String :right
|
46
|
+
# String :effect
|
47
|
+
# String :shadow
|
48
|
+
# String :border
|
49
|
+
# String :fill
|
50
|
+
# Float :x
|
51
|
+
# Float :xx
|
52
|
+
# Float :y
|
53
|
+
# Float :yy
|
54
|
+
# Float :z
|
55
|
+
# Float :zz
|
56
|
+
# Float :width
|
57
|
+
# Float :height
|
58
|
+
# Float :depth
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# end
|
62
|
+
# eden
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# end
|
66
66
|
|
67
67
|
class App < Roda
|
68
68
|
# comment below when test will be done
|
@@ -1,217 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# database handling for eDen Db
|
4
|
-
|
5
4
|
class Database
|
5
|
+
class << self
|
6
|
+
Sequel.extension :migration
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
if eden.table_exists?(table_name)
|
10
|
-
puts "La table #{table_name} existe dans la base de données."
|
11
|
-
else
|
12
|
-
puts "La table suivante : #{table_name} n'existe pas dans la base de données."
|
8
|
+
def db_access
|
9
|
+
Sequel.connect("sqlite://eden.sqlite3")
|
13
10
|
end
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
# def self.create_table(table_name)
|
18
|
-
def self.connect_database
|
19
|
-
if File.exist?("eden.sqlite3")
|
12
|
+
def create_table(table_name)
|
20
13
|
eden = Sequel.connect("sqlite://eden.sqlite3")
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
eden = Sequel.connect("sqlite://eden.sqlite3")
|
25
|
-
eden.create_table :atome do
|
26
|
-
primary_key :atome_id
|
27
|
-
String :creator
|
28
|
-
end
|
29
|
-
|
30
|
-
eden.create_table :communication do
|
31
|
-
primary_key :communication_id
|
32
|
-
String :connection
|
33
|
-
JSON :data
|
34
|
-
JSON :controller
|
35
|
-
end
|
36
|
-
|
37
|
-
###################
|
38
|
-
|
39
|
-
Sequel.extension :migration
|
40
|
-
|
41
|
-
Sequel.migration do
|
42
|
-
change do
|
43
|
-
add_column :communication, :jesaispas, String
|
14
|
+
unless eden.table_exists?(table_name)
|
15
|
+
eden.create_table table_name.to_sym do
|
16
|
+
primary_key "#{table_name}_id".to_sym
|
44
17
|
end
|
45
|
-
end.apply(eden, :up)
|
46
|
-
|
47
|
-
###################
|
48
|
-
|
49
|
-
eden.create_table :effect do
|
50
|
-
primary_key :effect_id
|
51
|
-
Int :smooth
|
52
|
-
Int :blur
|
53
|
-
end
|
54
|
-
|
55
|
-
eden.create_table :event do
|
56
|
-
primary_key :event_id
|
57
|
-
JSON :touch
|
58
|
-
Boolean :play
|
59
|
-
Boolean :pause
|
60
|
-
Int :time
|
61
|
-
Boolean :on
|
62
|
-
Boolean :fullscreen
|
63
|
-
Boolean :mute
|
64
|
-
Boolean :drag
|
65
|
-
Boolean :drop
|
66
|
-
Boolean :over
|
67
|
-
String :targets
|
68
|
-
Boolean :start
|
69
|
-
Boolean :stop
|
70
|
-
Time :begin
|
71
|
-
Time :end
|
72
|
-
Int :duration
|
73
|
-
Int :mass
|
74
|
-
Int :damping
|
75
|
-
Int :stiffness
|
76
|
-
Int :velocity
|
77
|
-
Boolean :repeat
|
78
|
-
Boolean :ease
|
79
|
-
Boolean :keyboard
|
80
|
-
Boolean :resize
|
81
|
-
Boolean :overflow
|
82
|
-
end
|
83
|
-
|
84
|
-
eden.create_table :geometry do
|
85
|
-
primary_key :geometry_id
|
86
|
-
Int :width
|
87
|
-
Int :height
|
88
|
-
Int :size
|
89
|
-
end
|
90
|
-
|
91
|
-
eden.create_table :hierarchy do
|
92
|
-
primary_key :hierarchy_id
|
93
|
-
String :attach
|
94
|
-
String :attached
|
95
|
-
String :apply
|
96
|
-
String :affect
|
97
|
-
String :detached
|
98
|
-
String :collect
|
99
|
-
end
|
100
|
-
|
101
|
-
eden.create_table :identity do
|
102
|
-
primary_key :identity_id
|
103
|
-
String :real
|
104
|
-
String :type
|
105
|
-
Int :id
|
106
|
-
String :name
|
107
|
-
String :firstname
|
108
|
-
String :email
|
109
|
-
String :nickname
|
110
|
-
Boolean :active
|
111
|
-
String :markup
|
112
|
-
String :bundle
|
113
|
-
String :data
|
114
|
-
String :category
|
115
|
-
String :selection
|
116
|
-
Boolean :selected
|
117
|
-
String :format
|
118
|
-
String :alien
|
119
|
-
end
|
120
|
-
|
121
|
-
eden.create_table :material do
|
122
|
-
primary_key :material_id
|
123
|
-
String :component
|
124
|
-
Boolean :edit
|
125
|
-
String :style
|
126
|
-
Boolean :hide
|
127
|
-
Boolean :remove
|
128
|
-
JSON :classes
|
129
|
-
Boolean :remove_classes
|
130
|
-
Int :opacity
|
131
|
-
String :definition
|
132
|
-
Int :gradient
|
133
|
-
Int :border
|
134
|
-
end
|
135
|
-
|
136
|
-
eden.create_table :property do
|
137
|
-
primary_key :property_id
|
138
|
-
String :red
|
139
|
-
String :green
|
140
|
-
String :blue
|
141
|
-
String :alpha
|
142
|
-
String :diffusion
|
143
|
-
Boolean :clean
|
144
|
-
String :insert
|
145
|
-
Boolean :remove
|
146
|
-
Int :sort
|
147
|
-
end
|
148
|
-
|
149
|
-
eden.create_table :security do
|
150
|
-
primary_key :security_id
|
151
|
-
String :password
|
152
|
-
end
|
153
|
-
|
154
|
-
eden.create_table :spatial do
|
155
|
-
primary_key :spatial_id
|
156
|
-
Int :left
|
157
|
-
Int :right
|
158
|
-
Int :top
|
159
|
-
Int :bottom
|
160
|
-
Int :rotate
|
161
|
-
String :direction
|
162
|
-
String :center
|
163
|
-
Int :depth
|
164
|
-
Int :position
|
165
|
-
String :organise
|
166
|
-
String :spacing
|
167
|
-
Boolean :display
|
168
|
-
String :layout
|
169
|
-
end
|
170
|
-
|
171
|
-
eden.create_table :time do
|
172
|
-
primary_key :time_id
|
173
|
-
JSON :markers
|
174
18
|
end
|
19
|
+
end
|
175
20
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
String :cursor
|
187
|
-
String :preset
|
188
|
-
JSON :relations
|
189
|
-
JSON :tag
|
190
|
-
String :web
|
191
|
-
JSON :unit
|
192
|
-
String :initialize
|
193
|
-
String :login
|
194
|
-
String :hypertext
|
195
|
-
String :hyperedit
|
196
|
-
String :terminal
|
197
|
-
String :browse
|
198
|
-
String :copies
|
199
|
-
Int :temporary
|
200
|
-
String :atomes
|
201
|
-
String :match
|
202
|
-
Boolean :invert
|
203
|
-
String :option
|
204
|
-
String :duplicate
|
205
|
-
String :copy
|
206
|
-
String :paste
|
207
|
-
String :backup
|
208
|
-
String :import
|
209
|
-
String :compute
|
210
|
-
String :get
|
21
|
+
def create_column(table, column_name, type)
|
22
|
+
eden = Sequel.connect("sqlite://eden.sqlite3")
|
23
|
+
if eden.table_exists?(table)
|
24
|
+
unless eden.schema(table).any? { |column| column.first == column_name }
|
25
|
+
Sequel.migration do
|
26
|
+
change do
|
27
|
+
add_column table, column_name, type
|
28
|
+
end
|
29
|
+
end.apply(eden, :up)
|
30
|
+
end
|
211
31
|
end
|
212
|
-
|
213
32
|
end
|
214
|
-
eden
|
215
33
|
end
|
216
34
|
|
217
35
|
end
|
@@ -3,63 +3,110 @@
|
|
3
3
|
# server utils to handle eDen Db
|
4
4
|
|
5
5
|
class EDen
|
6
|
+
class << self
|
7
|
+
def db_access
|
8
|
+
Database.db_access
|
9
|
+
end
|
6
10
|
|
7
|
-
|
8
|
-
|
9
|
-
|
11
|
+
def terminal(data, message_id)
|
12
|
+
{ data: { message: `#{data}` }, message_id: message_id }
|
13
|
+
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
def authorization(data, message_id)
|
16
|
+
db = db_access
|
17
|
+
security_items = db[:security]
|
18
|
+
user_password = data["password"]
|
19
|
+
user_exists = security_items.where(password: user_password).first
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
|
21
|
+
if !user_exists
|
22
|
+
{ return: 'Password not found', message_id: message_id }
|
23
|
+
# Ask to the user if he wants to subscribe
|
24
|
+
# Send the basic template
|
25
|
+
else
|
26
|
+
{ return: 'Password found, connected', message_id: message_id }
|
27
|
+
# Send the user account template
|
28
|
+
end
|
29
|
+
end
|
18
30
|
|
19
|
-
|
20
|
-
|
21
|
-
|
31
|
+
def authentication(data, message_id)
|
32
|
+
# { data: { message: 'login received' }, message_id: message_id }
|
33
|
+
db = db_access
|
34
|
+
identity_items = db[:identity]
|
35
|
+
user_email = data["email"]
|
36
|
+
mail_exists = identity_items.where(email: user_email).first
|
22
37
|
|
23
|
-
|
24
|
-
|
25
|
-
|
38
|
+
if !mail_exists
|
39
|
+
{ return: 'Email not found', message_id: message_id }
|
40
|
+
# { return: user_email, message_id: message_id }
|
41
|
+
# Ask to the user if he wants to subscribe
|
42
|
+
# Send the basic template
|
43
|
+
else
|
44
|
+
{ return: 'Email found, looking for pass', message_id: message_id }
|
45
|
+
# Verify password
|
46
|
+
# If password isn't ok, send error
|
47
|
+
# If the password is ok, send the user account template
|
48
|
+
end
|
49
|
+
end
|
26
50
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
51
|
+
def init_db(_data, message_id)
|
52
|
+
unless File.exist?("eden.sqlite3")
|
53
|
+
Sequel.connect("sqlite://eden.sqlite3")
|
54
|
+
end
|
55
|
+
{ data: { message: 'database initialised' }, message_id: message_id }
|
56
|
+
end
|
57
|
+
|
58
|
+
def crate_db_table(data, message_id)
|
59
|
+
table = data['table']
|
60
|
+
Database.create_table(table)
|
61
|
+
{ data: { message: "table #{table} added" }, message_id: message_id }
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_db_column(data, message_id)
|
65
|
+
table = data['table']
|
66
|
+
column = data['column']
|
67
|
+
type = data['type']
|
68
|
+
Database.create_column(table, column, type)
|
69
|
+
{ data: { message: "column #{column} with type : #{type} added" }, message_id: message_id }
|
70
|
+
end
|
71
|
+
|
72
|
+
def query(data, message_id)
|
73
|
+
identity_table = db_access[data['table'].to_sym]
|
74
|
+
result = identity_table.send(:all).send(:select)
|
75
|
+
{ data: { table: data['table'], infos: result }, message_id: message_id }
|
76
|
+
end
|
32
77
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
78
|
+
def insert(data, message_id)
|
79
|
+
table = data['table'].to_sym
|
80
|
+
particle = data['particle'].to_sym
|
81
|
+
data = data['data']
|
82
|
+
if db_access.table_exists?(table)
|
83
|
+
schema = db_access.schema(table)
|
84
|
+
if schema.any? { |col_def| col_def.first == particle }
|
85
|
+
identity_table = db_access[table.to_sym]
|
86
|
+
identity_table.insert(particle => data)
|
87
|
+
{ data: { message: "column : #{particle}, in table : #{table}, updated with : #{data}" }, message_id: message_id }
|
88
|
+
else
|
89
|
+
{ data: { message: "column not found: #{particle.class}" }, message_id: message_id }
|
90
|
+
end
|
43
91
|
else
|
44
|
-
{ data: { message: "
|
45
|
-
end
|
46
|
-
else
|
47
|
-
{ data: { message: "table not found: #{table.class}" }, message_id: message_id }
|
92
|
+
{ data: { message: "table not found: #{table.class}" }, message_id: message_id }
|
48
93
|
|
94
|
+
end
|
49
95
|
end
|
50
|
-
end
|
51
96
|
|
52
|
-
|
97
|
+
def file(data, message_id)
|
53
98
|
|
54
|
-
|
55
|
-
|
99
|
+
file_content = File.send(data['operation'], data['source'], data['value']).to_s
|
100
|
+
file_content = file_content.gsub("'", "\"")
|
56
101
|
|
57
|
-
|
58
|
-
|
59
|
-
|
102
|
+
file_content = file_content.gsub('#', '\x23')
|
103
|
+
{ data: "=> operation: #{data['operation']}, source: #{data['source']}, content: #{file_content}", message_id: message_id }
|
104
|
+
end
|
60
105
|
|
61
|
-
|
62
|
-
|
63
|
-
|
106
|
+
def safe_send(method_name, data, message_id)
|
107
|
+
method_sym = method_name.to_sym
|
108
|
+
send(method_sym, data, message_id)
|
109
|
+
end
|
64
110
|
end
|
111
|
+
|
65
112
|
end
|
@@ -67,7 +67,7 @@ const communication = {
|
|
67
67
|
|
68
68
|
// now new can exec user code : loadApplicationJs in index.html
|
69
69
|
loadApplicationJs();
|
70
|
-
rubyVMCallback("A.user_login");
|
70
|
+
// rubyVMCallback("A.user_login");
|
71
71
|
};
|
72
72
|
this.websocket.onmessage = function (event) {
|
73
73
|
// console.log(event.data)
|