Moved otaServerUrl and otaServerBranch into newsettings

This commit is contained in:
2021-12-29 15:29:48 +01:00
parent 6138c187f4
commit 2c1aca079f
5 changed files with 12 additions and 20 deletions

View File

@@ -167,10 +167,10 @@ namespace buildserver {
std::string get_descriptor_url(std::string base_url) std::string get_descriptor_url(std::string base_url)
{ {
if (stringSettings.otaServerBranch.empty()) if (configs.otaServerBranch.value.empty())
return fmt::format("{}/otaDescriptor?username={}", base_url, configs.otaUsername.value); return fmt::format("{}/otaDescriptor?username={}", base_url, configs.otaUsername.value);
else else
return fmt::format("{}/otaDescriptor?username={}&branch={}", base_url, configs.otaUsername.value, stringSettings.otaServerBranch); return fmt::format("{}/otaDescriptor?username={}&branch={}", base_url, configs.otaUsername.value, configs.otaServerBranch.value);
} }
void parse_response_into_variables(std::string response) void parse_response_into_variables(std::string response)

View File

@@ -13,6 +13,7 @@
#include "icons/back.h" #include "icons/back.h"
#include "icons/reboot.h" #include "icons/reboot.h"
#include "utils.h" #include "utils.h"
#include "newsettings.h"
#define ERR_MESSAGE(text) \ #define ERR_MESSAGE(text) \
constructMenuItem<makeComponent<MenuItem, StaticText<text>, DefaultFont, StaticColor<TFT_RED>, DummyAction>>(); \ constructMenuItem<makeComponent<MenuItem, StaticText<text>, DefaultFont, StaticColor<TFT_RED>, DummyAction>>(); \
@@ -51,7 +52,7 @@ public:
namespace { namespace {
std::string CurrentBranch::text() const std::string CurrentBranch::text() const
{ {
return stringSettings.otaServerBranch.empty() ? "All builds" : stringSettings.otaServerBranch; return configs.otaServerBranch.value.empty() ? "All builds" : configs.otaServerBranch.value;
} }
std::string BranchMenuItem::text() const std::string BranchMenuItem::text() const
@@ -71,16 +72,14 @@ void BranchMenuItem::setName(const std::string &name)
void BranchMenuItem::triggered() void BranchMenuItem::triggered()
{ {
stringSettings.otaServerBranch = m_name; configs.write_config(configs.otaServerBranch, m_name); // mir egal ob succeeded
saveSettings();
} }
void ClearBranchAction::triggered() void ClearBranchAction::triggered()
{ {
stringSettings.otaServerBranch = {}; configs.write_config(configs.otaServerBranch, {}); // mir egal ob succeeded
saveSettings();
}
} }
} // namespace
SelectBuildserverBranchMenu::SelectBuildserverBranchMenu() SelectBuildserverBranchMenu::SelectBuildserverBranchMenu()
{ {

View File

@@ -112,6 +112,8 @@ public:
ConfigWrapper<std::string> udpCloudHost {std::string{}, DoReset, {}, "udpCloudHost" }; ConfigWrapper<std::string> udpCloudHost {std::string{}, DoReset, {}, "udpCloudHost" };
ConfigWrapper<std::string> otaUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "otaUrl" }; ConfigWrapper<std::string> otaUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "otaUrl" };
ConfigWrapper<std::string> otaUsername {std::string{}, DoReset, {}, "otaUsername" }; ConfigWrapper<std::string> otaUsername {std::string{}, DoReset, {}, "otaUsername" };
ConfigWrapper<std::string> otaServerUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "otaServerUrl" };
ConfigWrapper<std::string> otaServerBranch {std::string{}, DoReset, {}, "otaServerBranch" };
ConfigWrapper<bool> dns_announce_enabled{true, DoReset, {}, "dnsAnnounceEnab" }; ConfigWrapper<bool> dns_announce_enabled{true, DoReset, {}, "dnsAnnounceEnab" };
ConfigWrapper<std::string> dns_announce_key {std::string{}, DoReset, {}, "dnsAnnounceKey" }; ConfigWrapper<std::string> dns_announce_key {std::string{}, DoReset, {}, "dnsAnnounceKey" };
ConfigWrapper<std::string> webserverPassword {std::string{}, DoReset, {}, "websPassword" }; ConfigWrapper<std::string> webserverPassword {std::string{}, DoReset, {}, "websPassword" };
@@ -255,6 +257,8 @@ public:
x(udpCloudHost) \ x(udpCloudHost) \
x(otaUrl) \ x(otaUrl) \
x(otaUsername) \ x(otaUsername) \
x(otaServerUrl) \
x(otaServerBranch) \
x(dns_announce_enabled) \ x(dns_announce_enabled) \
x(dns_announce_key) \ x(dns_announce_key) \
// x(webserverPassword) // x(webserverPassword)

View File

@@ -25,10 +25,6 @@ StringSettings makeDefaultStringSettings()
// ConfiguredOtaServer { .name = {}, .url = {} }, // ConfiguredOtaServer { .name = {}, .url = {} },
// ConfiguredOtaServer { .name = {}, .url = {} }, // ConfiguredOtaServer { .name = {}, .url = {} },
}, },
.otaServerUrl = {},
#endif
#ifdef FEATURE_OTA
.otaServerBranch = {},
#endif #endif
}; };
} }

View File

@@ -22,11 +22,7 @@ struct StringSettings
std::string url; std::string url;
}; };
std::array<ConfiguredOtaServer, 5> otaServers; std::array<ConfiguredOtaServer, 5> otaServers; std::string otaServerUrl;
std::string otaServerUrl;
#endif
#ifdef FEATURE_OTA
std::string otaServerBranch;
#endif #endif
}; };
@@ -57,9 +53,6 @@ void StringSettings::executeForEveryCommonSetting(T &&callable)
// callable("otaUrl8", otaServers[8].url); // callable("otaUrl8", otaServers[8].url);
// callable("otaName9", otaServers[9].name); // callable("otaName9", otaServers[9].name);
// callable("otaUrl9", otaServers[9].url); // callable("otaUrl9", otaServers[9].url);
callable("otaserver", otaServerUrl);
callable("otaBranch", otaServerBranch);
#endif #endif
} }