From c4a9e27b5f15309372f7d2c4ce8a467e167af621 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 27 Jul 2018 20:34:49 +0000 Subject: [PATCH] --- Controllers/OpsController.cs | 232 +++++++++++++----------- util/RfVersion.cs | 2 +- wwwroot/default.htm | 104 +++++------ wwwroot/js/app.api.js | 2 +- wwwroot/js/app.ops.js | 80 ++++---- wwwroot/js/templates/app.ops.handlebars | 43 ++++- wwwroot/js/templates/templates.js | 4 +- 7 files changed, 268 insertions(+), 199 deletions(-) diff --git a/Controllers/OpsController.cs b/Controllers/OpsController.cs index eff36a4..860d29b 100644 --- a/Controllers/OpsController.cs +++ b/Controllers/OpsController.cs @@ -26,137 +26,163 @@ namespace rockfishCore.Controllers //status of ops - [HttpGet("status")] - public dtoOpsStatus GetOpsStatus() + [HttpGet("status/{service}")] + public dtoOpsStatus GetOpsStatus([FromRoute] string service) { dtoOpsStatus Ret = new dtoOpsStatus(); - // //TESTING - // Ret.OpsCheckError="Fake error message\r\nwith more fake text\r\neot"; - // Ret.MailMirrorOK=true; - // Ret.ContactFormOK=true; - try { - Ret.MailMirrorOK = RfMail.MailIsMirroringProperly(); + switch (service) + { + case "MailMirror": + Ret.Status = true;//RfMail.MailIsMirroringProperly(); + break; + case "AyaNovaSite": + Ret.Status = false;//OpsDiagnostics.CheckWebsite("https://www.ayanova.com/", "Ground Zero Tech-Works Inc."); + break; + case "APISite": + Ret.Status = true;// OpsDiagnostics.CheckWebsite("https://api.ayanova.com/", "WorkorderTypes Enumeration"); + break; + case "ContactForm": + Ret.Status = false; //OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/contact", "Contact.Email"); + break; + case "RequestForm": + Ret.Status = true;// OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/request", "Contact.Email"); + break; + case "RequestLiteForm": + Ret.Status = false; //OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/requestlite", "Contact.Email"); + break; + case "Subversion": + Ret.Status = true; //OpsDiagnostics.CheckWebsite("http://svn.helloayanova.com:3343/csvn/login/auth", "Subversion Edge"); + break; + case "Forum": + Ret.Status = false; //OpsDiagnostics.CheckWebsite("http://forum.ayanova.com/", "AyaNova support resources"); + break; + case "DevOps": + Ret.Status = true; //OpsDiagnostics.CheckWebsite("https://test.helloayanova.com/api/v8/", "AyaNova server"); + break; + case "Backup": + Ret.Status = false;//OpsDiagnostics.VerifyBackups(); + break; + default: + Ret.Status = false; + Ret.ServiceCheckError=$"Unknown service: \"{service}\""; + break; + + } + } catch (Exception ex) { - Ret.OpsCheckError += $"Mail mirror: {ex.Message}\r\n"; + Ret.ServiceCheckError += $"{service}: {ex.Message}\r\n"; } - try - { - Ret.AyaNovaSiteOK = OpsDiagnostics.CheckWebsite("https://www.ayanova.com/", "Ground Zero Tech-Works Inc."); - } - catch (Exception ex) - { - Ret.OpsCheckError += $"AyaNova site: {ex.Message}\r\n"; - } +Ret.ServiceCheckError=$"test {service} error"; - try - { - Ret.APISiteOK = OpsDiagnostics.CheckWebsite("https://api.ayanova.com/", "WorkorderTypes Enumeration"); - } - catch (Exception ex) - { - Ret.OpsCheckError += $"API site: {ex.Message}\r\n"; - } + // try + // { + // Ret.MailMirrorOK = RfMail.MailIsMirroringProperly(); + // } + // catch (Exception ex) + // { + // Ret.OpsCheckError += $"Mail mirror: {ex.Message}\r\n"; + // } - try - { - Ret.ContactFormOK = OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/contact", "Contact.Email"); - } - catch (Exception ex) - { - Ret.OpsCheckError += $"Contact form: {ex.Message}\r\n"; - } + // try + // { + // Ret.AyaNovaSiteOK = OpsDiagnostics.CheckWebsite("https://www.ayanova.com/", "Ground Zero Tech-Works Inc."); + // } + // catch (Exception ex) + // { + // Ret.OpsCheckError += $"AyaNova site: {ex.Message}\r\n"; + // } - try - { - Ret.RequestFormOK = OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/request", "Contact.Email"); - } - catch (Exception ex) - { - Ret.OpsCheckError += $"Request form: {ex.Message}\r\n"; - } + // try + // { + // Ret.APISiteOK = OpsDiagnostics.CheckWebsite("https://api.ayanova.com/", "WorkorderTypes Enumeration"); + // } + // catch (Exception ex) + // { + // Ret.OpsCheckError += $"API site: {ex.Message}\r\n"; + // } - try - { - Ret.RequestLiteFormOK = OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/requestlite", "Contact.Email"); - } - catch (Exception ex) - { - Ret.OpsCheckError += $"RequestLite form: {ex.Message}\r\n"; - } + // try + // { + // Ret.ContactFormOK = OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/contact", "Contact.Email"); + // } + // catch (Exception ex) + // { + // Ret.OpsCheckError += $"Contact form: {ex.Message}\r\n"; + // } - try - { - Ret.SubversionOK = OpsDiagnostics.CheckWebsite("http://svn.helloayanova.com:3343/csvn/login/auth", "Subversion Edge"); - } - catch (Exception ex) - { - Ret.OpsCheckError += $"Subversion: {ex.Message}\r\n"; - } + // try + // { + // Ret.RequestFormOK = OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/request", "Contact.Email"); + // } + // catch (Exception ex) + // { + // Ret.OpsCheckError += $"Request form: {ex.Message}\r\n"; + // } - try - { - Ret.ForumOK = OpsDiagnostics.CheckWebsite("http://forum.ayanova.com/", "AyaNova support resources"); - } - catch (Exception ex) - { - Ret.OpsCheckError += $"Forum: {ex.Message}\r\n"; - } + // try + // { + // Ret.RequestLiteFormOK = OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/requestlite", "Contact.Email"); + // } + // catch (Exception ex) + // { + // Ret.OpsCheckError += $"RequestLite form: {ex.Message}\r\n"; + // } - try - { - Ret.DevOpsOK = OpsDiagnostics.CheckWebsite("https://test.helloayanova.com/api/v8/", "AyaNova server"); - } - catch (Exception ex) - { - Ret.OpsCheckError += $"DevOps: {ex.Message}\r\n"; - } + // try + // { + // Ret.SubversionOK = OpsDiagnostics.CheckWebsite("http://svn.helloayanova.com:3343/csvn/login/auth", "Subversion Edge"); + // } + // catch (Exception ex) + // { + // Ret.OpsCheckError += $"Subversion: {ex.Message}\r\n"; + // } - try - { - Ret.BackupOK = OpsDiagnostics.VerifyBackups(); - } - catch (Exception ex) - { - Ret.OpsCheckError += $"Backup: {ex.Message}\r\n"; - } + // try + // { + // Ret.ForumOK = OpsDiagnostics.CheckWebsite("http://forum.ayanova.com/", "AyaNova support resources"); + // } + // catch (Exception ex) + // { + // Ret.OpsCheckError += $"Forum: {ex.Message}\r\n"; + // } + + // try + // { + // Ret.DevOpsOK = OpsDiagnostics.CheckWebsite("https://test.helloayanova.com/api/v8/", "AyaNova server"); + // } + // catch (Exception ex) + // { + // Ret.OpsCheckError += $"DevOps: {ex.Message}\r\n"; + // } + + // try + // { + // Ret.BackupOK = OpsDiagnostics.VerifyBackups(); + // } + // catch (Exception ex) + // { + // Ret.OpsCheckError += $"Backup: {ex.Message}\r\n"; + // } return Ret; } public class dtoOpsStatus { - public bool MailMirrorOK; - public bool ForumOK; - public bool AyaNovaSiteOK; - public bool APISiteOK; - public bool ContactFormOK; - public bool RequestFormOK; - public bool RequestLiteFormOK; - public bool SubversionOK; - public bool DevOpsOK; - public bool BackupOK; - public string OpsCheckError; + public bool Status; + public string ServiceCheckError; public dtoOpsStatus() { - MailMirrorOK = false; - ForumOK = false; - AyaNovaSiteOK = false; - APISiteOK = false; - ContactFormOK = false; - RequestFormOK = false; - RequestLiteFormOK = false; - SubversionOK = false; - DevOpsOK = false; - BackupOK = false; - OpsCheckError = string.Empty; + Status = false; + ServiceCheckError = string.Empty; } } diff --git a/util/RfVersion.cs b/util/RfVersion.cs index 2f65c6e..ae26216 100644 --- a/util/RfVersion.cs +++ b/util/RfVersion.cs @@ -2,7 +2,7 @@ namespace rockfishCore.Util { public static class RfVersion { - public const string NumberOnly="6.5"; + public const string NumberOnly="6.6"; public const string Full = "Rockfish server " + NumberOnly; } } \ No newline at end of file diff --git a/wwwroot/default.htm b/wwwroot/default.htm index 48db6dd..6a87516 100644 --- a/wwwroot/default.htm +++ b/wwwroot/default.htm @@ -11,69 +11,69 @@ Rockfish loading.... - - - - - + + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + \ No newline at end of file diff --git a/wwwroot/js/app.api.js b/wwwroot/js/app.api.js index d5ca67b..ce726bd 100644 --- a/wwwroot/js/app.api.js +++ b/wwwroot/js/app.api.js @@ -27,7 +27,7 @@ app.api = (function() { generateFromRequest, licenseEmailResponse; - RockFishVersion = "6.5"; + RockFishVersion = "6.6"; ////////////////////////////////////////////////////////////////////////////////////// // NOT AUTHORIZED ERROR HANDLER diff --git a/wwwroot/js/app.ops.js b/wwwroot/js/app.ops.js index 787e4bb..de0849b 100644 --- a/wwwroot/js/app.ops.js +++ b/wwwroot/js/app.ops.js @@ -12,7 +12,7 @@ app.ops = (function() { //---------------- BEGIN MODULE SCOPE VARIABLES -------------- var stateMap = {}, configModule, - generateItem, + checkService, initModule; //----------------- END MODULE SCOPE VARIABLES --------------- @@ -20,19 +20,41 @@ app.ops = (function() { ////////////////// //Generate list item // - generateItem = function(okStatus, label) { + checkService = function(service) { + // var okClassFragment = okStatus + // ? "mdi-check-circle text-success" + // : "mdi-alert text-danger"; - var okClassFragment = okStatus - ? "mdi-check-circle text-success" - : "mdi-alert text-danger"; + // return ( + // '

' + + // label + + // "

" + // ); - return ( - '

' + - label + - "

" - ); + app.api.get("ops/status/" + service, function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + if (res.ServiceCheckError) { + var errorText = $("#rf-ops-error").text(); + errorText += "\r\n"; + errorText += res.ServiceCheckError; + $("#rf-ops-error").text(errorText); + } + + var serviceElement = $("#" + service); + serviceElement.removeClass("mdi-help-circle-outline text-warning"); + if (res.status == true) { + serviceElement.addClass("mdi-check-circle text-success"); + } else { + serviceElement.addClass("mdi-alert text-danger"); + } + //remove ? class and warning class + //add appropriate icon and text color class + } + }); }; //-------------------- END UTILITY METHODS ------------------- @@ -59,37 +81,17 @@ app.ops = (function() { } $container.html(Handlebars.templates["app.ops"]({})); $("#rf-ops-error").text(""); - $("#rf-ops-status").html("

Checking...

"); + // $("#rf-ops-status").html("

Checking...

"); //Context menu app.nav.contextClear(); - app.api.get("ops/status/", function(res) { - if (res.error) { - $.gevent.publish("app-show-error", res.msg); - } else { - if (res.opsCheckError) { - $("#rf-ops-error").text(res.opsCheckError); - } - - var generatedHtml = ""; - generatedHtml += generateItem(res.mailMirrorOK, "Mail & mirror"); - generatedHtml += generateItem(res.ayaNovaSiteOK, "AyaNova site"); - generatedHtml += generateItem(res.backupOK, "Backup"); - generatedHtml += generateItem(res.contactFormOK, "Contact form"); - generatedHtml += generateItem(res.requestFormOK, "Request form"); - generatedHtml += generateItem( - res.requestLiteFormOK, - "Request lite form" - ); - generatedHtml += generateItem(res.forumOK, "Forum"); - generatedHtml += generateItem(res.subversionOK, "Subversion"); - generatedHtml += generateItem(res.devOpsOK, "Devops site"); - generatedHtml += generateItem(res.apiSiteOK, "API site"); - - $("#rf-ops-status").html(generatedHtml); - } - }); + checkService("MailMirror"); + checkService("AyaNovaSite"); + checkService("APISite"); + checkService("ContactForm"); + checkService("RequestForm"); + checkService("Backup"); }; //PUBLIC METHODS diff --git a/wwwroot/js/templates/app.ops.handlebars b/wwwroot/js/templates/app.ops.handlebars index 0776317..524b46e 100644 --- a/wwwroot/js/templates/app.ops.handlebars +++ b/wwwroot/js/templates/app.ops.handlebars @@ -1,5 +1,46 @@

     
+

+ + Mail / mirror +

+

+ + AyaNova site +

+

+ + Backup +

+

+ + Contact form +

+

+ + Request form +

+

+ + Request lite form +

+

+ + Forum +

+

+ + Subversion +

+

+ + DevOps server +

+

+ + API site +

+
-
\ No newline at end of file + diff --git a/wwwroot/js/templates/templates.js b/wwwroot/js/templates/templates.js index 80a3301..bfcbe51 100644 --- a/wwwroot/js/templates/templates.js +++ b/wwwroot/js/templates/templates.js @@ -1,2 +1,2 @@ -!function(){var n=Handlebars.template,e=Handlebars.templates=Handlebars.templates||{};e["app.authenticate"]=n({compiler:[7,">= 4.0.0"],main:function(n,e,a,l,t){return'
\n Rockfish logo\n

Login

\n
\n

\n

\n

\n
\n
'},useData:!0}),e["app.customerEdit"]=n({compiler:[7,">= 4.0.0"],main:function(n,e,a,l,t){return'
\n
\n\n\n
\n \n \n
\n\n
\n \n \n
\n\n
\n \n \n
\n\n
\n \n \n
\n\n
\n \n
\n\n\n
\n \n
\n\n\n\n
\n \n