Skip to content

Commit

Permalink
UI fixes, import/export views
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlong committed Sep 9, 2020
1 parent eb9792d commit a3ce412
Show file tree
Hide file tree
Showing 20 changed files with 600 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
shell: bash

- name: Install Global Dependencies
run: npm install -g yarn sass cross-env
run: npm install -g yarn sass cross-env mjml

- name: Download Frontend Dependencies
working-directory: ./frontend
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
shell: bash

- name: Install Global Dependencies
run: npm install -g yarn sass cross-env
run: npm install -g yarn sass cross-env mjml

- name: Download Frontend Dependencies
working-directory: ./frontend
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# 0.90.66 (09-08-2020)
- Added Import and Export views in Dashboard

# 0.90.65 (09-01-2020)
- Fixed issue with dashboard not logging in (notifier panic)
- Modified static email templates to github.com/statping/emails
- Modified Regenerate API function to keep API_SECRET env
- Added DEMO_MODE env variable, if true, 'admin' cannot be deleted
- Modified Service sparklines on Dashboard
- Added modal popup for UI deletes/edits

# 0.90.64 (08-18-2020)
- Modified max-width for container to 1012px, larger UI
Expand Down
92 changes: 44 additions & 48 deletions cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
"github.com/statping/statping/handlers"
"github.com/statping/statping/source"
"github.com/statping/statping/types/checkins"
"github.com/statping/statping/types/configs"
"github.com/statping/statping/types/core"
"github.com/statping/statping/types/groups"
"github.com/statping/statping/types/messages"
"github.com/statping/statping/types/services"
"github.com/statping/statping/types/users"
"github.com/statping/statping/utils"
"io/ioutil"
"os"
Expand Down Expand Up @@ -109,7 +106,7 @@ func exportCli(args []string) error {
if len(args) == 1 {
filename = fmt.Sprintf("%s/%s", utils.Directory, args)
}
var data []byte
var data *handlers.ExportData
if err := utils.InitLogs(); err != nil {
return err
}
Expand All @@ -126,10 +123,10 @@ func exportCli(args []string) error {
if _, err := services.SelectAllServices(false); err != nil {
return err
}
if data, err = ExportSettings(); err != nil {
if data, err = handlers.ExportSettings(); err != nil {
return fmt.Errorf("could not export settings: %v", err.Error())
}
if err = utils.SaveFile(filename, data); err != nil {
if err = utils.SaveFile(filename, data.JSON()); err != nil {
return fmt.Errorf("could not write file statping-export.json: %v", err.Error())
}
log.Infoln("Statping export file saved to ", filename)
Expand Down Expand Up @@ -233,7 +230,7 @@ func importCli(args []string) error {
if data, err = ioutil.ReadFile(args[0]); err != nil {
return err
}
var exportData ExportData
var exportData handlers.ExportData
if err = json.Unmarshal(data, &exportData); err != nil {
return err
}
Expand Down Expand Up @@ -285,7 +282,6 @@ func importCli(args []string) error {
return err
}
}

if ask("Import Core settings?") {
c := exportData.Core
if err := c.Update(); err != nil {
Expand Down Expand Up @@ -482,16 +478,16 @@ type gitUploader struct {

// ExportChartsJs renders the charts for the index page

type ExportData struct {
Config *configs.DbConfig `json:"config"`
Core *core.Core `json:"core"`
Services []services.Service `json:"services"`
Messages []*messages.Message `json:"messages"`
Checkins []*checkins.Checkin `json:"checkins"`
Users []*users.User `json:"users"`
Groups []*groups.Group `json:"groups"`
Notifiers []core.AllNotifiers `json:"notifiers"`
}
//type ExportData struct {
// Config *configs.DbConfig `json:"config"`
// Core *core.Core `json:"core"`
// Services []services.Service `json:"services"`
// Messages []*messages.Message `json:"messages"`
// Checkins []*checkins.Checkin `json:"checkins"`
// Users []*users.User `json:"users"`
// Groups []*groups.Group `json:"groups"`
// Notifiers []core.AllNotifiers `json:"notifiers"`
//}

// ExportSettings will export a JSON file containing all of the settings below:
// - Core
Expand All @@ -501,35 +497,35 @@ type ExportData struct {
// - Services
// - Groups
// - Messages
func ExportSettings() ([]byte, error) {
c, err := core.Select()
if err != nil {
return nil, err
}
var srvs []services.Service
for _, s := range services.AllInOrder() {
s.Failures = nil
srvs = append(srvs, s)
}

cfg, err := configs.LoadConfigs(configFile)
if err != nil {
return nil, err
}

data := ExportData{
Config: cfg,
Core: c,
Notifiers: core.App.Notifications,
Checkins: checkins.All(),
Users: users.All(),
Services: srvs,
Groups: groups.All(),
Messages: messages.All(),
}
export, err := json.Marshal(data)
return export, err
}
//func ExportSettings() ([]byte, error) {
// c, err := core.Select()
// if err != nil {
// return nil, err
// }
// var srvs []services.Service
// for _, s := range services.AllInOrder() {
// s.Failures = nil
// srvs = append(srvs, s)
// }
//
// cfg, err := configs.LoadConfigs(configFile)
// if err != nil {
// return nil, err
// }
//
// data := ExportData{
// Config: cfg,
// Core: c,
// Notifiers: core.App.Notifications,
// Checkins: checkins.All(),
// Users: users.All(),
// Services: srvs,
// Groups: groups.All(),
// Messages: messages.All(),
// }
// export, err := json.Marshal(data)
// return export, err
//}

// ExportIndexHTML returns the HTML of the index page as a string
//func ExportIndexHTML() []byte {
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const tokenKey = "statping_auth";

class Api {
constructor() {
this.version = "0.90.65";
this.commit = "5bc10fcc8536a08ce7a099a0b4cbceb2dc9fc35b";
this.version = "0.90.66";
this.commit = "eb9792d18480736630f4811caf56add31b78c3c2";
}

async oauth() {
Expand Down Expand Up @@ -97,7 +97,6 @@ class Api {
}

async groups_reorder(data) {
window.console.log('api/reorder/groups', data)
return axios.post('api/reorder/groups', data).then(response => (response.data))
}

Expand Down Expand Up @@ -233,6 +232,10 @@ class Api {
return axios.post('api/theme', data).then(response => (response.data))
}

async import(data) {
return axios.post('api/settings/import', data).then(response => (response.data))
}

async check_token(token) {
const f = {token: token}
return axios.post('api/users/token', qs.stringify(f)).then(response => (response.data))
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/scss/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.copy-btn {
position: absolute;
right: 0;
z-index: 9999999;
z-index: 995;
}

.copy-btn BUTTON {
Expand Down
36 changes: 32 additions & 4 deletions frontend/src/assets/scss/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ A:HOVER {
}

.modal-backdrop {
position: absolute;
top: 0;
left: 0;
position: absolute;
display: block;
z-index: 10000;
z-index: 1040;
width: 100%;
height: 100%;
background-color: #00000073;
background-color: rgb(0 0 0 / 50%);
}

.modal {
Expand Down Expand Up @@ -204,3 +203,32 @@ A:HOVER {
-ms-user-select: none;
user-select: none;
}

.dates{
padding:10px 0px;
margin:10px 20px;
font-weight:600;
overflow:auto;
color: darken($card-background, 45%);
font-size: 22px;
}
.dates div{
float:left;
width:50%;
text-align:center;
position:relative;
}
.dates strong {
display:block;
color: darken($card-background, 20%);
font-size:20px;
font-weight:700;
}
.dates span{
width:1px;
height:60px;
position:absolute;
right:0;
top:0;
background: darken($card-background, 10%);
}
Loading

0 comments on commit a3ce412

Please sign in to comment.