Trying to add enable button to info panel
This commit is contained in:
@@ -44,7 +44,7 @@ class AutoPlaylistUsermod : public Usermod {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AutoPlaylistUsermod(const char *name, bool enabled):Usermod(name, enabled) {}
|
AutoPlaylistUsermod(bool enabled):Usermod("AutoPlaylist", enabled) {}
|
||||||
|
|
||||||
// gets called once at boot. Do all initialization that doesn't depend on
|
// gets called once at boot. Do all initialization that doesn't depend on
|
||||||
// network here
|
// network here
|
||||||
@@ -156,6 +156,18 @@ class AutoPlaylistUsermod : public Usermod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonArray infoArr = user.createNestedArray(FPSTR(_name)); // name
|
JsonArray infoArr = user.createNestedArray(FPSTR(_name)); // name
|
||||||
|
String uiDomString = F("<button class=\"btn btn-xs\" onclick=\"requestJson({");
|
||||||
|
uiDomString += FPSTR(_name);
|
||||||
|
uiDomString += F(":{");
|
||||||
|
uiDomString += FPSTR(_enabled);
|
||||||
|
uiDomString += enabled ? F(":false}});\">") : F(":true}});\">");
|
||||||
|
uiDomString += F("<i class=\"icons");
|
||||||
|
uiDomString += enabled ? F(" on") : F(" off");
|
||||||
|
uiDomString += F("\"></i>");
|
||||||
|
uiDomString += F("</button>");
|
||||||
|
infoArr.add(uiDomString);
|
||||||
|
|
||||||
|
infoArr = user.createNestedArray(F(""));
|
||||||
if(!enabled) {
|
if(!enabled) {
|
||||||
infoArr.add("disabled");
|
infoArr.add("disabled");
|
||||||
}
|
}
|
||||||
@@ -177,10 +189,11 @@ class AutoPlaylistUsermod : public Usermod {
|
|||||||
*/
|
*/
|
||||||
void readFromJsonState(JsonObject& root) {
|
void readFromJsonState(JsonObject& root) {
|
||||||
if (!initDone) return; // prevent crash on boot applyPreset()
|
if (!initDone) return; // prevent crash on boot applyPreset()
|
||||||
bool en = enabled;
|
|
||||||
JsonObject um = root[FPSTR(_name)];
|
JsonObject um = root[FPSTR(_name)];
|
||||||
if (!um.isNull()) {
|
if (!um.isNull()) {
|
||||||
if (en != enabled) enabled = en;
|
if (um[FPSTR(_enabled)].is<bool>()) {
|
||||||
|
enabled = um[FPSTR(_enabled)].as<bool>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ void registerUsermods()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USERMOD_AUTO_PLAYLIST
|
#ifdef USERMOD_AUTO_PLAYLIST
|
||||||
usermods.add(new AutoPlaylistUsermod("Auto Playlist", true));
|
usermods.add(new AutoPlaylistUsermod(true));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user