lib/splash/webadmin/portal/controllers/logs.rb in prometheus-splash-0.8.4 vs lib/splash/webadmin/portal/controllers/logs.rb in prometheus-splash-0.8.5

- old
+ new

@@ -27,10 +27,14 @@ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/logs/show/#{params[:label].to_s}.yml" raw = RestClient::Request.execute(method: 'GET', url: url,timeout: 10) res = YAML::load(raw) @data = res[:data] if res[:status] == :success @data[:old_label] = params[:label].to_s + if @data[:retention].class == Hash then + prov = @data[:retention].flatten.reverse.join(' ') + @data[:retention] = prov + end end slim :log_form, :format => :html end @@ -48,14 +52,24 @@ end WebAdminApp.post '/save_log' do get_menu 0 log = get_logger - log.call "WEB : logs, verb : POST, controller : /save_log/?:label?" + log.call "WEB : logs, verb : POST, controller : /save_log " data = {} + 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 data[:log] = params[:log] data[:pattern] = params[:pattern] - data[:label] = params[:label].to_sym + data[:label] = params[:label].split(' ').first.to_sym if params[:update] then url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/config/deletelog/#{params[:old_label]}" raw = RestClient::Request.execute(method: 'DELETE', url: url,timeout: 10) end url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/config/addlog.yml"