Skip to content

Commit d35d9c4

Browse files
committed
FR-181 - added sized adjustment
1 parent dfd951f commit d35d9c4

File tree

8 files changed

+60
-11
lines changed

8 files changed

+60
-11
lines changed

Components/PanelUserSettings/PanelUserSettings.razor

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@
6666
Code="UpdateDashboardSetting('LinkTarget', event)" />
6767
</span>
6868
</div>
69+
70+
71+
<div class="setting integer">
72+
<span class="label">@Translator.Instant($"Labels.SizeAdjustment")</span>
73+
<span class="value">
74+
@{
75+
var value = 0;
76+
int min = -5;
77+
int max = 5;
78+
var percent = (double)(value - min) / (max - min) * 100;
79+
var style = $"background-size: {percent}% 100%";
80+
<input onchange="UpdateSetting('SizeAdjustment', event)" id="slider-SizeAdjustment" style="@style" type="range" min="@min" max="@max" value="@value" />
81+
<span class="range-value" id="SizeAdjustment-value">@value</span>
82+
}
83+
</span>
84+
</div>
85+
86+
87+
6988
@if (SearchEngines?.Any() == true || SystemSearchEngines?.Any() == true)
7089
{
7190
<div class="setting">

Controllers/DashboardAppController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public IActionResult Icon([FromRoute] string name, [FromRoute] string iconFile)
6363
/// <returns>the app</returns>
6464
private AppInstance? GetAppInstance(Guid userUid, string name, Guid uid)
6565
{
66-
6766
List<Group> groups;
6867
string groupKey = userUid + "_Groups";
6968
lock (Cache)
@@ -77,7 +76,6 @@ public IActionResult Icon([FromRoute] string name, [FromRoute] string iconFile)
7776
}
7877
}
7978

80-
8179
if (groups.SelectMany(x => x.Items).FirstOrDefault(x => x.Uid == uid) is AppItem userApp == false)
8280
return null;
8381

Models/UserSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class UserSettings: IModal
2828
/// Gets or sets the language for this user
2929
/// </summary>
3030
public string Language { get; set; }
31-
31+
3232
/// <summary>
3333
/// Gets or sets the users theme settings
3434
/// </summary>

Views/Shared/_Layout.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
var themeInstance = ViewBag.Theme;
1313
var theme = themeInstance.Name;
1414
bool isGuest = ViewBag.IsGuest;
15-
var userSettings = ViewBag.UserSettings;
15+
var userSettings = ViewBag.UserSettings as UserSettings;
1616
var dashboards = ViewBag.Dashboards;
1717
var dashboard = ViewBag.Dashboard;
1818
var searchEngines = ViewBag.SearchEngines;
@@ -42,6 +42,7 @@
4242
</style>
4343
}
4444

45+
4546
@{
4647
var accentColor = ViewBag.AccentColor ?? "#FF0090";
4748
var bkgColor = ViewBag.BackgroundColor ?? "#009099";

i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"Address": "Address",
6666
"Icon": "Icon",
6767
"UnsavedTitle": "Warning Unsaved Changed",
68-
"UnsavedMessage": "Warning: Leaving this page without saving will result in the loss of any unsaved changes. Please make sure to save your work before navigating away."
68+
"UnsavedMessage": "Warning: Leaving this page without saving will result in the loss of any unsaved changes. Please make sure to save your work before navigating away.",
69+
"SizeAdjustment": "Zoom"
6970
},
7071
"ContextMenu": {
7172
"EditDashboard": "Edit Dashboard",

wwwroot/css/01_site.scss

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ html {
1515
min-height: 100%;
1616
// font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"
1717
font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
18-
font-size:13px;
18+
--site-font-size:13px;
19+
font-size:var(--site-font-size);
1920
font-weight: 400;
2021
}
21-
@media only screen and (min-resolution: 108dpi), only screen and (min-resolution: 1.08dppx) {
22-
html {
23-
font-size: 13px;
24-
}
25-
}
2622
body {
2723
/* variables */
2824
--color-rgb: 240, 240, 240;

wwwroot/fenrus.png

42.7 KB
Loading

wwwroot/js/site.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ function UpdateSetting(setting, event)
218218
changeDashboard(event);
219219
return;
220220
}
221+
if(setting === 'SizeAdjustment'){
222+
let value = event.target.value;
223+
localStorage.setItem('SizeAdjustment', value);
224+
sizeAdjustment(value);
225+
return;
226+
}
221227
UpdateSettingValue(`/settings/update-setting/${setting}/#VALUE#`, event);
222228
}
223229

@@ -367,6 +373,7 @@ async function UpdateThemeSetting(theme, setting, event)
367373

368374
function UpdateSettingValue(url, event)
369375
{
376+
let dashboardSetting = url.indexOf('/dashboard') >= 0;
370377
return new Promise((resolve, reject) => {
371378

372379
if(event?.target?.className === 'slider round') {
@@ -399,6 +406,9 @@ function UpdateSettingValue(url, event)
399406
window.location.reload();
400407
return;
401408
}
409+
410+
if(!dashboardSetting)
411+
return;
402412

403413
let eleDashboard = document.querySelector('.dashboard');
404414
eleDashboard.classList.remove('hide-group-titles');
@@ -515,3 +525,27 @@ window.focusElement = (element, delay) => {
515525
element.focus();
516526
}
517527
};
528+
529+
530+
document.addEventListener("DOMContentLoaded", function() {
531+
let size = parseInt(localStorage.getItem('SizeAdjustment') || 0);
532+
if (isNaN(size))
533+
size = 0;
534+
sizeAdjustment(size);
535+
});
536+
537+
function sizeAdjustment(size){
538+
document.documentElement.style.fontSize = `calc(var(--site-font-size) + ${size}px)`;
539+
let ele = document.getElementById('slider-SizeAdjustment');
540+
if(ele) {
541+
let min = -5;
542+
let max = 5;
543+
let percent = ((size - min) / (max - min)) * 100;
544+
ele.style.backgroundSize = `${percent}% 100%`;
545+
if(ele.value !== size)
546+
ele.value = size;
547+
}
548+
let eleValue = document.getElementById('SizeAdjustment-value');
549+
if(eleValue)
550+
eleValue.innerText = size;
551+
}

0 commit comments

Comments
 (0)