Skip to content

Commit

Permalink
language
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlong committed Jun 4, 2020
1 parent eddf378 commit 128c53e
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 37 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.90.46 (06-04-2020)
- Add i18n language translations for frontend
- Added PR for heatmap https://github.com/statping/statping/pull/589
- Added Statping newsletter option during /setup mode
- Fix for disabling logs with `DISABLE_LOGS` env

# 0.90.45 (06-01-2020)
- Merged PR [#612](https://github.com/statping/statping/pull/612) for edit/create service issue.

Expand Down
30 changes: 15 additions & 15 deletions frontend/src/forms/Setup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="row">
<div class="col-6">
<div class="form-group">
<label>{{ $t('setup.language') }}</label>
<label class="text-capitalize">{{ $t('setup.language') }}</label>
<select @change="changeLanguages" v-model="setup.language" id="language" class="form-control">
<option value="en">English</option>
<option value="es">Spanish</option>
Expand All @@ -19,31 +19,31 @@
</select>
</div>
<div class="form-group">
<label>{{ $t('setup.connection') }}</label>
<label class="text-capitalize">{{ $t('setup.connection') }}</label>
<select @change="canSubmit" v-model="setup.db_connection" id="db_connection" class="form-control">
<option value="sqlite">SQLite</option>
<option value="postgres">Postgres</option>
<option value="mysql">MySQL</option>
</select>
</div>
<div v-if="setup.db_connection !== 'sqlite'" class="form-group">
<label>{{ $t('setup.host') }}</label>
<label class="text-capitalize">{{ $t('setup.host') }}</label>
<input @keyup="canSubmit" v-model="setup.db_host" id="db_host" type="text" class="form-control" placeholder="localhost">
</div>
<div v-if="setup.db_connection !== 'sqlite'" class="form-group">
<label>{{ $t('port') }}</label>
<label class="text-capitalize">{{ $t('port') }}</label>
<input @keyup="canSubmit" v-model="setup.db_port" id="db_port" type="text" class="form-control" placeholder="localhost">
</div>
<div v-if="setup.db_connection !== 'sqlite'" class="form-group">
<label>{{ $t('username') }}</label>
<label class="text-capitalize">{{ $t('username') }}</label>
<input @keyup="canSubmit" v-model="setup.db_user" id="db_user" type="text" class="form-control" placeholder="root">
</div>
<div v-if="setup.db_connection !== 'sqlite'" class="form-group">
<label for="db_password">{{ $t('password') }}</label>
<label for="db_password" class="text-capitalize">{{ $t('password') }}</label>
<input @keyup="canSubmit" v-model="setup.db_password" id="db_password" type="password" class="form-control" placeholder="password123">
</div>
<div v-if="setup.db_connection !== 'sqlite'" class="form-group">
<label for="db_database">{{ $t('database') }}</label>
<label for="db_database" class="text-capitalize">{{ $t('database') }}</label>
<input @keyup="canSubmit" v-model="setup.db_database" id="db_database" type="text" class="form-control" placeholder="Database name">
</div>

Expand All @@ -52,43 +52,43 @@
<div class="col-6">

<div class="form-group">
<label>{{ $t('setup.project_name') }}</label>
<label class="text-capitalize">{{ $t('setup.project_name') }}</label>
<input @keyup="canSubmit" v-model="setup.project" id="project" type="text" class="form-control" placeholder="Great Uptime" required>
</div>

<div class="form-group">
<label>{{ $t('setup.project_description') }}</label>
<label class="text-capitalize">{{ $t('setup.project_description') }}</label>
<input @keyup="canSubmit" v-model="setup.description" id="description" type="text" class="form-control" placeholder="Great Uptime">
</div>

<div class="form-group">
<label for="domain">{{ $t('setup.domain') }}</label>
<label class="text-capitalize" for="domain">{{ $t('setup.domain') }}</label>
<input @keyup="canSubmit" v-model="setup.domain" type="text" class="form-control" id="domain" required>
</div>

<div class="form-group">
<label>{{ $t('setup.username') }}</label>
<label class="text-capitalize">{{ $t('setup.username') }}</label>
<input @keyup="canSubmit" v-model="setup.username" id="username" type="text" class="form-control" placeholder="admin" required>
</div>

<div class="form-group">
<label>{{ $t('setup.username') }}</label>
<label class="text-capitalize">{{ $t('setup.username') }}</label>
<input @keyup="canSubmit" v-model="setup.password" id="password" type="password" class="form-control" placeholder="password" required>
</div>

<div class="form-group">
<label>{{ $t('setup.password_confirm') }}</label>
<label class="text-capitalize">{{ $t('setup.password_confirm') }}</label>
<input @keyup="canSubmit" v-model="setup.confirm_password" id="password_confirm" type="password" class="form-control" placeholder="password" required>
</div>

<div class="form-group">
<div class="row">
<div class="col-8">
<label>{{ $t('email') }}</label>
<label class="text-capitalize">{{ $t('email') }}</label>
<input @keyup="canSubmit" v-model="setup.email" id="email" type="text" class="form-control" placeholder="[email protected]">
</div>
<div class="col-4">
<label class="d-none d-sm-block">{{ $t('setup.newsletter') }}</label>
<label class="d-none d-sm-block text-capitalize text-capitalize">{{ $t('setup.newsletter') }}</label>
<span @click="setup.newsletter = !!setup.newsletter" class="switch">
<input v-model="setup.newsletter" type="checkbox" name="using_cdn" class="switch" id="send_newsletter" :checked="setup.newsletter">
<label for="send_newsletter"></label>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/languages/english.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const english = {
project_description: "Project Description",
domain: "Domain URL",
username: "Admin Username",
password: "Admin Username",
password: "Admin Password",
password_confirm: "Confirm Admin Username",
newsletter: "Newsletter",
newsletter_note: "We will not share your email, emails are only for major updates.",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/getsentry/sentry-go v0.5.1
github.com/go-mail/mail v2.3.1+incompatible
github.com/golang/protobuf v1.3.5
github.com/golang/protobuf v1.3.5 // indirect
github.com/gorilla/mux v1.7.4
github.com/jinzhu/gorm v1.9.12
github.com/magiconair/properties v1.8.1
Expand Down
19 changes: 17 additions & 2 deletions handlers/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/statping/statping/types/core"
"github.com/statping/statping/utils"
"net/http"
"net/http/pprof"
)

var (
Expand All @@ -29,7 +30,6 @@ func Router() *mux.Router {

authUser := utils.Params.GetString("AUTH_USERNAME")
authPass := utils.Params.GetString("AUTH_PASSWORD")

if authUser != "" && authPass != "" {
r.Use(basicAuthHandler)
}
Expand All @@ -45,7 +45,22 @@ func Router() *mux.Router {
r.Handle("/", sentryHandler.Handle(http.HandlerFunc(indexHandler)))
}

r.Use(sendLog)
if !utils.Params.GetBool("DISABLE_LOGS") {
r.Use(sendLog)
}

if utils.Params.GetString("GO_ENV") == "test" {
go func() {
log.Infoln("Starting pprof web server on http://0.0.0.0:9090")
r := http.NewServeMux()
r.HandleFunc("/debug/pprof/", pprof.Index)
r.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
r.HandleFunc("/debug/pprof/profile", pprof.Profile)
r.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
r.HandleFunc("/debug/pprof/trace", pprof.Trace)
http.ListenAndServe(":9090", r)
}()
}

if source.UsingAssets(dir) {
indexHandler := http.FileServer(http.Dir(dir + "/assets/"))
Expand Down
12 changes: 12 additions & 0 deletions utils/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
"github.com/spf13/viper"
"io/ioutil"
"os"
"time"
)
Expand All @@ -28,6 +29,17 @@ func InitCLI() {
Params.ReadInConfig()

Params.Set("VERSION", version)

// check if logs are disabled
disableLogs = Params.GetBool("DISABLE_LOGS")
if disableLogs {
Log.Out = ioutil.Discard
}

Log.Debugln("current working directory: ", Directory)
Log.AddHook(new(hook))
Log.SetNoLock()
checkVerboseMode()
}

func setDefaults() {
Expand Down
5 changes: 3 additions & 2 deletions utils/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func createLog(dir string) error {

// InitLogs will create the '/logs' directory and creates a file '/logs/statup.log' for application logging
func InitLogs() error {
if Params.GetBool("DISABLE_LOGS") {
return nil
}
if err := createLog(Directory); err != nil {
return err
}
Expand All @@ -164,8 +167,6 @@ func InitLogs() error {
DisableColors: false,
})
checkVerboseMode()

LastLines = make([]*logRow, 0)
return nil
}

Expand Down
15 changes: 0 additions & 15 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@ var (
disableLogs bool
)

// init will set the utils.Directory to the current running directory, or STATPING_DIR if it is set
func init() {
InitCLI()
// check if logs are disabled
disableLogs = Params.GetBool("DISABLE_LOGS")
if disableLogs {
Log.Out = ioutil.Discard
}

Log.Debugln("current working directory: ", Directory)
Log.AddHook(new(hook))
Log.SetNoLock()
checkVerboseMode()
}

type env struct {
data interface{}
}
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.90.45
0.90.46

0 comments on commit 128c53e

Please sign in to comment.