You are viewing a plain text version of this content. The canonical link for it is here.
Posted to alois-commits@incubator.apache.org by fl...@apache.org on 2010/11/04 18:27:42 UTC
svn commit: r1031127 [10/22] - in /incubator/alois/trunk: ./ bin/ debian/
doc/ etc/ etc/alois/ etc/alois/apache2/ etc/alois/environments/
etc/alois/prisma/ etc/cron.d/ etc/default/ etc/logrotate.d/ prisma/
prisma/bin/ prisma/conf/ prisma/conf/prisma/ p...
Added: incubator/alois/trunk/rails/app/models/sentinel.rb
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/models/sentinel.rb?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/models/sentinel.rb (added)
+++ incubator/alois/trunk/rails/app/models/sentinel.rb Thu Nov 4 18:27:22 2010
@@ -0,0 +1,260 @@
+# Copyright 2010 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ class Sentinel < ActiveRecord::Base
+ has_many :alarms
+ has_many :reports
+
+ belongs_to :report_template
+ belongs_to :view
+
+ CRONTAB_REGEX = /([0-5]?[0-9]|\*) ([0-1]?[0-9]|2[0-4]|\*) (\d*|\*) (\d*|\*) (\d*|\*)/
+ ACTIONS = {
+ 0 => :disabled,
+ 1 => :report,
+ 2 => :alarm,
+ 3 => :alarm_and_report}
+
+ validates_presence_of :name, :threshold, :view
+ validates_uniqueness_of :name
+ validates_format_of :cron_interval, :with => CRONTAB_REGEX
+
+ validate do |s|
+ if s.action_name == :report or s.action_name == :alarm_and_report
+ s.errors.add("action", "Please specify a report_template for action '#{s.action_name}'") unless
+ s.report_template
+ end
+ if s.time_range and s.time_range != "" and s.view
+ begin
+ s.date_condition.validate(s.view)
+ rescue
+ s.errors.add("time_range",$!)
+ end
+ end
+
+ if s.view
+ begin
+ s.filters.each {|f|
+ s.errors.add("filters", "Filter #{f.id} is not applicable for view #{s.view.id}") unless
+ f.valid_for_table?(s.view)
+ }
+ s.conditions
+ rescue
+ s.errors.add("Error building conditions: #{$!}")
+ end
+ end
+ end
+
+ # hm, otherwise test fails: ruby test/functional/sentinels_controller_test.rb --name test_load_yaml
+ def include_csv_in_email; include_csv_in_email? rescue include_csv_in_email; end
+ def include_report_in_email; include_report_in_email? rescue include_report_in_email; end
+
+ def date_condition
+ Condition.create("date","DATE",time_range) if time_range and time_range != ""
+ end
+
+ def filters
+ Filter.parse_text_field(self["filters"])
+ end
+
+ def filters=(val)
+ remove_instance_variable("@count") if
+ instance_variable_defined?("@count")
+ super
+ end
+
+ def conditions(options = {})
+ options[:table_class] ||= view
+ c = ([date_condition] + filters).compact.map {|f| f.sql(options)}.join(" AND ")
+ return nil if c.strip == ""
+ c
+ end
+
+ ## To use this add the following line into the sudoers file
+ # www-data ALL=(prisma) NOPASSWD:/usr/bin/prisma-sentinel --generate-crontab
+ if RAILS_ENV == 'production'
+ UPDATE_COMMAND = "/usr/bin/sudo -S -p '' -u prisma /usr/bin/alois-sentinel --generate-crontab < /dev/null"
+ else
+ UPDATE_COMMAND = RAILS_ROOT + "/script/sentinel --list-crontab > /dev/null"
+ end
+ def update_cron
+ errors.add_to_base("Error while updating crontab (#{UPDATE_COMMAND}).") unless system("#{UPDATE_COMMAND}")
+ end
+
+ def save
+ ret = super
+ update_cron
+ ret
+ end
+
+ def destroy
+ update_cron
+ super
+ end
+
+ def enabled
+ action != ACTIONS.invert[:disabled]
+ end
+
+ def count
+ return @count if defined?(@count)
+ raise "No view defined." unless view
+ view.create_view
+ @count = view.table.count(:conditions => conditions)
+ end
+
+ def time_range=(val)
+ remove_instance_variable("@count") if
+ instance_variable_defined?("@count")
+ super
+ end
+
+ def is_alarm?
+ threshold < count
+ end
+
+ def action_name
+ ACTIONS[self.action]
+ end
+
+ def action=(val)
+ if val.is_a?(Symbol)
+ "Action '#{val}' not found." unless ACTIONS.value?(val)
+ val = ACTIONS.invert[val]
+ end
+ super(val)
+ end
+
+ def alarm_level_color
+ Alarm::ALARM_COLORS[self.alarm_level]
+ end
+
+ def alarm_level_name
+ Alarm::ALARM_LEVELS[self.alarm_level]
+ end
+
+ def alarm_level=(val)
+ if val.is_a?(Symbol)
+ "Alarm '#{val}' not found." unless Alarm::ALARM_LEVELS.value?(val)
+ val = Alarm::ALARM_LEVELS.invert[val]
+ end
+ super(val)
+ end
+
+ def datasource
+ view
+ end
+
+ def process
+ raise "This sentinel is disabled." if action_name == :disabled
+
+ $log.debug "Processing sentinel.#{self.id}." if $log.debug?
+ alarm = nil
+ report = nil
+ @process_errors = []
+ options = { :conditions => conditions, :datasource => view }
+ if is_alarm?
+ $log.debug "Sentinel claim it's an alarm." if $log.debug?
+
+ if action_name == :report or action_name == :alarm_and_report
+ begin
+ rt = report_template
+ $log.info("Generating report.")
+ report = Report.generate(rt, self, options)
+ $log.info("Generated report has id #{report.id}.")
+ rescue
+ $log.error("Error generating report: '#{$!}'")
+ @process_errors.push($!)
+ end
+ end
+
+
+ if action_name == :alarm or action_name == :alarm_and_report
+ begin
+ alarm = Alarm.generate(self, report, options)
+ rescue
+ $log.error("Error generating alarm: '#{$!}'")
+ @process_errors.push($!)
+ end
+ end
+
+
+ if send_mail
+ begin
+ $log.info("Sending mails to '#{self.mail_to.inspect}'.")
+
+ if alarm
+ AlarmMailer.deliver_simple(self.mail_to, alarm)
+ end
+ if report
+ if self.include_report_in_email
+ ReportMailer.deliver_normal(self.mail_to, report, {:add_csv => self.include_csv_in_email})
+ else
+ ReportMailer.deliver_simple(self.mail_to, report, {:add_csv => self.include_csv_in_email})
+ end
+ end
+
+ $log.info("Mails sucessfully sent.")
+ rescue
+ $log.error("Error sending mail: '#{$!}'")
+ @process_errors.push($!)
+ end
+ end
+ end
+
+ if @process_errors.length > 0
+ # send error mail
+ BaseMailer.send_exception(@process_errors)
+ else
+ @process_errors = nil
+ end
+
+ [alarm,report]
+ end
+
+ def process_errors
+ return nil if @process_errors.nil?
+ return @process_errors
+ end
+
+
+ def text
+throw "Deprecated function"
+ return @text if @text
+ total = self.view.table.count
+
+ ret = "#{self.name}\n"
+ ret += "-" * self.name.length + "\n\n"
+ ret += "#{self.description}\n\n\n"
+ if total > RECORD_LIMIT
+ ret += "DATATABLE (top #{RECORD_LIMIT} of #{total} records):\n"
+ else
+ ret += "DATATABLE (#{total} records):\n"
+ end
+
+ begin
+ @data = view.table.report_table(:all, :limit => RECORD_LIMIT)
+ txt = @data.as(:text, :ignore_table_width => true)
+ txt = "#{ret[0..MAX_TEXT_LENGTH]}\n.... (truncated) ...\n" if
+ ret.length > MAX_TEXT_LENGTH
+ rescue
+ txt = "ERROR GENERATING TABLE\n#{$!.inspect}"
+ end
+ @text = ret + txt
+ return @text
+
+ end
+
+ end
+
Added: incubator/alois/trunk/rails/app/models/sql_condition.rb
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/models/sql_condition.rb?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/models/sql_condition.rb (added)
+++ incubator/alois/trunk/rails/app/models/sql_condition.rb Thu Nov 4 18:27:22 2010
@@ -0,0 +1,48 @@
+# Copyright 2010 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ # The value field of SqlCondition will directly be inserted in the where clause of sql
+ class SqlCondition < Condition
+
+ def validate(table_class=nil)
+ self.sql(table_class)
+ if table_class
+ raise "Condition not appliable to #{table_class}." unless applyable(table_class)
+ end
+ end
+
+ def initialize(query, options = {})
+ @value = query
+ end
+
+ # Always empty, column must be included in value
+ def column
+ ""
+ end
+
+ # Always "SQL", operator must be included in value
+ def operator
+ "SQL"
+ end
+
+ # Sql statement, value with brackets, so ORs can be included.
+ # TODO: here pure SQL is included, maybe we should do some security checks
+ def sql(options = {})
+ "( #{@value} )"
+ end
+
+ def applyable(table_class)
+ return true
+ end
+ end
Added: incubator/alois/trunk/rails/app/models/table.rb
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/models/table.rb?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/models/table.rb (added)
+++ incubator/alois/trunk/rails/app/models/table.rb Thu Nov 4 18:27:22 2010
@@ -0,0 +1,186 @@
+# Copyright 2010 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class Table < ActiveRecord::Base
+ has_and_belongs_to_many :report_templates
+
+ attr_accessor :datasource
+ attr_accessor :conditions
+
+ validate do |t|
+ if t.datasource
+ cns = t.datasource.table.columns.map{|c| c.name}
+ ["columns","order_by","group_by"].each {|name|
+ missing_cols = t.send("#{name}_arr").reject {|cn| cns.include?(cn) }
+ t.errors.add(name,"Missing columns in datasource: #{missing_cols.inspect}.") unless
+ missing_cols.length == 0
+ }
+ end
+ end
+
+ def columns_arr
+ @columns_arr = columns.split(",").map{|n|
+ if n =~ /\((.*)\)/
+ $1.strip
+ else
+ n.strip
+ end
+ }.reject {|n| n == "*"}
+ @columns_arr
+ end
+ def order_by_arr
+ return [] if order_by.nil? or order_by.strip == ""
+ group_by.split(",").map{|n| n.strip.split(" ")[0]}
+ end
+ def group_by_arr
+ return [] if group_by.nil? or group_by.strip == ""
+ group_by.split(",").map{|n| n.strip}
+ end
+ def needed_column_names
+ columns_arr + order_by_arr + group_by_arr
+ end
+
+ def applyable?(ds)
+ t = self.clone
+ t.datasource = ds
+ return t.valid?
+ end
+
+ def text
+ render
+ return open(text_filename) {|f| f.readlines} if File.exist?(text_filename)
+ end
+
+ def html
+ "<pre>#{text}</pre>"
+ end
+
+ def base_name; (data_directory + "table").to_s; end
+
+ def data_filename; base_name + ".data"; end
+ def data_date; File.mtime(data_filename) rescue nil; end
+
+ def text_filename; base_name + ".txt"; end
+ def text_date; File.mtime(text_filename) rescue nil; end
+
+ def save_yaml
+ open((base_name + ".yaml"),"w") {|f| f.write(self.clone.to_yaml)}
+ end
+
+ def self.load_yaml(data_dir)
+ if data_dir.to_i == 0
+ data_directory = Pathname.new(data_dir)
+ raise "Data '#{data_dir}' directory not found." unless data_directory.exist?
+ else
+ data_directory = Pathname.new(RAILS_ROOT) + "tmp/tables/#{data_dir}"
+ end
+ file = (data_directory + "table.yaml").to_s
+ t = Table.from_yaml(open(file,"r"){|f|f.readlines.join})
+ t.set_data_directory(data_directory)
+ t
+ end
+
+ def render(options = {})
+ return if File.exist?(text_filename) and not (text_date < data_date rescue false)
+ save_yaml
+
+ data = get_data
+ if data.column_names.length == 0
+ txt = "--------------------------\n"
+ txt += "| No columns to display. |\n"
+ txt += "--------------------------\n"
+ else
+ txt = data.as(:text, :ignore_table_width => true)
+ end
+ open(text_filename,"w") {|f| f.write(txt) }
+ end
+
+ def set_data_directory(dir)
+ @data_directory = dir
+ end
+ def data_directory
+ if @data_directory
+ p = Pathname.new(@data_directory)
+ else
+ p = Pathname.new(RAILS_ROOT) + "tmp/tables/#{id}"
+ end
+ p.mkpath
+ p
+ end
+ def delete_data
+ d = data_directory
+ d.rmtree if d.exist? and d.directory?
+ end
+
+ def group_by
+ return nil if super and super == ""
+ super
+ end
+
+ def order_by
+ return nil if super and super == ""
+ super
+ end
+
+ def to_csv
+ get_data.to_csv
+ end
+ def as(type, options = {})
+ d = get_data
+ return nil if d.length == 0
+ d.as(type,options)
+ end
+ def count
+ get_data.length
+ end
+
+ def remove_cache
+ File.delete(data_filename) if File.exists?(data_filename)
+ end
+
+ def get_data(recreate_data = false)
+ if !recreate_data and File.exists?(data_filename)
+ @data = YAML::load(File.open(data_filename))
+ else
+
+ if datasource.respond_to?(:data)
+ raise "Group by not supported by this datasource '#{datasource.name}'" if group_by
+ raise "Order by not supported by this datasource '#{datasource.name}'" if order_by
+
+ data = datasource.data
+ cols = datasource.columns.map{|c| c.name}.select {|n| columns_arr.include?(n)}
+ data = data.map {|row|
+ nr = []
+ cols.each{|col| nr.push(row[col])}
+ nr
+ }
+
+ @data = Ruport::Data::Table.new :data => data, :column_names => cols
+
+ else
+ @data = @datasource.table.report_table(:all,
+ :select => if (columns.nil? or columns == "") then nil else columns end,
+ :limit => max_count,
+ :only => if (columns.nil? or columns == "") then nil else columns.split(",").map{|n| n.strip} end,
+ :order => order_by,
+ :group => group_by,
+ :conditions => conditions)
+ end
+
+ File.open(data_filename, 'w') { |f| f.puts @data.to_yaml }
+ end
+ @data
+ end
+
+end
Added: incubator/alois/trunk/rails/app/models/view.rb
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/models/view.rb?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/models/view.rb (added)
+++ incubator/alois/trunk/rails/app/models/view.rb Thu Nov 4 18:27:22 2010
@@ -0,0 +1,272 @@
+# Copyright 2010 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ class View < ActiveRecord::Base
+ has_many :sentinels
+
+ validate do |view|
+ if view.do_not_use_view_for_query
+ view.example_replacement_query
+ end
+ end
+
+ def example_replacement_query
+ # try to replace the values
+ View.update_query(self.sql,
+ {:conditions => "date = CURRENT_DATE and id LIKE '1%'",
+ :order => "id",
+ :limit => "13",
+ :offset => "9"})
+ end
+
+ def host
+ view_connection.host
+ end
+
+ def display_name
+ self.name
+ end
+
+ def self.get_class_from_tablename(tablename)
+ return nil unless tablename
+ if tablename =~ /^view_(\d*)$/
+ return find($1)
+ end
+ return nil
+ end
+
+ def source_table_class
+ return @source_table_class if @source_table_class
+ @source_table_class = Prisma::Database.get_class_from_tablename(id_source_table) if defined?(Prisma::Database)
+ @source_table_class = View.get_class_from_tablename(id_source_table) unless @source_table_class
+ @source_table_class = GenericRecord.get_class_from_tablename(id_source_table) unless @source_table_class
+ return @source_table_class
+ end
+
+ # Override Base functions
+ def save
+ create_view
+ ret = super
+ create_view
+ ret
+ end
+
+ def table
+ return @table if @table
+ GenericRecord.table_name = view_name
+ GenericRecord.reset_column_information()
+ ActiveRecord::Base.connection_handler.connection_pools["GenericRecord"] = view_connection.pool
+
+ begin
+ create_view unless GenericRecord.table_exists?
+ rescue
+ $log.error("Error creating view: #{$!}")
+ end
+ @table = GenericRecord
+ return @table
+ end
+
+ def self.get_join
+ return nil
+ end
+
+ def destroy
+ View.drop_view(view_connection, view_name)
+ super
+ end
+
+ def view_name
+ "view_#{id}"
+ end
+
+ def table_name
+ view_name
+ end
+
+ def sql
+ s = self.sql_declaration
+ s.gsub!(/<<VIEW\(([^\)]*)\)>>/) {|match|
+ view = View.find_by_name($1)
+ throw "View with name '#{$1}' not found!" unless view
+ view.table_name
+ }
+ s
+ end
+
+ # Create a new view in the default (normally alois) database.
+ def View.create_view(connection, name, query, throw_exception = false)
+ begin
+ View.drop_view(connection, name)
+ throw "No query given." unless query
+ throw "No name given." unless name
+ create = "CREATE VIEW #{name} AS " + query
+ $log.debug{create}
+ connection.activerecord_connection.execute(create)
+ rescue ActiveRecord::Transactions::TransactionError
+ raise $!
+ rescue
+ $log.warn "Could not create view #{name}: #{$!.to_s}" if $log.warn?
+ throw $! if throw_exception
+ end
+ end
+
+ # Drop the view with the given name in the default (normally alois) database..
+ def View.drop_view(connection, name)
+ drop = "DROP VIEW IF EXISTS #{name}"
+ $log.debug{drop}
+ connection.activerecord_connection.execute(drop)
+ end
+
+ def view_connection
+ # TODO: implement function to find correct parent class
+ if !id_source_table.blank? and !(id_source_table =~ /^view_/)
+ klass = eval(id_source_table.classify)
+ else
+ klass = LogMeta
+ end
+
+ conn = Connection.from_pool(klass.connection_pool)
+ raise "Connection for class #{klass.name} not found" unless conn
+ conn
+ end
+
+ def create_view
+ # not working because show field does not
+ # work anymore. Always create view
+ # Prisma.drop_view(view_name)
+# if self.do_not_use_view_for_query
+# Prisma.create_view(view_name, sql_declaration,true)
+# else
+ View.create_view(view_connection, view_name, sql,true)
+# end
+ end
+
+ def get_date_column
+ date_column_name or "date"
+ end
+
+ def get_select
+ return "*"
+ end
+
+ def get_join
+ return nil
+ end
+
+ #-------------------- quering ---------
+ # SELECT
+ # [ALL | DISTINCT | DISTINCTROW ]
+ # [HIGH_PRIORITY]
+ # [STRAIGHT_JOIN]
+ # [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
+ # [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
+ # select_expr, ...
+ # [FROM table_references
+ # [WHERE where_condition]
+ # [GROUP BY {col_name | expr | position}
+ # [ASC | DESC], ... [WITH ROLLUP]]
+ # [HAVING where_condition]
+ # [ORDER BY {col_name | expr | position}
+ # [ASC | DESC], ...]
+ # [LIMIT {[offset,] row_count | row_count OFFSET offset}]
+ # [PROCEDURE procedure_name(argument_list)]
+ # [INTO OUTFILE 'file_name' export_options
+ # | INTO DUMPFILE 'file_name'
+ # | INTO var_name [, var_name]]
+ # [FOR UPDATE | LOCK IN SHARE MODE]]
+
+ def View.insert_generic(type, query, value, regexps)
+ return query if value == "" or value.nil?
+
+ regex = regexps.select {|reg| query =~ reg}[0]
+ if regex
+ query =~ regex
+ case type
+ when :before
+ throw "Missing ( ) in regexp #{regex}." unless $1
+ query.sub(regex, "#{value} #{$1}")
+ when :after
+ throw "Missing ( ) in regexp #{regex}." unless $1
+ query.sub(regex, "#{$1} #{value}")
+ when :substitute, :replace
+ query.sub(regex, "#{value}")
+ end
+ end
+ end
+
+ def View.insert_condition(query, condition)
+ return query if condition == "" or condition.nil?
+
+ insert_generic(:after, query, "#{condition} AND", [/(WHERE)/i]) or
+ insert_generic(:before, query, "WHERE #{condition}", [/(GROUP BY)/i,/(HAVING)/i, /(ORDER BY)/i, /(LIMIT)/i]) or
+ query + " WHERE #{condition}"
+ end
+
+ def View.insert_limit_offset(query, limit, offset = nil)
+ if offset
+ val = "LIMIT #{offset.to_i}, #{limit.to_i}"
+ else
+ val = "LIMIT #{limit.to_i}"
+ end
+ insert_generic(:replace, query, val, [/LIMIT\s*\d+,\s*\d+/i,/LIMIT\s*\d+\s*OFFSET\s*\d+/i,/LIMIT\s*\d+/]) or
+ insert_generic(:before, query, val, [/(PROCEDURE)/i,/(INTO\s)/i,/(FOR UPDATE)/i, /(LOCK IN)/i]) or
+ query + " " + val
+ end
+
+ def View.insert_order(query, order)
+ val = "ORDER BY #{order}"
+ insert_generic(:replace, query, "#{val} LIMIT", [/ORDER\s*BY\s.*\s*LIMIT/i]) or
+ insert_generic(:replace, query, "#{val} PROCEDURE", [/ORDER\s*BY\s.*\s*PROCEDURE/i]) or
+ insert_generic(:replace, query, "#{val} INTO", [/ORDER\s*BY\s.*\s*INTO/i]) or
+ insert_generic(:replace, query, "#{val} FOR UPDATE", [/ORDER\s*BY\s.*\s*FOR UPDATE/i]) or
+ insert_generic(:replace, query, "#{val} LOCK IN", [/ORDER\s*BY\s.*\s*LOCK IN/i]) or
+ insert_generic(:replace, query, "#{val}", [/ORDER\s*BY\s.*$/i]) or
+ insert_generic(:before, query, val, [/(LIMIT)/i,/(PROCEDURE)/i,/(INTO\s)/i,/(FOR UPDATE)/i, /(LOCK IN)/i]) or
+ query + " " + val
+ end
+
+ def View.update_query(query, options = {})
+ return query if options.nil? or options.length == 0
+ # SELECT ...
+ # UNION [ALL | DISTINCT] SELECT ...
+ # [UNION [ALL | DISTINCT] SELECT ...]
+ parts = query.split(/union/i)
+ new_query = parts.map! {|part|
+ part = part.strip
+ # remove leading ALL or DISTINCT
+ start = ""
+ part.sub!(/^(all)\s/i) {|v| start = $1; "" }
+ part.sub!(/^(distinct)\s/i) {|v| start = $1; "" }
+ if start == ""
+ start += "("
+ else
+ start += " ("
+ end
+
+ # remove leading and tailing brackets
+ while part.strip.starts_with?("(")
+ throw "'#{part}' starts with a ( but does not end with one." unless
+ part.strip.ends_with?(")")
+ part = part.strip[1..-2]
+ end
+
+ part = View.insert_condition(part,options[:conditions]) if options[:conditions]
+ part = View.insert_limit_offset(part,options[:limit],options[:offset]) if options[:limit]
+ part = View.insert_order(part,options[:order]) if options[:order]
+ part += " " unless part.ends_with?(" ")
+ start + part
+ }.join(") UNION ") + ")"
+ end
+
+ end
Added: incubator/alois/trunk/rails/app/views/_count_text.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/_count_text.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/_count_text.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/_count_text.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1 @@
+<%= get_count_text() %>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/_messages.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/_messages.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/_messages.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/_messages.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,24 @@
+<%
+ message_class = nil
+ message_class = "messages" unless notices.empty?
+ message_class = "important_messages" unless errors.empty?
+%>
+
+<% unless message_class.nil? %>
+ <table class="form">
+ <tr>
+ <th colspan="2" class="<%= message_class %>">Hinweis</th>
+ </tr>
+ <% for message in errors %>
+ <tr>
+ <td style="width: 20px" class="important_message"><%= image_tag 'important_message.png' %></td><td class="important_message"><%=h message %></td>
+ </tr>
+ <% end %>
+
+ <% for message in notices %>
+ <tr>
+ <td style="width: 20px"><%= image_tag 'message.png' %></td><td><%=h message %></td>
+ </tr>
+ <% end %>
+ </table>
+<% end %>
Added: incubator/alois/trunk/rails/app/views/alarm_mailer/simple.html.erb
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarm_mailer/simple.html.erb?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarm_mailer/simple.html.erb (added)
+++ incubator/alois/trunk/rails/app/views/alarm_mailer/simple.html.erb Thu Nov 4 18:27:22 2010
@@ -0,0 +1,32 @@
+Alarm ocurred on <%= @alarm.created_at %>.
+<table class="form">
+
+<!-- sentinel -->
+ <tr>
+ <th><label>ID</label></th>
+ <td><%=h @alarm.id %></td>
+ </tr>
+
+<% if @sentinel = @alarm.sentinel %>
+ <tr>
+ <th><label>Created by Sentinel</label></th>
+ <td><%= @sentinel.name %>
+ <br>
+ <%=h @sentinel.description %>
+ </td>
+ </tr>
+<% end %>
+ <tr>
+ <th><label>Alarm Level</label></th>
+ <td style="background-color:<%=h @alarm.color %>;"><%=h @alarm.alarm_level %>: <%= @alarm.alarm_level_name %></td>
+ </tr>
+ <tr>
+ <th><label>Comment</label></th>
+ <td><%=h @alarm.comment %></td>
+ </tr>
+ <tr>
+ <th><label>Link</label></th>
+ <td><%= link_to "Alarm \##{@alarm.id}", :only_path => false,:controller => :alarms, :action => :show, :id => @alarm %></td>
+ </tr>
+
+</table>
Added: incubator/alois/trunk/rails/app/views/alarm_mailer/simple.plain.erb
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarm_mailer/simple.plain.erb?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarm_mailer/simple.plain.erb (added)
+++ incubator/alois/trunk/rails/app/views/alarm_mailer/simple.plain.erb Thu Nov 4 18:27:22 2010
@@ -0,0 +1,12 @@
+Alarm ocurred on <%=h @alarm.created_at %>.
+ ID: <%=h @alarm.id %>
+<% if @sentinel = @alarm.sentinel -%>
+ Created by Sentinel: <%= @sentinel.name %>
+<% end -%>
+ Alarm Level: <%=h @alarm.alarm_level %>
+ Link: <%= url_for :only_path => false,:controller => :alarms, :action => :show, :id => @alarm %>
+
+Comment:
+<%=h @alarm.comment %>
+
+
Added: incubator/alois/trunk/rails/app/views/alarms/_form.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarms/_form.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarms/_form.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/alarms/_form.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,17 @@
+<%= error_messages_for 'alarm' %>
+
+ <tr>
+ <th class="form_header" colspan="2">Alarm</th>
+ </tr>
+
+ <tr>
+ <th><label for="alarm_comment">Comment</label></th>
+ <td><%= text_area 'alarm', 'comment' %></td>
+ </tr>
+ <tr>
+ <th><label for="sentinel_process_state">Process State</label></th>
+ <td><%= select("alarm", "process_state", Alarm::PROCESS_STATES.map {|num, name| [name.to_s,num]}.sort_by{|p| p[1]}) %></td>
+ </tr>
+
+
+
Added: incubator/alois/trunk/rails/app/views/alarms/_status_item.html.erb
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarms/_status_item.html.erb?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarms/_status_item.html.erb (added)
+++ incubator/alois/trunk/rails/app/views/alarms/_status_item.html.erb Thu Nov 4 18:27:22 2010
@@ -0,0 +1,15 @@
+ <tr>
+ <td><%=h @alarm.id %><%= @alarm.acknowledge %></td>
+<% if @alarm.acknowledge %>
+ <td style="background-color:DDFFDD;green;color:<%=h @alarm.color %>"><%=h @alarm.alarm_level_name %></td>
+<% else %>
+ <td style="background-color:<%=h @alarm.color %>"><%=h @alarm.alarm_level_name %></td>
+<% end %>
+ <td><%= fobj(@alarm.sentinel) %></td>
+ <td><%=h @alarm.created_at.strftime("%F %T") %></td>
+ <td><%=h @alarm.process_state %></td>
+ <td><%=h @alarm.comment %></td>
+ <td>
+ <%= link_to image_tag( 'show.png' ), :action => 'show', :id => @alarm %><%= link_to image_tag( 'edit.png' ), :action => 'edit', :id => @alarm %>
+ </td>
+ </tr>
Added: incubator/alois/trunk/rails/app/views/alarms/_survey_component.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarms/_survey_component.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarms/_survey_component.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/alarms/_survey_component.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,33 @@
+<%= title @controller.controller_name.humanize %>
+
+<div id="page">
+<%= error_messages %>
+
+<table class="form">
+ <tr>
+ <th class="form_header">ID</th>
+ <th class="form_header">Sentinel Name</th>
+ <th class="form_header">Date</th>
+ <th class="form_header">Process State</th>
+ <th class="form_header" style="width: 160px"/>
+ </tr>
+<% for alarm in @alarms %>
+ <tr>
+ <td><%=h alarm.id %></td>
+ <td><%=h alarm.sentinel.name if alarm.sentinel %></td>
+ <td><%=h alarm.created_at %></td>
+ <td><%=h alarm.process_state %></td>
+ <td>
+ <%= link_to image_tag( 'show.png' ), :action => 'show', :id => alarm %><%= link_to image_tag( 'edit.png' ), :action => 'edit', :id => alarm %>
+ </td>
+ </tr>
+<% end %>
+ <tr>
+ <td class="button-bar" colspan="5">
+<%= link_to 'Previous page', { :page => @alarm_pages.current.previous } if @alarm_pages.current.previous %>
+<%= link_to 'Next page', { :page => @alarm_pages.current.next } if @alarm_pages.current.next %>
+ </td>
+ </tr>
+
+</table>
+</div>
Added: incubator/alois/trunk/rails/app/views/alarms/edit.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarms/edit.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarms/edit.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/alarms/edit.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,13 @@
+<%= title "#{@controller.action_name.humanize} #{@controller.controller_name.singularize.humanize} - #{@alarm.id}" %>
+
+<div id="page">
+
+ <table class="form">
+ <% form_tag :action => 'update', :id => @alarm do %>
+ <%= render :partial => 'form' %>
+ <tr>
+ <td class="button-bar" colspan="2"><%= submit_tag "Update" %> <%= submit_tag "Cancel" %></td>
+ </tr>
+ <% end %>
+ </table>
+</div>
Added: incubator/alois/trunk/rails/app/views/alarms/list.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarms/list.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarms/list.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/alarms/list.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,31 @@
+<%= title @controller.controller_name.humanize %>
+
+<div id="page">
+<%= error_messages %>
+
+<table class="form">
+ <tr>
+ <th class="form_header">ID</th>
+ <th class="form_header">Sentinel Name</th>
+ <th class="form_header">Date</th>
+ <th class="form_header">Process State</th>
+ <th class="form_header" style="width: 160px"/>
+ </tr>
+<% for alarm in @alarms %>
+ <tr>
+ <td><%=h alarm.id %></td>
+ <td><%=h alarm.sentinel.name if alarm.sentinel %></td>
+ <td><%=h alarm.created_at %></td>
+ <td><%=h alarm.process_state %></td>
+ <td>
+ <%= link_to image_tag( 'show.png' ), :action => 'show', :id => alarm %><%= link_to image_tag( 'edit.png' ), :action => 'edit', :id => alarm %>
+ </td>
+ </tr>
+<% end %>
+ <tr>
+ <td class="button-bar" colspan="5"><%= will_paginate @alarms %>
+ </td>
+ </tr>
+
+</table>
+</div>
Added: incubator/alois/trunk/rails/app/views/alarms/new.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarms/new.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarms/new.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/alarms/new.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,8 @@
+<h1>New alarm</h1>
+
+<% form_tag :action => 'create' do %>
+ <%= render :partial => 'form' %>
+ <%= submit_tag "Create" %>
+<% end %>
+
+<%= link_to 'Back', :action => 'list' %>
Added: incubator/alois/trunk/rails/app/views/alarms/send_to_email.html.erb
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarms/send_to_email.html.erb?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarms/send_to_email.html.erb (added)
+++ incubator/alois/trunk/rails/app/views/alarms/send_to_email.html.erb Thu Nov 4 18:27:22 2010
@@ -0,0 +1 @@
+Alarm <%= @alarm.id %> sent to <%= params[:addresses].inspect %>.<br>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/alarms/show.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarms/show.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarms/show.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/alarms/show.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,83 @@
+<%= title("Alarm - #{@alarm.id}") %>
+
+<div class="page">
+<table class="form">
+ <tr>
+ <th class="form_header" colspan="2">Alarm</th>
+ </tr>
+
+ <tr>
+ <th><label for="alarm_id">ID</label></th>
+ <td><%=h @alarm.id %></td>
+ </tr>
+ <tr>
+ <th><label for="alarm_created_at">Created At</label></th>
+ <td><%=h @alarm.created_at %></td>
+ </tr>
+ <tr>
+ <th><label for="alarm_alarm_level">Alarm Level</label></th>
+ <td style="background-color:<%= @alarm.color %>;"><%=h @alarm.alarm_level %>: <%= @alarm.alarm_level_name %></td>
+ </tr>
+ <tr>
+ <th><label for="alarm_sentinel">Created by Sentinel</label></th>
+ <td><%= fobj(@alarm.sentinel) %>
+ <% if @sentinel = @alarm.sentinel %><br>
+ <%=h @sentinel.description %>
+ <% end %>
+ </td>
+ </tr>
+ <tr>
+ <th><label for="sentinel_alarms">Active Aalrms of this Sentinel</label></th>
+ <td><% @sentinel.alarms.reject {|a| a.acknowledge}.each {|a| %>
+ <%=h a.created_at %>: <%= fobj(a) %><br>
+ <% } %>
+ </td>
+ </tr>
+
+ <tr><th style="text-align:center" colspan="2">Comment</th></tr>
+ <tr>
+ <th><label for="alarm_comment">Comment</label></th>
+ <td><%=h @alarm.comment %></td>
+ </tr>
+ <tr>
+ <th><label for="alarm_process_state">Process State</label></th>
+ <td><%=h @alarm.process_state %></td>
+ </tr>
+
+
+ <tr><th style="text-align:center" colspan="2">Data</th></tr>
+ <tr>
+ <th><label for="alarm_text">Text</label></th>
+ <td><pre><%=h @alarm.text rescue $! %></pre></td>
+ </tr>
+ <tr>
+ <th><label for="alarm_link">Link</label></th>
+ <td><%= link_to "#{@alarm.sentinel.view.table_name} WHERE #{@alarm.conditions}",
+ :controller => "survey", :action => :list,
+ :table => @alarm.sentinel.view.table_name,
+ :default_filter => @alarm.conditions %> </td>
+ </tr>
+ <tr>
+ <th><label for="alarm_log">Log</label></th>
+ <td><pre><%=h @alarm.log %></pre></td>
+ </tr>
+ <tr>
+ <th><label for="alarm_path">Path</label></th>
+ <td><%=h @alarm.path %></td>
+ </tr>
+
+ <tr>
+ <th><label for="alarm_report">Report</label></th>
+ <td><%= fobj(@alarm.report) %></td>
+ </tr>
+ <tr>
+ <td class="button-bar" colspan="2"><%= button_to "Edit", :action => :edit, :id => @alarm %><%= button_to "List all", :action => :list %>
+
+<% form_tag :action => :send_to_email, :id => @alarm do %>
+ Send to alarm notification to email: <%= text_field_tag 'addresses' %>
+ <%= submit_tag "Send" %>
+<% end %>
+
+ </tr>
+</table>
+</div>
Added: incubator/alois/trunk/rails/app/views/alarms/status.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/alarms/status.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/alarms/status.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/alarms/status.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,63 @@
+<%= title @controller.controller_name.humanize %>
+
+<div id="page">
+<%= error_messages %>
+
+<table class="form">
+ <tr>
+ <th class="form_header" style="width:5%">ID</th>
+ <th class="form_header" style="width:10%">Level</th>
+ <th class="form_header" style="width:15%">Sentinel</th>
+ <th class="form_header" style="width:15%">Date</th>
+ <th class="form_header" style="width:10%">Process State</th>
+ <th class="form_header" style="width:40%">Comment</th>
+ <th class="form_header" style="width:5%"/>
+ </tr>
+<% if @alarms.length == 0 and not params[:page]%>
+ <tr>
+ <th class="form_header" style="background-color:<%= Alarm.status_color %>;" colspan="7">No Current Alarms</th>
+ </tr>
+ <tr>
+ <td class="button-bar" colspan="7">
+ <%= link_to "Reload", :action => "list" %>
+ </td>
+ </tr>
+<% else %>
+ <tr>
+ <th class="form_header" style="background-color:<%= Alarm.status_color %>;" colspan="7">Current Alarms</th>
+ </tr>
+<% for @alarm in @alarms %>
+ <%= render :partial => "status_item" %>
+<% end %>
+ <tr>
+ <td class="button-bar" colspan="7" style="background-color:<%= Alarm.status_color %>;"><%= will_paginate @alarms %>
+ <%= link_to "Reload", :action => "list" %>
+ </td>
+ </tr>
+
+<% end %>
+
+ <tr>
+ <th class="form_header" colspan="7">Latest Acknowledgements</th>
+ </tr>
+<% for @alarm in @ack_alarms %>
+ <%= render :partial => "status_item" %>
+<% end %>
+ <tr>
+ <td class="button-bar" colspan="7"><%= will_paginate @ack_alarms,:param_name => "page_ack" %>
+ </td>
+ </tr>
+
+ <tr>
+ <th class="form_header" colspan="7">Informational or Debug Alarms</th>
+ </tr>
+<% for @alarm in @infos %>
+ <%= render :partial => "status_item" %>
+<% end %>
+ <tr>
+ <td class="button-bar" colspan="7"><%= will_paginate @infos, :param_name => "page_info" %>
+ </td>
+ </tr>
+
+</table>
+</div>
Added: incubator/alois/trunk/rails/app/views/bookmarks/_form.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/bookmarks/_form.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/bookmarks/_form.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/bookmarks/_form.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,26 @@
+<%= error_messages_for 'bookmark' %>
+
+<!--[form:bookmark]-->
+<p><label for="bookmark_title">Title</label><br/>
+<%= text_field 'bookmark', 'title' %></p>
+
+<p><label for="bookmark_description">Description</label><br/>
+<%= text_area 'bookmark', 'description' %></p>
+
+<p><label for="bookmark_table_name">Table name</label><br/>
+<%= select 'bookmark', 'table_name', Prisma::Database.data_sources.map {|s| [s.name,s.table.table_name] }.sort_by{|x|(x[0] or "")}, {:include_blank => true} %>
+
+<p><label for="bookmark_controller">Controller</label><br/>
+<%= text_field 'bookmark', 'controller' %></p>
+
+<p><label for="bookmark_action">Action</label><br/>
+<%= text_field 'bookmark', 'action' %></p>
+
+<p><label for="bookmark_identifier">Identifier</label><br/>
+<%= text_field 'bookmark', 'identifier' %></p>
+
+<p><label for="bookmark_mode">Mode</label><br/>
+<%= text_field 'bookmark', 'mode' %></p>
+
+<!--[eoform:bookmark]-->
+
Added: incubator/alois/trunk/rails/app/views/bookmarks/edit.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/bookmarks/edit.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/bookmarks/edit.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/bookmarks/edit.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,9 @@
+<h1>Editing bookmark</h1>
+
+<% form_tag :action => 'update', :id => @bookmark do %>
+ <%= render :partial => 'form' %>
+ <%= submit_tag 'Save' %>
+<% end %>
+
+<%= link_to 'Show', :action => 'show', :id => @bookmark %> |
+<%= link_to 'Back', :action => 'list' %>
Added: incubator/alois/trunk/rails/app/views/bookmarks/list.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/bookmarks/list.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/bookmarks/list.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/bookmarks/list.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,29 @@
+<%= title @controller.controller_name.humanize %>
+
+<div id="page">
+<%= error_messages %>
+
+<table class="form">
+ <tr>
+ <th class="form_header" style="width:30px;">ID</th>
+ <th class="form_header">Title</th>
+ <th class="form_header" style="width:180px;"/>
+ </tr>
+<% for bookmark in @bookmarks %>
+ <tr>
+ <td><%=h bookmark.id %></td>
+ <td><%=h bookmark.title %></td>
+ <td>
+ <%= link_to image_tag( 'goto.png' ), bookmark.url rescue "" %><%= link_to image_tag( 'show.png' ), :action => 'show', :id => bookmark %><%= link_to image_tag( 'edit.png' ), :action => 'edit', :id => bookmark %><%= link_to image_tag( 'delete.png' ),{:action => 'destroy', :id => bookmark }, :confirm => 'Are you sure?', :method => :post %>
+ </td>
+ </tr>
+<% end %>
+ <tr>
+ <td class="button-bar" colspan="3">
+<%= will_paginate(@bookmarks) %>
+<%= link_to 'New bookmark', { :action => "new" } %>
+ </td>
+ </tr>
+
+</table>
+</div>
Added: incubator/alois/trunk/rails/app/views/bookmarks/new.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/bookmarks/new.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/bookmarks/new.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/bookmarks/new.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,8 @@
+<h1>New bookmark</h1>
+
+<% form_tag :action => 'create' do %>
+ <%= render :partial => 'form' %>
+ <%= submit_tag "Create" %>
+<% end %>
+
+<%= link_to 'Back', :action => 'list' %>
Added: incubator/alois/trunk/rails/app/views/bookmarks/show.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/bookmarks/show.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/bookmarks/show.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/bookmarks/show.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,8 @@
+<% for column in Bookmark.content_columns %>
+<p>
+ <b><%= column.human_name %>:</b> <%=h @bookmark.send(column.name) %>
+</p>
+<% end %>
+
+<%= link_to 'Edit', :action => 'edit', :id => @bookmark %> |
+<%= link_to 'Back', :action => 'list' %>
Added: incubator/alois/trunk/rails/app/views/charts/_column_fields.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/_column_fields.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/_column_fields.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/_column_fields.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,69 @@
+ <table class="form">
+ <tr>
+ <th></th>
+ <th>X-Axis <%= short_help "Chart X-Axis","The column to use for the X-Axis of the chart." %></th>
+ <th>Y-Axis <%= short_help "Chart Y-Axis, Aggregation Function", "This function and column is used to compute the data values for the chart. The value used is then AGG_FUNC(AGG_COL) (e.g. COUNT(*) or SUM(bytes)...)." %></th>
+ <th>Z-Axis <%= short_help "Chart Z-Axis","The column to use for the Y-Axis of the chart (select a column to get a stacket chart)." %></th>
+ <th>Multi Chart <%= short_help "Mutli Chart","Select a column to define for which values a sepearate chart should be rendered." %></th>
+ </tr>
+ <tr>
+ <th>Data</th>
+ <% if current_table %>
+ <td><%= select("chart", "column1", current_table.columns.map {|c| c.name }.sort) %></td>
+ <td style="white-space:nowrap;"><%= select("chart", "aggregation_function", Chart::AGGREGATION_FUNCTIONS) -%><%= select("chart", "aggregation_column", ["*"] + current_table.columns.map {|c| c.name} ) %></td>
+ <td><%= select("chart", "column2", current_table.columns.map {|c| c.name }.sort, { :include_blank => true }) %></td>
+ <td><%= select("chart", "column3", current_table.columns.map {|c| c.name }.sort, { :include_blank => true }) %></td>
+ <% else %>
+ <td><%= text_field("chart", "column1",:size => 10) %></td>
+ <td style="white-space:nowrap;"><%= select("chart", "aggregation_function", Chart::AGGREGATION_FUNCTIONS) -%><%= text_field("chart", "aggregation_column", {:default => "*",:size => 10}) %></td>
+ <td><%= text_field("chart", "column2",:size => 10) %></td>
+ <td><%= text_field("chart", "column3",:size => 10) %></td>
+ <% end %>
+ <th></th>
+ </tr>
+ <% ["1st","2nd","3rd"].each {|num| %>
+ <tr>
+ <th><%= num %>-Order <%= short_help "How the data should be orderd in the chart", "Select an order an the chart will be ordered like this. SQL syntax is used here. For example COUNT(*) DESC means it will be orderd by COUNT(*) descending." %></th>
+ <% Chart::ORDER_NAMES.each_with_index {|order_name,index| %>
+ <td><%= image_tag("up.png") %><%= radio_button "chart", "order_#{num}", "#{order_name}" %>
+ <%= image_tag("down.png") %><%= radio_button "chart", "order_#{num}", "#{order_name}_desc" %></td>
+ <% } %>
+ <% if current_table %>
+ <td style="white-space:nowrap;"><%= radio_button "chart", "order_#{num}", "none" %><%= select("chart", "order_field_#{num}", @chart.possible_orders, { :include_blank => true } ) %>
+ <% else %>
+ <td><%= text_field("chart", "order_by",:size => 10) %>
+ <% end %>
+ </tr>
+ <% } %>
+
+<tr>
+ <th>Type</th>
+ <td colspan="5">
+
+ <table>
+ <tr>
+ <% Chart::CHART_TYPES.each {|chart_type| %>
+ <th>
+ <%= image_tag("#{chart_type}-chart.png") %>
+ <%= short_help "#{chart_type.to_s.camelize} Chart",Chart::CHART_TEXTS[chart_type][1] %>
+ </th>
+ <% } %>
+ <% Chart::CHART_OPTIONS.each {|option| %>
+ <th><%= option.to_s.camelize %></th>
+ <% } %>
+</tr>
+ <tr>
+ <% Chart::CHART_TYPES.each {|chart_type| %>
+ <td><%= radio_button "chart", "chart_type", chart_type %></td>
+ <% } %>
+ <% Chart::CHART_OPTIONS.each {|option| %>
+ <td><%= check_box "chart", option %></td>
+ <% } %>
+ </tr>
+ </td>
+ </tr></table>
+
+ </table>
+
+
+
Added: incubator/alois/trunk/rails/app/views/charts/_form.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/_form.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/_form.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/_form.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,28 @@
+ <tr>
+ <th><label for="chart_name">Name</label></th>
+ <td><%= text_field 'chart', 'name' %></td>
+ </tr>
+ <tr>
+ <th><label for="chart_description">Description</label></th>
+ <td><%= text_area 'chart', 'description', :style => "width: 99%", :rows => 4 %></td>
+ </tr>
+ <tr>
+ <th><label for="sentinel_time_range">Time range</label></th>
+ <td><%= text_field_with_auto_complete :chart, :time_range, :autocomplete => "off", :style => 'width: 98%', :rows => 4 %></td>
+ </tr>
+ <tr>
+ <th><label for="chart_width">Width</label></th>
+ <td><%= text_field 'chart', 'width', :style => "width: 99%" %></td>
+ </tr>
+ <tr>
+ <th><label for="chart_height">Height</label></th>
+ <td><%= text_field 'chart', 'height', :style => "width: 99%"%></td>
+ </tr>
+ <tr>
+ <th><label for="chart_max_values">Max Values</label></th>
+ <td><%= text_field 'chart', 'max_values', :style => "width: 99%"%></td>
+ </tr>
+
+ <tr>
+ <td colspan='2'><%= render :partial => "column_fields" %></td>
+ </tr>
Added: incubator/alois/trunk/rails/app/views/charts/_render_chart_inline.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/_render_chart_inline.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/_render_chart_inline.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/_render_chart_inline.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,19 @@
+<% if @chart.datasource(true) %>
+ <%= @chart.image_tag({:url => url_for(:action => "chart_image", :id => @chart, :table => params[:table])}) %>
+ <%= @chart.image_map({:link => url_for(:controller => "survey",:action => "chart_click",:table => @chart.datasource.table.table_name) + "?"}) %>
+
+<br>
+ <% if @chart.data_date %>
+ Data generated: <%= @chart.data_date.strftime("%c") %>
+ <% end %>
+ <% if @chart.image_date %>
+ Image generated: <%= @chart.image_date.strftime("%c") %>
+ <% end %>
+
+ <%= link_to_remote "Reload",
+ :before => "table_reload()",
+ :update => 'survey_chart',
+ :url => { :controller=> 'survey', :action => 'chart_inline', :state_id => @state_id, :recreate_data => true} %>
+<% else %>
+
+<% end %>
Added: incubator/alois/trunk/rails/app/views/charts/_show_conditions.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/_show_conditions.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/_show_conditions.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/_show_conditions.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,3 @@
+<% @current_filter.conditions.each_with_index { |@condition, @condition_index| %>
+ <%= @condition.sql(nil) %><br/>
+<% } %>
Added: incubator/alois/trunk/rails/app/views/charts/edit.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/edit.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/edit.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/edit.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,22 @@
+<%= title "#{@controller.action_name.humanize} #{@controller.controller_name.singularize.humanize} - #{@chart.name}" %>
+
+<!-- leave that for function calls to this div -->
+<div id="log_table"></div>
+
+<% form_tag :action => 'update', :id => @chart, :state_id => @state_id do %>
+<div id="page">
+ <%= error_messages_for 'chart' %>
+
+ <table class="form">
+ <tr>
+ <th class="form_header" colspan="2">Chart</th>
+ </tr>
+
+ <%= render :partial => "form" %>
+
+ <tr>
+ <td class="button-bar" colspan="2"><%= submit_tag "Save" %><%= submit_tag "Cancel" %></td>
+ </tr>
+ </table>
+</div>
+<% end %>
Added: incubator/alois/trunk/rails/app/views/charts/edit_current.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/edit_current.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/edit_current.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/edit_current.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,6 @@
+<div id="edit_filter">
+<% form_remote_tag :update => 'edit_filter', :url => {:controller=> 'filters', :action => 'index', :id => @filter,:state_id => @state_id} do %>
+ <%= render :partial => 'form' %>
+ <%= submit_tag 'Update' %>
+<% end %>
+</div>
Added: incubator/alois/trunk/rails/app/views/charts/list.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/list.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/list.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/list.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,27 @@
+<%= title @controller.controller_name.humanize %>
+
+<div id="page">
+<%= error_messages %>
+
+<table class="form">
+ <tr>
+ <th class="form_header">Name</th>
+ <th class="form_header">Description</th>
+ <th class="form_header" style="width: 160px"/>
+ </tr>
+<% for chart in @charts %>
+ <tr>
+ <td><%=h chart.name %></td>
+ <td><%=h chart.description %></td>
+ <td>
+ <%= link_to image_tag( 'show.png' ), :action => 'show', :id => chart %><%= link_to image_tag( 'edit.png' ), :action => 'edit', :id => chart %> <%= link_to image_tag('delete.png'), { :action => 'destroy', :id => chart }, :confirm => 'Are you sure?', :method => :post %>
+ </td>
+ </tr>
+<% end %>
+ <tr>
+ <td class="button-bar" colspan="3">
+ <%= button_to "New #{@controller.controller_name.singularize.humanize}", :action => 'new' %>
+ </td>
+ </tr>
+</table>
+</div>
Added: incubator/alois/trunk/rails/app/views/charts/list_inline.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/list_inline.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/list_inline.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/list_inline.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,33 @@
+<table>
+
+<th>Name</th>
+<th></th>
+<th><%= link_to_remote(image_tag("update.png", :alt => "Reload filter list"), :update => "filters", :url => {:controller => "filters", :action => "list_inline", :params=>@current_filter.get_params}) %>
+</th>
+
+
+<% for filter in @filters %>
+ <tr>
+ <td><%=h filter.send("name") %> </td>
+ <td><a href="<%= url_for :controller => "table/#{filter.table}", :action => 'list', :params => filter.get_params %>">Use</a>
+ <td><%= link_to_remote 'Destroy', :update => "filters", :url => {:controller => "filters", :action => 'destroy_inline', :id => filter }, :confirm => 'Are you sure?', :method => :post %></td>
+ </tr>
+<% end %>
+</table>
+
+
+<%= link_to_remote("Previous page", :update => "filters", :url => {:controller => "filters", :action => "list_inline", :page => @filter_pages.current.previous }) if @filter_pages.current.previous %>
+
+<%= link_to_remote("next page", :update => "filters", :url => {:controller => "filters", :action => "list_inline", :page => @filter_pages.current.next }) if @filter_pages.current.next %>
+
+
+<% form_remote_tag :update => 'filters', :url => {:controller => "filters", :action => 'add_inline', :id => nil} do %>
+
+ <%= text_field_tag :name %>
+ <% ps = @current_filter.get_params %>
+ <% for (name,value) in ps %>
+ <%= hidden_field_tag name,value %>
+ <% end %>
+<input type="submit" value="Create"/>
+
+<% end %>
Added: incubator/alois/trunk/rails/app/views/charts/new.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/new.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/new.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/new.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,20 @@
+<%= title "#{h @controller.action_name.humanize} #{h @controller.controller_name.singularize.humanize}" %>
+
+<div id="page">
+ <%= error_messages_for 'chart' %>
+
+ <% form_tag :action => 'create', :state_id => @state_id do %>
+ <table class="form">
+ <tr>
+ <th class="form_header" colspan="2"><%=h controller.controller_name.singularize.humanize %></th>
+ </tr>
+
+ <%= render :partial => "form" %>
+
+ <tr>
+ <td class="button-bar" colspan="2"><%= submit_tag "Create" %><%= submit_tag "Cancel" %></td>
+ </tr>
+ <% end %>
+ <%= post_attribute_new %>
+ </table>
+</div>
Added: incubator/alois/trunk/rails/app/views/charts/render_chart.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/render_chart.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/render_chart.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/render_chart.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1 @@
+<%= render :partial => "render_chart_inline" %>
Added: incubator/alois/trunk/rails/app/views/charts/show.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/charts/show.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/charts/show.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/charts/show.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,38 @@
+<%= title("#{h @controller.controller_name.singularize.humanize} - #{h @chart.name}") %>
+
+<div class="page">
+<table class="form">
+ <tr>
+ <th class="form_header" colspan="2">Chart</th>
+ </tr>
+ <% for col in @chart.class.columns %>
+ <tr>
+ <th><label for="chart_#{col.name}"><%= col.human_name %></label></th>
+ <td><%=h @chart.send(col.name) %></td>
+ </tr>
+ <% end %>
+
+ <%= post_attributes_show %>
+
+ <tr>
+ <td class="button-bar" colspan="2"><%= button_to "Edit", :action => :edit, :id => @chart %><%= button_to "Delete", { :action => :destroy, :id => @chart }, :confirm => 'Are you sure?' %><%= button_to "List all", :action => :list %></td>
+ </tr>
+ <tr>
+ <th class="form_header" colspan="2">Render</th>
+ </tr>
+ <tr>
+ <th>Select datasource to render with:</th><td>
+<% form_tag :action => :render_chart, :id => @chart do %>
+
+<%= select_tag('table', options_for_select(Prisma::Database.data_sources.select {|s|
+ @chart.applyable?(s)
+ }.map {|s|
+ [s.name,s.table_name]
+ }.sort{|x,y| (x[0] or "") <=> (y[0] or "")}), {:include_blank => true}) %>
+<%= submit_tag "Render"%>
+<% end %>
+ </td>
+ </tr>
+
+</table>
+</div>
Added: incubator/alois/trunk/rails/app/views/exception/_generic.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/exception/_generic.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/exception/_generic.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/exception/_generic.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,16 @@
+<h1>A unhandled exception occurred: <%= @exception_name %></h1>
+<p>This application is still under development. Something unexpected happened:</p>
+<h3><%=h @exception.to_s %></h3>
+<p>If you think this is a bug of the application and should work, please report the error to the developer: <a href="mailto:flavio.pellanda@logintas.ch">Flavio Pellanda</a> The more information you can give the more we can help.</p>
+<h2>Message:</h2>
+<pre>
+<%=h $!.message %>
+</pre>
+<h2>Params:</h2>
+<pre>
+<%=h params.inspect %>
+</pre>
+<h2>Trace:</h2>
+<pre>
+<%=h $!.backtrace.join("\n") %>
+</pre>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/exception/generic.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/exception/generic.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/exception/generic.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/exception/generic.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1 @@
+<%= render :partial => "generic" %>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/exception/record_not_found.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/exception/record_not_found.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/exception/record_not_found.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/exception/record_not_found.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1 @@
+RECORD NOT FOUND EXCEPTION <%= params[:exception].inspect %>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/filters/_add_condition_help.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/_add_condition_help.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/_add_condition_help.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/_add_condition_help.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,40 @@
+<%= help_title("Adding Conditions") %>
+<p>A condition consists of a column, operator and a
+value.</p>
+
+<%= help_subtitle("Column") %>
+<p>Dropdown: You can select a column or ANY. ANY means that
+the value compared with the selected operator must match for
+any column of the view. E.g. you can look for a existence of
+a word in any column.<br>
+The column is always ment to be the one from
+the current view, so you do not have to declare the
+table name.</p>
+
+<%= help_subtitle("Operator") %>
+<p>The operator generally have the same meaning as in SQL.
+There are two special operators:
+</p>
+
+<%= help_subsubtitle("SQL") %>
+<p>Use this operator if you want to type a sql statement by
+yourself. In this case the column will be ignored totally and
+you can enter the sql statement in the value textbox.<br>
+<%= help_notice("Be aware there will not be any semantic check in that case.") %></p>
+
+<%= help_subsubtitle("DATE") %>
+<p>If you select this operator you can enter the meaningful name
+for a date period into the value field. At the moment the following
+values are supported:
+<ul>
+ <% for name in DateCondition.get_date_descriptions %>
+ <li><%= name %></li>
+ <% end %>
+</ul>
+</p>
+
+<%= help_subtitle("Value") %>
+<p>The value you want to compare with. Do not use any quotes
+for string or any value. The system can check the type of
+the column and do the proper escapement.<br>
+<%= help_notice("You must take care of the escapements when using the SQL operator.") %></p>
Added: incubator/alois/trunk/rails/app/views/filters/_condition.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/_condition.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/_condition.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/_condition.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,18 @@
+ <td><%= @condition.column %></td>
+ <td><%= @condition.operator %></td>
+<% if @condition.updatable? then %>
+ <td><% form_remote_tag :update => 'edit_filter',:url => {:controller=> 'filters',
+ :action => 'update_condition',
+ :state_id => @state_id,
+ :condition_id => @condition_index} do -%>
+ <%= submit_to_remote "Send","Update",
+ :update => 'edit_filter',
+ :before => 'table_reload()',
+ :loaded => 'update_table()', :url => {:controller=> 'filters',
+ :action => 'update_condition',
+ :state_id => @state_id,
+ :condition_id => @condition_index} -%>
+ <% if @condition.operator == "DATE" and @condition_index -%><%= text_field_with_auto_complete :condition, :value, :autocomplete => "off", :size => 25 -%><% else -%><%= text_field :condition, :value, :size => 25 %><% end -%><% end -%></td>
+<% else %>
+<td><%= @condition.value %></td>
+<% end %>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/filters/_condition_form.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/_condition_form.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/_condition_form.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/_condition_form.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,39 @@
+<tr>
+ <td>
+ <% if current_table %>
+ <select name="column" style="width: 99%">
+ <option value="ANY">ANY</option>
+ <% for column in current_table.columns %>
+ <option value="<%= column.name %>">
+ <%= column.name %>
+ </option>
+ <% end %>
+ </select>
+ <% else %>
+ <%= text_field_tag "column", nil, :style => "width: 99%" %>
+ <% end %>
+ </td>
+ <td>
+ <select name="operator" style="width: 99%">
+ <% Condition::OPERATORS.each {|operator| %>
+ <option value="<%= operator %>"><%=h operator %></option>
+ <% } %>
+ </select>
+ </td>
+ <td>
+ <input name="value" style="width: 99%"/>
+ </td>
+ <td>
+ <%= submit_to_remote "Send", "Add",
+ :update => 'edit_filter',
+ :before => "table_reload()",
+ :loaded => 'update_table()',
+ :url => { :controller=> 'filters',
+ :action => 'add_condition',
+ :state_id => @state_id} %>
+
+ <%= help_button "filter","condition_form" %>
+ </td>
+</tr>
+<!--
+ <tr><td < if @negative_set > style="background-color:red;"<en%> ><= link_to 'display negative set', :action => 'negative_set' ></td></tr> -->
Added: incubator/alois/trunk/rails/app/views/filters/_date_condition.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/_date_condition.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/_date_condition.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/_date_condition.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,8 @@
+<% form_tag :action => 'add_date_condition', :params => @current_filter.get_params ,:id => nil do %>
+<h1><%= select_date @current_filter.from_date, :prefix => "new_from_date", :include_blank => true %>
+ -
+<%= select_date @current_filter.to_date, :prefix => "new_to_date", :include_blank => true %>
+<%= select "current_filter", "time_description", Filter.get_date_descriptions, { :include_blank => true } %>
+<input type="submit" value="Apply"/>
+</h1>
+<% end %>
Added: incubator/alois/trunk/rails/app/views/filters/_detail_form.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/_detail_form.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/_detail_form.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/_detail_form.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,11 @@
+<tr>
+ <th class="form_header" colspan="2">Detail</th>
+</tr>
+<tr>
+ <th><label for="current_filter_name">Name</label></th>
+ <td><%= text_field 'current_filter', 'name' %></td>
+</tr>
+<tr>
+ <th><label for="current_filter_description">Description</label></th>
+ <td><%= text_area 'current_filter', 'description', :style => "width: 99%", :rows => 4 %></td>
+</tr>
Added: incubator/alois/trunk/rails/app/views/filters/_form.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/_form.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/_form.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/_form.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,31 @@
+<div id="edit_filter">
+<%= error_messages_for 'current_filter', :header_message => "" %><br>
+<% form_remote_tag :update => 'edit_filter',
+ :url => {:controller=> 'filters',
+ :action => 'index',
+ :state_id => @state_id} do %>
+ <table class="form" style="border: none">
+ <tr>
+ <th style="text-align: left; width: 30%;">Column</th>
+ <th style="text-align: left; width: 10;">Operator</th>
+ <th style="text-align: left; width: 50%;">Value</th>
+ <th> </th>
+ </tr>
+ <% @current_filter.conditions.each_with_index { |@condition,@condition_index| %>
+ <tr>
+ <%= render :partial => "/filters/condition" %>
+ <td><%= submit_to_remote "Send", "Delete",
+ :update => 'edit_filter',
+ :before => 'table_reload()',
+ :loaded => 'update_table()',
+ :url => { :controller=> 'filters',
+ :action => 'remove_condition',
+ :condition_id => @condition_index,
+ :state_id => @state_id} -%></td>
+ </tr>
+ <% } %>
+
+ <%= render :partial => "/filters/condition_form" %>
+ </table>
+<% end %>
+</div>
Added: incubator/alois/trunk/rails/app/views/filters/_form_with_functions.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/_form_with_functions.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/_form_with_functions.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/_form_with_functions.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,5 @@
+<%= javascript_tag("function table_invalid(){Element.setStyle('log_table', {'background-color' : '#FFBBBB'})}") %>
+<%= javascript_tag("function table_reload(){Element.setStyle('log_table', {'background-color' : '#FFFF66'})}") %>
+<%= javascript_tag("function table_valid(){Element.setStyle('log_table', {'background-color' : 'transparent'})}") %>
+
+<%= render :partial => "/filters/form" %>
Added: incubator/alois/trunk/rails/app/views/filters/_possible_filters.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/_possible_filters.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/_possible_filters.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/_possible_filters.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,3 @@
+Possible Filters for source <%= current_datasource.name %>: <% @filters.each {|f| %>
+ <%= f.id %>: <%= fobj(f) %>
+<% } %>
Added: incubator/alois/trunk/rails/app/views/filters/_remove_condition_help.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/_remove_condition_help.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/_remove_condition_help.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/_remove_condition_help.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,2 @@
+<%= help_title("Remove Filter") %>
+<p>Press the "Delete" button near the condition you want to delete.</p>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/filters/_show_conditions.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/_show_conditions.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/_show_conditions.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/_show_conditions.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,3 @@
+<% @current_filter.conditions.each_with_index { |@condition, @condition_index| %>
+ <%= @condition.sql(nil) rescue $! %><br/>
+<% } %>
Added: incubator/alois/trunk/rails/app/views/filters/edit.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/edit.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/edit.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/edit.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,22 @@
+<%= title "#{@controller.action_name.humanize} #{@controller.controller_name.singularize.humanize} - #{@current_filter.name}" %>
+
+<!-- leave that for function calls to this div-->
+<div id="log_table"></div>
+
+<div id="page">
+
+ <table class="form">
+ <tr>
+ <th class="form_header" colspan="2">Conditions</th>
+ </tr>
+ <tr>
+ <td colspan="2"><%= render :partial => "form_with_functions" %></td>
+ </tr>
+ <% form_tag :action => 'update', :id => @current_filter, :state_id => @state_id do %>
+ <%= render :partial => 'detail_form' %>
+ <tr>
+ <td class="button-bar" colspan="2"><%= submit_tag "Save" %><%= submit_tag "Cancel" %></td>
+ </tr>
+ <% end %>
+ </table>
+</div>
Added: incubator/alois/trunk/rails/app/views/filters/edit_current.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/edit_current.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/edit_current.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/edit_current.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,6 @@
+<div id="edit_filter">
+<% form_remote_tag :update => 'edit_filter', :url => {:controller=> 'filters', :action => 'index', :id => @filter,:state_id => @state_id} do %>
+ <%= render :partial => 'form' %>
+ <%= submit_tag 'Update' %>
+<% end %>
+</div>
Added: incubator/alois/trunk/rails/app/views/filters/list.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/list.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/list.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/list.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,32 @@
+<%= title @controller.controller_name.humanize %>
+
+<div id="page">
+<%= error_messages %>
+
+<table summary="List of filters." class="form">
+ <tr>
+ <th class="form_header" style="width:0px;">ID</th>
+ <th class="form_header">Name</th>
+ <th class="form_header">Description</th>
+ <th class="form_header">Rules</th>
+ <th class="form_header" style="width:160px;"/>
+ </tr>
+<% for filter in @filters %>
+ <tr>
+ <td><%=h filter.id %></td>
+ <td><%=h filter.name %></td>
+ <td><%=h filter.description %></td>
+<% @current_filter = filter %>
+ <td><%= render :partial => "show_conditions" %></td>
+ <td>
+ <%= link_to image_tag( 'show.png' ), :action => 'show', :id => filter %><%= link_to image_tag( 'edit.png' ), :action => 'edit', :id => filter %> <%= link_to image_tag('delete.png'), { :action => 'destroy', :id => filter }, :confirm => 'Are you sure?', :method => :post %>
+ </td>
+ </tr>
+<% end %>
+ <tr>
+ <td class="button-bar" colspan="5">
+ <%= button_to "New #{@controller.controller_name.singularize.humanize}", :action => 'new' %>
+ </td>
+ </tr>
+</table>
+</div>
Added: incubator/alois/trunk/rails/app/views/filters/list_inline.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/list_inline.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/list_inline.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/list_inline.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,33 @@
+<table>
+
+<th>Name</th>
+<th></th>
+<th><%= link_to_remote(image_tag("update.png", :alt => "Reload filter list"), :update => "filters", :url => {:controller => "filters", :action => "list_inline", :params=>@current_filter.get_params}) %>
+</th>
+
+
+<% for filter in @filters %>
+ <tr>
+ <td><%=h filter.send("name") %> </td>
+ <td><a href="<%= url_for :controller => "table/#{filter.table}", :action => 'list', :params => filter.get_params %>">Use</a>
+ <td><%= link_to_remote 'Destroy', :update => "filters", :url => {:controller => "filters", :action => 'destroy_inline', :id => filter }, :confirm => 'Are you sure?', :method => :post, :id => @first_id %></td>
+ </tr>
+<% end %>
+</table>
+
+
+<%= link_to_remote("Previous page", :update => "filters", :url => {:controller => "filters", :action => "list_inline", :page => @filter_pages.current.previous }) if @filter_pages.current.previous %>
+
+<%= link_to_remote("next page", :update => "filters", :url => {:controller => "filters", :action => "list_inline", :page => @filter_pages.current.next }) if @filter_pages.current.next %>
+
+
+<% form_remote_tag :update => 'filters', :url => {:controller => "filters", :action => 'add_inline', :id => nil} do %>
+
+ <%= text_field_tag :name %>
+ <% ps = @current_filter.get_params %>
+ <% for (name,value) in ps %>
+ <%= hidden_field_tag name,value %>
+ <% end %>
+<input type="submit" value="Create"/>
+
+<% end %>
Added: incubator/alois/trunk/rails/app/views/filters/new.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/new.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/new.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/new.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,35 @@
+<%= title "#{h @controller.action_name.humanize} #{h @controller.controller_name.singularize.humanize}" %>
+
+<!-- leave that for function calls to this div-->
+<div id="log_table"></div>
+
+<div id="page">
+ <%= error_messages_for 'current_filter' %>
+
+ <table class="form">
+ <tr>
+ <th class="form_header" colspan="2">Conditions</th>
+ </tr>
+ <tr>
+ <td colspan="2"><%= render :partial => "form_with_functions" %></td>
+ </tr>
+ <% form_tag :action => 'create', :state_id => @state_id do %>
+ <%= render :partial => 'detail_form' %>
+ <tr>
+ <td class="button-bar" colspan="2"><%= submit_tag "Create" %><%= submit_tag "Cancel" %></td>
+ </tr>
+ <% end %>
+ <% form_tag :action=>'new', :state_id => @state_id do %>
+ <tr>
+ <th class="form_header" colspan="2">Upload</th>
+ </tr>
+ <tr>
+ <th>ZIP</th>
+ <td><%= text_area_tag 'filter_zip', '', :rows => 4 %></td>
+ </tr>
+ <tr>
+ <td class="button-bar" colspan="2"><%= submit_tag "Load" %><%= submit_tag "Cancel" %></td>
+ </tr>
+ <% end %>
+ </table>
+</div>
Added: incubator/alois/trunk/rails/app/views/filters/show.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/show.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/show.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/show.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,27 @@
+<%= title("#{h @controller.controller_name.singularize.humanize} - #{h @current_filter.name}") %>
+
+<div id="page">
+<table summary="Filter content" class="form">
+ <tr>
+ <th class="form_header" colspan="2">Filter</th>
+ </tr>
+ <tr>
+ <th>Description</th><td><%=h @current_filter.description %></td>
+ </tr>
+ <tr>
+ <th>Rules</th>
+ <td><%= render :partial => "show_conditions" %></td>
+ </tr>
+ <tr>
+ <th>Serialized</th>
+ <td><pre><%=h @current_filter.to_zip %></pre></td>
+ </tr>
+ <tr>
+ <td class="button-bar" colspan="2">
+ <%= button_to 'Edit filter', :action => 'edit', :id => @filter %>
+ <%= button_to 'List all filters', :action => 'list' %>
+ </td>
+ </tr>
+
+</table>
+</div>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/filters/show_inline.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/filters/show_inline.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/filters/show_inline.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/filters/show_inline.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,2 @@
+<%= render :partial => "show_conditions" %>
+<!-- <%= link_to 'Edit', :controller => 'filters', :action => 'edit', :id => @filter %>-->
Added: incubator/alois/trunk/rails/app/views/help/_alois_in_help.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/help/_alois_in_help.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/help/_alois_in_help.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/help/_alois_in_help.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,9 @@
+<%= help_title("Dobby in rate") %>
+<p>The total aomunt of reocrds written by
+prisma into the dobby database.</p>
+<p>This rate is bigger than the
+<%= help_link "pumpy outgoing rate", "pumpy_out" %>
+because each message will be splited into
+several sub records. So one incoming message may
+be part of e.g. 5 records.</p>
+<p>The unit is messages per second.</p>
Added: incubator/alois/trunk/rails/app/views/help/_cron_help.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/help/_cron_help.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/help/_cron_help.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/help/_cron_help.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,35 @@
+<%= help_title "Cron interval" %>
+<p>The following is an extract from linux contab man pages and gives you a explanation how to format the cron field.
+In our environment there is only a list of numbers or asterix allowed.<br>
+</p>
+
+<pre>
+Commands are executed by cron(8) when the minute, hour,
+and month of year fields match the current time, and
+when at least one of the two day fields (day of
+month, or day of week) match the current time examines
+cron entries once every minute. The time and date fields
+are:
+
+field allowed values
+----- --------------
+minute 0-59
+hour 0-23
+day of month 1-31
+month 1-12 (or names, see below)
+day of week 0-7 (0 or 7 is Sun, or use names)
+
+A field may be an asterisk (*), which always stands for
+first-last.
+
+</pre>
+<p>Here is a list of examples:<p>
+<pre>
+Run once a year, "0 0 1 1 *".
+Run once a month, "0 0 1 * *".
+Run once a week, "0 0 * * 0".
+Run once a day, "0 0 * * *".
+Run once an hour, "0 * * * *".
+Run once an hour at five past, "5 * * * *".
+
+</pre>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/help/_dobby_help.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/help/_dobby_help.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/help/_dobby_help.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/help/_dobby_help.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,8 @@
+<%= help_title("Dobby") %>
+<p>Dobby is the database where the dispatched
+messages are stored. This is the main database
+where all the queries and sentinels work on.</p>
+<p> On the <%= help_link "Tablelist" %>
+page you can see which system tables exists in
+the database and on the <%= help_link "Views" %>
+you can see the views..</p>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/help/_filter_help.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/help/_filter_help.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/help/_filter_help.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/help/_filter_help.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,2 @@
+<%= help_title("Filter") %>
+<p>A filter is a set of sql conditions. You can apply a filter to a <%= help_link "view" %> or a table. By doing so you pick a specific set of data out of the whole datasource. Maybe you want to specify a filter for data on a day where something special happened, for a group of users and so on.</p>
\ No newline at end of file
Added: incubator/alois/trunk/rails/app/views/help/_help.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/help/_help.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/help/_help.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/help/_help.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,17 @@
+<div id="help">
+<%= help_title("Help about the help") %>
+<p>Probably you got here because a help page could not be found. Sorry for that. Maybe you can find the desired information somewhere under the following helps.</p>
+<p>
+<ul>
+<% lc = nil %>
+<% get_all_help_pages.each {|category,name,context,page| %>
+<% unless lc == category %>
+<% lc = category %>
+</ul><h2><%= context.humanize %></h2><ul>
+<% end %>
+<li><%= name %>: <%= link_to image_tag("goto.png"),:controller => 'help',:action => 'index',:context => context,:page => page %></li>
+<% } %>
+</ul>
+</p>
+
+</div>
Added: incubator/alois/trunk/rails/app/views/help/_help_not_found.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/help/_help_not_found.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/help/_help_not_found.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/help/_help_not_found.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,6 @@
+<%= help_title("Help Not Found") %>
+<p>The requested help page could not be found.</p>
+<p>Context: <%=h params[:context]%></p>
+<p>Page: <%=h params[:page]%></p>
+<p>Help home: <%= help_goto "help" %></p>
+<!-- '<<%=h "#{params[:context]}/#{params[:page]}"%>'-->
Added: incubator/alois/trunk/rails/app/views/help/_hidden_help.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/help/_hidden_help.rhtml?rev=1031127&view=auto
==============================================================================
(empty)
Added: incubator/alois/trunk/rails/app/views/help/_index_help.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/help/_index_help.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/help/_index_help.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/help/_index_help.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,14 @@
+<%= help_title("Help Index") %>
+<p>
+<table><tr><td><ul>
+<% lc = nil %>
+<% get_all_help_pages.each {|category,name,context,page| %>
+<% unless lc == category %>
+<% lc = category %>
+</ul></td><td style="vertical-align:top;"><h2><%= category %></h2><ul>
+<% end %>
+<li><%= name %>: <%= link_to image_tag("goto.png"),:context => context,:page => page %></li>
+<% } %>
+</ul>
+</td></tr></table>
+</p>
Added: incubator/alois/trunk/rails/app/views/help/_lizard_help.rhtml
URL: http://svn.apache.org/viewvc/incubator/alois/trunk/rails/app/views/help/_lizard_help.rhtml?rev=1031127&view=auto
==============================================================================
--- incubator/alois/trunk/rails/app/views/help/_lizard_help.rhtml (added)
+++ incubator/alois/trunk/rails/app/views/help/_lizard_help.rhtml Thu Nov 4 18:27:22 2010
@@ -0,0 +1,6 @@
+<%= help_title("Lizard") %>
+<p>The Lizard appliance searches the <%= help_link "Dobby" %>
+database for unusual activities in your environment. It executes
+so called <%= help_link "Sentinels" %> that will find
+events that are diverging from predefined policies.</p>
+