diff --git a/SingularityService/src/main/java/com/hubspot/singularity/config/UIConfiguration.java b/SingularityService/src/main/java/com/hubspot/singularity/config/UIConfiguration.java index 1ad1f483ac..52782baa5b 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/config/UIConfiguration.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/config/UIConfiguration.java @@ -66,6 +66,12 @@ public static RootUrlMode parse(String value) { @NotNull private String taskS3LogOmitPrefix = ""; + @NotEmpty + private String timestampFormat = "lll"; + + @NotEmpty + private String timestampWithSecondsFormat = "lll:ss"; + public boolean isHideNewDeployButton() { return hideNewDeployButton; } @@ -150,4 +156,19 @@ public void setTaskS3LogOmitPrefix(String taskS3LogOmitPrefix) { this.taskS3LogOmitPrefix = taskS3LogOmitPrefix; } + public String getTimestampFormat() { + return timestampFormat; + } + + public void setTimestampFormat(String timestampFormat) { + this.timestampFormat = timestampFormat; + } + + public String getTimestampWithSecondsFormat() { + return timestampWithSecondsFormat; + } + + public void setTimestampWithSecondsFormat(String timestampWithSecondsFormat) { + this.timestampWithSecondsFormat = timestampWithSecondsFormat; + } } diff --git a/SingularityService/src/main/java/com/hubspot/singularity/views/IndexView.java b/SingularityService/src/main/java/com/hubspot/singularity/views/IndexView.java index b1abae7ba7..cb991315dd 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/views/IndexView.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/views/IndexView.java @@ -39,6 +39,10 @@ public class IndexView extends View { private final Integer warnIfScheduledJobIsRunningPastNextRunPct; + private final String timestampFormat; + + private final String timestampWithSecondsFormat; + public IndexView(String singularityUriBase, String appRoot, SingularityConfiguration configuration) { super("index.mustache"); @@ -76,6 +80,10 @@ public IndexView(String singularityUriBase, String appRoot, SingularityConfigura this.taskS3LogOmitPrefix = configuration.getUiConfiguration().getTaskS3LogOmitPrefix(); this.warnIfScheduledJobIsRunningPastNextRunPct = configuration.getWarnIfScheduledJobIsRunningPastNextRunPct(); + + this.timestampFormat = configuration.getUiConfiguration().getTimestampFormat(); + + this.timestampWithSecondsFormat = configuration.getUiConfiguration().getTimestampWithSecondsFormat(); } public String getAppRoot() { @@ -158,6 +166,14 @@ public Integer getWarnIfScheduledJobIsRunningPastNextRunPct() { return warnIfScheduledJobIsRunningPastNextRunPct; } + public String getTimestampFormat() { + return timestampFormat; + } + + public String getTimestampWithSecondsFormat() { + return timestampWithSecondsFormat; + } + @Override public String toString() { return "IndexView[" + @@ -180,6 +196,8 @@ public String toString() { ", finishedTaskLogPath='" + finishedTaskLogPath + '\'' + ", commonHostnameSuffixToOmit='" + commonHostnameSuffixToOmit + '\'' + ", warnIfScheduledJobIsRunningPastNextRunPct='" + warnIfScheduledJobIsRunningPastNextRunPct + '\'' + + ", timestampFormat='" + timestampFormat + '\'' + + ", timestampWithSecondsFormat='" + timestampWithSecondsFormat + '\'' + ']'; } } diff --git a/SingularityUI/app/assets/_index.mustache b/SingularityUI/app/assets/_index.mustache index a563c6aee4..655dc5a63f 100644 --- a/SingularityUI/app/assets/_index.mustache +++ b/SingularityUI/app/assets/_index.mustache @@ -37,6 +37,8 @@ taskS3LogOmitPrefix: "{{{ taskS3LogOmitPrefix }}}", slaveHttpPort: {{{slaveHttpPort}}}, warnIfScheduledJobIsRunningPastNextRunPct: {{{warnIfScheduledJobIsRunningPastNextRunPct}}}, + timestampFormat: localStorage.getItem('timestampFormatOverride') || "{{{timestampFormat}}}", + timestampWithSecondsFormat: localStorage.getItem('timestampWithSecondsFormatOverride') || "{{{timestampWithSecondsFormat}}}", {{#slaveHttpsPort}} slaveHttpsPort: {{{slaveHttpsPort}}} {{/slaveHttpsPort}} diff --git a/SingularityUI/app/handlebarsHelpers.coffee b/SingularityUI/app/handlebarsHelpers.coffee index 5447eb67ab..9e4e21b158 100644 --- a/SingularityUI/app/handlebarsHelpers.coffee +++ b/SingularityUI/app/handlebarsHelpers.coffee @@ -60,7 +60,7 @@ Handlebars.registerHelper 'withLast', (list, options) -> Handlebars.registerHelper 'timestampFromNow', (timestamp) -> return '' if not timestamp timeObject = moment timestamp - "#{timeObject.fromNow()} (#{ timeObject.format 'lll'})" + "#{timeObject.fromNow()} (#{ timeObject.format window.config.timestampFormat})" Handlebars.registerHelper 'ifTimestampInPast', (timestamp, options) -> return options.inverse @ if not timestamp @@ -81,12 +81,12 @@ Handlebars.registerHelper 'timestampDuration', (timestamp) -> Handlebars.registerHelper 'timestampFormatted', (timestamp) -> return '' if not timestamp timeObject = moment timestamp - timeObject.format 'lll' + timeObject.format window.config.timestampFormat Handlebars.registerHelper 'timestampFormattedWithSeconds', (timestamp) -> return '' if not timestamp timeObject = moment timestamp - timeObject.format 'lll:ss' + timeObject.format window.config.timestampWithSecondsFormat # 'DRIVER_NOT_RUNNING' => 'Driver not running' Handlebars.registerHelper 'humanizeText', (text) -> diff --git a/SingularityUI/config.coffee b/SingularityUI/config.coffee index 537869624d..8abc52328a 100644 --- a/SingularityUI/config.coffee +++ b/SingularityUI/config.coffee @@ -55,6 +55,8 @@ exports.config = commonHostnameSuffixToOmit: process.env.SINGULARITY_COMMON_HOSTNAME_SUFFIX_TO_OMIT ? "" taskS3LogOmitPrefix: process.env.SINGULARITY_TASK_S3_LOG_OMIT_PREFIX ? '' warnIfScheduledJobIsRunningPastNextRunPct: process.env.SINGULARITY_WARN_IF_SCHEDULED_JOB_IS_RUNNING_PAST_NEXT_RUN_PCT ? 200 + timestampFormat: process.env.SINGULARITY_TIMESTAMP_FORMAT ? 'lll' + timestampWithSecondsFormat: process.env.SINGULARITY_TIMESTAMP_WITH_SECONDS_FORMAT ? 'lll:ss' compiledTemplate = handlebars.compile(indexTemplate)(templateData) fs.writeFileSync destination, compiledTemplate