Added Admin Overview

This commit is contained in:
Thorsten Sommer 2015-06-22 14:08:29 +02:00
parent 5cd7f237a3
commit ea2a790bad
21 changed files with 6411 additions and 6271 deletions

View File

@ -1,6 +1,6 @@
package Assets package Assets
var CSSLog string = ` var CSSAdmin string = `
body { body {
font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
color: #333; color: #333;
@ -75,6 +75,26 @@ p {
.button.optionbuttons.applyfilters { .button.optionbuttons.applyfilters {
margin-left: 0px; margin-left: 0px;
} }
.button.optionbuttons.currentoption {
background-color: #00aeff;
}
.button.adminbutton {
width: 222px;
height: 50px;
max-height: 50px;
max-width: 222px;
min-height: 50px;
min-width: 222px;
padding-top: 15px;
background-color: #cfcfcf;
color: black;
font-size: 20px;
font-weight: 700;
}
.button.adminbutton:hover {
background-color: #00aeff;
color: white;
}
.headercontainer { .headercontainer {
height: 50px; height: 50px;
margin-top: -19px; margin-top: -19px;
@ -226,6 +246,19 @@ p {
.labels { .labels {
display: block; display: block;
} }
.adminsection {
margin-top: 30px;
}
.adminitem {
min-height: 50px;
background-color: #cfcfcf;
font-size: 20px;
font-weight: 700;
text-align: center;
}
.adminitemlog {
padding-top: 14px;
}
@media (max-width: 991px) { @media (max-width: 991px) {
.icons.oneback { .icons.oneback {
margin-left: 113px; margin-left: 113px;

View File

@ -1,54 +1,7 @@
package Assets package Assets
var CSSNormalize string = ` var CSSNormalize string = `
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */ /*! normalize.css v3.0.2 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct "block" display not defined in IE 8/9.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
display: block;
}
/**
* Correct "inline-block" display not defined in IE 8/9.
*/
audio,
canvas,
video {
display: inline-block;
}
/**
* Prevent modern browsers from displaying "audio" without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address "[hidden]" styling not present in IE 8/9.
* Hide the "template" element in IE, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none;
}
/* ==========================================================================
Base
========================================================================== */
/** /**
* 1. Set default font family to sans-serif. * 1. Set default font family to sans-serif.
* 2. Prevent iOS text size adjust after orientation change, without disabling * 2. Prevent iOS text size adjust after orientation change, without disabling
@ -68,20 +21,65 @@ html {
body { body {
margin: 0; margin: 0;
} }
/* ========================================================================== /* HTML5 display definitions
Links ========================================================================== */
/**
* Correct 'block' display not defined for any HTML5 element in IE 8/9.
* Correct 'block' display not defined for 'details' or 'summary' in IE 10/11
* and Firefox.
* Correct 'block' display not defined for 'main' in IE 11.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
display: block;
}
/**
* 1. Correct 'inline-block' display not defined in IE 8/9.
* 2. Normalize vertical alignment of 'progress' in Chrome, Firefox, and Opera.
*/
audio,
canvas,
progress,
video {
display: inline-block;
/* 1 */
vertical-align: baseline;
/* 2 */
}
/**
* Prevent modern browsers from displaying 'audio' without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address '[hidden]' styling not present in IE 8/9/10.
* Hide the 'template' element in IE 8/9/11, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none;
}
/* Links
========================================================================== */ ========================================================================== */
/** /**
* Remove the gray background color from active links in IE 10. * Remove the gray background color from active links in IE 10.
*/ */
a { a {
background: transparent; background-color: transparent;
}
/**
* Address "outline" inconsistency between Chrome and other browsers.
*/
a:focus {
outline: thin dotted;
} }
/** /**
* Improve readability when focused and also mouse hovered in all browsers. * Improve readability when focused and also mouse hovered in all browsers.
@ -90,43 +88,34 @@ a:active,
a:hover { a:hover {
outline: 0; outline: 0;
} }
/* ========================================================================== /* Text-level semantics
Typography
========================================================================== */ ========================================================================== */
/** /**
* Address variable "h1" font-size and margin within "section" and "article" * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
* contexts in Firefox 4+, Safari 5, and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/**
* Address styling not present in IE 8/9, Safari 5, and Chrome.
*/ */
abbr[title] { abbr[title] {
border-bottom: 1px dotted; border-bottom: 1px dotted;
} }
/** /**
* Address style set to "bolder" in Firefox 4+, Safari 5, and Chrome. * Address style set to 'bolder' in Firefox 4+, Safari, and Chrome.
*/ */
b, b,
strong { strong {
font-weight: bold; font-weight: bold;
} }
/** /**
* Address styling not present in Safari 5 and Chrome. * Address styling not present in Safari and Chrome.
*/ */
dfn { dfn {
font-style: italic; font-style: italic;
} }
/** /**
* Address differences between Firefox and other browsers. * Address variable 'h1' font-size and margin within 'section' and 'article'
* contexts in Firefox 4+, Safari, and Chrome.
*/ */
hr { h1 {
-moz-box-sizing: content-box; font-size: 2em;
box-sizing: content-box; margin: 0.67em 0;
height: 0;
} }
/** /**
* Address styling not present in IE 8/9. * Address styling not present in IE 8/9.
@ -135,28 +124,6 @@ mark {
background: #ff0; background: #ff0;
color: #000; color: #000;
} }
/**
* Correct font family set oddly in Safari 5 and Chrome.
*/
code,
kbd,
pre,
samp {
font-family: monospace, serif;
font-size: 1em;
}
/**
* Improve readability of pre-formatted text in all browsers.
*/
pre {
white-space: pre-wrap;
}
/**
* Set consistent quote types.
*/
q {
quotes: "\201C" "\201D" "\2018" "\2019";
}
/** /**
* Address inconsistent and variable font size in all browsers. * Address inconsistent and variable font size in all browsers.
*/ */
@ -164,7 +131,7 @@ small {
font-size: 80%; font-size: 80%;
} }
/** /**
* Prevent "sub" and "sup" affecting "line-height" in all browsers. * Prevent 'sub' and 'sup' affecting 'line-height' in all browsers.
*/ */
sub, sub,
sup { sup {
@ -179,91 +146,98 @@ sup {
sub { sub {
bottom: -0.25em; bottom: -0.25em;
} }
/* ========================================================================== /* Embedded content
Embedded content
========================================================================== */ ========================================================================== */
/** /**
* Remove border when inside "a" element in IE 8/9. * Remove border when inside 'a' element in IE 8/9/10.
*/ */
img { img {
border: 0; border: 0;
} }
/** /**
* Correct overflow displayed oddly in IE 9. * Correct overflow not hidden in IE 9/10/11.
*/ */
svg:not(:root) { svg:not(:root) {
overflow: hidden; overflow: hidden;
} }
/* ========================================================================== /* Grouping content
Figures
========================================================================== */ ========================================================================== */
/** /**
* Address margin not present in IE 8/9 and Safari 5. * Address margin not present in IE 8/9 and Safari.
*/ */
figure { figure {
margin: 0; margin: 1em 40px;
} }
/* ========================================================================== /**
Forms * Address differences between Firefox and other browsers.
*/
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
/**
* Contain overflow in all browsers.
*/
pre {
overflow: auto;
}
/**
* Address odd 'em'-unit font size rendering in all browsers.
*/
code,
kbd,
pre,
samp {
font-family: monospace, monospace;
font-size: 1em;
}
/* Forms
========================================================================== */ ========================================================================== */
/** /**
* Define consistent border, margin, and padding. * Known limitation: by default, Chrome and Safari on OS X allow very limited
* styling of 'select', unless a 'border' property is set.
*/ */
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/** /**
* 1. Correct "color" not being inherited in IE 8/9. * 1. Correct color not being inherited.
* 2. Remove padding so people aren't caught out if they zero out fieldsets. * Known issue: affects color of disabled elements.
*/ * 2. Correct font properties not being inherited.
legend { * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
border: 0;
/* 1 */
padding: 0;
/* 2 */
}
/**
* 1. Correct font family not being inherited in all browsers.
* 2. Correct font size not being inherited in all browsers.
* 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome.
*/ */
button, button,
input, input,
optgroup,
select, select,
textarea { textarea {
font-family: inherit; color: inherit;
/* 1 */ /* 1 */
font-size: 100%; font: inherit;
/* 2 */ /* 2 */
margin: 0; margin: 0;
/* 3 */ /* 3 */
} }
/** /**
* Address Firefox 4+ setting "line-height" on "input" using "!important" in * Address 'overflow' set to 'hidden' in IE 8/9/10/11.
* the UA stylesheet.
*/ */
button, button {
input { overflow: visible;
line-height: normal;
} }
/** /**
* Address inconsistent "text-transform" inheritance for "button" and "select". * Address inconsistent 'text-transform' inheritance for 'button' and 'select'.
* All other form control elements do not inherit "text-transform" values. * All other form control elements do not inherit 'text-transform' values.
* Correct "button" style inheritance in Chrome, Safari 5+, and IE 8+. * Correct 'button' style inheritance in Firefox, IE 8/9/10/11, and Opera.
* Correct "select" style inheritance in Firefox 4+ and Opera. * Correct 'select' style inheritance in Firefox.
*/ */
button, button,
select { select {
text-transform: none; text-transform: none;
} }
/** /**
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native "audio" * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native 'audio'
* and "video" controls. * and 'video' controls.
* 2. Correct inability to style clickable "input" types in iOS. * 2. Correct inability to style clickable 'input' types in iOS.
* 3. Improve usability and consistency of cursor style between image-type * 3. Improve usability and consistency of cursor style between image-type
* "input" and others. * 'input' and others.
*/ */
button, button,
html input[type="button"], html input[type="button"],
@ -282,7 +256,25 @@ html input[disabled] {
cursor: default; cursor: default;
} }
/** /**
* 1. Address box sizing set to "content-box" in IE 8/9/10. * Remove inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/**
* Address Firefox 4+ setting 'line-height' on 'input' using '!important' in
* the UA stylesheet.
*/
input {
line-height: normal;
}
/**
* It's recommended that you don't attempt to style these elements.
* Firefox's implementation doesn't respect box-sizing, padding, or width.
*
* 1. Address box sizing set to 'content-box' in IE 8/9/10.
* 2. Remove excess padding in IE 8/9/10. * 2. Remove excess padding in IE 8/9/10.
*/ */
input[type="checkbox"], input[type="checkbox"],
@ -293,9 +285,18 @@ input[type="radio"] {
/* 2 */ /* 2 */
} }
/** /**
* 1. Address "appearance" set to "searchfield" in Safari 5 and Chrome. * Fix the cursor style for Chrome's increment/decrement buttons. For certain
* 2. Address "box-sizing" set to "border-box" in Safari 5 and Chrome * 'font-size' values of the 'input', it causes the cursor style of the
* (include "-moz" to future-proof). * decrement button to change from 'default' to 'text'.
*/
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Address 'appearance' set to 'searchfield' in Safari and Chrome.
* 2. Address 'box-sizing' set to 'border-box' in Safari and Chrome
* (include '-moz' to future-proof).
*/ */
input[type="search"] { input[type="search"] {
-webkit-appearance: textfield; -webkit-appearance: textfield;
@ -306,33 +307,46 @@ input[type="search"] {
box-sizing: content-box; box-sizing: content-box;
} }
/** /**
* Remove inner padding and search cancel button in Safari 5 and Chrome * Remove inner padding and search cancel button in Safari and Chrome on OS X.
* on OS X. * Safari (but not Chrome) clips the cancel button when the search input has
* padding (and 'textfield' appearance).
*/ */
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none; -webkit-appearance: none;
} }
/** /**
* Remove inner padding and border in Firefox 4+. * Define consistent border, margin, and padding.
*/ */
button::-moz-focus-inner, fieldset {
input::-moz-focus-inner { border: 1px solid #c0c0c0;
border: 0; margin: 0 2px;
padding: 0; padding: 0.35em 0.625em 0.75em;
} }
/** /**
* 1. Remove default vertical scrollbar in IE 8/9. * 1. Correct 'color' not being inherited in IE 8/9/10/11.
* 2. Improve readability and alignment in all browsers. * 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0;
/* 1 */
padding: 0;
/* 2 */
}
/**
* Remove default vertical scrollbar in IE 8/9/10/11.
*/ */
textarea { textarea {
overflow: auto; overflow: auto;
/* 1 */
vertical-align: top;
/* 2 */
} }
/* ========================================================================== /**
Tables * Don't inherit the 'font-weight' (applied by a rule above).
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
*/
optgroup {
font-weight: bold;
}
/* Tables
========================================================================== */ ========================================================================== */
/** /**
* Remove most spacing between table cells. * Remove most spacing between table cells.
@ -340,4 +354,8 @@ textarea {
table { table {
border-collapse: collapse; border-collapse: collapse;
border-spacing: 0; border-spacing: 0;
}
td,
th {
padding: 0;
}` }`

View File

@ -75,7 +75,7 @@ a:focus {
.w-hidden { .w-hidden {
display: none; display: none;
} }
html[w-dynpage] [w-cloak] { html[data-w-dynpage] [data-w-cloak] {
color: transparent !important; color: transparent !important;
} }
h1, h1,
@ -1319,7 +1319,7 @@ textarea.w-select {
overflow-y: hidden; overflow-y: hidden;
} }
/* /*
* 1. We use content-box to avoid having to do "width: calc(10vh + 2vw)" * 1. We use content-box to avoid having to do 'width: calc(10vh + 2vw)'
* which doesnt work in Safari anyway. * which doesnt work in Safari anyway.
* 2. Chrome renders images pixelated when switching to GPU. Making sure * 2. Chrome renders images pixelated when switching to GPU. Making sure
* the parent is also rendered on the GPU (by setting translate3d for * the parent is also rendered on the GPU (by setting translate3d for
@ -1646,10 +1646,6 @@ textarea.w-select {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
.w-dyn-loading {
display: block;
padding: 10px;
}
.w-dyn-items { .w-dyn-items {
display: none; display: none;
} }
@ -1657,6 +1653,7 @@ textarea.w-select {
display: block; display: block;
} }
.w-dyn-empty { .w-dyn-empty {
display: none;
padding: 10px; padding: 10px;
background-color: #dddddd; background-color: #dddddd;
} }

View File

@ -1,8 +1,8 @@
package Web package Admin
import ( import (
"fmt" "fmt"
"github.com/SommerEngineering/Ocean/Log/Web/Assets" "github.com/SommerEngineering/Ocean/Admin/Assets"
"github.com/SommerEngineering/Ocean/MimeTypes" "github.com/SommerEngineering/Ocean/MimeTypes"
"github.com/SommerEngineering/Ocean/Shutdown" "github.com/SommerEngineering/Ocean/Shutdown"
"net/http" "net/http"
@ -33,7 +33,7 @@ func HandlerCSSWebflow(response http.ResponseWriter, request *http.Request) {
} }
// Handler for some CSS data for the web logger. // Handler for some CSS data for the web logger.
func HandlerCSSLog(response http.ResponseWriter, request *http.Request) { func HandlerCSSAdmin(response http.ResponseWriter, request *http.Request) {
if Shutdown.IsDown() { if Shutdown.IsDown() {
http.NotFound(response, request) http.NotFound(response, request)
@ -41,7 +41,7 @@ func HandlerCSSLog(response http.ResponseWriter, request *http.Request) {
} }
MimeTypes.Write2HTTP(response, MimeTypes.TypeWebCSS) MimeTypes.Write2HTTP(response, MimeTypes.TypeWebCSS)
fmt.Fprint(response, Assets.CSSLog) fmt.Fprint(response, Assets.CSSAdmin)
} }
// Handler for some JS for the web logger. // Handler for some JS for the web logger.

25
Admin/HandlerOverview.go Normal file
View File

@ -0,0 +1,25 @@
package Admin
import (
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
"github.com/SommerEngineering/Ocean/MimeTypes"
"github.com/SommerEngineering/Ocean/Shutdown"
"net/http"
)
// Handler for accessing the admin's overview.
func HandlerOverview(response http.ResponseWriter, request *http.Request) {
// Case: The system goes down now.
if Shutdown.IsDown() {
http.NotFound(response, request)
return
}
// Write the MIME type and execute the template:
MimeTypes.Write2HTTP(response, MimeTypes.TypeWebHTML)
if executeError := AdminTemplates.ExecuteTemplate(response, `Overview`, nil); executeError != nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameEXECUTE, `Was not able to execute the admin's overview template.`, executeError.Error())
}
}

25
Admin/Init.go Normal file
View File

@ -0,0 +1,25 @@
package Admin
import (
"github.com/SommerEngineering/Ocean/Admin/Templates"
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
"html/template"
)
// The init function for this package.
func init() {
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Init the admin area.`)
defer Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Init the admin area done.`)
// Create the cache of all admin templates:
AdminTemplates = template.New(`root`)
if _, err := AdminTemplates.Parse(Templates.LoggingViewer); err != nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNamePARSE, `Was not able to parse the template for the web log viewer.`, err.Error())
}
if _, err := AdminTemplates.Parse(Templates.Overview); err != nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNamePARSE, `Was not able to parse the template for the admin overview.`, err.Error())
}
}

View File

@ -1,7 +1,7 @@
package Templates package Templates
// The template for the web log viewer: // The template for the web log viewer:
var Viewer string = ` var LoggingViewer string = `
{{define "WebLog"}} {{define "WebLog"}}
<!DOCTYPE html> <!DOCTYPE html>
<!-- This site was created in Webflow. http://www.webflow.com--> <!-- This site was created in Webflow. http://www.webflow.com-->
@ -15,14 +15,14 @@ var Viewer string = `
{{end}} {{end}}
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="Webflow"> <meta name="generator" content="Webflow">
<link rel="stylesheet" type="text/css" href="/log/css/normalize.css"> <link rel="stylesheet" type="text/css" href="/admin/css/normalize.css">
<link rel="stylesheet" type="text/css" href="/log/css/webflow.css"> <link rel="stylesheet" type="text/css" href="/admin/css/webflow.css">
<link rel="stylesheet" type="text/css" href="/log/css/log.css"> <link rel="stylesheet" type="text/css" href="/admin/css/admin.css">
<script type="text/javascript" src="/log/js/modernizr.js"></script> <script type="text/javascript" src="/admin/js/modernizr.js"></script>
</head> </head>
<body> <body>
<div class="headercontainer"> <div class="headercontainer">
<h1>Logbook</h1> <h1>Logging Viewer</h1>
</div> </div>
<div class="controlsection"> <div class="controlsection">
<div class="w-row"> <div class="w-row">
@ -131,8 +131,8 @@ var Viewer string = `
</div> </div>
<div class="w-hidden-main w-hidden-medium newlineblock"></div><a class="button changepagebutton" href="#">+1</a><a class="button changepagebutton" href="#">Last</a> <div class="w-hidden-main w-hidden-medium newlineblock"></div><a class="button changepagebutton" href="#">+1</a><a class="button changepagebutton" href="#">Last</a>
</div> </div>
<script type="text/javascript" src="/log/js/jquery.min.js"></script> <script type="text/javascript" src="/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/log/js/webflow.js"></script> <script type="text/javascript" src="/admin/js/webflow.js"></script>
</body> </body>
</html> </html>
{{end}}` {{end}}`

View File

@ -0,0 +1,36 @@
package Templates
var Overview = `
{{define "Overview"}}
<!DOCTYPE html>
<!-- This site was created in Webflow. http://www.webflow.com-->
<!-- Last Published: Mon Jun 22 2015 10:36:36 GMT+0000 (UTC) -->
<html data-wf-site="547b44aa3e9ac2216ec5d048" data-wf-page="5587d2abbf862f2179c4373b">
<head>
<meta charset="utf-8">
<title>Overview</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="Webflow">
<link rel="stylesheet" type="text/css" href="/admin/css/normalize.css">
<link rel="stylesheet" type="text/css" href="/admin/css/webflow.css">
<link rel="stylesheet" type="text/css" href="/admin/css/admin.css">
<script type="text/javascript" src="/admin/js/modernizr.js"></script>
</head>
<body>
<div class="w-section headercontainer">
<h1>Administration</h1>
</div>
<div class="w-container adminsection">
<div class="w-row">
<div class="w-col w-col-4"><a class="button adminbutton" href="/log">Logging Viewer</a>
</div>
<div class="w-col w-col-4"></div>
<div class="w-col w-col-4"></div>
</div>
</div>
<script type="text/javascript" src="/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/admin/js/webflow.js"></script>
</body>
</html>
{{end}}
`

11
Admin/Variables.go Normal file
View File

@ -0,0 +1,11 @@
package Admin
import (
LM "github.com/SommerEngineering/Ocean/Log/Meta"
"html/template"
)
var (
AdminTemplates *template.Template = nil // The admin templates
senderName LM.Sender = `System::Admin` // This is the name for logging event from this package
)

View File

@ -1,10 +1,11 @@
package Web package Web
import ( import (
"github.com/SommerEngineering/Ocean/Admin"
"github.com/SommerEngineering/Ocean/Admin/Scheme"
"github.com/SommerEngineering/Ocean/Log" "github.com/SommerEngineering/Ocean/Log"
"github.com/SommerEngineering/Ocean/Log/DeviceDatabase" "github.com/SommerEngineering/Ocean/Log/DeviceDatabase"
LM "github.com/SommerEngineering/Ocean/Log/Meta" LM "github.com/SommerEngineering/Ocean/Log/Meta"
"github.com/SommerEngineering/Ocean/Log/Web/Scheme"
"github.com/SommerEngineering/Ocean/MimeTypes" "github.com/SommerEngineering/Ocean/MimeTypes"
"github.com/SommerEngineering/Ocean/Shutdown" "github.com/SommerEngineering/Ocean/Shutdown"
"net/http" "net/http"
@ -26,7 +27,7 @@ func HandlerWebLog(response http.ResponseWriter, request *http.Request) {
// Setup the data for the HTML template: // Setup the data for the HTML template:
data := Scheme.Viewer{} data := Scheme.Viewer{}
data.Title = `Web Log Viewer` data.Title = `Logging Viewer`
data.Sender = DeviceDatabase.ReadSenderNames() data.Sender = DeviceDatabase.ReadSenderNames()
data.MessageNames = DeviceDatabase.ReadMessageNames() data.MessageNames = DeviceDatabase.ReadMessageNames()
@ -99,7 +100,7 @@ func HandlerWebLog(response http.ResponseWriter, request *http.Request) {
// Write the MIME type and execute the template: // Write the MIME type and execute the template:
MimeTypes.Write2HTTP(response, MimeTypes.TypeWebHTML) MimeTypes.Write2HTTP(response, MimeTypes.TypeWebHTML)
if executeError := templates.ExecuteTemplate(response, `WebLog`, data); executeError != nil { if executeError := Admin.AdminTemplates.ExecuteTemplate(response, `WebLog`, data); executeError != nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameEXECUTE, `Was not able to execute the web log viewer template.`, executeError.Error()) Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameEXECUTE, `Was not able to execute the web log viewer template.`, executeError.Error())
} }
} }

View File

@ -3,8 +3,6 @@ package Web
import ( import (
"github.com/SommerEngineering/Ocean/Log" "github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta" LM "github.com/SommerEngineering/Ocean/Log/Meta"
WebTemp "github.com/SommerEngineering/Ocean/Log/Web/Templates"
"html/template"
) )
// The init function for this package. // The init function for this package.
@ -12,10 +10,4 @@ func init() {
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Init the web log.`) Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Init the web log.`)
defer Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Init the web log done.`) defer Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameINIT, `Init the web log done.`)
// Create the cache of all web logging templates:
templates = template.New(`root`)
if _, err := templates.Parse(WebTemp.Viewer); err != nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNamePARSE, `Was not able to parse the template for the web log viewer.`, err.Error())
}
} }

View File

@ -2,8 +2,8 @@ package Web
import ( import (
"fmt" "fmt"
"github.com/SommerEngineering/Ocean/Admin/Scheme"
"github.com/SommerEngineering/Ocean/Log/DeviceDatabase" "github.com/SommerEngineering/Ocean/Log/DeviceDatabase"
"github.com/SommerEngineering/Ocean/Log/Web/Scheme"
"strings" "strings"
) )

View File

@ -2,8 +2,8 @@ package Web
import ( import (
"fmt" "fmt"
"github.com/SommerEngineering/Ocean/Admin/Scheme"
"github.com/SommerEngineering/Ocean/Log/DeviceDatabase" "github.com/SommerEngineering/Ocean/Log/DeviceDatabase"
"github.com/SommerEngineering/Ocean/Log/Web/Scheme"
"strings" "strings"
) )

View File

@ -2,10 +2,8 @@ package Web
import ( import (
LM "github.com/SommerEngineering/Ocean/Log/Meta" LM "github.com/SommerEngineering/Ocean/Log/Meta"
"html/template"
) )
var ( var (
templates *template.Template = nil // The web logging templates senderName LM.Sender = `System::WebLog` // This is the name for logging event from this package
senderName LM.Sender = `System::WebLog` // This is the name for logging event from this package
) )

View File

@ -1,6 +1,7 @@
package System package System
import ( import (
"github.com/SommerEngineering/Ocean/Admin"
"github.com/SommerEngineering/Ocean/BinaryAssets" "github.com/SommerEngineering/Ocean/BinaryAssets"
"github.com/SommerEngineering/Ocean/ConfigurationDB" "github.com/SommerEngineering/Ocean/ConfigurationDB"
"github.com/SommerEngineering/Ocean/Handlers" "github.com/SommerEngineering/Ocean/Handlers"
@ -51,17 +52,20 @@ func InitHandlers() {
// Handler for binary assets, used for the admin pages: // Handler for binary assets, used for the admin pages:
Handlers.AddAdminHandler(`/binaryAssets/`, BinaryAssets.HandlerBinaryAssets) Handlers.AddAdminHandler(`/binaryAssets/`, BinaryAssets.HandlerBinaryAssets)
// Handler for the admin's overview:
Handlers.AddAdminHandler(`/`, Admin.HandlerOverview)
// Handler for the web logging: // Handler for the web logging:
Handlers.AddAdminHandler(`/log`, Web.HandlerWebLog) Handlers.AddAdminHandler(`/log`, Web.HandlerWebLog)
// Handler for the web logging's CSS and JS: // Handler for the web logging's CSS and JS:
Handlers.AddAdminHandler(`/log/css/normalize.css`, Web.HandlerCSSNormalize) Handlers.AddAdminHandler(`/admin/css/normalize.css`, Admin.HandlerCSSNormalize)
Handlers.AddAdminHandler(`/log/css/webflow.css`, Web.HandlerCSSWebflow) Handlers.AddAdminHandler(`/admin/css/webflow.css`, Admin.HandlerCSSWebflow)
Handlers.AddAdminHandler(`/log/css/log.css`, Web.HandlerCSSLog) Handlers.AddAdminHandler(`/admin/css/admin.css`, Admin.HandlerCSSAdmin)
Handlers.AddAdminHandler(`/log/js/modernizr.js`, Web.HandlerJSModernizr) Handlers.AddAdminHandler(`/admin/js/modernizr.js`, Admin.HandlerJSModernizr)
Handlers.AddAdminHandler(`/log/js/jquery.min.js`, Web.HandlerJSjQuery) Handlers.AddAdminHandler(`/admin/js/jquery.min.js`, Admin.HandlerJSjQuery)
Handlers.AddAdminHandler(`/log/js/jquery.min.map`, Web.HandlerJSjQueryMap) Handlers.AddAdminHandler(`/admin/js/jquery.min.map`, Admin.HandlerJSjQueryMap)
Handlers.AddAdminHandler(`/log/js/webflow.js`, Web.HandlerJSWebflow) Handlers.AddAdminHandler(`/admin/js/webflow.js`, Admin.HandlerJSWebflow)
// Are the static files mapped to the public? // Are the static files mapped to the public?
if ConfigurationDB.Read(`MapStaticFiles2Root`) == "true" { if ConfigurationDB.Read(`MapStaticFiles2Root`) == "true" {