Skip to content

Commit

Permalink
HeatMap Color
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Dec 23, 2023
1 parent 5d8a967 commit 4f1b00d
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 72 deletions.
43 changes: 0 additions & 43 deletions .rename.sh

This file was deleted.

4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
All notable changes to this project will be documented in this file.


## [1.0.0] - 2023-07-25
## [0.1.0] - 2023-12-23
### Added
- One thing
- Config: HeatMap color

### Changed

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ Configuration can be done through config file or environment variables
| PORT | Port for web GUI | 8851 |
| THEME | Any theme name from https://bootswatch.com in lowcase | grass |
| COLOR | Background color: light or dark | light |
| HEATCOLOR | HeatMap color | #03a70c |
| TZ | Set your timezone for correct time | "" |

## Options

| Key | Description | Default |
| -------- | ----------- | ------- |
| -c | Path to config file | /data/exercisediary/config.yaml |
| -c | Path to config dir | /data/ExerciseDiary |

## Thanks
- All go packages listed in [dependencies](https://github.com/aceberg/exercisediary/network/dependencies)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: "3"
services:
ExerciseDiary:
image: aceberg/ExerciseDiary
image: aceberg/exercisediary
restart: unless-stopped
volumes:
- ~/.dockerdata/ExerciseDiary:/data/ExerciseDiary
environment:
TZ: Asia/Novosibirsk # required, default: ""
HOST: "0.0.0.0" # optional, default: 0.0.0.0
PORT: "8830" # optional, default: 8830
THEME: "simplex" # optional, default: simplex
COLOR: "dark" # optional, default: dark
PORT: "8851" # optional, default: 8851
THEME: "grass" # optional, default: grass
COLOR: "light" # optional, default: light
3 changes: 3 additions & 0 deletions internal/conf/getconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func Get(path string) models.Conf {
viper.SetDefault("PORT", "8851")
viper.SetDefault("THEME", "grass")
viper.SetDefault("COLOR", "light")
viper.SetDefault("HEATCOLOR", "#03a70c")

viper.SetConfigFile(path)
viper.SetConfigType("yaml")
Expand All @@ -27,6 +28,7 @@ func Get(path string) models.Conf {
config.Port, _ = viper.Get("PORT").(string)
config.Theme, _ = viper.Get("THEME").(string)
config.Color, _ = viper.Get("COLOR").(string)
config.HeatColor, _ = viper.Get("HEATCOLOR").(string)

return config
}
Expand All @@ -41,6 +43,7 @@ func Write(config models.Conf) {
viper.Set("port", config.Port)
viper.Set("theme", config.Theme)
viper.Set("color", config.Color)
viper.Set("heatcolor", config.HeatColor)

err := viper.WriteConfig()
check.IfError(err)
Expand Down
32 changes: 16 additions & 16 deletions internal/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package models

// Conf - web gui config
type Conf struct {
Host string
Port string
Theme string
Color string
Icon string
DBPath string
DirPath string
ConfPath string
NodePath string
Host string
Port string
Theme string
Color string
Icon string
DBPath string
DirPath string
ConfPath string
NodePath string
HeatColor string
}

// Exercise - one exercise
Expand Down Expand Up @@ -52,11 +53,10 @@ type HeatMapData struct {

// GuiData - web gui data
type GuiData struct {
Config Conf
Themes []string
ExData AllExData
GroupMap map[string]string
OneEx Exercise
HeatMap []HeatMapData
HeatColor string
Config Conf
Themes []string
ExData AllExData
GroupMap map[string]string
OneEx Exercise
HeatMap []HeatMapData
}
1 change: 1 addition & 0 deletions internal/web/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func saveConfigHandler(c *gin.Context) {
appConfig.Port = c.PostForm("port")
appConfig.Theme = c.PostForm("theme")
appConfig.Color = c.PostForm("color")
appConfig.HeatColor = c.PostForm("heatcolor")

conf.Write(appConfig)

Expand Down
1 change: 0 additions & 1 deletion internal/web/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func indexHandler(c *gin.Context) {
guiData.ExData = exData
guiData.GroupMap = createGroupMap()
guiData.HeatMap = generateHeatMap()
guiData.HeatColor = "#03a70c"

// Sort exercises by Place
sort.Slice(guiData.ExData.Exs, func(i, j int) bool {
Expand Down
7 changes: 3 additions & 4 deletions internal/web/public/js/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ function makeChart(heat, hcolor) {
options: {
onClick: (e) => {
const res = window.myMatrix.getElementsAtEventForMode(e, 'nearest', { intersect: true }, true);

console.log('res =', res[0].element.$context.raw.d);

// window.location.href = "/diary_show?from="+dayD+"&to="+dayD+"";
let clickDate = res[0].element.$context.raw.d;
console.log('CLICK DATE =', clickDate);
document.getElementById("formDate").value = clickDate;
},
plugins: {
legend: false,
Expand Down
6 changes: 6 additions & 0 deletions internal/web/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
<option value="dark">dark</option>
</select></td>
</tr>
<tr>
<td>HeatMap Color</td>
<td>
<input name="heatcolor" value="{{ .Config.HeatColor }}" type="color" class="form-control form-control-color">
</td>
</tr>
<tr>
<td><button type="submit" class="btn btn-primary">Save</button></td>
<td></td>
Expand Down
2 changes: 1 addition & 1 deletion internal/web/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h5 class="modal-title">Exercise details</h5>

<script>
setFormDateSets({{ .ExData.Sets }});
makeChart({{ .HeatMap }}, {{ .HeatColor }});
makeChart({{ .HeatMap }}, {{ .Config.HeatColor }});
</script>
{{ template "footer.html" }}
{{ end }}

0 comments on commit 4f1b00d

Please sign in to comment.