-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
923ea14
commit 42e3315
Showing
8 changed files
with
415 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.IO; | ||
using System.Text.Json; | ||
|
||
[ApiController] | ||
[Route("api/settings")] | ||
public class SettingsController : ControllerBase | ||
{ | ||
private const string SettingsFilePath = "settings.json"; | ||
|
||
[HttpGet] | ||
public ActionResult<Settings> GetSettings() | ||
{ | ||
if (!System.IO.File.Exists(SettingsFilePath)) | ||
{ | ||
return new Settings(); | ||
} | ||
|
||
var json = System.IO.File.ReadAllText(SettingsFilePath); | ||
return JsonSerializer.Deserialize<Settings>(json); | ||
} | ||
|
||
[HttpPost] | ||
public IActionResult SaveSettings([FromBody] Settings settings) | ||
{ | ||
var json = JsonSerializer.Serialize(settings); | ||
System.IO.File.WriteAllText(SettingsFilePath, json); | ||
return Ok(); | ||
} | ||
} | ||
|
||
public class Settings | ||
{ | ||
public Updating Updating { get; set; } | ||
public Scanning Scanning { get; set; } | ||
public Counting Counting { get; set; } | ||
public Filtering Filtering { get; set; } | ||
public Calibration Calibration { get; set; } | ||
} | ||
|
||
public class Updating | ||
{ | ||
public bool AutoUpdate { get; set; } | ||
public bool PreRelease { get; set; } | ||
} | ||
|
||
public class Scanning | ||
{ | ||
public int? ForgetAfterMs { get; set; } | ||
} | ||
|
||
public class Counting | ||
{ | ||
public string IdPrefixes { get; set; } | ||
public double? StartCountingDistance { get; set; } | ||
public double? StopCountingDistance { get; set; } | ||
public int? IncludeDevicesAge { get; set; } | ||
} | ||
|
||
public class Filtering | ||
{ | ||
public string IncludeIds { get; set; } | ||
public string ExcludeIds { get; set; } | ||
public double? MaxReportDistance { get; set; } | ||
public double? EarlyReportDistance { get; set; } | ||
public int? SkipReportAge { get; set; } | ||
} | ||
|
||
public class Calibration | ||
{ | ||
public int? RssiAt1m { get; set; } | ||
public int? RssiAdjustment { get; set; } | ||
public double? AbsorptionFactor { get; set; } | ||
public int? IBeaconRssiAt1m { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.IO; | ||
using System.Text.Json; | ||
|
||
[ApiController] | ||
[Route("api/settings")] | ||
public class SettingsController : ControllerBase | ||
{ | ||
private const string SettingsFilePath = "settings.json"; | ||
|
||
[HttpGet] | ||
public ActionResult<Settings> GetSettings() | ||
{ | ||
if (!System.IO.File.Exists(SettingsFilePath)) | ||
{ | ||
return new Settings(); | ||
} | ||
|
||
var json = System.IO.File.ReadAllText(SettingsFilePath); | ||
return JsonSerializer.Deserialize<Settings>(json); | ||
} | ||
|
||
[HttpPost] | ||
public IActionResult SaveSettings([FromBody] Settings settings) | ||
{ | ||
var json = JsonSerializer.Serialize(settings); | ||
System.IO.File.WriteAllText(SettingsFilePath, json); | ||
return Ok(); | ||
} | ||
} | ||
|
||
public class Settings | ||
{ | ||
public UpdatingSettings Updating { get; set; } = new UpdatingSettings(); | ||
public ScanningSettings Scanning { get; set; } = new ScanningSettings(); | ||
public CountingSettings Counting { get; set; } = new CountingSettings(); | ||
public FilteringSettings Filtering { get; set; } = new FilteringSettings(); | ||
public CalibrationSettings Calibration { get; set; } = new CalibrationSettings(); | ||
} | ||
|
||
public class UpdatingSettings | ||
{ | ||
public bool? AutoUpdate { get; set; } | ||
public bool? PreRelease { get; set; } | ||
} | ||
|
||
public class ScanningSettings | ||
{ | ||
public int? ForgetAfterMs { get; set; } | ||
} | ||
|
||
public class CountingSettings | ||
{ | ||
public string IdPrefixes { get; set; } | ||
public double? StartCountingDistance { get; set; } | ||
public double? StopCountingDistance { get; set; } | ||
public int? IncludeDevicesAge { get; set; } | ||
} | ||
|
||
public class FilteringSettings | ||
{ | ||
public string IncludeIds { get; set; } | ||
public string ExcludeIds { get; set; } | ||
public double? MaxReportDistance { get; set; } | ||
public double? EarlyReportDistance { get; set; } | ||
public int? SkipReportAge { get; set; } | ||
} | ||
|
||
public class CalibrationSettings | ||
{ | ||
public int? RssiAt1m { get; set; } | ||
public int? RssiAdjustment { get; set; } | ||
public double? AbsorptionFactor { get; set; } | ||
public int? IBeaconRssiAt1m { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script lang="ts"> | ||
export let checked: boolean | null = false; | ||
export let id: string; | ||
function handleClick(event: Event) { | ||
const cb = event.target as HTMLInputElement; | ||
if (cb.readOnly) { | ||
cb.checked = false; | ||
cb.readOnly = false; | ||
checked = false; | ||
} else if (!cb.checked) { | ||
cb.readOnly = true; | ||
cb.indeterminate = true; | ||
checked = null; | ||
} else { | ||
checked = true; | ||
} | ||
} | ||
$: ariaChecked = checked === null ? 'mixed' : checked; | ||
</script> | ||
|
||
<input | ||
type="checkbox" | ||
class="checkbox" | ||
{id} | ||
on:click={handleClick} | ||
checked={checked === true} | ||
indeterminate={checked === null} | ||
readOnly={checked === null} | ||
aria-checked={ariaChecked} | ||
/> | ||
|
||
<style> | ||
input[type="checkbox"]:indeterminate { | ||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e"); | ||
} | ||
</style> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.