2018-12-04 05:57:11 +00:00
|
|
|
// Statping
|
2018-08-16 06:22:20 +00:00
|
|
|
// Copyright (C) 2018. Hunter Long and the project contributors
|
|
|
|
// Written by Hunter Long <info@socialeck.com> and the project contributors
|
|
|
|
//
|
2018-12-04 04:17:29 +00:00
|
|
|
// https://github.com/hunterlong/statping
|
2018-08-16 06:22:20 +00:00
|
|
|
//
|
|
|
|
// The licenses for most software and other practical works are designed
|
|
|
|
// to take away your freedom to share and change the works. By contrast,
|
|
|
|
// the GNU General Public License is intended to guarantee your freedom to
|
|
|
|
// share and change all versions of a program--to make sure it remains free
|
|
|
|
// software for all its users.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2020-03-04 10:29:00 +00:00
|
|
|
package handlers
|
2018-06-23 05:59:29 +00:00
|
|
|
|
|
|
|
import (
|
2020-02-25 17:39:38 +00:00
|
|
|
"encoding/json"
|
2020-03-04 10:29:00 +00:00
|
|
|
"github.com/hunterlong/statping/types/checkins"
|
|
|
|
"github.com/hunterlong/statping/types/core"
|
|
|
|
"github.com/hunterlong/statping/types/groups"
|
|
|
|
"github.com/hunterlong/statping/types/messages"
|
|
|
|
"github.com/hunterlong/statping/types/services"
|
|
|
|
"github.com/hunterlong/statping/types/users"
|
2018-06-23 05:59:29 +00:00
|
|
|
)
|
|
|
|
|
2018-10-07 04:48:33 +00:00
|
|
|
// ExportChartsJs renders the charts for the index page
|
2018-11-25 03:56:09 +00:00
|
|
|
|
|
|
|
type ExportData struct {
|
2020-03-05 08:27:51 +00:00
|
|
|
Core *core.Core `json:"core"`
|
|
|
|
Services map[int64]*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"`
|
2018-11-25 03:56:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-09 04:20:43 +00:00
|
|
|
// ExportSettings will export a JSON file containing all of the settings below:
|
|
|
|
// - Core
|
|
|
|
// - Notifiers
|
|
|
|
// - Checkins
|
|
|
|
// - Users
|
|
|
|
// - Services
|
|
|
|
// - Groups
|
|
|
|
// - Messages
|
2020-02-25 17:39:38 +00:00
|
|
|
func ExportSettings() ([]byte, error) {
|
|
|
|
data := ExportData{
|
2020-03-04 10:29:00 +00:00
|
|
|
Core: core.App,
|
|
|
|
//Notifiers: notifications.All(),
|
|
|
|
Checkins: checkins.All(),
|
|
|
|
Users: users.All(),
|
2020-03-05 08:27:51 +00:00
|
|
|
Services: services.Services(),
|
2020-03-04 10:29:00 +00:00
|
|
|
Groups: groups.All(),
|
|
|
|
Messages: messages.All(),
|
2020-02-25 17:39:38 +00:00
|
|
|
}
|
|
|
|
export, err := json.Marshal(data)
|
|
|
|
return export, err
|
|
|
|
}
|