Skip to content

Commit

Permalink
Improve prefs loading; format.
Browse files Browse the repository at this point in the history
  • Loading branch information
spahrenk committed Dec 5, 2024
1 parent d1890b3 commit d51aa90
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions scripts/python/plotting/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@

async function write_json_file(filename, json_data) {
fst = 'filename=' + filename;
fst += '&json_data' + json_data;
const response = await fetch('http://localhost:8000/write_json?' + fst,
fst += '&json_data=' + JSON.stringify(json_data);
await fetch('http://localhost:8000/write_json?' + fst,
{
method: 'GET'
}
Expand Down Expand Up @@ -254,11 +254,11 @@
<!-- content -->
<form id="model_form">
<label for="model_name">model name:</label>
<select name="model_name" id="model_name" style="width: 400px" onclick="change_menu_value();">
<select name="model_name" id="model_name" style="width: 400px" onchange="change_menu_value();">
</select><br><br>

<label for="model_spec">model spec:</label>
<select name="model_spec" id="model_spec" style="width: 150px">
<select name="model_spec" id="model_spec" style="width: 150px" onchange="change_menu_value();">
<option selected="selected" value="File">File</option>
<option value="Preset">Preset</option>
<option value="JSON">JSON</option>
Expand Down
2 changes: 1 addition & 1 deletion scripts/python/plotting/prefs.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
null
{"model_name": "LG_APHWC50", "model_spec": "Preset", "build_dir": "../../../build"}
7 changes: 4 additions & 3 deletions scripts/python/plotting/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ def do_GET(self):
elif self.path.startswith('/write_json'):
query_components = urlparse.parse_qs(urlparse.urlparse(self.path).query)
filename = query_components.get('filename', [None])[0]
json_data = query_components.get('json_data', [None])[0]
response = {}
json_str = query_components.get('json_data', [None])[0]
print(json_str)
json_data = json.loads(json_str)
with open(filename, "w") as json_file:
#json_file.write(json_data)
json.dump(json_data, json_file)
json_file.close()

self.send_response(200)
self.send_header("Content-type", "text/html")
self.send_header("Content-Length", 0)
self.send_header("Access-Control-Allow-Origin", "*")
self.end_headers()
return
Expand Down
2 changes: 1 addition & 1 deletion src/Condenser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1087,4 +1087,4 @@ void HPWH::Condenser::convertMapToGrid(std::vector<std::vector<double>>& tempGri

tempGridValues.push_back(inputPowers_W);
tempGridValues.push_back(heatingCapacities_W);
}
}

0 comments on commit d51aa90

Please sign in to comment.