Skip to content

Commit 2be4602

Browse files
author
Andrew
committed
Merge branch 'develop'
2 parents 34780d9 + 7bf730a commit 2be4602

File tree

7 files changed

+65
-28
lines changed

7 files changed

+65
-28
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,12 @@ Prerequisites:
102102

103103
* [Flight Inventory](https://github.com/openflighthpc/flight-inventory) installed
104104
* [Flight Inventory Diagrams](https://github.com/alces-software/flight-inventory-diagrams) plugin installed
105+
* [Template](templates/switchOW.md.erb) moved to the `templates` directory of the `Flight Inventory` install
106+
* Within `Flight Inventory` add the following to the `etc/templates.yml` file:
107+
108+
```
109+
overware:
110+
default: server.md.erb
111+
server: server.md.erb
112+
switch: switchOW.md.erb
113+
```

app/assets/stylesheets/application.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,10 @@ textarea {
5151
max-width: initial;
5252
max-width: max-content;
5353
}
54+
55+
a.fill-container {
56+
display: block;
57+
height: 100%;
58+
width: 100%;
59+
text-decoration: none;
60+
}

app/assets/stylesheets/assets.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@
1414
white-space: nowrap;
1515
padding: 0px 4px;
1616
}
17+
18+
h1 span {
19+
position: relative;
20+
}
21+
22+
h1 span i {
23+
position: absolute;
24+
right: calc(100% + 20px);
25+
margin-top: 0.5rem !important;
26+
}

app/controllers/assets_controller.rb

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,33 @@ class AssetsController < ApplicationController
33

44
def index
55
redirect_unless_bolt_on('Assets')
6+
67
cmd = "flight inventory list"
7-
if params[:filter_on] and !params[:filter_arg].blank?
8+
@active_cluster = execute("flight inventory list-cluster").
9+
lines.first.remove('*').strip.capitalize
10+
11+
if params[:filter_on]
812
cmd = cmd + " --#{params[:filter_on]} #{params[:filter_arg].downcase}"
913
end
14+
1015
@assets = get_assets(cmd)
1116
end
1217

1318
def single_asset
1419
redirect_unless_bolt_on('Assets')
20+
1521
@name = params[:name]
16-
cmd = "flight inventory show #{@name} -f diagram-markdown;"
22+
cmd = "flight inventory show #{@name} -f overware;"
1723
@asset_data = execute(cmd)
18-
img_regex = /<img\ssrc=.+>/
19-
if @asset_data.match?(img_regex)
20-
parts = @asset_data.partition(img_regex)
21-
22-
asset_list = []
23-
get_assets.each do |key, value|
24-
asset_list.concat(value)
25-
end
26-
27-
parts[0] = format_markdown(parts[0])
28-
parts[2] = format_markdown(parts[2])
29-
30-
[parts[0], parts[2]].each do |p|
31-
p.scan(/[\w-]+/).each do |w|
32-
if asset_list.include?(w)
33-
p[w] = view_context.link_to(w, assets_path + '/' + w)
34-
end
35-
end
36-
end
37-
38-
@content = parts.reduce{ |a, b| a + b }
39-
else
40-
@content = format_markdown(@asset_data)
41-
end
24+
@content = format_markdown(@asset_data)
4225
end
4326

4427
def asset_params
4528
params.require(:asset).permit(:filter_on, :filter_arg)
4629
end
4730

4831
private
32+
4933
# currently just returns stdout, this may need to be altered
5034
def execute(cmd)
5135
#This ';' is neccessary to force shell execution

app/models/concerns/markdown.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def self.render(markdown_text)
1313
[
1414
:GITHUB_PRE_LANG,
1515
:HARDBREAKS,
16+
:UNSAFE,
1617
],
1718
[:tagfilter]
1819
).strip

app/views/assets/index.html.erb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,23 @@
2424
<% end %>
2525
</div>
2626
</div>
27+
<h1>
28+
<span>
29+
<i class="fa fa-server"></i>
30+
<%= @active_cluster %>
31+
</span>
32+
</h1>
2733
<br>
2834
<% if @assets and not @assets.empty? %>
2935
<% @assets.each do |type, assets| %>
3036
<div id="accordion-<%= type.downcase %>" class="center w-25">
3137
<div class="card mb-1">
3238
<div class="card-header">
3339
<h5 class="mb-0">
34-
<a data-toggle="collapse" href="#<%= type %>">
40+
<a data-toggle="collapse" href="#<%= type %>" class="fill-container">
3541
<%= type.downcase.capitalize %>
42+
<i class="fa fa-minus fa-pull-right mt-1"></i>
3643
</a>
37-
<i class="fa fa-minus fa-pull-right mt-1"></i>
3844
</h5>
3945
</div>
4046

templates/switchOW.md.erb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# <a href="<%= @asset_data.name %>"><%= @asset_data.name %></a>
2+
3+
<% @asset_hash['mutable']['maps'].each do |map| %>
4+
5+
## <%= map.first %>
6+
7+
<img class="mb-2" src="data:image/svg+xml;base64,<%= render_switch_base64(
8+
map[1]['map'],
9+
width: map[1]['map_width'],
10+
height: map[1]['map_height'],
11+
layout: map[1]['map_layout'],
12+
)%>">
13+
14+
15+
|Port|Note|
16+
|----|----|
17+
<% (map[1]['map'] || {}).to_h.each do |k,v| -%>
18+
|<%= k %>|<a href="<%= v %>"><%= v %></a>|
19+
<% end %>
20+
<% end %>

0 commit comments

Comments
 (0)