Skip to content

Commit

Permalink
add defaultTimeRange setting (arkime#2501)
Browse files Browse the repository at this point in the history
* add defaultTimeRange setting

* ??
  • Loading branch information
31453 authored Nov 8, 2023
1 parent afb011d commit 0d3b058
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions tests/config.test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ arkimeWebURL = localhost:8123/arkime/
turnOffGraphDays = 30
disableUserPasswordUI=false
authMode=digest
defaultTimeRange=-1

[testmulties]
pcapWriteMethod=simple
Expand Down
3 changes: 2 additions & 1 deletion viewer/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,8 @@ app.use(cspHeader, setCookie, (req, res) => {
businessDays: Config.get('businessDays', '1,2,3,4,5'),
turnOffGraphDays: Config.get('turnOffGraphDays', 30),
disableUserPasswordUI: Config.get('disableUserPasswordUI', true),
logoutUrl: Auth.logoutUrl
logoutUrl: Auth.logoutUrl,
defaultTimeRange: Config.get('defaultTimeRange', '1')
};

// Create a fresh Vue app instance
Expand Down
1 change: 1 addition & 0 deletions viewer/vueapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
const TURN_OFF_GRAPH_DAYS = {{ turnOffGraphDays }};
const DISABLE_USER_PASSWORD_UI = {{ disableUserPasswordUI }};
const LOGOUT_URL = '{{ logoutUrl }}';
const DEFAULT_TIME_RANGE = '{{ defaultTimeRange }}';
</script>
</head>
<body class="{{ theme }}">
Expand Down
8 changes: 4 additions & 4 deletions viewer/vueapp/src/components/search/Time.vue
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ export default {
this.setCurrentTime();

let date = this.$route.query.date;
// if no time params exist, default to last hour
// if no time params exist, default to config default or last hour
if (!this.$route.query.startTime &&
!this.$route.query.stopTime &&
!this.$route.query.date) {
date = 1;
date = this.$constants.DEFAULT_TIME_RANGE ?? 1;
}

this.setupTimeParams(
Expand Down Expand Up @@ -711,11 +711,11 @@ export default {
this.localStartTime = moment(start * 1000);
this.time.startTime = start;
} else { // if we can't parse stop or start time, set default
this.timeRange = '1'; // default to 1 hour
this.timeRange = this.$constants.DEFAULT_TIME_RANGE ?? '1'; // default to config or 1 hour
}
} else {
// there are no time query parameters, so set defaults
this.timeRange = '1'; // default to 1 hour
this.timeRange = this.$constants.DEFAULT_TIME_RANGE ?? '1'; // default to config or 1 hour
}
},
/* watch for the url parameters to change and update the page */
Expand Down
3 changes: 2 additions & 1 deletion viewer/vueapp/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ new Vue({
DISABLE_USER_PASSWORD_UI,
BUILD_VERSION, // from webpack.DefinePlugin
BUILD_DATE, // from webpack.DefinePlugin
LOGOUT_URL
LOGOUT_URL,
DEFAULT_TIME_RANGE
};
}
});
2 changes: 1 addition & 1 deletion viewer/vueapp/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const store = new Vuex.Store({
fieldsMap: {}, // NOTE: this has duplicate fields where dbField and dbField2 are different
fieldsAliasMap: {},
fieldhistory: [],
timeRange: 1,
timeRange: DEFAULT_TIME_RANGE ?? 1, /* eslint-disable-line no-undef */
expression: undefined,
time: {
startTime: undefined,
Expand Down
2 changes: 2 additions & 0 deletions viewer/vueapp/tests/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
jest.setTimeout(30000);

global.DEFAULT_TIME_RANGE = 1;

0 comments on commit 0d3b058

Please sign in to comment.