From d2331fe14b71836a72bcc3d7d26b8a61480b636a Mon Sep 17 00:00:00 2001 From: hunterlong Date: Tue, 18 Feb 2020 20:07:22 -0800 Subject: [PATCH] vue --- cmd/cli.go | 2 +- core/checkin.go | 22 +- core/core.go | 14 +- core/database.go | 90 +- core/failures.go | 20 +- core/groups.go | 8 +- core/hits.go | 18 +- core/incidents.go | 20 +- core/integrations/csv_file_test.go | 2 +- core/integrations/docker_test.go | 2 + core/integrations/integrations_test.go | 15 - core/integrations/testdata/bulk_import.csv | 11 + core/integrations/traefik_test.go | 4 +- core/messages.go | 12 +- core/notifier/notifiers.go | 13 +- core/notifier/notifiers_test.go | 20 +- core/sample.go | 5 +- core/services.go | 12 +- core/users.go | 14 +- frontend/config/webpack.config.common.js | 4 +- frontend/config/webpack.config.dev.js | 7 +- frontend/config/webpack.config.prod.js | 13 +- frontend/package.json | 6 +- frontend/public/base.gohtml | 34 + .../components/Service/ServiceFailures.vue | 75 + frontend/src/forms/Login.vue | 70 + frontend/src/forms/Message.vue | 16 +- frontend/src/forms/Setup.vue | 50 +- frontend/src/forms/User.vue | 1 - frontend/src/pages/Dashboard.vue | 6 - frontend/src/pages/Login.vue | 47 +- frontend/src/pages/Service.vue | 15 +- frontend/src/pages/Settings.vue | 20 +- frontend/yarn.lock | 8423 ----------------- handlers/api.go | 10 +- handlers/api_test.go | 26 +- handlers/benchmark_test.go | 46 - handlers/cache.go | 43 +- handlers/dashboard.go | 12 +- handlers/dashboard_test.go | 146 - handlers/messages_test.go | 31 - handlers/routes.go | 2 - handlers/services_test.go | 37 - handlers/settings.go | 230 - handlers/users_test.go | 31 - notifiers/notifiers_test.go | 2 +- source/source.go | 68 +- source/source_test.go | 21 +- types/core.go | 2 +- types/failure.go | 2 +- types/gorm.go | 320 +- types/service.go | 10 + types/time.go | 2 +- types/types.go | 4 +- types/user.go | 2 +- utils/utils.go | 2 +- 56 files changed, 671 insertions(+), 9469 deletions(-) delete mode 100644 core/integrations/integrations_test.go create mode 100644 core/integrations/testdata/bulk_import.csv create mode 100644 frontend/public/base.gohtml create mode 100644 frontend/src/components/Service/ServiceFailures.vue create mode 100644 frontend/src/forms/Login.vue delete mode 100644 frontend/yarn.lock delete mode 100644 handlers/benchmark_test.go delete mode 100644 handlers/dashboard_test.go delete mode 100644 handlers/messages_test.go delete mode 100644 handlers/services_test.go delete mode 100644 handlers/users_test.go diff --git a/cmd/cli.go b/cmd/cli.go index e5c2a713..da879679 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -65,7 +65,7 @@ func catchCLI(args []string) error { if err := runAssets(); err != nil { return err } - if err := source.CompileSASS(dir); err != nil { + if err := source.CompileSASS(); err != nil { return err } return errors.New("end") diff --git a/core/checkin.go b/core/checkin.go index 364c1277..92905ffd 100644 --- a/core/checkin.go +++ b/core/checkin.go @@ -93,7 +93,7 @@ func (c *Checkin) CreateFailure() (int64, error) { Checkin: c.Id, PingTime: c.Expected().Seconds(), }} - row := failuresDB().Create(&fail) + row := Database(&Failure{}).Create(&fail) sort.Sort(types.FailSort(c.Failures)) c.Failures = append(c.Failures, fail) if len(c.Failures) > limitedFailures { @@ -105,14 +105,14 @@ func (c *Checkin) CreateFailure() (int64, error) { // LimitedHits will return the last amount of successful hits from a checkin func (c *Checkin) LimitedHits(amount int) []*types.CheckinHit { var hits []*types.CheckinHit - checkinHitsDB().Where("checkin = ?", c.Id).Order("id desc").Limit(amount).Find(&hits) + Database(&CheckinHit{}).Where("checkin = ?", c.Id).Order("id desc").Limit(amount).Find(&hits) return hits } // AllCheckins returns all checkin in system func AllCheckins() []*Checkin { var checkins []*Checkin - checkinDB().Find(&checkins) + Database(&types.Checkin{}).Find(&checkins) return checkins } @@ -152,7 +152,7 @@ func (c *Checkin) Expected() time.Duration { // Last returns the last checkinHit for a Checkin func (c *Checkin) Last() *CheckinHit { var hit CheckinHit - checkinHitsDB().Where("checkin = ?", c.Id).Last(&hit) + Database(c).Where("checkin = ?", c.Id).Last(&hit) return &hit } @@ -163,7 +163,7 @@ func (c *Checkin) Link() string { // AllHits returns all of the CheckinHits for a given Checkin func (c *Checkin) AllHits() []*types.CheckinHit { var checkins []*types.CheckinHit - checkinHitsDB().Where("checkin = ?", c.Id).Order("id DESC").Find(&checkins) + Database(&types.CheckinHit{}).Where("checkin = ?", c.Id).Order("id DESC").Find(&checkins) return checkins } @@ -171,7 +171,7 @@ func (c *Checkin) AllHits() []*types.CheckinHit { func (c *Checkin) LimitedFailures(amount int) []types.FailureInterface { var failures []*Failure var failInterfaces []types.FailureInterface - col := failuresDB().Where("checkin = ?", c.Id).Where("method = 'checkin'").Limit(amount).Order("id desc") + col := Database(&types.Failure{}).Where("checkin = ?", c.Id).Where("method = 'checkin'").Limit(amount).Order("id desc") col.Find(&failures) for _, f := range failures { failInterfaces = append(failInterfaces, f) @@ -182,7 +182,7 @@ func (c *Checkin) LimitedFailures(amount int) []types.FailureInterface { // Hits returns all of the CheckinHits for a given Checkin func (c *Checkin) AllFailures() []*types.Failure { var failures []*types.Failure - col := failuresDB().Where("checkin = ?", c.Id).Where("method = 'checkin'").Order("id desc") + col := Database(&types.Failure{}).Where("checkin = ?", c.Id).Where("method = 'checkin'").Order("id desc") col.Find(&failures) return failures } @@ -194,7 +194,7 @@ func (c *Checkin) Delete() error { service := c.Service() slice := service.Checkins service.Checkins = append(slice[:i], slice[i+1:]...) - row := checkinDB().Delete(&c) + row := Database(c).Delete(&c) return row.Error() } @@ -211,7 +211,7 @@ func (c *Checkin) index() int { // Create will create a new Checkin func (c *Checkin) Create() (int64, error) { c.ApiKey = utils.RandomString(7) - row := checkinDB().Create(&c) + row := Database(c).Create(&c) if row.Error() != nil { log.Warnln(row.Error()) return 0, row.Error() @@ -225,7 +225,7 @@ func (c *Checkin) Create() (int64, error) { // Update will update a Checkin func (c *Checkin) Update() (int64, error) { - row := checkinDB().Update(&c) + row := Database(c).Update(&c) if row.Error() != nil { log.Warnln(row.Error()) return 0, row.Error() @@ -238,7 +238,7 @@ func (c *CheckinHit) Create() (int64, error) { if c.CreatedAt.IsZero() { c.CreatedAt = utils.Now() } - row := checkinHitsDB().Create(&c) + row := Database(c).Create(&c) if row.Error() != nil { log.Warnln(row.Error()) return 0, row.Error() diff --git a/core/core.go b/core/core.go index e4db19c0..00445db4 100644 --- a/core/core.go +++ b/core/core.go @@ -83,7 +83,7 @@ func InsertNotifierDB() error { return errors.New("database connection has not been created") } } - notifier.SetDB(DbSession, CoreApp.Timezone) + notifier.SetDB(DbSession) return nil } @@ -101,7 +101,7 @@ func InsertIntegratorDB() error { // UpdateCore will update the CoreApp variable inside of the 'core' table in database func UpdateCore(c *Core) (*Core, error) { - db := coreDB().Update(&c) + db := Database(&Core{}).Update(&c) return c, db.Error() } @@ -116,7 +116,7 @@ func (c Core) CurrentTime() string { // Messages will return the current local time func (c Core) Messages() []*Message { var message []*Message - messagesDb().Where("service = ?", 0).Limit(10).Find(&message) + Database(&Message{}).Where("service = ?", 0).Limit(10).Find(&message) return message } @@ -130,7 +130,7 @@ func (c Core) SassVars() string { if !source.UsingAssets(utils.Directory) { return "" } - return source.OpenAsset(utils.Directory, "scss/variables.scss") + return source.OpenAsset("scss/variables.scss") } // BaseSASS is the base design , this opens the file /assets/scss/base.scss to be edited in Theme @@ -138,7 +138,7 @@ func (c Core) BaseSASS() string { if !source.UsingAssets(utils.Directory) { return "" } - return source.OpenAsset(utils.Directory, "scss/base.scss") + return source.OpenAsset("scss/base.scss") } // MobileSASS is the -webkit responsive custom css designs. This opens the @@ -147,7 +147,7 @@ func (c Core) MobileSASS() string { if !source.UsingAssets(utils.Directory) { return "" } - return source.OpenAsset(utils.Directory, "scss/mobile.scss") + return source.OpenAsset("scss/mobile.scss") } // AllOnline will be true if all services are online @@ -171,7 +171,7 @@ func SelectCore() (*Core, error) { log.Errorf("core database has not been setup yet, does not have the 'core' table") return nil, errors.New("core database has not been setup yet.") } - db := coreDB().First(&CoreApp) + db := Database(&Core{}).First(&CoreApp) if db.Error() != nil { return nil, db.Error() } diff --git a/core/database.go b/core/database.go index bc29722d..9cee93bf 100644 --- a/core/database.go +++ b/core/database.go @@ -47,68 +47,42 @@ func init() { // DbConfig stores the config.yml file for the statup configuration type DbConfig types.DbConfig -// failuresDB returns the 'failures' database column -func failuresDB() types.Database { - return DbSession.Model(&types.Failure{}) -} - -// hitsDB returns the 'hits' database column -func hitsDB() types.Database { - return DbSession.Model(&types.Hit{}) -} - -// servicesDB returns the 'services' database column -func servicesDB() types.Database { - return DbSession.Model(&types.Service{}) -} - -// coreDB returns the single column 'core' -func coreDB() types.Database { - return DbSession.Table("core").Model(&CoreApp) -} - -// usersDB returns the 'users' database column -func usersDB() types.Database { - return DbSession.Model(&types.User{}) -} - -// checkinDB returns the Checkin records for a service -func checkinDB() types.Database { - return DbSession.Model(&types.Checkin{}) -} - -// checkinHitsDB returns the Checkin Hits records for a service -func checkinHitsDB() types.Database { - return DbSession.Model(&types.CheckinHit{}) -} - -// messagesDb returns the Checkin records for a service -func messagesDb() types.Database { - return DbSession.Model(&types.Message{}) -} - -// messagesDb returns the Checkin records for a service -func groupsDb() types.Database { - return DbSession.Model(&types.Group{}) -} - -// incidentsDB returns the 'incidents' database column -func incidentsDB() types.Database { - return DbSession.Model(&types.Incident{}) -} - -// incidentsUpdatesDB returns the 'incidents updates' database column -func incidentsUpdatesDB() types.Database { - return DbSession.Model(&types.IncidentUpdate{}) +func Database(obj interface{}) types.Database { + switch obj.(type) { + case *types.Service, *Service, []*Service: + return DbSession.Model(&types.Service{}) + case *types.Hit, *Hit, []*Hit: + return DbSession.Model(&types.Hit{}) + case *types.Failure, *Failure, []*Failure: + return DbSession.Model(&types.Failure{}) + case *types.Core, *Core: + return DbSession.Table("core").Model(&CoreApp) + case *types.Checkin, *Checkin, []*Checkin: + return DbSession.Model(&types.Checkin{}) + case *types.CheckinHit, *CheckinHit, []*CheckinHit: + return DbSession.Model(&types.CheckinHit{}) + case *types.User, *User, []*User: + return DbSession.Model(&types.User{}) + case *types.Group, *Group, []*Group: + return DbSession.Model(&types.Group{}) + case *types.Incident, *Incident, []*Incident: + return DbSession.Model(&types.Incident{}) + case *types.IncidentUpdate, *IncidentUpdate, []*IncidentUpdate: + return DbSession.Model(&types.IncidentUpdate{}) + case *types.Message, *Message, []*Message: + return DbSession.Model(&types.Message{}) + default: + return DbSession + } } // HitsBetween returns the gorm database query for a collection of service hits between a time range func (s *Service) HitsBetween(t1, t2 time.Time, group string, column string) types.Database { selector := Dbtimestamp(group, column) if CoreApp.Config.DbConn == "postgres" { - return hitsDB().Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.UTC().Format(types.TIME), t2.UTC().Format(types.TIME)) + return Database(&Hit{}).Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.UTC().Format(types.TIME), t2.UTC().Format(types.TIME)) } else { - return hitsDB().Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.UTC().Format(types.TIME_DAY), t2.UTC().Format(types.TIME_DAY)) + return Database(&Hit{}).Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.UTC().Format(types.TIME_DAY), t2.UTC().Format(types.TIME_DAY)) } } @@ -186,7 +160,7 @@ func (c *Core) InsertCore(db *types.DbConfig) (*Core, error) { MigrationId: time.Now().Unix(), Config: db, }} - query := coreDB().Create(&CoreApp) + query := Database(CoreApp).Create(&CoreApp) return CoreApp, query.Error() } @@ -345,7 +319,7 @@ func (c *Core) CreateCore() *Core { Domain: c.Domain, MigrationId: time.Now().Unix(), } - db := coreDB().Create(&newCore) + db := Database(newCore).Create(&newCore) if db.Error() == nil { CoreApp = &Core{Core: newCore} } @@ -409,7 +383,7 @@ func (c *Core) MigrateDatabase() error { } if err := tx.Table("core").AutoMigrate(&types.Core{}); err.Error() != nil { tx.Rollback() - log.Errorln(fmt.Sprintf("Statping Database could not be migrated: %v", tx.Error)) + log.Errorln(fmt.Sprintf("Statping Database could not be migrated: %v", tx.Error())) return tx.Error() } log.Infoln("Statping Database Migrated") diff --git a/core/failures.go b/core/failures.go index 3cc23d37..f80b3835 100644 --- a/core/failures.go +++ b/core/failures.go @@ -37,7 +37,7 @@ const ( // CreateFailure will create a new Failure record for a service func (s *Service) CreateFailure(f *types.Failure) (int64, error) { f.Service = s.Id - row := failuresDB().Create(f) + row := Database(&types.Failure{}).Create(f) if row.Error() != nil { log.Errorln(row.Error()) return 0, row.Error() @@ -62,7 +62,7 @@ func (s *Service) AllFailures() []types.Failure { } func (s *Service) FailuresDb(r *http.Request) types.Database { - return failuresDB().Where("service = ?", s.Id).QuerySearch(r).Order("id desc") + return Database(&types.Failure{}).Where("service = ?", s.Id).QuerySearch(r).Order("id desc") } // DeleteFailures will delete all failures for a service @@ -77,14 +77,14 @@ func (s *Service) DeleteFailures() { // LimitedFailures will return the last amount of failures from a service func (s *Service) LimitedFailures(amount int) []*Failure { var failArr []*Failure - failuresDB().Where("service = ?", s.Id).Not("method = 'checkin'").Order("id desc").Limit(amount).Find(&failArr) + Database(&types.Failure{}).Where("service = ?", s.Id).Not("method = 'checkin'").Order("id desc").Limit(amount).Find(&failArr) return failArr } // LimitedFailures will return the last amount of failures from a service func (s *Service) LimitedCheckinFailures(amount int) []*Failure { var failArr []*Failure - failuresDB().Where("service = ?", s.Id).Where("method = 'checkin'").Order("id desc").Limit(amount).Find(&failArr) + Database(&types.Failure{}).Where("service = ?", s.Id).Where("method = 'checkin'").Order("id desc").Limit(amount).Find(&failArr) return failArr } @@ -101,7 +101,7 @@ func (f *Failure) Select() *types.Failure { // Delete will remove a Failure record from the database func (f *Failure) Delete() error { - db := failuresDB().Delete(f) + db := Database(&types.Failure{}).Delete(f) return db.Error() } @@ -119,9 +119,9 @@ func (c *Core) Count24HFailures() uint64 { // CountFailures returns the total count of failures for all services func CountFailures() uint64 { var count uint64 - err := failuresDB().Count(&count) + err := Database(&types.Failure{}).Count(&count) if err.Error() != nil { - log.Warnln(err.Error) + log.Warnln(err.Error()) return 0 } return count @@ -132,7 +132,7 @@ func (s *Service) TotalFailuresOnDate(ago time.Time) (uint64, error) { var count uint64 date := ago.UTC().Format("2006-01-02 00:00:00") dateend := ago.UTC().Format("2006-01-02") + " 23:59:59" - rows := failuresDB().Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, date, dateend).Not("method = 'checkin'") + rows := Database(&types.Failure{}).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, date, dateend).Not("method = 'checkin'") err := rows.Count(&count) return count, err.Error() } @@ -146,7 +146,7 @@ func (s *Service) TotalFailures24() (uint64, error) { // TotalFailures returns the total amount of failures for a service func (s *Service) TotalFailures() (uint64, error) { var count uint64 - rows := failuresDB().Where("service = ?", s.Id) + rows := Database(&types.Failure{}).Where("service = ?", s.Id) err := rows.Count(&count) return count, err.Error() } @@ -161,7 +161,7 @@ func (s *Service) FailuresDaysAgo(days int) uint64 { // TotalFailuresSince returns the total amount of failures for a service since a specific time/date func (s *Service) TotalFailuresSince(ago time.Time) (uint64, error) { var count uint64 - rows := failuresDB().Where("service = ? AND created_at > ?", s.Id, ago.UTC().Format("2006-01-02 15:04:05")).Not("method = 'checkin'") + rows := Database(&types.Failure{}).Where("service = ? AND created_at > ?", s.Id, ago.UTC().Format("2006-01-02 15:04:05")).Not("method = 'checkin'") err := rows.Count(&count) return count, err.Error() } diff --git a/core/groups.go b/core/groups.go index 3b4338a2..1741ad49 100644 --- a/core/groups.go +++ b/core/groups.go @@ -16,21 +16,21 @@ func (g *Group) Delete() error { s.GroupId = 0 s.Update(false) } - err := groupsDb().Delete(g) + err := Database(&Group{}).Delete(g) return err.Error() } // Create will create a group and insert it into the database func (g *Group) Create() (int64, error) { g.CreatedAt = time.Now().UTC() - db := groupsDb().Create(g) + db := Database(&Group{}).Create(g) return g.Id, db.Error() } // Update will update a group func (g *Group) Update() (int64, error) { g.UpdatedAt = time.Now().UTC() - db := groupsDb().Update(g) + db := Database(&Group{}).Update(g) return g.Id, db.Error() } @@ -64,7 +64,7 @@ func (g *Group) VisibleServices(auth bool) []*Service { func SelectGroups(includeAll bool, auth bool) []*Group { var groups []*Group var validGroups []*Group - groupsDb().Find(&groups).Order("order_id desc") + Database(&Group{}).Find(&groups).Order("order_id desc") for _, g := range groups { if !g.Public.Bool { if auth { diff --git a/core/hits.go b/core/hits.go index cbe8c379..2fd656df 100644 --- a/core/hits.go +++ b/core/hits.go @@ -27,7 +27,7 @@ type Hit struct { // CreateHit will create a new 'hit' record in the database for a successful/online service func (s *Service) CreateHit(h *types.Hit) (int64, error) { - db := hitsDB().Create(&h) + db := Database(&types.Hit{}).Create(&h) if db.Error() != nil { log.Errorln(db.Error()) return 0, db.Error() @@ -38,7 +38,7 @@ func (s *Service) CreateHit(h *types.Hit) (int64, error) { // CountHits returns a int64 for all hits for a service func (s *Service) CountHits() (int64, error) { var hits int64 - col := hitsDB().Where("service = ?", s.Id) + col := Database(&types.Hit{}).Where("service = ?", s.Id) err := col.Count(&hits) return hits, err.Error() } @@ -46,19 +46,19 @@ func (s *Service) CountHits() (int64, error) { // Hits returns all successful hits for a service func (s *Service) HitsQuery(r *http.Request) ([]*types.Hit, error) { var hits []*types.Hit - col := hitsDB().Where("service = ?", s.Id).QuerySearch(r).Order("id desc") + col := Database(&types.Hit{}).Where("service = ?", s.Id).QuerySearch(r).Order("id desc") err := col.Find(&hits) return hits, err.Error() } func (s *Service) HitsDb(r *http.Request) types.Database { - return hitsDB().Where("service = ?", s.Id).QuerySearch(r).Order("id desc") + return Database(&types.Hit{}).Where("service = ?", s.Id).QuerySearch(r).Order("id desc") } // Hits returns all successful hits for a service func (s *Service) Hits() ([]*types.Hit, error) { var hits []*types.Hit - col := hitsDB().Where("service = ?", s.Id).Order("id desc") + col := Database(&types.Hit{}).Where("service = ?", s.Id).Order("id desc") err := col.Find(&hits) return hits, err.Error() } @@ -66,7 +66,7 @@ func (s *Service) Hits() ([]*types.Hit, error) { // LimitedHits returns the last 1024 successful/online 'hit' records for a service func (s *Service) LimitedHits(amount int) ([]*types.Hit, error) { var hits []*types.Hit - col := hitsDB().Where("service = ?", s.Id).Order("id desc").Limit(amount) + col := Database(&types.Hit{}).Where("service = ?", s.Id).Order("id desc").Limit(amount) err := col.Find(&hits) return reverseHits(hits), err.Error() } @@ -82,21 +82,21 @@ func reverseHits(input []*types.Hit) []*types.Hit { // TotalHits returns the total amount of successful hits a service has func (s *Service) TotalHits() (uint64, error) { var count uint64 - col := hitsDB().Where("service = ?", s.Id).Count(&count) + col := Database(&types.Hit{}).Where("service = ?", s.Id).Count(&count) return count, col.Error() } // TotalHitsSince returns the total amount of hits based on a specific time/date func (s *Service) TotalHitsSince(ago time.Time) (uint64, error) { var count uint64 - rows := hitsDB().Where("service = ? AND created_at > ?", s.Id, ago.UTC().Format("2006-01-02 15:04:05")).Count(&count) + rows := Database(&types.Hit{}).Where("service = ? AND created_at > ?", s.Id, ago.UTC().Format("2006-01-02 15:04:05")).Count(&count) return count, rows.Error() } // Sum returns the added value Latency for all of the services successful hits. func (s *Service) Sum() float64 { var sum float64 - rows, _ := hitsDB().Where("service = ?", s.Id).Select("sum(latency) as total").Rows() + rows, _ := Database(&types.Hit{}).Where("service = ?", s.Id).Select("sum(latency) as total").Rows() for rows.Next() { rows.Scan(&sum) } diff --git a/core/incidents.go b/core/incidents.go index 42631723..125a0bc4 100644 --- a/core/incidents.go +++ b/core/incidents.go @@ -21,17 +21,17 @@ func ReturnIncident(u *types.Incident) *Incident { // SelectIncident returns the Incident based on the Incident's ID. func SelectIncident(id int64) (*Incident, error) { var incident Incident - err := incidentsDB().Where("id = ?", id).First(&incident) + err := Database(incident).Where("id = ?", id).First(&incident) return &incident, err.Error() } // AllIncidents will return all incidents and updates recorded func AllIncidents() []*Incident { var incidents []*Incident - incidentsDB().Find(&incidents).Order("id desc") + Database(incidents).Find(&incidents).Order("id desc") for _, i := range incidents { var updates []*types.IncidentUpdate - incidentsUpdatesDB().Find(&updates).Order("id desc") + Database(updates).Find(&updates).Order("id desc") i.Updates = updates } return incidents @@ -40,46 +40,46 @@ func AllIncidents() []*Incident { // Incidents will return the all incidents for a service func (s *Service) Incidents() []*Incident { var incidentArr []*Incident - incidentsDB().Where("service = ?", s.Id).Order("id desc").Find(&incidentArr) + Database(incidentArr).Where("service = ?", s.Id).Order("id desc").Find(&incidentArr) return incidentArr } // AllUpdates will return the all updates for an incident func (i *Incident) AllUpdates() []*IncidentUpdate { var updatesArr []*IncidentUpdate - incidentsUpdatesDB().Where("incident = ?", i.Id).Order("id desc").Find(&updatesArr) + Database(updatesArr).Where("incident = ?", i.Id).Order("id desc").Find(&updatesArr) return updatesArr } // Delete will remove a incident func (i *Incident) Delete() error { - err := incidentsDB().Delete(i) + err := Database(i).Delete(i) return err.Error() } // Create will create a incident and insert it into the database func (i *Incident) Create() (int64, error) { i.CreatedAt = time.Now().UTC() - db := incidentsDB().Create(i) + db := Database(i).Create(i) return i.Id, db.Error() } // Update will update a incident func (i *Incident) Update() (int64, error) { i.UpdatedAt = time.Now().UTC() - db := incidentsDB().Update(i) + db := Database(i).Update(i) return i.Id, db.Error() } // Delete will remove a incident update func (i *IncidentUpdate) Delete() error { - err := incidentsUpdatesDB().Delete(i) + err := Database(i).Delete(i) return err.Error() } // Create will create a incident update and insert it into the database func (i *IncidentUpdate) Create() (int64, error) { i.CreatedAt = time.Now().UTC() - db := incidentsUpdatesDB().Create(i) + db := Database(i).Create(i) return i.Id, db.Error() } diff --git a/core/integrations/csv_file_test.go b/core/integrations/csv_file_test.go index 89f0e693..3ec27e51 100644 --- a/core/integrations/csv_file_test.go +++ b/core/integrations/csv_file_test.go @@ -8,7 +8,7 @@ import ( ) func TestCsvFileIntegration(t *testing.T) { - data, err := ioutil.ReadFile("../../source/tmpl/bulk_import.csv") + data, err := ioutil.ReadFile("testdata/bulk_import.csv") require.Nil(t, err) t.Run("Set Field Value", func(t *testing.T) { diff --git a/core/integrations/docker_test.go b/core/integrations/docker_test.go index 49bb7f58..8c1a0cc6 100644 --- a/core/integrations/docker_test.go +++ b/core/integrations/docker_test.go @@ -8,6 +8,8 @@ import ( func TestDockerIntegration(t *testing.T) { + t.SkipNow() + t.Run("Set Field Value", func(t *testing.T) { formPost := map[string][]string{} formPost["path"] = []string{"unix:///var/run/docker.sock"} diff --git a/core/integrations/integrations_test.go b/core/integrations/integrations_test.go deleted file mode 100644 index 9aa152f1..00000000 --- a/core/integrations/integrations_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package integrations - -import ( - "github.com/stretchr/testify/assert" - "testing" -) - -func TestIntegrations(t *testing.T) { - - t.Run("Collect Integrations", func(t *testing.T) { - amount := len(Integrations) - assert.Equal(t, 3, amount) - }) - -} diff --git a/core/integrations/testdata/bulk_import.csv b/core/integrations/testdata/bulk_import.csv new file mode 100644 index 00000000..82230c30 --- /dev/null +++ b/core/integrations/testdata/bulk_import.csv @@ -0,0 +1,11 @@ +name,domain,expected,expected_status,interval,type,method,post_data,port,timeout,order,allow_notifications,public,group_id,headers,permalink,verify_ssl +Bulk Upload,http://google.com,,200,60s,http,get,,,60s,1,TRUE,TRUE,,Authorization=example,bulk_example,FALSE +JSON Post,https://jsonplaceholder.typicode.com/posts,,200,1m,http,post,"{""id"": 1, ""title"": 'foo', ""body"": 'bar', ""userId"": 1}",,15s,2,TRUE,TRUE,,Content-Type=application/json,json_post_example,FALSE +Google DNS,8.8.8.8,,,60s,tcp,,,53,10s,3,TRUE,TRUE,,,google_dns_example,FALSE +Google DNS UDP,8.8.8.8,,,60s,udp,,,53,10s,4,TRUE,TRUE,,,google_dns_udp_example,FALSE +Statping Demo Page,https://demo.statping.com/health,"(\""online\"": true)",200,30s,http,get,,,10s,5,TRUE,TRUE,,,demo_link,FALSE +Statping MySQL Page,https://mysql.statping.com/health,"(\""online\"": true)",200,30s,http,get,,,10s,6,TRUE,TRUE,,,mysql_demo_link,FALSE +Statping SQLite Page,https://sqlite.statping.com/health,"(\""online\"": true)",200,30s,http,get,,,10s,7,TRUE,TRUE,,,sqlite_demo_link,FALSE +Token Balance,https://status.tokenbalance.com/health,"(\""online\"": true)",200,30s,http,get,,,10s,8,TRUE,TRUE,,,token_balance,FALSE +CloudFlare DNS,1.1.1.1,,,60s,tcp,,,53,10s,9,TRUE,TRUE,,,cloudflare_dns_example,FALSE +Verisign DNS,64.6.64.4,,,60s,tcp,,,53,10s,10,TRUE,TRUE,,,verisign_dns_example,FALSE diff --git a/core/integrations/traefik_test.go b/core/integrations/traefik_test.go index 4da316bd..3e91de1f 100644 --- a/core/integrations/traefik_test.go +++ b/core/integrations/traefik_test.go @@ -8,15 +8,15 @@ import ( func TestTraefikIntegration(t *testing.T) { + t.SkipNow() + t.Run("List Services from Traefik", func(t *testing.T) { - t.SkipNow() services, err := TraefikIntegrator.List() require.Nil(t, err) assert.NotEqual(t, 0, len(services)) }) t.Run("Confirm Services from Traefik", func(t *testing.T) { - t.SkipNow() services, err := TraefikIntegrator.List() require.Nil(t, err) for _, s := range services { diff --git a/core/messages.go b/core/messages.go index ae226d2f..d9cc0c9f 100644 --- a/core/messages.go +++ b/core/messages.go @@ -28,7 +28,7 @@ type Message struct { // SelectServiceMessages returns all messages for a service func SelectServiceMessages(id int64) []*Message { var message []*Message - messagesDb().Where("service = ?", id).Limit(10).Find(&message) + Database(&Message{}).Where("service = ?", id).Limit(10).Find(&message) return message } @@ -40,14 +40,14 @@ func ReturnMessage(m *types.Message) *Message { // SelectMessages returns all messages func SelectMessages() ([]*Message, error) { var messages []*Message - db := messagesDb().Find(&messages).Order("id desc") + db := Database(&Message{}).Find(&messages).Order("id desc") return messages, db.Error() } // SelectMessage returns a Message based on the ID passed func SelectMessage(id int64) (*Message, error) { var message Message - db := messagesDb().Where("id = ?", id).Find(&message) + db := Database(&Message{}).Where("id = ?", id).Find(&message) return &message, db.Error() } @@ -61,7 +61,7 @@ func (m *Message) Service() *Service { // Create will create a Message and insert it into the database func (m *Message) Create() (int64, error) { m.CreatedAt = time.Now().UTC() - db := messagesDb().Create(m) + db := Database(&Message{}).Create(m) if db.Error() != nil { log.Errorln(fmt.Sprintf("Failed to create message %v #%v: %v", m.Title, m.Id, db.Error())) return 0, db.Error() @@ -71,13 +71,13 @@ func (m *Message) Create() (int64, error) { // Delete will delete a Message from database func (m *Message) Delete() error { - db := messagesDb().Delete(m) + db := Database(&Message{}).Delete(m) return db.Error() } // Update will update a Message in the database func (m *Message) Update() (*Message, error) { - db := messagesDb().Update(m) + db := Database(&Message{}).Update(m) if db.Error() != nil { log.Errorln(fmt.Sprintf("Failed to update message %v #%v: %v", m.Title, m.Id, db.Error())) return nil, db.Error() diff --git a/core/notifier/notifiers.go b/core/notifier/notifiers.go index 0f5ed556..aa24ef4b 100644 --- a/core/notifier/notifiers.go +++ b/core/notifier/notifiers.go @@ -93,8 +93,8 @@ type NotificationLog struct { // AfterFind for Notification will set the timezone func (n *Notification) AfterFind() (err error) { - n.CreatedAt = utils.Timezoner(n.CreatedAt, timezone) - n.UpdatedAt = utils.Timezoner(n.UpdatedAt, timezone) + n.CreatedAt = utils.Now() + n.UpdatedAt = utils.Now() return } @@ -116,9 +116,8 @@ func modelDb(n *Notification) types.Database { } // SetDB is called by core to inject the database for a notifier to use -func SetDB(d types.Database, zone float32) { +func SetDB(d types.Database) { db = d - timezone = zone } // asNotification accepts a Notifier and returns a Notification struct @@ -247,8 +246,8 @@ func Init(n Notifier) (*Notification, error) { var notify *Notification if err == nil { notify, _ = SelectNotification(n) - notify.CreatedAt = utils.Timezoner(notify.CreatedAt, timezone) - notify.UpdatedAt = utils.Timezoner(notify.UpdatedAt, timezone) + notify.CreatedAt = time.Now().UTC() + notify.UpdatedAt = time.Now().UTC() if notify.Delay.Seconds() == 0 { notify.Delay = time.Duration(1 * time.Second) } @@ -350,7 +349,7 @@ func (n *Notification) SentLastMinute() int { func (n *Notification) SentLast(since time.Time) int { sent := 0 for _, v := range n.Logs() { - lastTime := time.Time(v.Time) + lastTime := time.Time(v.Time).UTC() if lastTime.After(since) { sent++ } diff --git a/core/notifier/notifiers_test.go b/core/notifier/notifiers_test.go index 0b32df20..73a96d89 100644 --- a/core/notifier/notifiers_test.go +++ b/core/notifier/notifiers_test.go @@ -19,7 +19,6 @@ import ( "fmt" "github.com/hunterlong/statping/types" "github.com/hunterlong/statping/utils" - "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/sqlite" "github.com/stretchr/testify/assert" "testing" @@ -56,19 +55,20 @@ var core = &types.Core{ } func injectDatabase() { - utils.DeleteFile(dir + "/notifier.db") - db, _ = gorm.Open("sqlite3", dir+"/notifier.db") + sqlPath := dir + "/notifier.db" + utils.DeleteFile(sqlPath) + db, _ = types.Openw("sqlite3", sqlPath) db.CreateTable(&Notification{}) } func TestIsBasicType(t *testing.T) { - assert.True(t, isType(example, new(Notifier))) - assert.True(t, isType(example, new(BasicEvents))) - assert.True(t, isType(example, new(ServiceEvents))) - assert.True(t, isType(example, new(UserEvents))) - assert.True(t, isType(example, new(CoreEvents))) - assert.True(t, isType(example, new(NotifierEvents))) - assert.True(t, isType(example, new(Tester))) + assert.True(t, utils.IsType(example, new(Notifier))) + assert.True(t, utils.IsType(example, new(BasicEvents))) + assert.True(t, utils.IsType(example, new(ServiceEvents))) + assert.True(t, utils.IsType(example, new(UserEvents))) + assert.True(t, utils.IsType(example, new(CoreEvents))) + assert.True(t, utils.IsType(example, new(NotifierEvents))) + assert.True(t, utils.IsType(example, new(Tester))) } func TestIsInDatabase(t *testing.T) { diff --git a/core/sample.go b/core/sample.go index 0e8221ea..d4107584 100644 --- a/core/sample.go +++ b/core/sample.go @@ -207,7 +207,7 @@ func insertSampleCheckins() error { // InsertSampleHits will create a couple new hits for the sample services func InsertSampleHits() error { - tx := hitsDB().Begin() + tx := Database(&Hit{}).Begin() sg := new(sync.WaitGroup) for i := int64(1); i <= 5; i++ { sg.Add(1) @@ -250,7 +250,7 @@ func insertSampleCore() error { CreatedAt: time.Now().UTC(), UseCdn: types.NewNullBool(false), } - query := coreDB().Create(core) + query := Database(&Core{}).Create(core) return query.Error() } @@ -510,6 +510,7 @@ func TmpRecords(dbFile string) error { var err error CoreApp = NewCore() CoreApp.Name = "Tester" + CoreApp.Setup = true configs := &types.DbConfig{ DbConn: "sqlite", Project: "Tester", diff --git a/core/services.go b/core/services.go index 12f99b65..c7c4fab8 100644 --- a/core/services.go +++ b/core/services.go @@ -103,14 +103,14 @@ func (s *Service) CheckinProcess() { // AllCheckins will return a slice of AllCheckins for a Service func (s *Service) AllCheckins() []*Checkin { var checkin []*Checkin - checkinDB().Where("service = ?", s.Id).Find(&checkin) + Database(&Checkin{}).Where("service = ?", s.Id).Find(&checkin) return checkin } // SelectAllServices returns a slice of *core.Service to be store on []*core.Services, should only be called once on startup. func (c *Core) SelectAllServices(start bool) ([]*Service, error) { var services []*Service - db := servicesDB().Find(&services).Order("order_id desc") + db := Database(&Service{}).Find(&services).Order("order_id desc") if db.Error() != nil { log.Errorln(fmt.Sprintf("service error: %v", db.Error())) return nil, db.Error() @@ -354,9 +354,9 @@ func updateService(s *Service) { // Delete will remove a service from the database, it will also end the service checking go routine func (s *Service) Delete() error { i := s.index() - err := servicesDB().Delete(s) + err := Database(&Service{}).Delete(s) if err.Error() != nil { - log.Errorln(fmt.Sprintf("Failed to delete service %v. %v", s.Name, err.Error)) + log.Errorln(fmt.Sprintf("Failed to delete service %v. %v", s.Name, err.Error())) return err.Error() } s.Close() @@ -369,7 +369,7 @@ func (s *Service) Delete() error { // Update will update a service in the database, the service's checking routine can be restarted by passing true func (s *Service) Update(restart bool) error { - err := servicesDB().Update(&s) + err := Database(&Service{}).Update(&s) if err.Error() != nil { log.Errorln(fmt.Sprintf("Failed to update service %v. %v", s.Name, err)) return err.Error() @@ -396,7 +396,7 @@ func (s *Service) Update(restart bool) error { // Create will create a service and insert it into the database func (s *Service) Create(check bool) (int64, error) { s.CreatedAt = time.Now().UTC() - db := servicesDB().Create(s) + db := Database(&Service{}).Create(s) if db.Error() != nil { log.Errorln(fmt.Sprintf("Failed to create service %v #%v: %v", s.Name, s.Id, db.Error())) return 0, db.Error() diff --git a/core/users.go b/core/users.go index ce50c3ec..02eb45dc 100644 --- a/core/users.go +++ b/core/users.go @@ -35,35 +35,35 @@ func ReturnUser(u *types.User) *User { // CountUsers returns the amount of users func CountUsers() int64 { var amount int64 - usersDB().Count(&amount) + Database(&User{}).Count(&amount) return amount } // SelectUser returns the User based on the User's ID. func SelectUser(id int64) (*User, error) { var user User - err := usersDB().Where("id = ?", id).First(&user) + err := Database(&User{}).Where("id = ?", id).First(&user) return &user, err.Error() } // SelectUsername returns the User based on the User's username func SelectUsername(username string) (*User, error) { var user User - res := usersDB().Where("username = ?", username) + res := Database(&User{}).Where("username = ?", username) err := res.First(&user) return &user, err.Error() } // Delete will remove the User record from the database func (u *User) Delete() error { - return usersDB().Delete(u).Error() + return Database(&User{}).Delete(u).Error() } // Update will update the User's record in database func (u *User) Update() error { u.ApiKey = utils.NewSHA1Hash(5) u.ApiSecret = utils.NewSHA1Hash(10) - return usersDB().Update(u).Error() + return Database(&User{}).Update(u).Error() } // Create will insert a new User into the database @@ -72,7 +72,7 @@ func (u *User) Create() (int64, error) { u.Password = utils.HashPassword(u.Password) u.ApiKey = utils.NewSHA1Hash(5) u.ApiSecret = utils.NewSHA1Hash(10) - db := usersDB().Create(u) + db := Database(&User{}).Create(u) if db.Error() != nil { return 0, db.Error() } @@ -86,7 +86,7 @@ func (u *User) Create() (int64, error) { // SelectAllUsers returns all users func SelectAllUsers() ([]*User, error) { var users []*User - db := usersDB().Find(&users) + db := Database(&User{}).Find(&users) if db.Error() != nil { log.Errorln(fmt.Sprintf("Failed to load all users. %v", db.Error())) return nil, db.Error() diff --git a/frontend/config/webpack.config.common.js b/frontend/config/webpack.config.common.js index 0c700769..5a85a3f7 100644 --- a/frontend/config/webpack.config.common.js +++ b/frontend/config/webpack.config.common.js @@ -1,7 +1,6 @@ 'use strict'; const VueLoaderPlugin = require('vue-loader/lib/plugin'); -const HtmlPlugin = require('html-webpack-plugin'); const MiniCSSExtractPlugin = require('mini-css-extract-plugin'); const helpers = require('./helpers'); const isDev = process.env.NODE_ENV === 'development'; @@ -60,8 +59,7 @@ const webpackConfig = { ] }, plugins: [ - new VueLoaderPlugin(), - new HtmlPlugin({ template: 'public/index.html', chunksSortMode: 'dependency' }) + new VueLoaderPlugin() ] }; diff --git a/frontend/config/webpack.config.dev.js b/frontend/config/webpack.config.dev.js index a226d8bb..a04d7837 100644 --- a/frontend/config/webpack.config.dev.js +++ b/frontend/config/webpack.config.dev.js @@ -2,6 +2,7 @@ const webpack = require('webpack'); const merge = require('webpack-merge'); +const HtmlPlugin = require('html-webpack-plugin'); const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin'); const helpers = require('./helpers'); const commonConfig = require('./webpack.config.common'); @@ -25,7 +26,11 @@ const webpackConfig = merge(commonConfig, { plugins: [ new webpack.EnvironmentPlugin(environment), new webpack.HotModuleReplacementPlugin(), - new FriendlyErrorsPlugin() + new FriendlyErrorsPlugin(), + new HtmlPlugin({ + template: 'public/index.html', + chunksSortMode: 'dependency' + }) ], devServer: { compress: true, diff --git a/frontend/config/webpack.config.prod.js b/frontend/config/webpack.config.prod.js index 84d8a3b3..523da6bf 100644 --- a/frontend/config/webpack.config.prod.js +++ b/frontend/config/webpack.config.prod.js @@ -2,6 +2,7 @@ const webpack = require('webpack'); const merge = require('webpack-merge'); +const HtmlPlugin = require('html-webpack-plugin'); const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const MiniCSSExtractPlugin = require('mini-css-extract-plugin'); const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); @@ -48,7 +49,7 @@ const webpackConfig = merge(commonConfig, { }, styles: { test: /\.css$/, - name: 'styles', + name: 'style', chunks: 'all', enforce: true } @@ -59,7 +60,7 @@ const webpackConfig = merge(commonConfig, { new webpack.EnvironmentPlugin(environment), new MiniCSSExtractPlugin({ filename: 'css/[name].css', - chunkFilename: 'css/[name].[hash].css' + chunkFilename: 'css/[name].css' }), new CompressionPlugin({ filename: '[path].gz[query]', @@ -68,7 +69,13 @@ const webpackConfig = merge(commonConfig, { threshold: 10240, minRatio: 0.8 }), - new webpack.HashedModuleIdsPlugin() + new webpack.HashedModuleIdsPlugin(), + new HtmlPlugin({ + template: 'public/base.gohtml', + filename: 'base.gohtml', + inject: false, + minify: false + }) ] }); diff --git a/frontend/package.json b/frontend/package.json index 32e92bac..e1a5ecc2 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,12 +4,11 @@ "private": true, "scripts": { "serve": "vue-cli-service serve", - "build": "rm -rf dist && cross-env NODE_ENV=production webpack", + "build": "rm -rf dist && cross-env NODE_ENV=production webpack --mode production", "dev": "cross-env NODE_ENV=development webpack-dev-server --host 0.0.0.0 --port 8888 --progress", "lint": "vue-cli-service lint" }, "dependencies": { - "@babel/polyfill": "~7.2", "@fortawesome/fontawesome-free-solid": "^5.1.0-3", "@fortawesome/fontawesome-svg-core": "^1.2.26", "@fortawesome/free-brands-svg-icons": "^5.12.0", @@ -37,6 +36,7 @@ "@babel/plugin-proposal-json-strings": "~7.2", "@babel/plugin-syntax-dynamic-import": "~7.2", "@babel/plugin-syntax-import-meta": "~7.2", + "@babel/polyfill": "~7.2", "@babel/preset-env": "~7.8.3", "@vue/babel-preset-app": "^4.1.2", "@vue/cli-plugin-babel": "^4.1.0", @@ -57,7 +57,7 @@ "eslint-plugin-vue": "~5.1", "file-loader": "^5.0.2", "friendly-errors-webpack-plugin": "~1.7", - "html-webpack-plugin": "~3.2", + "html-webpack-plugin": "^4.0.0-beta.11", "mini-css-extract-plugin": "~0.5", "node-sass": "^4.13.1", "optimize-css-assets-webpack-plugin": "~5.0", diff --git a/frontend/public/base.gohtml b/frontend/public/base.gohtml new file mode 100644 index 00000000..f9fb8378 --- /dev/null +++ b/frontend/public/base.gohtml @@ -0,0 +1,34 @@ +{{ define "base" }} + + + + + {{Name}} + + + + + {{if USE_CDN}} + + {{else}} + + <% _.each(htmlWebpackPlugin.tags.headTags, function(headTag) { %> + <%= headTag %> <% }) %> + {{end}} + + + + +
+ +{{if USE_CDN}} + +{{else}} +<% _.each(htmlWebpackPlugin.tags.bodyTags, function(bodyTag) { %> +<%= bodyTag %> <% }) %> +{{end}} + + +{{end}} diff --git a/frontend/src/components/Service/ServiceFailures.vue b/frontend/src/components/Service/ServiceFailures.vue new file mode 100644 index 00000000..a786933b --- /dev/null +++ b/frontend/src/components/Service/ServiceFailures.vue @@ -0,0 +1,75 @@ + + + + + + diff --git a/frontend/src/forms/Login.vue b/frontend/src/forms/Login.vue new file mode 100644 index 00000000..f92d2869 --- /dev/null +++ b/frontend/src/forms/Login.vue @@ -0,0 +1,70 @@ + + + + + + diff --git a/frontend/src/forms/Message.vue b/frontend/src/forms/Message.vue index 52b60061..e20127a1 100644 --- a/frontend/src/forms/Message.vue +++ b/frontend/src/forms/Message.vue @@ -41,13 +41,6 @@ -
- -
- -
-
-
@@ -58,7 +51,14 @@
-
+
+ +
+ +
+
+ +
diff --git a/frontend/src/forms/Setup.vue b/frontend/src/forms/Setup.vue index c20847f5..efbed611 100644 --- a/frontend/src/forms/Setup.vue +++ b/frontend/src/forms/Setup.vue @@ -11,7 +11,7 @@
- @@ -19,23 +19,23 @@
- +
- +
- +
- +
- +
@@ -44,37 +44,37 @@
- +
- +
- +
- +
- +
- +
- +
@@ -85,7 +85,7 @@ {{error}}
-
@@ -105,6 +105,7 @@ return { error: null, loading: false, + disabled: true, setup: { db_connection: "sqlite", db_host: "", @@ -128,7 +129,7 @@ if (!this.$store.getters.hasPublicData) { await this.$store.dispatch('loadRequired') } - this.$router.push('/') + this.$router.push('/') } }, mounted() { @@ -136,12 +137,23 @@ }, methods: { canSubmit() { - if (this.db_connection !== 'sqlite') { - if (!this.db_host || !this.db_port || !this.db_user || !this.db_password || !this.db_database) { - return false + this.error = null + const s = this.setup + if (s.db_connection !== 'sqlite') { + if (!s.db_host || !s.db_port || !s.db_user || !s.db_password || !s.db_database) { + this.disabled = true + return } } - return !(!this.project || !this.description || !this.domain || !this.username || !this.password || !this.confirm_password); + if (!s.project || !s.description || !s.domain || !s.username || !s.password || !s.confirm_password) { + this.disabled = true + return + } + if (s.password !== s.confirm_password) { + this.disabled = true + return + } + this.disabled = false }, async saveSetup() { this.loading = true diff --git a/frontend/src/forms/User.vue b/frontend/src/forms/User.vue index c5acfa67..bf45168e 100644 --- a/frontend/src/forms/User.vue +++ b/frontend/src/forms/User.vue @@ -82,7 +82,6 @@ watch: { in_user() { const u = this.in_user - delete u.password this.user = u } }, diff --git a/frontend/src/pages/Dashboard.vue b/frontend/src/pages/Dashboard.vue index 7283019f..98efe272 100644 --- a/frontend/src/pages/Dashboard.vue +++ b/frontend/src/pages/Dashboard.vue @@ -19,12 +19,6 @@ authenticated: false } }, - async mounted() { - const core = await Api.core() - if (!core.logged_in) { - this.$router.push('/login') - } - }, } diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index 653e85a6..aa3a6df1 100644 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -5,30 +5,7 @@
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
+
@@ -36,34 +13,20 @@ diff --git a/frontend/src/pages/Service.vue b/frontend/src/pages/Service.vue index 2862e706..adb00cd9 100644 --- a/frontend/src/pages/Service.vue +++ b/frontend/src/pages/Service.vue @@ -60,16 +60,7 @@
-
- -
-
-
{{failure.issue}}
- {{failure.created_at | moment("dddd, MMMM Do YYYY")}} -
-

{{failure.issue}}

-
-
+
@@ -109,6 +100,7 @@