mirror of https://github.com/statping/statping
				
				
				
			
							parent
							
								
									24ccf94e3d
								
							
						
					
					
						commit
						277594f212
					
				
							
								
								
									
										2
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										2
									
								
								Makefile
								
								
								
								
							| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
VERSION=0.66
 | 
					VERSION=0.67
 | 
				
			||||||
BINARY_NAME=statup
 | 
					BINARY_NAME=statup
 | 
				
			||||||
GOPATH:=$(GOPATH)
 | 
					GOPATH:=$(GOPATH)
 | 
				
			||||||
GOCMD=go
 | 
					GOCMD=go
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -222,18 +222,13 @@ func (s *Service) Downtime() time.Duration {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func GraphDataRaw(service types.ServiceInterface, start, end time.Time) *DateScanObj {
 | 
					func GraphDataRaw(service types.ServiceInterface, start, end time.Time) *DateScanObj {
 | 
				
			||||||
	var d []DateScan
 | 
						var d []DateScan
 | 
				
			||||||
	//s := service.Select()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	model := service.(*Service).HitsBetween(start, end)
 | 
						model := service.(*Service).HitsBetween(start, end)
 | 
				
			||||||
	rows, _ := model.Rows()
 | 
						rows, _ := model.Rows()
 | 
				
			||||||
 | 
					 | 
				
			||||||
	//sql := GroupDataBy("hits", s.Id, start, end, 3600)
 | 
					 | 
				
			||||||
	for rows.Next() {
 | 
						for rows.Next() {
 | 
				
			||||||
		var gd DateScan
 | 
							var gd DateScan
 | 
				
			||||||
		var createdAt string
 | 
							var createdAt string
 | 
				
			||||||
		var value float64
 | 
							var value float64
 | 
				
			||||||
		rows.Scan(&createdAt, &value)
 | 
							rows.Scan(&createdAt, &value)
 | 
				
			||||||
 | 
					 | 
				
			||||||
		createdTime, _ := time.Parse(types.TIME, createdAt)
 | 
							createdTime, _ := time.Parse(types.TIME, createdAt)
 | 
				
			||||||
		gd.CreatedAt = utils.Timezoner(createdTime, CoreApp.Timezone).Format(types.TIME)
 | 
							gd.CreatedAt = utils.Timezoner(createdTime, CoreApp.Timezone).Format(types.TIME)
 | 
				
			||||||
		gd.Value = int64(value * 1000)
 | 
							gd.Value = int64(value * 1000)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,7 @@
 | 
				
			||||||
package handlers
 | 
					package handlers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"bytes"
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"github.com/hunterlong/statup/core"
 | 
						"github.com/hunterlong/statup/core"
 | 
				
			||||||
| 
						 | 
					@ -24,6 +25,8 @@ import (
 | 
				
			||||||
	"github.com/hunterlong/statup/types"
 | 
						"github.com/hunterlong/statup/types"
 | 
				
			||||||
	"github.com/hunterlong/statup/utils"
 | 
						"github.com/hunterlong/statup/utils"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func dashboardHandler(w http.ResponseWriter, r *http.Request) {
 | 
					func dashboardHandler(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
| 
						 | 
					@ -117,11 +120,18 @@ func exportHandler(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data := exportData{core.CoreApp, notifiers}
 | 
						data := exportData{core.CoreApp, notifiers}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	w.Header().Set("Content-Type", "application/json")
 | 
						export, _ := json.Marshal(data)
 | 
				
			||||||
	json.NewEncoder(w).Encode(data)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	w.Header().Set("Content-Disposition", "attachment; filename=Wiki.png")
 | 
						mime := http.DetectContentType(export)
 | 
				
			||||||
	w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
 | 
						fileSize := len(string(export))
 | 
				
			||||||
	w.Header().Set("Content-Length", r.Header.Get("Content-Length"))
 | 
					
 | 
				
			||||||
 | 
						w.Header().Set("Content-Type", mime)
 | 
				
			||||||
 | 
						w.Header().Set("Content-Disposition", "attachment; filename=export.json")
 | 
				
			||||||
 | 
						w.Header().Set("Expires", "0")
 | 
				
			||||||
 | 
						w.Header().Set("Content-Transfer-Encoding", "binary")
 | 
				
			||||||
 | 
						w.Header().Set("Content-Length", strconv.Itoa(fileSize))
 | 
				
			||||||
 | 
						w.Header().Set("Content-Control", "private, no-transform, no-store, must-revalidate")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						http.ServeContent(w, r, "export.json", time.Now(), bytes.NewReader(export))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -132,10 +132,14 @@
 | 
				
			||||||
                            <label for="api_secret" class="col-sm-3 col-form-label">API Secret</label>
 | 
					                            <label for="api_secret" class="col-sm-3 col-form-label">API Secret</label>
 | 
				
			||||||
                            <div class="col-sm-9">
 | 
					                            <div class="col-sm-9">
 | 
				
			||||||
                                <input type="text" class="form-control select-input" value="{{ .ApiSecret }}" id="api_secret" readonly>
 | 
					                                <input type="text" class="form-control select-input" value="{{ .ApiSecret }}" id="api_secret" readonly>
 | 
				
			||||||
                                <small id="emailHelp" class="form-text text-muted">You can <a href="/api/renew">Regenerate API Keys</a> if you need to.</small>
 | 
					                                <small class="form-text text-muted">You can <a href="/api/renew">Regenerate API Keys</a> if you need to.</small>
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        <div class="row">
 | 
				
			||||||
 | 
					                            <a href="/settings/export" class="btn btn-sm btn-secondary float-right">Export Settings</a>
 | 
				
			||||||
 | 
					                        </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    </form>
 | 
					                    </form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
| 
						 | 
					@ -256,9 +260,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <div class="tab-pane fade" id="v-pills-backups" role="tabpanel" aria-labelledby="v-pills-backups-tab">
 | 
					                <div class="tab-pane fade" id="v-pills-backups" role="tabpanel" aria-labelledby="v-pills-backups-tab">
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    <a href="/backups/create" class="btn btn-primary btn-block">Backup Database</a>
 | 
					                    <a href="/backups/create" class="btn btn-primary btn-block">Backup Database</a>
 | 
				
			||||||
 | 
					 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                {{ range .Plugins }}
 | 
					                {{ range .Plugins }}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue