lib/splash/webadmin/portal/controllers/processes.rb in prometheus-splash-0.8.4 vs lib/splash/webadmin/portal/controllers/processes.rb in prometheus-splash-0.8.5
- old
+ new
@@ -25,10 +25,14 @@
if params[:process] then
url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/processes/show/#{params[:process].to_s}.yml"
raw = RestClient::Request.execute(method: 'GET', url: url,timeout: 10)
res = YAML::load(raw)
@data = res[:data] if res[:status] == :success
+ if @data[:retention].class == Hash then
+ prov = @data[:retention].flatten.reverse.join(' ')
+ @data[:retention] = prov
+ end
if @data[:patterns].class == Array then
prov = @data[:patterns].join('|')
@data[:patterns] = prov
end
@data[:old_process] = params[:process].to_s
@@ -51,13 +55,23 @@
end
WebAdminApp.post '/save_process' do
get_menu 1
log = get_logger
- log.call "WEB : processes, verb : POST, controller : /save_process/?:process?"
+ log.call "WEB : processes, verb : POST, controller : /save_process"
data = {}
data[:patterns] = params[:patterns].split('|')
- data[:process] = params[:process].to_sym
+ data[:process] = params[:process].split(' ').first.to_sym
+ unless params[:retention].blank?
+ value, key = params[:retention].split(' ')
+ key = (key.nil?)? :days : key.to_sym
+ value = value.to_i
+ key = :days if key == :day
+ key = :hours if key == :hour
+ if [:hours,:days].include? key then
+ data[:retention] = {key => value}
+ end
+ end
if params[:update] then
url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/config/deleteprocess/#{params[:old_process]}"
raw = RestClient::Request.execute(method: 'DELETE', url: url,timeout: 10)
end
url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/config/addprocess.yml"