New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optional redirect in ui when receiving a 401 from the api #955

Merged
merged 4 commits into from Apr 11, 2016
Jump to file or symbol
Failed to load files and symbols.
+29 −9
Diff settings

Always

Just for now

Next

optional redirect in ui when receiving a 401 from the api

  • Loading branch information...
ssalinas committed Mar 17, 2016
commit d2ee3e8f222fbac90095dc1fb8ab4007ad168b79
@@ -43,7 +43,7 @@ public static RootUrlMode parse(String value) {
private String title = "Singularity";
@JsonProperty
private String navColor = "";
private Optional<String> navColor;
@JsonProperty
private String baseUrl;
@@ -69,14 +69,17 @@ public static RootUrlMode parse(String value) {
private String rootUrlMode = RootUrlMode.INDEX_CATCHALL.name();
@NotNull
private String taskS3LogOmitPrefix = "";
private Optional<String> taskS3LogOmitPrefix;
@NotEmpty
private String timestampFormat = "lll";
@NotEmpty
private String timestampWithSecondsFormat = "lll:ss";
@JsonProperty
private Optional<String> redirectOnUnauthorizedUrl;
public boolean isHideNewDeployButton() {
return hideNewDeployButton;
}
@@ -109,11 +112,11 @@ public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
public String getNavColor() {
public Optional<String> getNavColor() {
return navColor;
}
public void setNavColor(String navColor) {
public void setNavColor(Optional<String> navColor) {
this.navColor = navColor;
}
@@ -161,11 +164,11 @@ public String getFinishedTaskLogPath() {
return finishedTaskLogPath;
}
public String getTaskS3LogOmitPrefix() {
public Optional<String> getTaskS3LogOmitPrefix() {
return taskS3LogOmitPrefix;
}
public void setTaskS3LogOmitPrefix(String taskS3LogOmitPrefix) {
public void setTaskS3LogOmitPrefix(Optional<String> taskS3LogOmitPrefix) {
this.taskS3LogOmitPrefix = taskS3LogOmitPrefix;
}
@@ -184,4 +187,12 @@ public String getTimestampWithSecondsFormat() {
public void setTimestampWithSecondsFormat(String timestampWithSecondsFormat) {
this.timestampWithSecondsFormat = timestampWithSecondsFormat;
}
public Optional<String> getRedirectOnUnauthorizedUrl() {
return redirectOnUnauthorizedUrl;
}
public void setRedirectOnUnauthorizedUrl(Optional<String> redirectOnUnauthorizedUrl) {
this.redirectOnUnauthorizedUrl = redirectOnUnauthorizedUrl;
}
}
@@ -54,6 +54,8 @@
private final String timestampWithSecondsFormat;
private final String redirectOnUnauthorizedUrl;
public IndexView(String singularityUriBase, String appRoot, SingularityConfiguration configuration, ObjectMapper mapper) {
super("index.mustache");
@@ -78,7 +80,7 @@ public IndexView(String singularityUriBase, String appRoot, SingularityConfigura
this.hideNewRequestButton = configuration.getUiConfiguration().isHideNewRequestButton();
this.loadBalancingEnabled = !Strings.isNullOrEmpty(configuration.getLoadBalancerUri());
this.navColor = configuration.getUiConfiguration().getNavColor();
this.navColor = configuration.getUiConfiguration().getNavColor().or("");
this.defaultBounceExpirationMinutes = configuration.getDefaultBounceExpirationMinutes();
this.defaultHealthcheckIntervalSeconds = configuration.getHealthcheckIntervalSeconds();
@@ -91,10 +93,12 @@ public IndexView(String singularityUriBase, String appRoot, SingularityConfigura
this.commonHostnameSuffixToOmit = configuration.getCommonHostnameSuffixToOmit().or("");
this.taskS3LogOmitPrefix = configuration.getUiConfiguration().getTaskS3LogOmitPrefix();
this.taskS3LogOmitPrefix = configuration.getUiConfiguration().getTaskS3LogOmitPrefix().or("");
this.warnIfScheduledJobIsRunningPastNextRunPct = configuration.getWarnIfScheduledJobIsRunningPastNextRunPct();
this.redirectOnUnauthorizedUrl = configuration.getUiConfiguration().getRedirectOnUnauthorizedUrl().or("");
ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
try {
this.shellCommands = ow.writeValueAsString(configuration.getUiConfiguration().getShellCommands());
@@ -239,6 +243,7 @@ public String toString() {
", shellCommands='" + shellCommands + '\'' +
", timestampFormat='" + timestampFormat + '\'' +
", timestampWithSecondsFormat='" + timestampWithSecondsFormat + '\'' +
", redirectOnUnauthorizedUrl='" + redirectOnUnauthorizedUrl + '\'' +
']';
}
}
@@ -107,6 +107,8 @@ class Application
if jqxhr.status is 502
Messenger().info
message: "Singularity is deploying, your requests cannot be handled. Things should resolve in a few seconds so just hang tight!"
else if jqxhr.status is 401 and config.redirectOnUnauthorizedUrl
window.location.href = config.redirectOnUnauthorizedUrl.replace('{URL}', encodeURIComponent(window.location.href))
else if jqxhr.statusText is 'timeout'
Messenger().error
message: "<p>A <code>#{ jqxhr.statusText }</code> error occurred while accessing:</p><pre>#{ url }</pre>"
@@ -41,6 +41,7 @@
slaveHttpsPort: {{{slaveHttpsPort}}},
{{/slaveHttpsPort}}
shellCommands: {{{shellCommands}}},
redirectOnUnauthorizedUrl: "{{{redirectOnUnauthorizedUrl}}}"
};
</script>
<script src="{{{staticRoot}}}/js/app.js"></script>
@@ -36,7 +36,8 @@ var templateData = {
warnIfScheduledJobIsRunningPastNextRunPct: process.env.SINGULARITY_WARN_IF_SCHEDULED_JOB_IS_RUNNING_PAST_NEXT_RUN_PCT || 200,
shellCommands: process.env.SINGULARITY_SHELL_COMMANDS || "[]",
timestampFormat: process.env.SINGULARITY_TIMESTAMP_FORMAT || 'lll',
timestampWithSecondsFormat: process.env.SINGULARITY_TIMESTAMP_WITH_SECONDS_FORMAT || 'lll:ss'
timestampWithSecondsFormat: process.env.SINGULARITY_TIMESTAMP_WITH_SECONDS_FORMAT || 'lll:ss',
redirectOnUnauthorizedUrl: process.env.SINGULARITY_REDIRECT_ON_UNAUTHORIZED_URL || ''
}
var dest = path.resolve(__dirname, '../SingularityService/target/generated-resources/assets');
ProTip! Use n and p to navigate between commits in a pull request.