+
{
+ setDurationSettings({ ...durationSettings, count: value });
+ setChanged(true);
+ }}
/>
diff --git a/frontend/app/constants/index.js b/frontend/app/constants/index.js
index 239c7478a..30c5c5095 100644
--- a/frontend/app/constants/index.js
+++ b/frontend/app/constants/index.js
@@ -20,3 +20,4 @@ export {
WEBHOOK as CHANNEL_WEBHOOK
} from './schedule';
export { default } from './filterOptions';
+export { default as storageKeys } from './storageKeys';
\ No newline at end of file
diff --git a/frontend/app/constants/storageKeys.ts b/frontend/app/constants/storageKeys.ts
new file mode 100644
index 000000000..ee39d53d6
--- /dev/null
+++ b/frontend/app/constants/storageKeys.ts
@@ -0,0 +1,3 @@
+export const SKIP_TO_ISSUE = "__$session-skipToIssue$__"
+export const TIMEZONE = "__$session-timezone$__"
+export const DURATION_FILTER = "__$session-durationFilter$__"
\ No newline at end of file
diff --git a/frontend/app/duck/search.js b/frontend/app/duck/search.js
index dd879592c..c003515a9 100644
--- a/frontend/app/duck/search.js
+++ b/frontend/app/duck/search.js
@@ -9,6 +9,7 @@ import { fetchList as fetchSessionList } from './sessions';
import { fetchList as fetchErrorsList } from './errors';
import { FilterCategory, FilterKey, IssueType } from 'Types/filter/filterType';
import { filtersMap, liveFiltersMap, generateFilterOptions, generateLiveFilterOptions } from 'Types/filter/newFilter';
+import { DURATION_FILTER } from 'App/constants/storageKeys'
const ERRORS_ROUTE = errorsRoute();
@@ -149,6 +150,28 @@ export const reduceThenFetchResource = actionCreator => (...args) => (dispatch,
filter.limit = 10;
filter.page = getState().getIn([ 'search', 'currentPage']);
+ // duration filter from local storage
+ if (!filter.filters.find(f => f.type === FilterKey.DURATION)) {
+ const durationFilter = JSON.parse(localStorage.getItem(DURATION_FILTER) || '{"count": 0}');
+ let durationValue = parseInt(durationFilter.count)
+ if (durationValue > 0) {
+ const value = [0];
+ durationValue = durationFilter.countType === 'min' ? durationValue * 60 * 1000 : durationValue * 1000;
+ if (durationFilter.operator === '<') {
+ value[0] = durationValue;
+ } else if (durationFilter.operator === '>') {
+ value[1] = durationValue;
+ }
+
+ filter.filters = filter.filters.concat({
+ type: FilterKey.DURATION,
+ operator: 'is',
+ value,
+ });
+ }
+ }
+
+
return isRoute(ERRORS_ROUTE, window.location.pathname)
? dispatch(fetchErrorsList(filter))
: dispatch(fetchSessionList(filter));
diff --git a/frontend/app/mstore/index.tsx b/frontend/app/mstore/index.tsx
index 39c1d84a4..f72972121 100644
--- a/frontend/app/mstore/index.tsx
+++ b/frontend/app/mstore/index.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import DashboardStore, { IDashboardSotre } from './dashboardStore';
import MetricStore, { IMetricStore } from './metricStore';
import APIClient from 'App/api_client';
-import { dashboardService, metricService } from 'App/services';
+import { dashboardService, metricService, sessionService } from 'App/services';
import SettingsStore from './settingsStore';
export class RootStore {
@@ -20,6 +20,7 @@ export class RootStore {
const client = new APIClient();
dashboardService.initClient(client)
metricService.initClient(client)
+ sessionService.initClient(client)
}
}
diff --git a/frontend/app/mstore/settingsStore.ts b/frontend/app/mstore/settingsStore.ts
index 82a33a5cb..0a666f75d 100644
--- a/frontend/app/mstore/settingsStore.ts
+++ b/frontend/app/mstore/settingsStore.ts
@@ -1,7 +1,10 @@
-import { makeAutoObservable, runInAction, observable, action, reaction } from "mobx"
+import { makeAutoObservable, observable, action } from "mobx"
import SessionSettings from "./types/sessionSettings"
+import { sessionService } from "App/services"
+import { toast } from 'react-toastify';
export default class SettingsStore {
+ loadingCaptureRate: boolean = false;
sessionSettings: SessionSettings = new SessionSettings()
constructor() {
makeAutoObservable(this, {
@@ -9,7 +12,29 @@ export default class SettingsStore {
})
}
- updateCaptureRate(value: number) {
- this.sessionSettings.updateKey('captureRate', value);
+ saveCaptureRate(data: any) {
+ return sessionService.saveCaptureRate(data)
+ .then(data => {
+ this.sessionSettings.merge({
+ captureRate: data.rate,
+ captureAll: data.captureAll
+ })
+ toast.success("Capture rate saved successfully");
+ }).catch(err => {
+ toast.error("Error saving capture rate");
+ })
+ }
+
+ fetchCaptureRate(): Promise
{
+ this.loadingCaptureRate = true;
+ return sessionService.fetchCaptureRate()
+ .then(data => {
+ this.sessionSettings.merge({
+ captureRate: data.rate,
+ captureAll: data.captureAll
+ })
+ }).finally(() => {
+ this.loadingCaptureRate = false;
+ })
}
}
\ No newline at end of file
diff --git a/frontend/app/mstore/types/sessionSettings.ts b/frontend/app/mstore/types/sessionSettings.ts
index 37317cacd..9374b0df1 100644
--- a/frontend/app/mstore/types/sessionSettings.ts
+++ b/frontend/app/mstore/types/sessionSettings.ts
@@ -1,13 +1,10 @@
import { makeAutoObservable, runInAction, observable, action, reaction } from "mobx"
+import { SKIP_TO_ISSUE, TIMEZONE, DURATION_FILTER } from 'App/constants/storageKeys'
export default class SessionSettings {
- skipToIssue: boolean = false
- timezone: string = "EST"
- durationFilter: any = {
- count: 0,
- countType: 'min',
- operator: '>'
- }
+ skipToIssue: boolean = localStorage.getItem(SKIP_TO_ISSUE) === 'true';
+ timezone: string = localStorage.getItem(TIMEZONE) || 'UTC';
+ durationFilter: any = JSON.parse(localStorage.getItem(DURATION_FILTER) || '{}');
captureRate: number = 0
captureAll: boolean = false
@@ -17,10 +14,25 @@ export default class SessionSettings {
})
}
+ merge(settings: any) {
+ for (const key in settings) {
+ if (settings.hasOwnProperty(key)) {
+ this.updateKey(key, settings[key]);
+ }
+ }
+ }
+
updateKey(key: string, value: any) {
- console.log(`SessionSettings.updateKey(${key}, ${value})`)
runInAction(() => {
this[key] = value
})
+
+ if (key === 'captureRate' || key === 'captureAll') return
+
+ if (key === 'durationFilter') {
+ localStorage.setItem(`__$session-${key}$__`, JSON.stringify(value));
+ } else {
+ localStorage.setItem(`__$session-${key}$__`, value);
+ }
}
}
diff --git a/frontend/app/player/MessageDistributor/StatedScreen/Screen/Cursor.ts b/frontend/app/player/MessageDistributor/StatedScreen/Screen/Cursor.ts
index 1b74ab027..b030403b8 100644
--- a/frontend/app/player/MessageDistributor/StatedScreen/Screen/Cursor.ts
+++ b/frontend/app/player/MessageDistributor/StatedScreen/Screen/Cursor.ts
@@ -27,7 +27,6 @@ export default class Cursor {
}
click() {
- console.log("clickong ", styles.clicked)
this.cursor.classList.add(styles.clicked)
setTimeout(() => {
this.cursor.classList.remove(styles.clicked)
diff --git a/frontend/app/player/Player.ts b/frontend/app/player/Player.ts
index f1f305868..358ed52c4 100644
--- a/frontend/app/player/Player.ts
+++ b/frontend/app/player/Player.ts
@@ -25,7 +25,7 @@ const HIGHEST_SPEED = 16;
const SPEED_STORAGE_KEY = "__$player-speed$__";
const SKIP_STORAGE_KEY = "__$player-skip$__";
-const SKIP_TO_ISSUE_STORAGE_KEY = "__$player-skip-to-issue$__";
+const SKIP_TO_ISSUE_STORAGE_KEY = "__$session-skipToIssue$__";
const AUTOPLAY_STORAGE_KEY = "__$player-autoplay$__";
const SHOW_EVENTS_STORAGE_KEY = "__$player-show-events$__";
const storedSpeed: number = parseInt(localStorage.getItem(SPEED_STORAGE_KEY) || "") ;
diff --git a/frontend/app/services/SessionService.ts b/frontend/app/services/SessionService.ts
new file mode 100644
index 000000000..a7940edc1
--- /dev/null
+++ b/frontend/app/services/SessionService.ts
@@ -0,0 +1,23 @@
+import APIClient from 'App/api_client';
+
+export default class SettingsService {
+ private client: APIClient;
+
+ constructor(client?: APIClient) {
+ this.client = client ? client : new APIClient();
+ }
+
+ initClient(client?: APIClient) {
+ this.client = client || new APIClient();
+ }
+
+ saveCaptureRate(data: any) {
+ return this.client.post('/sample_rate', data);
+ }
+
+ fetchCaptureRate() {
+ return this.client.get('/sample_rate')
+ .then(response => response.json())
+ .then(response => response.data || 0);
+ }
+}
\ No newline at end of file
diff --git a/frontend/app/services/index.ts b/frontend/app/services/index.ts
index 944877c16..e721e0f10 100644
--- a/frontend/app/services/index.ts
+++ b/frontend/app/services/index.ts
@@ -1,5 +1,7 @@
import DashboardService, { IDashboardService } from "./DashboardService";
import MetricService, { IMetricService } from "./MetricService";
+import SessionSerivce from "./SessionService";
export const dashboardService: IDashboardService = new DashboardService();
-export const metricService: IMetricService = new MetricService();
\ No newline at end of file
+export const metricService: IMetricService = new MetricService();
+export const sessionService: SessionSerivce = new SessionSerivce();
\ No newline at end of file