diff --git a/Makefile b/Makefile
index 4fffa559..858e58f4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=0.5
+VERSION=0.51
BINARY_NAME=statup
GOPATH:=$(GOPATH)
GOCMD=go
diff --git a/cmd/cli.go b/cmd/cli.go
index 67b18a7d..45cb8105 100644
--- a/cmd/cli.go
+++ b/cmd/cli.go
@@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"github.com/hunterlong/statup/core"
+ "github.com/hunterlong/statup/handlers"
"github.com/hunterlong/statup/source"
"github.com/hunterlong/statup/types"
"github.com/hunterlong/statup/utils"
@@ -44,6 +45,8 @@ func CatchCLI(args []string) error {
LoadDotEnvs()
switch args[1] {
+ case "app":
+ handlers.DesktopInit(ipAddress, port)
case "version":
if COMMIT != "" {
fmt.Printf("Statup v%v (%v)\n", VERSION, COMMIT)
diff --git a/core/failures.go b/core/failures.go
index b8bc8cbb..b9b2e351 100644
--- a/core/failures.go
+++ b/core/failures.go
@@ -56,11 +56,9 @@ func (s *Service) AllFailures() []*types.Failure {
}
func (u *Service) DeleteFailures() {
- var fails []*Failure
- col := DbSession.Collection("failures")
- col.Find("service", u.Id).All(&fails)
- for _, fail := range fails {
- fail.Delete()
+ _, err := DbSession.Exec(`DELETE FROM failures WHERE service = ?`, u.Id)
+ if err != nil {
+ utils.Log(3, fmt.Sprintf("failed to delete all failures: %v", err))
}
u.Failures = nil
}
diff --git a/handlers/index.go b/handlers/index.go
index 09dd0b30..7d332f79 100644
--- a/handlers/index.go
+++ b/handlers/index.go
@@ -16,7 +16,10 @@
package handlers
import (
+ "fmt"
"github.com/hunterlong/statup/core"
+ "github.com/hunterlong/statup/types"
+ "github.com/hunterlong/statup/utils"
"net/http"
)
@@ -31,3 +34,61 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
}
ExecuteResponse(w, r, "index.html", core.CoreApp)
}
+
+func TrayHandler(w http.ResponseWriter, r *http.Request) {
+ ExecuteResponse(w, r, "tray.html", core.CoreApp)
+}
+
+func DesktopInit(ip string, port int) {
+ config := &core.DbConfig{DbConfig: &types.DbConfig{
+ DbConn: "sqlite",
+ Project: "Statup",
+ Description: "Statup running as an App!",
+ Domain: "http://localhost",
+ Username: "admin",
+ Password: "admin",
+ Email: "user@email.com",
+ Error: nil,
+ Location: utils.Directory,
+ }}
+
+ fmt.Println(config)
+
+ err := config.Save()
+ if err != nil {
+ utils.Log(4, err)
+ }
+
+ if err != nil {
+ utils.Log(3, err)
+ return
+ }
+
+ core.Configs, err = core.LoadConfig()
+ if err != nil {
+ utils.Log(3, err)
+ config.Error = err
+ return
+ }
+
+ err = core.DbConnection(core.Configs.Connection, false, utils.Directory)
+ if err != nil {
+ utils.Log(3, err)
+ core.DeleteConfig()
+ config.Error = err
+ return
+ }
+
+ admin := core.ReturnUser(&types.User{
+ Username: config.Username,
+ Password: config.Password,
+ Email: config.Email,
+ Admin: true,
+ })
+ admin.Create()
+
+ core.LoadSampleData()
+
+ core.InitApp()
+ RunHTTPServer(ip, port)
+}
diff --git a/handlers/routes.go b/handlers/routes.go
index 4d8b2992..4fea8a9b 100644
--- a/handlers/routes.go
+++ b/handlers/routes.go
@@ -101,10 +101,11 @@ func Router() *mux.Router {
r.Handle("/api/checkin/{api}", http.HandlerFunc(ApiCheckinHandler))
r.Handle("/metrics", http.HandlerFunc(PrometheusHandler))
r.NotFoundHandler = http.HandlerFunc(Error404Handler)
+ r.Handle("/tray", http.HandlerFunc(TrayHandler))
return r
}
-func resetRouter() {
+func ResetRouter() {
router = Router()
httpServer.Handler = router
}
diff --git a/handlers/settings.go b/handlers/settings.go
index c918bd21..1b88004d 100644
--- a/handlers/settings.go
+++ b/handlers/settings.go
@@ -73,10 +73,12 @@ func SaveSASSHandler(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
theme := r.PostForm.Get("theme")
variables := r.PostForm.Get("variables")
+ mobile := r.PostForm.Get("mobile")
source.SaveAsset([]byte(theme), utils.Directory, "scss/base.scss")
source.SaveAsset([]byte(variables), utils.Directory, "scss/variables.scss")
+ source.SaveAsset([]byte(mobile), utils.Directory, "scss/mobile.scss")
source.CompileSASS(utils.Directory)
- resetRouter()
+ ResetRouter()
ExecuteResponse(w, r, "settings.html", core.CoreApp)
}
@@ -96,7 +98,7 @@ func SaveAssetsHandler(w http.ResponseWriter, r *http.Request) {
source.CopyToPublic(source.CssBox, dir+"/assets/css", "base.css")
utils.Log(2, "Default 'base.css' was insert because SASS did not work.")
}
- resetRouter()
+ ResetRouter()
ExecuteResponse(w, r, "settings.html", core.CoreApp)
}
@@ -106,7 +108,7 @@ func DeleteAssetsHandler(w http.ResponseWriter, r *http.Request) {
return
}
source.DeleteAllAssets(utils.Directory)
- resetRouter()
+ ResetRouter()
ExecuteResponse(w, r, "settings.html", core.CoreApp)
}
diff --git a/source/css/base.css b/source/css/base.css
index e0a6b74a..95964b97 100644
--- a/source/css/base.css
+++ b/source/css/base.css
@@ -354,22 +354,29 @@ HTML, BODY {
box-shadow: 0 0 7px #47d337;
animation: glow-grow 2s ease-out infinite; }
-.sortable {
+.sortable_drag {
+ background-color: #0000000f; }
+
+.drag_icon {
cursor: move;
/* fallback if grab cursor is unsupported */
cursor: grab;
cursor: -moz-grab;
- cursor: -webkit-grab; }
+ cursor: -webkit-grab;
+ width: 25px;
+ height: 25px;
+ display: inline-block;
+ margin-right: 5px;
+ margin-left: -10px;
+ text-align: center;
+ color: #b1b1b1; }
/* (Optional) Apply a "closed-hand" cursor during drag operation. */
-.sortable:active {
+.drag_icon:active {
cursor: grabbing;
cursor: -moz-grabbing;
cursor: -webkit-grabbing; }
-.sortable_drag {
- background-color: #0000000f; }
-
@media (max-width: 767px) {
HTML, BODY {
background-color: #fcfcfc; }
diff --git a/source/js/main.js b/source/js/main.js
index e83bd91b..55d1a627 100644
--- a/source/js/main.js
+++ b/source/js/main.js
@@ -15,61 +15,63 @@
* along with this program. If not, see .
*/
-$(".service_li").on('click', function() {
+
+$('.service_li').on('click', function() {
var id = $(this).attr('data-id');
- var position = $("#service_id_"+id).offset();
- window.scroll(0,position.top-23);
+ var position = $('#service_id_' + id).offset();
+ window.scroll(0, position.top - 23);
return false;
});
$('form').submit(function() {
- $(this).find("button[type='submit']").prop('disabled',true);
+ console.log(this);
+ $(this).find('button[type=submit]').prop('disabled', true);
});
$('select#service_type').on('change', function() {
var selected = $('#service_type option:selected').val();
- if (selected === "tcp") {
- $("#service_port").parent().parent().removeClass("d-none");
- $("#service_check_type").parent().parent().addClass("d-none");
- $("#service_url").attr("placeholder", "localhost");
+ if (selected === 'tcp') {
+ $('#service_port').parent().parent().removeClass('d-none');
+ $('#service_check_type').parent().parent().addClass('d-none');
+ $('#service_url').attr('placeholder', 'localhost');
- $("#post_data").parent().parent().addClass("d-none");
- $("#service_response").parent().parent().addClass("d-none");
- $("#service_response_code").parent().parent().addClass("d-none");
+ $('#post_data').parent().parent().addClass('d-none');
+ $('#service_response').parent().parent().addClass('d-none');
+ $('#service_response_code').parent().parent().addClass('d-none');
} else {
- $("#post_data").parent().parent().removeClass("d-none");
- $("#service_response").parent().parent().removeClass("d-none");
- $("#service_response_code").parent().parent().removeClass("d-none");
- $("#service_check_type").parent().parent().removeClass("d-none");
- $("#service_url").attr("placeholder", "https://google.com");
+ $('#post_data').parent().parent().removeClass('d-none');
+ $('#service_response').parent().parent().removeClass('d-none');
+ $('#service_response_code').parent().parent().removeClass('d-none');
+ $('#service_check_type').parent().parent().removeClass('d-none');
+ $('#service_url').attr('placeholder', 'https://google.com');
- $("#service_port").parent().parent().addClass("d-none");
+ $('#service_port').parent().parent().addClass('d-none');
}
});
$('select#service_check_type').on('change', function() {
var selected = $('#service_check_type option:selected').val();
- if (selected === "POST") {
- $("#post_data").parent().parent().removeClass("d-none");
+ if (selected === 'POST') {
+ $('#post_data').parent().parent().removeClass('d-none');
} else {
- $("#post_data").parent().parent().addClass("d-none");
+ $('#post_data').parent().parent().addClass('d-none');
}
});
$(function() {
var pathname = window.location.pathname;
- if (pathname==="/logs") {
+ if (pathname === '/logs') {
var lastline;
- var logArea = $("#live_logs");
+ var logArea = $('#live_logs');
setInterval(function() {
- $.get("/logs/line", function(data, status){
+ $.get('/logs/line', function(data, status) {
if (lastline !== data) {
var curr = $.trim(logArea.text());
- var line = data.replace(/(\r\n|\n|\r)/gm, " ");
- line = line + "\n";
+ var line = data.replace(/(\r\n|\n|\r)/gm, ' ');
+ line = line + '\n';
logArea.text(line + curr);
lastline = data;
}
@@ -79,9 +81,9 @@ $(function() {
});
-$(".confirm-btn").on('click', function() {
- var r = confirm("Are you sure you want to delete?");
- if (r == true) {
+$('.confirm-btn').on('click', function() {
+ var r = confirm('Are you sure you want to delete?');
+ if (r === true) {
return true;
} else {
return false;
@@ -89,30 +91,64 @@ $(".confirm-btn").on('click', function() {
});
-$(".select-input").on("click", function () {
+$('.select-input').on('click', function() {
$(this).select();
});
+// $('input[name=password], input[name=password_confirm]').on('change keyup input paste', function() {
+// var password = $('input[name=password]'),
+// repassword = $('input[name=password_confirm]'),
+// both = password.add(repassword).removeClass('is-valid is-invalid');
+//
+// var btn = $(this).parents('form:first').find('button[type=submit]');
+// password.addClass(
+// password.val().length > 0 ? 'is-valid' : 'is-invalid'
+// );
+// repassword.addClass(
+// password.val().length > 0 ? 'is-valid' : 'is-invalid'
+// );
+//
+// if (password.val() !== repassword.val()) {
+// both.addClass('is-invalid');
+// btn.prop('disabled', true);
+// } else {
+// btn.prop('disabled', false);
+// }
+// });
+
+
var ranVar = false;
var ranTheme = false;
-$('a[data-toggle="pill"]').on('shown.bs.tab', function (e) {
- var target = $(e.target).attr("href");
- if (target==="#v-pills-style" && !ranVar) {
- var sass_vars = CodeMirror.fromTextArea(document.getElementById("sass_vars"), {
+var ranMobile = false;
+$('a[data-toggle=pill]').on('shown.bs.tab', function(e) {
+ var target = $(e.target).attr('href');
+ if (target === '#v-pills-style' && !ranVar) {
+ var sass_vars = CodeMirror.fromTextArea(document.getElementById('sass_vars'), {
lineNumbers: true,
matchBrackets: true,
- mode: "text/x-scss",
- colorpicker : true
+ mode: 'text/x-scss',
+ colorpicker: true
});
+ sass_vars.setSize(null, 900);
ranVar = true;
- } else if (target==="#pills-theme" && !ranTheme) {
- var theme_css = CodeMirror.fromTextArea(document.getElementById("theme_css"), {
+ } else if (target === '#pills-theme' && !ranTheme) {
+ var theme_css = CodeMirror.fromTextArea(document.getElementById('theme_css'), {
lineNumbers: true,
matchBrackets: true,
- mode: "text/x-scss",
- colorpicker : true
+ mode: 'text/x-scss',
+ colorpicker: true
});
+ theme_css.setSize(null, 900);
ranTheme = true;
+ } else if (target === '#pills-mobile' && !ranMobile) {
+ var mobile_css = CodeMirror.fromTextArea(document.getElementById('mobile_css'), {
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: 'text/x-scss',
+ colorpicker: true
+ });
+ mobile_css.setSize(null, 900);
+ ranMobile = true;
}
});
\ No newline at end of file
diff --git a/source/scss/base.scss b/source/scss/base.scss
index ac0a07e5..2ba9f69d 100644
--- a/source/scss/base.scss
+++ b/source/scss/base.scss
@@ -410,22 +410,29 @@ HTML,BODY {
animation: glow-grow 2s ease-out infinite;
}
-.sortable {
+.sortable_drag {
+ background-color: #0000000f;
+}
+
+.drag_icon {
cursor: move; /* fallback if grab cursor is unsupported */
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
+ width: 25px;
+ height: 25px;
+ display: inline-block;
+ margin-right: 5px;
+ margin-left: -10px;
+ text-align: center;
+ color: #b1b1b1;
}
/* (Optional) Apply a "closed-hand" cursor during drag operation. */
-.sortable:active {
+.drag_icon:active {
cursor: grabbing;
cursor: -moz-grabbing;
cursor: -webkit-grabbing;
}
-.sortable_drag {
- background-color: #0000000f;
-}
-
@import 'mobile';
\ No newline at end of file
diff --git a/source/tmpl/dashboard.html b/source/tmpl/dashboard.html
index a2d59945..a99c20ba 100644
--- a/source/tmpl/dashboard.html
+++ b/source/tmpl/dashboard.html
@@ -66,7 +66,7 @@
{{.ParseError}}
- Reported {{.Ago}}
+ {{.Ago}}
{{.Issue}}
diff --git a/source/tmpl/service.html b/source/tmpl/service.html
index fb6d9947..1e403cfc 100644
--- a/source/tmpl/service.html
+++ b/source/tmpl/service.html
@@ -64,7 +64,7 @@
{{.ParseError}}
- Reported {{.Ago}}
+ {{.Ago}}
{{.Issue}}
@@ -109,10 +109,13 @@
-