-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added launch-local launch point for kicking off a local-resource base…
…d launch. includes functionality to present a list of resource bundles in a predefined local folder to the user, and to collect the name of one of them from the user in order to kick off a launch. for issue #31
- Loading branch information
Showing
6 changed files
with
4,439 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package edu.ohsu.cmp.coach.util; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class FileUtil { | ||
private static final Logger logger = LoggerFactory.getLogger(FileUtil.class); | ||
|
||
public static List<String> getResourceFilenameList(String resourcePath) throws IOException { | ||
List<String> list = new ArrayList<>(); | ||
|
||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | ||
try (InputStream in = classLoader.getResourceAsStream(resourcePath)) { | ||
if (in != null) { | ||
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); | ||
String resource; | ||
while ((resource = reader.readLine()) != null) { | ||
list.add(resource); | ||
} | ||
} else { | ||
logger.error("couldn't obtain resource as stream for resourcePath=" + resourcePath); | ||
} | ||
} | ||
|
||
return list; | ||
} | ||
|
||
public static List<String> getFilenameList(String path) throws IOException { | ||
List<String> list = new ArrayList<>(); | ||
|
||
File dir = new File(path); | ||
File[] fileArr = dir.listFiles(); | ||
if (fileArr != null) { | ||
for (File file : fileArr) { | ||
list.add(file.getName()); | ||
} | ||
|
||
} else { | ||
throw new IOException(path + " is not a directory"); | ||
} | ||
|
||
return list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
{{#permitLoadLocal}} | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>{{applicationName}} - Load Local Patient</title> | ||
<script type="text/javascript" src="/node_modules/jquery/dist/jquery.js"></script> | ||
<script type="text/javascript"> | ||
const REDIRECT_URL = "/"; | ||
function prepareSession(bundleName) { | ||
let data = { | ||
bundleName: bundleName | ||
}; | ||
// alert("useful development breakpoint"); | ||
$.ajax({ | ||
method: "POST", | ||
url: "/prepare-detached-session", | ||
data: data | ||
}).done(function(cards, textStatus, jqXHR) { | ||
if (jqXHR.status === 200) { | ||
$('body').html("Handshake completed, redirecting ...<br/>If you are not redirected, please <a href='" + REDIRECT_URL + "'>click here</a>.") | ||
window.location.href = REDIRECT_URL; | ||
} else { | ||
$('body').html("Error - received response " + response.status + " status"); | ||
} | ||
}); | ||
} | ||
$(document).on('click', '#launchButton', function() { | ||
let bundleName = $('#bundleName').val(); | ||
prepareSession(bundleName); | ||
}); | ||
$(document).on('change', '#bundleName', function() { | ||
$('#launchButton').prop('disabled', $(this).val() === ''); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
Select a local FHIR Resource Bundle: | ||
<form action="/prepare-detached-session"> | ||
<select id="bundleName"> | ||
<option value="">-- Select a Local Bundle --</option> | ||
{{#bundleItems}} | ||
<option value="{{.}}">{{.}}</option> | ||
{{/bundleItems}} | ||
</select> | ||
<input id="launchButton" type="button" value="Launch Detached" disabled /> | ||
</form> | ||
</body> | ||
{{/permitLoadLocal}} | ||
{{^permitLoadLocal}} | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>{{applicationName}} - Operation Not Supported</title> | ||
</head> | ||
<body> | ||
This operation is not currently supported. | ||
</body> | ||
{{/permitLoadLocal}} | ||
</html> |
Oops, something went wrong.