Move settings bundles into own file
This commit is contained in:
@@ -8,15 +8,14 @@ require (
|
||||
github.com/gogo/protobuf v1.3.1 // indirect
|
||||
github.com/golang/protobuf v1.4.1
|
||||
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.14.4 // indirect
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/micro/cli/v2 v2.1.2
|
||||
github.com/micro/go-micro/v2 v2.0.1-0.20200212105717-d76baf59de2e
|
||||
github.com/micro/micro/v2 v2.0.1-0.20200210100719-f38a1d8d5348
|
||||
github.com/oklog/run v1.1.0
|
||||
github.com/owncloud/ocis-pkg/v2 v2.2.1
|
||||
github.com/owncloud/ocis-settings v0.0.0-20200511093940-0fddb624d0da
|
||||
github.com/restic/calens v0.2.0
|
||||
github.com/spf13/afero v1.2.2 // indirect
|
||||
github.com/spf13/viper v1.6.3
|
||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84
|
||||
google.golang.org/protobuf v1.22.0
|
||||
|
||||
@@ -538,6 +538,7 @@ github.com/micro/go-micro v1.18.0/go.mod h1:klwUJL1gkdY1MHFyz+fFJXn52dKcty4hoe95
|
||||
github.com/micro/go-micro/v2 v2.0.0 h1:bMx549RwJ9Yuiui8cDVlfYhVNP8I8KBJTMyLthEXpRw=
|
||||
github.com/micro/go-micro/v2 v2.0.0/go.mod h1:v7QP5UhKRt37ixjJe8DouWmg0/eE6dltr5h0idJ9BpE=
|
||||
github.com/micro/go-micro/v2 v2.0.1-0.20200207205803-ef537270add3/go.mod h1:CDPVByZzOp1RNrJfNxEGgNOJ11wEw8NoHfADo8M3+LM=
|
||||
github.com/micro/go-micro/v2 v2.0.1-0.20200212105717-d76baf59de2e h1:EXYgiOLVc7zkUCIsAc++GQiOvPRh/gaGl++fqY1807g=
|
||||
github.com/micro/go-micro/v2 v2.0.1-0.20200212105717-d76baf59de2e/go.mod h1:CDPVByZzOp1RNrJfNxEGgNOJ11wEw8NoHfADo8M3+LM=
|
||||
github.com/micro/go-micro/v2 v2.5.1-0.20200417165434-16db76bee2fb h1:LjGUj/0hVn8pn8I+MoJCctj1gQny14lqT3a6v5THEoo=
|
||||
github.com/micro/go-micro/v2 v2.5.1-0.20200417165434-16db76bee2fb/go.mod h1:qz2UT4UFdFVs+qUGMuDK3xuHgude1BgntqQ29sbpPlE=
|
||||
@@ -668,6 +669,8 @@ github.com/owncloud/ocis-pkg v1.2.1-0.20191217084055-eab942498596/go.mod h1:Wo0Q
|
||||
github.com/owncloud/ocis-pkg/v2 v2.0.1/go.mod h1:7bVnn3VUaqdmvpMkXF0QVEF1fRugs35hSkuVTAq9yjk=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.2.1 h1:LK7WxHYugEFQ9NHTOz0EP8DRjbt51wXhyqruV03z6zI=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.2.1/go.mod h1:MXv7QzsYsu4YWuyJxhq1kLLmJa/r5gbqHe1FXulMHaw=
|
||||
github.com/owncloud/ocis-settings v0.0.0-20200511093940-0fddb624d0da h1:VVkg5s6zs37MvKZ1YQK0/dfN3D+WQ7VuESOfnrhdqP4=
|
||||
github.com/owncloud/ocis-settings v0.0.0-20200511093940-0fddb624d0da/go.mod h1:1PyfbVIZMTX21JxsRT+maRIjRFD3H+yhfpr1jMz3PeA=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
|
||||
+6
-210
@@ -3,11 +3,11 @@ package service
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/go-micro/v2"
|
||||
"github.com/owncloud/ocis-accounts/pkg/account"
|
||||
"github.com/owncloud/ocis-accounts/pkg/config"
|
||||
"github.com/owncloud/ocis-accounts/pkg/proto/v0"
|
||||
olog "github.com/owncloud/ocis-pkg/v2/log"
|
||||
mclient "github.com/micro/go-micro/v2/client"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
@@ -73,19 +73,17 @@ func (s Service) Search(ctx context.Context, in *proto.Query, res *proto.Records
|
||||
|
||||
// RegisterSettingsBundles pushes the settings bundle definitions for this extension to the ocis-settings service.
|
||||
func RegisterSettingsBundles(l *olog.Logger) {
|
||||
// TODO it's ok if this fails. But show a warning that the settings service is not reachable. Make sure that init doesn't die if the settings service is not reachable.
|
||||
svc := micro.NewService()
|
||||
svc.Init()
|
||||
service := settings.NewBundleService("com.owncloud.api.settings", svc.Client()) // TODO fetch service name instead of hardcoding it.
|
||||
// TODO this won't work with a registry other than mdns. Look into Micro's client initialization.
|
||||
// https://github.com/owncloud/ocis-proxy/issues/38
|
||||
service := settings.NewBundleService("com.owncloud.api.settings", mclient.DefaultClient)
|
||||
|
||||
// TODO avoid hardcoding these values, perhaps load them from a file and using jsonpb's type Marshal.
|
||||
requests := []settings.SaveSettingsBundleRequest{
|
||||
generateSettingsBundleProfileRequest(),
|
||||
generateSettingsBundleNotificationsRequest(),
|
||||
}
|
||||
|
||||
for _, request := range requests {
|
||||
res, err := service.SaveSettingsBundle(context.Background(), &request)
|
||||
for i := range requests {
|
||||
res, err := service.SaveSettingsBundle(context.Background(), &requests[i])
|
||||
if err != nil {
|
||||
l.Err(err).
|
||||
Msg("Error registering settings bundle")
|
||||
@@ -96,205 +94,3 @@ func RegisterSettingsBundles(l *olog.Logger) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func generateSettingsBundleProfileRequest() settings.SaveSettingsBundleRequest {
|
||||
return settings.SaveSettingsBundleRequest{
|
||||
SettingsBundle: &settings.SettingsBundle{
|
||||
Identifier: &settings.Identifier{
|
||||
Extension: "ocis-accounts",
|
||||
BundleKey: "profile",
|
||||
},
|
||||
DisplayName: "Profile",
|
||||
Settings: []*settings.Setting{
|
||||
{
|
||||
SettingKey: "firstname",
|
||||
DisplayName: "Firstname",
|
||||
Description: "Input for firstname",
|
||||
Value: &settings.Setting_StringValue{
|
||||
StringValue: &settings.StringSetting{
|
||||
Placeholder: "Set firstname",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "lastname",
|
||||
DisplayName: "Lastname",
|
||||
Description: "Input for lastname",
|
||||
Value: &settings.Setting_StringValue{
|
||||
StringValue: &settings.StringSetting{
|
||||
Placeholder: "Set lastname",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "age",
|
||||
DisplayName: "Age",
|
||||
Description: "Input for age",
|
||||
Value: &settings.Setting_IntValue{
|
||||
IntValue: &settings.IntSetting{
|
||||
Placeholder: "Set age",
|
||||
Min: 16,
|
||||
Max: 200,
|
||||
Step: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "timezone",
|
||||
DisplayName: "Timezone",
|
||||
Description: "User timezone",
|
||||
Value: &settings.Setting_SingleChoiceValue{
|
||||
SingleChoiceValue: &settings.SingleChoiceListSetting{
|
||||
Options: []*settings.ListOption{
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "Europe/Berlin",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Europe/Berlin",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "Asia/Kathmandu",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Asia/Kathmandu",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "language",
|
||||
DisplayName: "Language",
|
||||
Description: "User language",
|
||||
Value: &settings.Setting_SingleChoiceValue{
|
||||
SingleChoiceValue: &settings.SingleChoiceListSetting{
|
||||
Options: []*settings.ListOption{
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "cs",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Czech",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "de",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Deutsch",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "en",
|
||||
},
|
||||
},
|
||||
DisplayValue: "English",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "es",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Español",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "fr",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Français",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "gl",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Galego",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "it",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Italiano",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func generateSettingsBundleNotificationsRequest() settings.SaveSettingsBundleRequest {
|
||||
return settings.SaveSettingsBundleRequest{
|
||||
SettingsBundle: &settings.SettingsBundle{
|
||||
Identifier: &settings.Identifier{
|
||||
Extension: "ocis-accounts",
|
||||
BundleKey: "notifications",
|
||||
},
|
||||
DisplayName: "Notifications",
|
||||
Settings: []*settings.Setting{
|
||||
{
|
||||
SettingKey: "email",
|
||||
DisplayName: "Email",
|
||||
Value: &settings.Setting_BoolValue{
|
||||
BoolValue: &settings.BoolSetting{
|
||||
Default: false,
|
||||
Label: "Send via email",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "stream",
|
||||
DisplayName: "Stream",
|
||||
Value: &settings.Setting_BoolValue{
|
||||
BoolValue: &settings.BoolSetting{
|
||||
Default: true,
|
||||
Label: "Show in stream",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "transport",
|
||||
DisplayName: "Transport",
|
||||
Value: &settings.Setting_MultiChoiceValue{
|
||||
MultiChoiceValue: &settings.MultiChoiceListSetting{
|
||||
Options: []*settings.ListOption{
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "email",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Send via email",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "stream",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Show in stream",
|
||||
Default: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
package service
|
||||
|
||||
import settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
|
||||
func generateSettingsBundleProfileRequest() settings.SaveSettingsBundleRequest {
|
||||
return settings.SaveSettingsBundleRequest{
|
||||
SettingsBundle: &settings.SettingsBundle{
|
||||
Identifier: &settings.Identifier{
|
||||
Extension: "ocis-accounts",
|
||||
BundleKey: "profile",
|
||||
},
|
||||
DisplayName: "Profile",
|
||||
Settings: []*settings.Setting{
|
||||
{
|
||||
SettingKey: "firstname",
|
||||
DisplayName: "Firstname",
|
||||
Description: "Input for firstname",
|
||||
Value: &settings.Setting_StringValue{
|
||||
StringValue: &settings.StringSetting{
|
||||
Placeholder: "Set firstname",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "lastname",
|
||||
DisplayName: "Lastname",
|
||||
Description: "Input for lastname",
|
||||
Value: &settings.Setting_StringValue{
|
||||
StringValue: &settings.StringSetting{
|
||||
Placeholder: "Set lastname",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "age",
|
||||
DisplayName: "Age",
|
||||
Description: "Input for age",
|
||||
Value: &settings.Setting_IntValue{
|
||||
IntValue: &settings.IntSetting{
|
||||
Placeholder: "Set age",
|
||||
Min: 16,
|
||||
Max: 200,
|
||||
Step: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "timezone",
|
||||
DisplayName: "Timezone",
|
||||
Description: "User timezone",
|
||||
Value: &settings.Setting_SingleChoiceValue{
|
||||
SingleChoiceValue: &settings.SingleChoiceListSetting{
|
||||
Options: []*settings.ListOption{
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "Europe/Berlin",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Europe/Berlin",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "Asia/Kathmandu",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Asia/Kathmandu",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "language",
|
||||
DisplayName: "Language",
|
||||
Description: "User language",
|
||||
Value: &settings.Setting_SingleChoiceValue{
|
||||
SingleChoiceValue: &settings.SingleChoiceListSetting{
|
||||
Options: []*settings.ListOption{
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "cs",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Czech",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "de",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Deutsch",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "en",
|
||||
},
|
||||
},
|
||||
DisplayValue: "English",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "es",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Español",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "fr",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Français",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "gl",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Galego",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "it",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Italiano",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func generateSettingsBundleNotificationsRequest() settings.SaveSettingsBundleRequest {
|
||||
return settings.SaveSettingsBundleRequest{
|
||||
SettingsBundle: &settings.SettingsBundle{
|
||||
Identifier: &settings.Identifier{
|
||||
Extension: "ocis-accounts",
|
||||
BundleKey: "notifications",
|
||||
},
|
||||
DisplayName: "Notifications",
|
||||
Settings: []*settings.Setting{
|
||||
{
|
||||
SettingKey: "email",
|
||||
DisplayName: "Email",
|
||||
Value: &settings.Setting_BoolValue{
|
||||
BoolValue: &settings.BoolSetting{
|
||||
Default: false,
|
||||
Label: "Send via email",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "stream",
|
||||
DisplayName: "Stream",
|
||||
Value: &settings.Setting_BoolValue{
|
||||
BoolValue: &settings.BoolSetting{
|
||||
Default: true,
|
||||
Label: "Show in stream",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
SettingKey: "transport",
|
||||
DisplayName: "Transport",
|
||||
Value: &settings.Setting_MultiChoiceValue{
|
||||
MultiChoiceValue: &settings.MultiChoiceListSetting{
|
||||
Options: []*settings.ListOption{
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "email",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Send via email",
|
||||
},
|
||||
{
|
||||
Value: &settings.ListOptionValue{
|
||||
Option: &settings.ListOptionValue_StringValue{
|
||||
StringValue: "stream",
|
||||
},
|
||||
},
|
||||
DisplayValue: "Show in stream",
|
||||
Default: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user