Skip to content

Commit b878df4

Browse files
Mike Jolleycsharpfritz
authored andcommitted
Fixed a few issues with the Follower UI & FollowerCountConfiguration.LoadDefaultSettings method (#226)
* Fixed issue in FollowersCountConfiguration model that overwrote any custom background or font color codes that were already set. * Improved follower configuration UI to display based on a provided background & font color or display by default using values in the app.settings.
1 parent a94c554 commit b878df4

File tree

3 files changed

+30
-44
lines changed

3 files changed

+30
-44
lines changed

Fritz.StreamTools/Controllers/FollowersController.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,22 @@ public IActionResult Count(FollowerCountConfiguration model)
8181
return View("Docs_Count");
8282
}
8383

84-
// TODO: Read this from AppSettings?
8584
model.LoadDefaultSettings(CountConfiguration);
8685

87-
if (model.CurrentValue == 0)
88-
{
89-
model.CurrentValue = StreamService.CurrentFollowerCount;
90-
}
91-
92-
93-
86+
if (model.CurrentValue == 0)
87+
{
88+
model.CurrentValue = StreamService.CurrentFollowerCount;
89+
}
9490

9591
return View(model);
9692

9793
}
9894

9995
[Route("followers/count/configuration", Name ="ConfigurationFollowerCount")]
100-
public IActionResult CountConfigurationAction()
96+
public IActionResult CountConfigurationAction(FollowerCountConfiguration model)
10197
{
102-
return View("CountConfiguration");
98+
model.LoadDefaultSettings(CountConfiguration);
99+
return View("CountConfiguration", model);
103100
}
104101

105102
[Route("followers/goal/{*stuff}")]

Fritz.StreamTools/Models/FollowerCountConfiguration.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ public class FollowerCountConfiguration
1616

1717
internal void LoadDefaultSettings(FollowerCountConfiguration config)
1818
{
19-
this.BackgroundColor = string.IsNullOrWhiteSpace(this.BackgroundColor) ? config.BackgroundColor : "#000";
20-
this.FontColor = string.IsNullOrWhiteSpace(this.FontColor) ? config.FontColor : "#32cd32";
21-
19+
this.BackgroundColor = string.IsNullOrWhiteSpace(this.BackgroundColor) ? config.BackgroundColor : this.BackgroundColor;
20+
this.FontColor = string.IsNullOrWhiteSpace(this.FontColor) ? config.FontColor : this.FontColor;
2221
}
2322

2423
}

Fritz.StreamTools/Views/Followers/CountConfiguration.cshtml

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<div class="col-md-6 mb-3 form-inline">
2323
<label asp-for="BackgroundColor"></label>
2424
&nbsp;
25-
<input type="color" asp-for="BackgroundColor" value="#CCCCCC" />
25+
<input type="color" asp-for="BackgroundColor" value="@nameof(Model.FontColor)" />
2626
</div>
2727
</div>
2828

@@ -54,17 +54,15 @@
5454
FontColor: "@nameof(Model.FontColor)"
5555
};
5656
57-
var log = function (message, params) {
58-
@if (HostingEnvironment.IsDevelopment())
59-
{
60-
<text>console.log(message, params);</text>
61-
}
62-
};
63-
64-
(function () {
65-
66-
//document.getElementById('fontsPanel').style.display = 'none';
57+
var log = function (message, params) {
58+
@if (HostingEnvironment.IsDevelopment())
59+
{
60+
<text>console.log(message, params);</text>
61+
}
62+
};
6763
64+
(
65+
function () {
6866
loadPreview();
6967
7068
InitPreview();
@@ -83,33 +81,25 @@
8381
}
8482
8583
document.getElementById(quickPreviewButton).onclick = loadPreview;
86-
8784
}
8885
86+
function loadPreview() {
8987
90-
function loadPreview() {
91-
92-
const iframeWidth = document.getElementById("widgetPreview").clientWidth - 40;
93-
94-
95-
var urlTemplate = "/followers/count?";
96-
urlTemplate += `${ConfigurationModel.BackgroundColor}=${escape(document.getElementById(ConfigurationModel.BackgroundColor).value)}`;
97-
urlTemplate += `&${ConfigurationModel.FontColor}=${escape(document.getElementById(ConfigurationModel.FontColor).value)}`;
98-
//urlTemplate += `&fontName=${escape(fontName)}`;
99-
100-
document.getElementById("widgetPreview").src = urlTemplate + `&${ConfigurationModel.CurrentValue}=${document.getElementById(ConfigurationModel.CurrentValue).value}`
101-
log(urlTemplate);
102-
103-
document.getElementById("outputUrl").textContent = urlTemplate;
104-
document.getElementById("outputUrl").href = urlTemplate;
105-
//saveValues();
106-
107-
}
88+
const iframeWidth = document.getElementById("widgetPreview").clientWidth - 40;
10889
90+
var urlTemplate = "/followers/count?";
91+
urlTemplate += `${ConfigurationModel.BackgroundColor}=${escape(document.getElementById(ConfigurationModel.BackgroundColor).value)}`;
92+
urlTemplate += `&${ConfigurationModel.FontColor}=${escape(document.getElementById(ConfigurationModel.FontColor).value)}`;
93+
//urlTemplate += `&fontName=${escape(fontName)}`;
10994
95+
document.getElementById("widgetPreview").src = urlTemplate + `&${ConfigurationModel.CurrentValue}=${document.getElementById(ConfigurationModel.CurrentValue).value}`
96+
log(urlTemplate);
11097
98+
document.getElementById("outputUrl").textContent = urlTemplate;
99+
document.getElementById("outputUrl").href = urlTemplate;
100+
//saveValues();
111101
102+
}
112103
113104
</script>
114-
115105
}

0 commit comments

Comments
 (0)