|
@@ -87,6 +87,59 @@ class GetAllData < Riddl::Implementation
|
|
|
end
|
|
|
|
|
|
|
|
|
+class AddColumn < Riddl::Implementation
|
|
|
+ def response
|
|
|
+
|
|
|
+ colname = @p[0].value
|
|
|
+ colvalue = @p[1].value
|
|
|
+
|
|
|
+ fname = File.join('data',@r[-2],'data.db')
|
|
|
+ db = SQLite3::Database.open fname
|
|
|
+
|
|
|
+ searchstring = "SELECT DISTINCT __orderID__, alldata FROM Entries"
|
|
|
+ result = db.execute searchstring;
|
|
|
+
|
|
|
+ result.each do |item|
|
|
|
+ key = item[0]
|
|
|
+ newalldata = item[1]
|
|
|
+
|
|
|
+ thaData = JSON.parse(newalldata)
|
|
|
+ thaData[colname] = colvalue;
|
|
|
+
|
|
|
+ db.execute("UPDATE Entries SET alldata = ? WHERE __orderID__ = ?", thaData.to_json, key )
|
|
|
+ end
|
|
|
+
|
|
|
+ Riddl::Parameter::Complex.new('value','application/json',JSON.dump({status: "looks good?"}))
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+class DeleteColumn < Riddl::Implementation
|
|
|
+ def response
|
|
|
+ colname = @p[0].value
|
|
|
+
|
|
|
+ fname = File.join('data',@r[-2],'data.db')
|
|
|
+ db = SQLite3::Database.open fname
|
|
|
+
|
|
|
+ searchstring = "SELECT DISTINCT __orderID__, alldata FROM Entries"
|
|
|
+ result = db.execute searchstring;
|
|
|
+
|
|
|
+ result.each do |item|
|
|
|
+ key = item[0]
|
|
|
+ newalldata = item[1]
|
|
|
+
|
|
|
+ thaData = JSON.parse(newalldata)
|
|
|
+ thaData.delete(colname)
|
|
|
+
|
|
|
+ db.execute("UPDATE Entries SET alldata = ? WHERE __orderID__ = ?", thaData.to_json, key )
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+ Riddl::Parameter::Complex.new('value','application/json',JSON.dump({status: "looks good?"}))
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
class GetNData < Riddl::Implementation
|
|
|
def response
|
|
|
fname = File.join('data',@r[-2],'data.db')
|
|
@@ -613,6 +666,11 @@ server = Riddl::Server.new(File.join(__dir__,'/dashboard.xml'), :host => 'localh
|
|
|
run GetAllData if get
|
|
|
end
|
|
|
|
|
|
+ on resource 'Column' do
|
|
|
+ run AddColumn if post 'addColumn'
|
|
|
+ run DeleteColumn if post 'removeColumn'
|
|
|
+ end
|
|
|
+
|
|
|
on resource 'htmlform' do
|
|
|
run PostHtmlVals, opts[:signals][idx] if post
|
|
|
end
|