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
|
theme: default
|
||||||
language: en
|
language: en
|
||||||
|
maps:
|
||||||
|
animate: 5000
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
search: this.$gettext("Search"),
|
search: this.$gettext("Search"),
|
||||||
},
|
},
|
||||||
config: this.$config.values,
|
config: this.$config.values,
|
||||||
|
settings: this.$config.values.settings.maps,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -127,7 +128,7 @@
|
||||||
this.map.getSource("photos").setData(this.result);
|
this.map.getSource("photos").setData(this.result);
|
||||||
|
|
||||||
if (this.filter.q || !this.initialized) {
|
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;
|
this.initialized = true;
|
||||||
|
|
|
@ -24,6 +24,16 @@
|
||||||
flat
|
flat
|
||||||
></v-select>
|
></v-select>
|
||||||
</v-flex>
|
</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-layout>
|
||||||
|
|
||||||
<v-btn color="secondary-dark"
|
<v-btn color="secondary-dark"
|
||||||
|
@ -52,6 +62,7 @@
|
||||||
labels: {
|
labels: {
|
||||||
language: this.$gettext("Language"),
|
language: this.$gettext("Language"),
|
||||||
theme: this.$gettext("Theme"),
|
theme: this.$gettext("Theme"),
|
||||||
|
mapsAnimate: this.$gettext("Maps Animation"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -46,5 +46,23 @@
|
||||||
"text": "Seaweed",
|
"text": "Seaweed",
|
||||||
"value": "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{
|
result := ClientConfig{
|
||||||
|
"settings": c.Settings(),
|
||||||
"flags": strings.Join(flags, " "),
|
"flags": strings.Join(flags, " "),
|
||||||
"name": c.Name(),
|
"name": c.Name(),
|
||||||
"url": c.Url(),
|
"url": c.Url(),
|
||||||
|
@ -79,7 +80,6 @@ func (c *Config) PublicClientConfig() ClientConfig {
|
||||||
"thumbnails": Thumbnails,
|
"thumbnails": Thumbnails,
|
||||||
"jsHash": jsHash,
|
"jsHash": jsHash,
|
||||||
"cssHash": cssHash,
|
"cssHash": cssHash,
|
||||||
"settings": c.Settings(),
|
|
||||||
"count": count,
|
"count": count,
|
||||||
"pos": noPos,
|
"pos": noPos,
|
||||||
"years": []int{},
|
"years": []int{},
|
||||||
|
|
|
@ -9,15 +9,26 @@ import (
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type MapsSettings struct {
|
||||||
|
Animate int `json:"animate" yaml:"animate"`
|
||||||
|
}
|
||||||
|
|
||||||
// Settings contains Web UI settings
|
// Settings contains Web UI settings
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
Theme string `json:"theme" yaml:"theme" flag:"theme"`
|
Theme string `json:"theme" yaml:"theme"`
|
||||||
Language string `json:"language" yaml:"language" flag:"language"`
|
Language string `json:"language" yaml:"language"`
|
||||||
|
Maps MapsSettings `json:"maps" yaml:"maps"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSettings returns a empty Settings
|
// NewSettings returns a empty Settings
|
||||||
func NewSettings() *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.
|
// Load uses a yaml config file to initiate the configuration entity.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -29,8 +30,8 @@ func TestSettings_Load(t *testing.T) {
|
||||||
|
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
||||||
assert.Equal(t, "", c.Theme)
|
assert.Equal(t, "default", c.Theme)
|
||||||
assert.Equal(t, "", c.Language)
|
assert.Equal(t, "en", c.Language)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func TestSettings_Save(t *testing.T) {
|
func TestSettings_Save(t *testing.T) {
|
||||||
|
@ -56,6 +57,12 @@ func TestSettings_Save(t *testing.T) {
|
||||||
|
|
||||||
err := c.Save("testdata/configEmpty123.yml")
|
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
|
theme: lavendel
|
||||||
language: german
|
language: german
|
||||||
|
maps:
|
||||||
|
animate: 0
|
||||||
|
|
Loading…
Reference in a new issue