Maps: Add animation duration to settings
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
5f91d0d17b
commit
09e2385c67
@ -1,2 +1,4 @@
|
||||
theme: default
|
||||
language: en
|
||||
maps:
|
||||
animate: 5000
|
||||
|
@ -63,6 +63,7 @@
|
||||
search: this.$gettext("Search"),
|
||||
},
|
||||
config: this.$config.values,
|
||||
settings: this.$config.values.settings.maps,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -127,7 +128,7 @@
|
||||
this.map.getSource("photos").setData(this.result);
|
||||
|
||||
if (this.filter.q || !this.initialized) {
|
||||
this.map.fitBounds(this.result.bbox, {maxZoom: 17, padding: 100, duration: 15000, essential: false, animate: true});
|
||||
this.map.fitBounds(this.result.bbox, {maxZoom: 17, padding: 100, duration: this.settings.animate, essential: false, animate: this.settings.animate > 0});
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
|
@ -24,6 +24,16 @@
|
||||
flat
|
||||
></v-select>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12 sm6 class="pr-3">
|
||||
<v-select
|
||||
:items="options.mapsAnimate"
|
||||
:label="labels.mapsAnimate"
|
||||
color="secondary-dark"
|
||||
v-model="settings.maps.animate"
|
||||
flat
|
||||
></v-select>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-btn color="secondary-dark"
|
||||
@ -52,6 +62,7 @@
|
||||
labels: {
|
||||
language: this.$gettext("Language"),
|
||||
theme: this.$gettext("Theme"),
|
||||
mapsAnimate: this.$gettext("Maps Animation"),
|
||||
},
|
||||
};
|
||||
},
|
||||
|
@ -46,5 +46,23 @@
|
||||
"text": "Seaweed",
|
||||
"value": "seaweed"
|
||||
}
|
||||
],
|
||||
"mapsAnimate": [
|
||||
{
|
||||
"text": "None",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"text": "Fast",
|
||||
"value": 5000
|
||||
},
|
||||
{
|
||||
"text": "Medium",
|
||||
"value": 10000
|
||||
},
|
||||
{
|
||||
"text": "Slow",
|
||||
"value": 15000
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ func (c *Config) PublicClientConfig() ClientConfig {
|
||||
}{}
|
||||
|
||||
result := ClientConfig{
|
||||
"settings": c.Settings(),
|
||||
"flags": strings.Join(flags, " "),
|
||||
"name": c.Name(),
|
||||
"url": c.Url(),
|
||||
@ -79,7 +80,6 @@ func (c *Config) PublicClientConfig() ClientConfig {
|
||||
"thumbnails": Thumbnails,
|
||||
"jsHash": jsHash,
|
||||
"cssHash": cssHash,
|
||||
"settings": c.Settings(),
|
||||
"count": count,
|
||||
"pos": noPos,
|
||||
"years": []int{},
|
||||
|
@ -9,15 +9,26 @@ import (
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type MapsSettings struct {
|
||||
Animate int `json:"animate" yaml:"animate"`
|
||||
}
|
||||
|
||||
// Settings contains Web UI settings
|
||||
type Settings struct {
|
||||
Theme string `json:"theme" yaml:"theme" flag:"theme"`
|
||||
Language string `json:"language" yaml:"language" flag:"language"`
|
||||
Theme string `json:"theme" yaml:"theme"`
|
||||
Language string `json:"language" yaml:"language"`
|
||||
Maps MapsSettings `json:"maps" yaml:"maps"`
|
||||
}
|
||||
|
||||
// NewSettings returns a empty Settings
|
||||
func NewSettings() *Settings {
|
||||
return &Settings{}
|
||||
return &Settings{
|
||||
Theme: "default",
|
||||
Language: "en",
|
||||
Maps: MapsSettings{
|
||||
Animate: 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Load uses a yaml config file to initiate the configuration entity.
|
||||
|
@ -1,6 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -29,8 +30,8 @@ func TestSettings_Load(t *testing.T) {
|
||||
|
||||
assert.Error(t, err)
|
||||
|
||||
assert.Equal(t, "", c.Theme)
|
||||
assert.Equal(t, "", c.Language)
|
||||
assert.Equal(t, "default", c.Theme)
|
||||
assert.Equal(t, "en", c.Language)
|
||||
})
|
||||
}
|
||||
func TestSettings_Save(t *testing.T) {
|
||||
@ -56,6 +57,12 @@ func TestSettings_Save(t *testing.T) {
|
||||
|
||||
err := c.Save("testdata/configEmpty123.yml")
|
||||
|
||||
assert.Nil(t, err)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := os.Remove("testdata/configEmpty123.yml"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
2
internal/config/testdata/configEmpty.yml
vendored
2
internal/config/testdata/configEmpty.yml
vendored
@ -1,2 +1,4 @@
|
||||
theme: lavendel
|
||||
language: german
|
||||
maps:
|
||||
animate: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user