From c6cad5745301c93d20cf3e9e6a04379855e206b7 Mon Sep 17 00:00:00 2001 From: Lloyd Pick Date: Fri, 29 Jan 2016 14:11:18 +0000 Subject: [PATCH] ui design --- README.mdown | 2 ++ lib/config.rb | 12 +++++++----- ui.rb | 2 +- views/index.erb | 19 ++++++++----------- views/layout.erb | 15 +++++++++++++++ 5 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 views/layout.erb diff --git a/README.mdown b/README.mdown index 2e4e6f7..c93e5eb 100644 --- a/README.mdown +++ b/README.mdown @@ -71,6 +71,8 @@ Create a global config in `/etc/uphold/uphold.yml` (even if you leave it empty), * Can override the Docker container tag if you want to run from a specific version * `docker_mounts` (default: `none`) * If your backups exist on the host machine and you want to use the `local` transport, the folders they exist in need to be mounted into the container. You can specify them here as a YAML array of directories. They will be mounted at the same location inside the container +* `ui_datetime` (default: `%F %T %Z`) + * Overrides the strftime used by the UI to display the outcomes, useful if you want to make it smaller or add info If you change the global config you will need to restart the UI docker container, as some settings are only read at launch time. diff --git a/lib/config.rb b/lib/config.rb index c6cb0c0..6d08709 100644 --- a/lib/config.rb +++ b/lib/config.rb @@ -2,12 +2,13 @@ module Uphold class Config require 'yaml' include Logging + PREFIX = '/etc/uphold' attr_reader :yaml def initialize(config) fail unless config - yaml = YAML.load_file(File.join('/etc', 'uphold', 'conf.d', config)) + yaml = YAML.load_file(File.join(PREFIX, 'conf.d', config)) yaml.merge!(file: File.basename(config, '.yml')) @yaml = Config.deep_convert(yaml) fail unless valid? @@ -30,13 +31,13 @@ def supplement end def self.load_configs - Dir['/etc/uphold/conf.d/*.yml'].sort.map do |file| + Dir[File.join(PREFIX, 'conf.d', '*.yml')].sort.map do |file| new(File.basename(file)).yaml end end def self.load_global - yaml = YAML.load_file(File.join('/', 'etc', 'uphold', 'uphold.yml')) + yaml = YAML.load_file(File.join(PREFIX, 'uphold.yml')) yaml = deep_convert(yaml) yaml[:log_level] ||= 'DEBUG' yaml[:docker_url] ||= 'unix:///var/run/docker.sock' @@ -45,11 +46,12 @@ def self.load_global yaml[:docker_mounts] ||= [] yaml[:config_path] ||= '/etc/uphold' yaml[:docker_log_path] ||= '/var/log/uphold' + yaml[:ui_datetime] ||= '%F %T %Z' yaml end def self.load_engines - [Dir["#{ROOT}/lib/engines/*.rb"], Dir['/etc/uphold/engines/*.rb']].flatten.uniq.sort.each do |file| + [Dir["#{ROOT}/lib/engines/*.rb"], Dir[File.join(PREFIX, 'engines', '*.rb')]].flatten.uniq.sort.each do |file| require file basename = File.basename(file, '.rb') add_engine name: basename, klass: Object.const_get("Uphold::Engines::#{File.basename(file, '.rb').capitalize}") @@ -68,7 +70,7 @@ def self.add_engine(engine) end def self.load_transports - [Dir["#{ROOT}/lib/transports/*.rb"], Dir['/etc/uphold/transports/*.rb']].flatten.uniq.sort.each do |file| + [Dir["#{ROOT}/lib/transports/*.rb"], Dir[File.join(PREFIX, 'transports', '*.rb')]].flatten.uniq.sort.each do |file| require file basename = File.basename(file, '.rb') add_transport name: basename, klass: Object.const_get("Uphold::Transports::#{File.basename(file, '.rb').capitalize}") diff --git a/ui.rb b/ui.rb index 947f6b7..6d5d994 100644 --- a/ui.rb +++ b/ui.rb @@ -16,7 +16,7 @@ def h(text) end def epoch_to_datetime(epoch) - Time.at(epoch).utc.to_datetime + Time.at(epoch).utc.to_datetime.strftime(UPHOLD[:ui_datetime]) end end diff --git a/views/index.erb b/views/index.erb index 5f1a99d..2a0db1c 100644 --- a/views/index.erb +++ b/views/index.erb @@ -1,24 +1,21 @@ - - + <% @configs.each do |c| %> - - +
Config NameActionsConfig Name Outcomes
<%= c[:name] %>Run<%= c[:name] %> <% unless @logs[c[:name]].nil? %> - <% @logs[c[:name]].each_with_index do |log,i| %> - - <% if i == 0 %> - <%= epoch_to_datetime(log[:epoch]) %> - <% else %> - <%= epoch_to_datetime(log[:epoch]) %> - <% end %> +
    + <% @logs[c[:name]].each do |log| %> +
  • + <%= epoch_to_datetime(log[:epoch]) %> +
  • <% end %> +
<% else %> No logs <% end %> diff --git a/views/layout.erb b/views/layout.erb new file mode 100644 index 0000000..ac0dadf --- /dev/null +++ b/views/layout.erb @@ -0,0 +1,15 @@ + + + + + + Uphold + + + + + + + <%= yield %> + +