From 36e8cfe1d04be01368ac84a57b38f2175ac49b9d Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 18 Apr 2017 10:43:23 +0100 Subject: [PATCH] Modified admin interfaces, factored common css out --- lib/Pear/LocalLoop/Controller/Admin.pm | 10 ++++ public/static/admin/css/main.css | 10 ++++ templates/admin/home.html.ep | 43 +++++++------- templates/admin/tokens/index.html.ep | 80 +++++++++---------------- templates/admin/tokens/read.html.ep | 82 ++++++++++---------------- templates/layouts/admin.html.ep | 9 +-- 6 files changed, 106 insertions(+), 128 deletions(-) create mode 100644 public/static/admin/css/main.css diff --git a/lib/Pear/LocalLoop/Controller/Admin.pm b/lib/Pear/LocalLoop/Controller/Admin.pm index 75972e6..dbae956 100644 --- a/lib/Pear/LocalLoop/Controller/Admin.pm +++ b/lib/Pear/LocalLoop/Controller/Admin.pm @@ -15,6 +15,16 @@ sub under { sub home { my $c = shift; + + my $user_rs = $c->schema->resultset('User'); + my $token_rs = $c->schema->resultset('AccountToken'); + $c->stash( + user_count => $user_rs->count, + tokens => { + total => $token_rs->count, + unused => $token_rs->search({used => 0 })->count, + }, + ); } 1; diff --git a/public/static/admin/css/main.css b/public/static/admin/css/main.css new file mode 100644 index 0000000..41d82a2 --- /dev/null +++ b/public/static/admin/css/main.css @@ -0,0 +1,10 @@ +body { + background: whitesmoke; + padding-top: 70px; +} + +.panel { + -webkit-box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.2); + -moz-box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.2); + box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.2); +} diff --git a/templates/admin/home.html.ep b/templates/admin/home.html.ep index 05038ac..5c539aa 100644 --- a/templates/admin/home.html.ep +++ b/templates/admin/home.html.ep @@ -1,25 +1,26 @@ % layout 'admin'; % title 'Home'; -% content_for css => begin - -% end % content_for javascript => begin % end -
Admin Pages
+
+
+
+ User Count +
+
+

+ %= $user_count +

+
+
+
+
+ Unused Tokens +
+
+

+ <%= $tokens->{unused} %> / <%= $tokens->{total} %> +

+
+
+
diff --git a/templates/admin/tokens/index.html.ep b/templates/admin/tokens/index.html.ep index 33f507a..6cece6e 100644 --- a/templates/admin/tokens/index.html.ep +++ b/templates/admin/tokens/index.html.ep @@ -1,57 +1,35 @@ % layout 'admin'; % title 'Tokens'; -% content_for css => begin - -% end % content_for javascript => begin % end -
- % if ( my $error = flash 'error' ) { - - % } elsif ( my $success = flash 'success' ) { - - % } -
-
-
- - - - -
-
-
-
- % for my $token (@$tokens) { - -
- %= $token->{accounttokenname} -
-
- <%= $token->{used} == 1 ? 'Used' : 'Available' %> -
-
- % } +% if ( my $error = flash 'error' ) { + +% } elsif ( my $success = flash 'success' ) { + +% } +
+
+
+ + + + +
+
+
+ diff --git a/templates/admin/tokens/read.html.ep b/templates/admin/tokens/read.html.ep index 2ecfd20..43208ca 100644 --- a/templates/admin/tokens/read.html.ep +++ b/templates/admin/tokens/read.html.ep @@ -1,56 +1,34 @@ % layout 'admin'; % title 'Tokens'; -% content_for css => begin - -% end % content_for javascript => begin % end -
- % if ( my $error = flash 'error' ) { - - % } elsif ( my $success = flash 'success' ) { - - % } -
-
- - -
-
- - -
-
- -
-
-
-
- -
-
-
+% if ( my $error = flash 'error' ) { + +% } elsif ( my $success = flash 'success' ) { + +% } +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ +
+
diff --git a/templates/layouts/admin.html.ep b/templates/layouts/admin.html.ep index c3cfeea..a929f1f 100644 --- a/templates/layouts/admin.html.ep +++ b/templates/layouts/admin.html.ep @@ -11,7 +11,7 @@ - %= content_for 'css'; + %= stylesheet '/static/admin/css/main.css';
- - <%= content %> +
+ <%= content %> +
%= content_for 'javascript';