|
@@ -145,7 +145,10 @@ class AddEntry < Riddl::Implementation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- @a[0].send(JSON.dump(hash))
|
|
|
|
|
|
+ @a[0].send("reset")
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
nil
|
|
nil
|
|
|
|
|
|
end
|
|
end
|
|
@@ -201,11 +204,61 @@ class Put < Riddl::Implementation
|
|
|
|
|
|
def response
|
|
def response
|
|
hash = Put::putentry(@r, @p, @h)
|
|
hash = Put::putentry(@r, @p, @h)
|
|
- @a[0].send(JSON.dump(hash))
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @a[0].send("reset")
|
|
|
|
+
|
|
nil
|
|
nil
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+class PostHtmlVals < Riddl::Implementation
|
|
|
|
+ def response
|
|
|
|
+
|
|
|
|
+ Dir.mkdir(File.join('data',@r[-2])) rescue nil
|
|
|
|
+ Dir.mkdir(File.join('data',@r[-2], "js")) rescue nil
|
|
|
|
+ Dir.mkdir(File.join('data',@r[-2], "visus")) rescue nil
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ #prevent overriding ui and index in case user changed something there
|
|
|
|
+ if !File.file?(File.join('data',@r[-2],'js/ui.js'))
|
|
|
|
+ File.write(File.join('data',@r[-2],'js/ui.js'),File.open("defaultContent/js/ui.js").read)
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ if !File.file?(File.join('data',@r[-2],'index.html'))
|
|
|
|
+ file = File.open("defaultContent/index.html").read
|
|
|
|
+ newfile = file.gsub("!replaceThisString!", @r[-2])
|
|
|
|
+
|
|
|
|
+ File.write(File.join('data',@r[-2],'index.html'), newfile)
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ #prevent overriding visualization
|
|
|
|
+ if !File.file?(File.join('data',@r[-2],'visus.html'))
|
|
|
|
+ File.write(File.join('data',@r[-2],'visus.html'),File.open("defaultContent/visus.html").read)
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ file = JSON['{}']
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @p.each_with_index do |child, idx|
|
|
|
|
+ file[child.name] = child.value
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ fname = File.join('data',@r[-2],'data.db')
|
|
|
|
+ db = SQLite3::Database.open fname
|
|
|
|
+
|
|
|
|
+ db.execute "CREATE TABLE IF NOT EXISTS Entries(__orderID__ INTEGER PRIMARY KEY AUTOINCREMENT, alldata TEXT, cpeeInstance INTEGER)"
|
|
|
|
+ db.execute("INSERT OR REPLACE INTO Entries (alldata, cpeeInstance) VALUES (?,?)", JSON[file], "none")
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @a[0].send("reset")
|
|
|
|
+ Riddl::Parameter::Complex.new('ui','text/html', '<html><head><meta http-equiv="refresh" content="0; url =' +@h["REFERER"]+'"/></head>')
|
|
|
|
+ end
|
|
|
|
+end
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
class PutPrio < Riddl::Implementation
|
|
class PutPrio < Riddl::Implementation
|
|
def response
|
|
def response
|
|
@@ -360,6 +413,8 @@ class Delete < Riddl::Implementation
|
|
db = SQLite3::Database.open fname
|
|
db = SQLite3::Database.open fname
|
|
alldata = @p[0].value.read
|
|
alldata = @p[0].value.read
|
|
db.execute("DELETE FROM Entries WHERE alldata = '" + alldata + "'")
|
|
db.execute("DELETE FROM Entries WHERE alldata = '" + alldata + "'")
|
|
|
|
+ @a[0].send("reset")
|
|
|
|
+
|
|
nil
|
|
nil
|
|
end
|
|
end
|
|
end
|
|
end
|
|
@@ -374,6 +429,7 @@ class DeleteID < Riddl::Implementation
|
|
end
|
|
end
|
|
def response
|
|
def response
|
|
DeleteID::remove(@r.last, @p[0].value.read)
|
|
DeleteID::remove(@r.last, @p[0].value.read)
|
|
|
|
+ @a[0].send("reset")
|
|
nil
|
|
nil
|
|
end
|
|
end
|
|
end
|
|
end
|
|
@@ -381,6 +437,7 @@ end
|
|
class DeleteIDDirect < Riddl::Implementation
|
|
class DeleteIDDirect < Riddl::Implementation
|
|
def response
|
|
def response
|
|
DeleteID::remove(@r.last, @p[0].value)
|
|
DeleteID::remove(@r.last, @p[0].value)
|
|
|
|
+ @a[0].send("reset")
|
|
nil
|
|
nil
|
|
end
|
|
end
|
|
end
|
|
end
|
|
@@ -393,7 +450,7 @@ class DeletePK < Riddl::Implementation
|
|
db = SQLite3::Database.open fname
|
|
db = SQLite3::Database.open fname
|
|
pkvalue = @p[0].value
|
|
pkvalue = @p[0].value
|
|
db.execute("DELETE FROM Entries WHERE pkvalue = '" + pkvalue + "'")
|
|
db.execute("DELETE FROM Entries WHERE pkvalue = '" + pkvalue + "'")
|
|
-
|
|
|
|
|
|
+ @a[0].send("reset")
|
|
nil
|
|
nil
|
|
end
|
|
end
|
|
end
|
|
end
|
|
@@ -536,11 +593,11 @@ server = Riddl::Server.new(File.join(__dir__,'/dashboard.xml'), :host => 'localh
|
|
run Update if put 'update'
|
|
run Update if put 'update'
|
|
run Storesortedtable, opts[:signals][idx] if put 'storesortedtable'
|
|
run Storesortedtable, opts[:signals][idx] if put 'storesortedtable'
|
|
run AddEntry, opts[:signals][idx] if post 'directADD'
|
|
run AddEntry, opts[:signals][idx] if post 'directADD'
|
|
- run Delete if delete 'deleteMsg'
|
|
|
|
- run DeleteID if delete 'deleteByID'
|
|
|
|
- run DeletePK if delete 'deletePK'
|
|
|
|
- run DeleteAll if delete 'deleteAll'
|
|
|
|
- run DeleteIDDirect if delete
|
|
|
|
|
|
+ run Delete, opts[:signals][idx] if delete 'deleteMsg'
|
|
|
|
+ run DeleteID, opts[:signals][idx] if delete 'deleteByID'
|
|
|
|
+ run DeletePK, opts[:signals][idx] if delete 'deletePK'
|
|
|
|
+ run DeleteAll, opts[:signals][idx] if delete 'deleteAll'
|
|
|
|
+ run DeleteIDDirect, opts[:signals][idx] if delete
|
|
|
|
|
|
|
|
|
|
on resource '\d+' do
|
|
on resource '\d+' do
|
|
@@ -556,6 +613,9 @@ server = Riddl::Server.new(File.join(__dir__,'/dashboard.xml'), :host => 'localh
|
|
run GetAllData if get
|
|
run GetAllData if get
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+ on resource 'htmlform' do
|
|
|
|
+ run PostHtmlVals, opts[:signals][idx] if post
|
|
|
|
+ end
|
|
|
|
|
|
on resource 'search' do
|
|
on resource 'search' do
|
|
on resource 'PK' do
|
|
on resource 'PK' do
|
|
@@ -576,4 +636,4 @@ server = Riddl::Server.new(File.join(__dir__,'/dashboard.xml'), :host => 'localh
|
|
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|
|
-end.loop!
|
|
|
|
|
|
+end.loop!
|