From c2e134a57c29d05cbf046c8bdb902c09eccf9e46 Mon Sep 17 00:00:00 2001 From: Team5499 Date: Mon, 4 Feb 2019 15:53:34 -0800 Subject: [PATCH 1/4] Implemented specific type get and set functions --- .../org/team5499/dashboard/Dashboard.kt | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/org/team5499/dashboard/Dashboard.kt b/src/main/kotlin/org/team5499/dashboard/Dashboard.kt index 8cf0095..8c9d831 100644 --- a/src/main/kotlin/org/team5499/dashboard/Dashboard.kt +++ b/src/main/kotlin/org/team5499/dashboard/Dashboard.kt @@ -122,17 +122,59 @@ object Dashboard { SocketHandler.startBroadcastThread() // start broadcasting data } - fun setVariable(key: String, value: Any) { + fun setString(key: String, value: String) { variableUpdates.put(key, value) } - fun getVariable(key: String): T { + fun setInt(key: Int, value: Int) { + variableUpdates.put(key, value) + } + + fun setBool(key: Boolean, value: Boolean) { + variableUpdates.put(key, value) + } + + fun setDouble(key: Double, value: Double) { + variableUpdates.put(key, value) + } + + fun getString(key: String): T { + if ((!variables.has(key)) && (!variableUpdates.has(key))) { + throw DashboardException("The variable with name " + key + " was not found.") + } else if (variableUpdates.has(key)) { + return variableUpdates.get(key) + } else { + return variables.get(key) + } + } + + fun getInt(key: Int): T { + if ((!variables.has(key)) && (!variableUpdates.has(key))) { + throw DashboardException("The variable with name " + key + " was not found.") + } else if (variableUpdates.has(key)) { + return variableUpdates.get(key) + } else { + return variables.get(key) + } + } + + fun getBool(key: Boolean): T { + if ((!variables.has(key)) && (!variableUpdates.has(key))) { + throw DashboardException("The variable with name " + key + " was not found.") + } else if (variableUpdates.has(key)) { + return variableUpdates.get(key) + } else { + return variables.get(key) + } + } + + fun getDouble(key: Double): T { if ((!variables.has(key)) && (!variableUpdates.has(key))) { throw DashboardException("The variable with name " + key + " was not found.") } else if (variableUpdates.has(key)) { - return variableUpdates.get(key) as T + return variableUpdates.get(key) } else { - return variables.get(key) as T + return variables.get(key) } } From a1f633bac57fd228d050d7ccdd6413940470dd9d Mon Sep 17 00:00:00 2001 From: Team5499 Date: Mon, 4 Feb 2019 16:03:42 -0800 Subject: [PATCH 2/4] Fixed errors --- .../org/team5499/dashboard/Dashboard.kt | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/org/team5499/dashboard/Dashboard.kt b/src/main/kotlin/org/team5499/dashboard/Dashboard.kt index 8c9d831..36ba4e1 100644 --- a/src/main/kotlin/org/team5499/dashboard/Dashboard.kt +++ b/src/main/kotlin/org/team5499/dashboard/Dashboard.kt @@ -16,6 +16,7 @@ import org.json.JSONObject * * Handles starting the server */ +@Suppress("TooManyFunctions") object Dashboard { private var config: Config = Config() @@ -126,55 +127,55 @@ object Dashboard { variableUpdates.put(key, value) } - fun setInt(key: Int, value: Int) { + fun setInt(key: String, value: Int) { variableUpdates.put(key, value) } - fun setBool(key: Boolean, value: Boolean) { + fun setBool(key: String, value: Boolean) { variableUpdates.put(key, value) } - fun setDouble(key: Double, value: Double) { + fun setDouble(key: String, value: Double) { variableUpdates.put(key, value) } - fun getString(key: String): T { + fun getString(key: String): String { if ((!variables.has(key)) && (!variableUpdates.has(key))) { throw DashboardException("The variable with name " + key + " was not found.") } else if (variableUpdates.has(key)) { - return variableUpdates.get(key) + return variableUpdates.getString(key) } else { - return variables.get(key) + return variables.getString(key) } } - fun getInt(key: Int): T { + fun getInt(key: String): Int { if ((!variables.has(key)) && (!variableUpdates.has(key))) { throw DashboardException("The variable with name " + key + " was not found.") } else if (variableUpdates.has(key)) { - return variableUpdates.get(key) + return variableUpdates.getInt(key) } else { - return variables.get(key) + return variables.getInt(key) } } - fun getBool(key: Boolean): T { + fun getBool(key: String): Boolean { if ((!variables.has(key)) && (!variableUpdates.has(key))) { throw DashboardException("The variable with name " + key + " was not found.") } else if (variableUpdates.has(key)) { - return variableUpdates.get(key) + return variableUpdates.getBoolean(key) } else { - return variables.get(key) + return variables.getBoolean(key) } } - fun getDouble(key: Double): T { + fun getDouble(key: String): Double { if ((!variables.has(key)) && (!variableUpdates.has(key))) { throw DashboardException("The variable with name " + key + " was not found.") } else if (variableUpdates.has(key)) { - return variableUpdates.get(key) + return variableUpdates.getDouble(key) } else { - return variables.get(key) + return variables.getDouble(key) } } From 5b36dc84fab72a303c56fad81e32d745336b62be Mon Sep 17 00:00:00 2001 From: Team5499 Date: Mon, 4 Feb 2019 16:32:26 -0800 Subject: [PATCH 3/4] Added dropdown menu for bool vars --- .../static/javascript/widgets/rawvareditor.jsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/resources/static/javascript/widgets/rawvareditor.jsx b/src/main/resources/static/javascript/widgets/rawvareditor.jsx index 536eb09..33fc569 100644 --- a/src/main/resources/static/javascript/widgets/rawvareditor.jsx +++ b/src/main/resources/static/javascript/widgets/rawvareditor.jsx @@ -31,6 +31,7 @@ class RawVarEditor extends React.Component { onVarSave() { let newVal = $('#' + this.props.id + '_var_display').val(); SocketHandler.setVariable(this.state.targetName, newVal); + } onFieldEdit(e) { @@ -42,10 +43,19 @@ class RawVarEditor extends React.Component { } render() { + let input; + if(typeof $('#' + this.props.id + '_var_display').val() != "boolean"){ + input = this.onFieldEdit(e)} />; + }else{ + input = ; + } return ( - this.onFieldEdit(e)} /> + {input} this.onSettingsSave()}> From acd557924de61af91644a88602946182e28376ea Mon Sep 17 00:00:00 2001 From: Team5499 Date: Mon, 4 Feb 2019 16:40:13 -0800 Subject: [PATCH 4/4] A --- src/main/resources/base.html | 1 + src/main/resources/page.html | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/resources/base.html b/src/main/resources/base.html index afda699..401e984 100644 --- a/src/main/resources/base.html +++ b/src/main/resources/base.html @@ -45,6 +45,7 @@ {% block beforeScripts %}{% endblock %} + diff --git a/src/main/resources/page.html b/src/main/resources/page.html index e6f48f8..11ba25d 100644 --- a/src/main/resources/page.html +++ b/src/main/resources/page.html @@ -24,6 +24,7 @@ {% block beforeScripts %}{% endblock %} {% block afterJSLibs %} + {% if developmentEnvironment %}