Skip to content

Commit

Permalink
web don't auto add default models if some given on cmd line, issue wh…
Browse files Browse the repository at this point in the history
…en res not ok in web for model discon
  • Loading branch information
crotwell committed Oct 3, 2024
1 parent 26df884 commit 79b9401
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/main/java/edu/sc/seis/TauP/cmdline/TauP_WebServe.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,22 @@ public void handleParamHelp(Map<String, Deque<String>> queryParams, HttpServerEx

public void handleKnownModels(Map<String, Deque<String>> queryParams, HttpServerExchange exchange) {
JSONArray modList = new JSONArray();
modList.putAll(getKnownModels());
exchange.getResponseSender().send(modList.toString(2));
}

public List<String> getKnownModels() {
List<String> out = new ArrayList<>();
if (additionalModels.isEmpty()) {
for (String mod : TauModelLoader.defaultModelList) {
modList.put(mod);
out.add(mod);
}
} else {
for (String mod : additionalModels) {
modList.put(mod);
out.add(mod);
}
}
exchange.getResponseSender().send(modList.toString(2));
return out;
}

public void handleCmdLine(TauP_Tool tool, Map<String, Deque<String>> queryParams, HttpServerExchange exchange) throws TauPException {
Expand Down Expand Up @@ -310,8 +316,9 @@ public void webRunTool(TauP_Tool tool, Map<String, Deque<String>> queryParams, H
if (queryParams.containsKey("model")) {
modList.addAll(queryParams.get("model"));
}
List<String> knownModels = getKnownModels();
for (String mod : modList) {
if ( ! additionalModels.contains(mod)) {
if ( ! knownModels.contains(mod)) {
throw new VelocityModelException("Unknown model "+mod+" in "+tool.getClass().getName());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/edu/sc/seis/TauP/html/taup.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function createModelDisconRadio() {
if (res.ok) {
return res.json();
} else {
return { model: []};
return { models: [ { discon: [] }]};
}
}).then(json => {
const m = json.models[0];
Expand Down

0 comments on commit 79b9401

Please sign in to comment.