Skip to content

Commit

Permalink
use css variables to configure ui colors
Browse files Browse the repository at this point in the history
  • Loading branch information
jonstout committed Oct 14, 2021
1 parent eeb1ae8 commit 7683af1
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 11 deletions.
1 change: 1 addition & 0 deletions conf/routerproxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ frontend:
dropdown: 0
help: 'Note: some text that does not contain greater/less than sign'
network_name: My Network
primary_color: '#990000'
noc_mail: My Email Address
noc_name: My NOC
noc_site: http://noc.network.net
Expand Down
20 changes: 20 additions & 0 deletions lib/GRNOC/RouterProxy/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,26 @@ sub NetworkName {
return $self->{'frontend'}->{'network_name'};
}

=head2 PrimaryColor
Returns the primary UI color.
=cut
sub PrimaryColor {
my $self = shift;
return $self->{'frontend'}->{'primary_color'} || '#990000';
}

=head2 SecondaryColor
Returns the secondary UI color.
=cut
sub SecondaryColor {
my $self = shift;
return $self->{'frontend'}->{'secondary_color'} || $self->PrimaryColor();
}

=head2 NOCName
Returns the name of the NOC.
Expand Down
6 changes: 6 additions & 0 deletions templates/index.tt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
<html>
<link rel='stylesheet' type='text/css' href='style.css'>
<script type="text/javascript" src="routerproxy.js"></script>
<style>
:root {
--primary-color: [% primary_color %];
--secondary-color: [% secondary_color %];
}
</style>

<head>
<meta charset="UTF-8">
Expand Down
12 changes: 7 additions & 5 deletions webroot/index.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,13 @@ sub makeHTML2 {
}

my $html = "";
my $vars = { network_name => $conf->NetworkName(),
noc_mail => $conf->NOCMail(),
noc_name => $conf->NOCName(),
noc_site => $conf->NOCSite(),
groups => $conf->DeviceGroups(sort_devices => 1)
my $vars = { network_name => $conf->NetworkName(),
primary_color => $conf->PrimaryColor(),
secondary_color => $conf->SecondaryColor(),
noc_mail => $conf->NOCMail(),
noc_name => $conf->NOCName(),
noc_site => $conf->NOCSite(),
groups => $conf->DeviceGroups(sort_devices => 1)
};
$tt->process($input, $vars, \$html);

Expand Down
12 changes: 6 additions & 6 deletions webroot/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ div.logo {
font-size: 22px;
font-weight: bold;
text-align: center;
color: #990000;
color: var(--primary-color);
}

div.devices {
Expand Down Expand Up @@ -70,7 +70,7 @@ table.menu-table {
display: none;
width: auto;
border: 1px dotted black;
background-color: #990000;
background-color: var(--primary-color);
}

table.title {
Expand Down Expand Up @@ -117,7 +117,7 @@ select.host_command_select {

tr.menu-title {

background-color: #990000;
background-color: var(--primary-color);
color: white;
font-family: Arial,Helvetica;
font-size: 12px;
Expand All @@ -126,7 +126,7 @@ tr.menu-title {

tr.title {

background-color: #990000;
background-color: var(--primary-color);
color: white;
font-family: Arial,Helvetica;
font-size: 12px;
Expand Down Expand Up @@ -167,7 +167,7 @@ h4 {
a {

font-family: Arial,Helvetica;
color: #990000;
color: var(--primary-color);
text-decoration: none;
}

Expand Down Expand Up @@ -208,7 +208,7 @@ li ul {
position: absolute;
top: 11px;
left: 0;
background-color: #990000;
background-color: var(--primary-color);
}

li:hover ul, li.over ul {
Expand Down

0 comments on commit 7683af1

Please sign in to comment.