Skip to content
This repository has been archived by the owner on Jun 29, 2019. It is now read-only.

Commit

Permalink
ui design
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydpick committed Jan 29, 2016
1 parent 218d37d commit c6cad57
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
12 changes: 7 additions & 5 deletions lib/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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'
Expand All @@ -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}")
Expand All @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 8 additions & 11 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<table>
<thead>
<th>Config Name</th>
<th>Actions</th>
<th class="config_name">Config Name</th>
<th>Outcomes</th>
</thead>
<tbody>
<% @configs.each do |c| %>
<tr>
<td><%= c[:name] %></td>
<td><a href="/run/<%= c[:file] %>">Run</a></td>
<td class="config_name"><%= c[:name] %> <a class="run" href="/run/<%= c[:file] %>"></a></td>
<td>
<% unless @logs[c[:name]].nil? %>
<% @logs[c[:name]].each_with_index do |log,i| %>
<a href="/logs/<%= log[:filename] %>"><img title="<%= log[:state] %>" src="/images/<%= log[:state] %>.png" /></a>
<% if i == 0 %>
<strong><%= epoch_to_datetime(log[:epoch]) %></strong>
<% else %>
<%= epoch_to_datetime(log[:epoch]) %>
<% end %>
<ul>
<% @logs[c[:name]].each do |log| %>
<li>
<a title="<%= log[:state] %>" class="<%= log[:state] %>" href="/logs/<%= log[:filename] %>"></a> <%= epoch_to_datetime(log[:epoch]) %>
</li>
<% end %>
</ul>
<% else %>
No logs
<% end %>
Expand Down
15 changes: 15 additions & 0 deletions views/layout.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Uphold</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="/stylesheets/normalize.min.css">
<link rel="stylesheet" href="/stylesheets/uphold.css">
</head>
<body>
<%= yield %>
</body>
</html>

0 comments on commit c6cad57

Please sign in to comment.