From 55cdbbd63cbb97a3ba104cdb9fe42ae9b44be4e7 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 14:36:35 +0100 Subject: [PATCH 01/15] Allow raw/custom HTML --- app/models/concerns/markdown.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/concerns/markdown.rb b/app/models/concerns/markdown.rb index ff9498a..ae3ac9d 100644 --- a/app/models/concerns/markdown.rb +++ b/app/models/concerns/markdown.rb @@ -13,6 +13,7 @@ def self.render(markdown_text) [ :GITHUB_PRE_LANG, :HARDBREAKS, + :UNSAFE, ], [:tagfilter] ).strip From d9a0a60045f98abe2b0babb3e04b19c53056cd92 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 14:36:56 +0100 Subject: [PATCH 02/15] Refactor how asset data is handled The bulk work of this has either already been moved to templates within Inventory Diagrams or will be handled soon by a template within Overware. --- app/controllers/assets_controller.rb | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index f7b21d2..97a820f 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -15,30 +15,7 @@ def single_asset @name = params[:name] cmd = "flight inventory show #{@name} -f diagram-markdown;" @asset_data = execute(cmd) - img_regex = // - if @asset_data.match?(img_regex) - parts = @asset_data.partition(img_regex) - - asset_list = [] - get_assets.each do |key, value| - asset_list.concat(value) - end - - parts[0] = format_markdown(parts[0]) - parts[2] = format_markdown(parts[2]) - - [parts[0], parts[2]].each do |p| - p.scan(/[\w-]+/).each do |w| - if asset_list.include?(w) - p[w] = view_context.link_to(w, assets_path + '/' + w) - end - end - end - - @content = parts.reduce{ |a, b| a + b } - else - @content = format_markdown(@asset_data) - end + @content = format_markdown(@asset_data) end def asset_params From 37fe67f3928b5f48a17918151d5ed8d4bcfe7cf6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 14:37:58 +0100 Subject: [PATCH 03/15] Add Overware specific template for switches This template is to be used in conjunction with Flight Inventory and it's plugin Flight Inventory Diagrams. Therefore for now on an install this file would need to be copied/moved to the templates/ directory within Flight Inventory. --- templates/switchOW.md.erb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 templates/switchOW.md.erb diff --git a/templates/switchOW.md.erb b/templates/switchOW.md.erb new file mode 100644 index 0000000..c11a6a3 --- /dev/null +++ b/templates/switchOW.md.erb @@ -0,0 +1,20 @@ +# <%= @asset_data.name %> + +<% @asset_hash['mutable']['maps'].each do |map| %> + +## <%= map.first %> + + + + +|Port|Note| +|----|----| +<% (map[1]['map'] || {}).to_h.each do |k,v| -%> +|<%= k %>|<%= v %>| +<% end %> +<% end %> From 28ce94ec1bf7ab0d170e2da7afdac2bc399be1e3 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 14:50:27 +0100 Subject: [PATCH 04/15] Call the Overware template to render asset data Assuming the template has been placed in the correct location this will call it so that the asset data can be rendered. --- app/controllers/assets_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index 97a820f..cce3a36 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -13,7 +13,7 @@ def index def single_asset redirect_unless_bolt_on('Assets') @name = params[:name] - cmd = "flight inventory show #{@name} -f diagram-markdown;" + cmd = "flight inventory show #{@name} -t switchOW;" @asset_data = execute(cmd) @content = format_markdown(@asset_data) end From 14dd7c371d48a17e9ba66c4ed619e49de6f3267c Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 14:53:09 +0100 Subject: [PATCH 05/15] Include instructions for moving template --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ed26f6c..05fe6ba 100644 --- a/README.md +++ b/README.md @@ -102,3 +102,4 @@ Prerequisites: * [Flight Inventory](https://github.com/openflighthpc/flight-inventory) installed * [Flight Inventory Diagrams](https://github.com/alces-software/flight-inventory-diagrams) plugin installed +* [Template](https://github.com/alces-software/overware/templates/switchOW.md.erb) moved to the `templates` directory of the `Flight Inventory` install From b9cfca2a3eb5cba17eb9986608f39fd9bb6ca008 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 14:57:41 +0100 Subject: [PATCH 06/15] Use relative link to template --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 05fe6ba..00f615f 100644 --- a/README.md +++ b/README.md @@ -102,4 +102,4 @@ Prerequisites: * [Flight Inventory](https://github.com/openflighthpc/flight-inventory) installed * [Flight Inventory Diagrams](https://github.com/alces-software/flight-inventory-diagrams) plugin installed -* [Template](https://github.com/alces-software/overware/templates/switchOW.md.erb) moved to the `templates` directory of the `Flight Inventory` install +* [Template](templates/switchOW.md.erb) moved to the `templates` directory of the `Flight Inventory` install From de98d09068693db9f242455ee41c979d962dccde Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 15:21:02 +0100 Subject: [PATCH 07/15] Add instructions for adjusting templates YAML file --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 00f615f..f9e925c 100644 --- a/README.md +++ b/README.md @@ -103,3 +103,11 @@ Prerequisites: * [Flight Inventory](https://github.com/openflighthpc/flight-inventory) installed * [Flight Inventory Diagrams](https://github.com/alces-software/flight-inventory-diagrams) plugin installed * [Template](templates/switchOW.md.erb) moved to the `templates` directory of the `Flight Inventory` install +* Within `Flight Inventory` add the following to the `etc/templates.yml` file: + + ``` + overware: + default: server.md.erb + server: server.md.erb + switch: switchOW.md.erb + ``` From 8b3f03fc476e390f921e4a1c4d473026bfc2ee01 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 15:21:35 +0100 Subject: [PATCH 08/15] Get asset data using the overware format --- app/controllers/assets_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index cce3a36..d26544c 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -13,7 +13,7 @@ def index def single_asset redirect_unless_bolt_on('Assets') @name = params[:name] - cmd = "flight inventory show #{@name} -t switchOW;" + cmd = "flight inventory show #{@name} -f overware;" @asset_data = execute(cmd) @content = format_markdown(@asset_data) end From 839b90a1092ea6f3e7c100231dffd49b1e182080 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 15:34:53 +0100 Subject: [PATCH 09/15] Allow blank input on the asset filter bar --- app/controllers/assets_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index d26544c..f606f10 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -4,7 +4,7 @@ class AssetsController < ApplicationController def index redirect_unless_bolt_on('Assets') cmd = "flight inventory list" - if params[:filter_on] and !params[:filter_arg].blank? + if params[:filter_on] cmd = cmd + " --#{params[:filter_on]} #{params[:filter_arg].downcase}" end @assets = get_assets(cmd) From f7b9feda1e7553a50820c600f88863d93f591a66 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 15:35:45 +0100 Subject: [PATCH 10/15] Formatting adjustments --- app/controllers/assets_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index f606f10..dc9b92b 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -3,15 +3,19 @@ class AssetsController < ApplicationController def index redirect_unless_bolt_on('Assets') + cmd = "flight inventory list" + if params[:filter_on] cmd = cmd + " --#{params[:filter_on]} #{params[:filter_arg].downcase}" end + @assets = get_assets(cmd) end def single_asset redirect_unless_bolt_on('Assets') + @name = params[:name] cmd = "flight inventory show #{@name} -f overware;" @asset_data = execute(cmd) @@ -23,6 +27,7 @@ def asset_params end private + # currently just returns stdout, this may need to be altered def execute(cmd) #This ';' is neccessary to force shell execution From aeb559385c3c8728f8d360b08adaf4814b67a256 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 16:36:08 +0100 Subject: [PATCH 11/15] Grab the name of the active cluster --- app/controllers/assets_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index dc9b92b..f1b5ea2 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -5,6 +5,8 @@ def index redirect_unless_bolt_on('Assets') cmd = "flight inventory list" + @active_cluster = execute("flight inventory list-cluster"). + lines.first.remove('*').strip.capitalize if params[:filter_on] cmd = cmd + " --#{params[:filter_on]} #{params[:filter_arg].downcase}" From 3a7ac3251e806ca388e28c3e49f911c745f8775c Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 16:36:21 +0100 Subject: [PATCH 12/15] Add style to make link fill container --- app/assets/stylesheets/application.scss | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index f1ca27c..e21e7db 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -51,3 +51,10 @@ textarea { max-width: initial; max-width: max-content; } + +a.fill-container { + display: block; + height: 100%; + width: 100%; + text-decoration: none; +} From b216928b873405f573b8abedaaf4ea36e636ad11 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 16:37:15 +0100 Subject: [PATCH 13/15] Add active cluster to assets page --- app/views/assets/index.html.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb index 88586bd..42c0923 100644 --- a/app/views/assets/index.html.erb +++ b/app/views/assets/index.html.erb @@ -24,6 +24,12 @@ <% end %> +
+

+ + <%= @active_cluster %> +

+

<% if @assets and not @assets.empty? %> <% @assets.each do |type, assets| %> From 3afa5259da01fff9b2afb668f42b2e822c6f2480 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 16:37:33 +0100 Subject: [PATCH 14/15] Make more of the card-header clickable --- app/views/assets/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb index 42c0923..df00714 100644 --- a/app/views/assets/index.html.erb +++ b/app/views/assets/index.html.erb @@ -37,10 +37,10 @@
From bf9b42e9efcfbc3d6841cf43a2255fd0e368b8d2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 17 May 2019 16:48:42 +0100 Subject: [PATCH 15/15] Add styling to prevent the icon offsetting text --- app/assets/stylesheets/assets.scss | 10 ++++++++++ app/views/assets/index.html.erb | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/assets.scss b/app/assets/stylesheets/assets.scss index 8b2c815..46368cd 100644 --- a/app/assets/stylesheets/assets.scss +++ b/app/assets/stylesheets/assets.scss @@ -14,3 +14,13 @@ white-space: nowrap; padding: 0px 4px; } + +h1 span { + position: relative; +} + +h1 span i { + position: absolute; + right: calc(100% + 20px); + margin-top: 0.5rem !important; +} diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb index df00714..6ea6d2e 100644 --- a/app/views/assets/index.html.erb +++ b/app/views/assets/index.html.erb @@ -24,12 +24,12 @@ <% end %>
-
-

+

+ <%= @active_cluster %> -

-
+ +
<% if @assets and not @assets.empty? %> <% @assets.each do |type, assets| %>