Sha256: 931dbaf14f2f997e437fa65eadeb81335f89e60b0a4222561bf3c16604c7e454
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
module RestFtpDaemon module ViewsHelper def dashboard_job_url job "#{MOUNT_JOBS}/#{job.id}" if job.respond_to? :id end def job_runs_style runs return "label-outline" if runs <= 0 return "label-info" if runs == 1 return "label-warning" if runs == 2 return "label-danger" if runs > 2 end def job_method_label method return if method.nil? klass = case method when JOB_METHOD_FILE "label-primary" when JOB_METHOD_FTP "label-warning" when JOB_METHOD_FTPS "label-success" else "label-default" end "<div class=\"transfer-method label #{klass}\">#{method.upcase}</div>" end def datetime_short datetime # return param.class return "-" if datetime.nil? return "?" unless datetime.respond_to? :to_date return datetime.to_datetime.strftime("%H:%M:%S") if datetime.to_date == Time.now.to_date datetime.to_datetime.strftime("%d/%m %H:%M:%S") end def formatted_duration duration out = [] hours = duration / (60 * 60) minutes = (duration / 60) % 60 seconds = duration % 60 out << "#{hours}h" if hours > 0 out << "#{minutes}mn" if (minutes > 0) || (hours > 0) out << "#{seconds}s" out.join(" ") end def remove_credentials path return unless path.is_a? String path.sub(/([a-z]+:\/\/[^\/]+):[^\/]+\@/, '\1@') end def token_to_label name, url = '' clean_url = remove_credentials url sprintf '<span class="token" title="%s">%s</span>', clean_url, name end def token_highlight path return unless path.is_a? String path.gsub(/\[([^\[]+)\]/, token_to_label('\1')) end def text_or_empty text return "-" if text.nil? || text.empty? text end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rest-ftp-daemon-0.306.4 | lib/rest-ftp-daemon/helpers/views.rb |
rest-ftp-daemon-0.306.3 | lib/rest-ftp-daemon/helpers/views.rb |
rest-ftp-daemon-0.306.1 | lib/rest-ftp-daemon/helpers/views.rb |