src/app/store/ui.state.ts
Properties |
Methods |
|
constructor(store: Store, ga: GoogleAnalyticsService)
|
|||||||||
Defined in src/app/store/ui.state.ts:104
|
|||||||||
Parameters :
|
closeBottomSheet | |||||
closeBottomSheet(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(CloseBottomSheet)
|
|||||
Defined in src/app/store/ui.state.ts:439
|
|||||
Action to close bottom sheet. Empty the bottom sheet data from the state Set the bottom sheet open variable to false
Parameters :
Returns :
void
|
closeBottomSheetDOI | |||||
closeBottomSheetDOI(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(CloseBottomSheetDOI)
|
|||||
Defined in src/app/store/ui.state.ts:429
|
|||||
Action to close bottom sheet. Empty the bottom sheet data from the state
Parameters :
Returns :
void
|
closeCompare | |||||
closeCompare(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(CloseCompare)
|
|||||
Defined in src/app/store/ui.state.ts:470
|
|||||
Action to close compare sidenav
Parameters :
Returns :
void
|
closeLoading | |||||||
closeLoading(undefined: StateContext<UIStateModel>, undefined: CloseLoading)
|
|||||||
Decorators :
@Action(CloseLoading)
|
|||||||
Defined in src/app/store/ui.state.ts:305
|
|||||||
Action to close loading. Set loading to false and clear loading text
Parameters :
Returns :
void
|
closeRightSideNav | |||||
closeRightSideNav(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(CloseRightSideNav)
|
|||||
Defined in src/app/store/ui.state.ts:367
|
|||||
Action to close right side. Set Report, IL, Debug Log, Compare to false.
Parameters :
Returns :
void
|
closeSearch | |||||
closeSearch(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(CloseSearch)
|
|||||
Defined in src/app/store/ui.state.ts:490
|
|||||
Parameters :
Returns :
void
|
closeSnackbar | |||||
closeSnackbar(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(CloseSnackbar)
|
|||||
Defined in src/app/store/ui.state.ts:250
|
|||||
Action to close snackbar. Update the UI State by setting the snackbar state to false and success state
Parameters :
Returns :
void
|
Static getBottomSheet | ||||||||
getBottomSheet(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:208
|
||||||||
Select the bottom sheet state
Parameters :
Returns :
boolean
|
Static getCompareState | ||||||||
getCompareState(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:218
|
||||||||
Select the compare sidenav state
Parameters :
Returns :
boolean
|
Static getControlPaneState | ||||||||
getControlPaneState(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:146
|
||||||||
Select control pane state
Parameters :
Returns :
boolean
|
Static getDebugLog | ||||||||
getDebugLog(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:198
|
||||||||
Select the debug sidenav state
Parameters :
Returns :
boolean
|
Static getError | ||||||||
getError(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:156
|
||||||||
Select the error state
Parameters :
Returns :
{ error: Error; }
|
Static getIndentList | ||||||||
getIndentList(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:168
|
||||||||
Select indented list sidenav state
Parameters :
Returns :
boolean
|
Static getLoading | ||||||||
getLoading(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:126
|
||||||||
Select the loading state
Parameters :
Returns :
boolean
|
Static getLoadingText | ||||||||
getLoadingText(state: UIStateModel)
|
||||||||
Decorators :
@Select()
|
||||||||
Defined in src/app/store/ui.state.ts:136
|
||||||||
Select the loading text
Parameters :
Returns :
string
|
Static getReport | ||||||||
getReport(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:178
|
||||||||
Select the report sidenav state
Parameters :
Returns :
boolean
|
Static getRightSideNav | ||||||||
getRightSideNav(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:188
|
||||||||
Select the right sidenav state
Parameters :
Returns :
boolean
|
Static getSearchState | ||||||||
getSearchState(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:228
|
||||||||
Select the search panel state
Parameters :
Returns :
boolean
|
Static getSnackbar | ||||||||
getSnackbar(state: UIStateModel)
|
||||||||
Decorators :
@Selector()
|
||||||||
Defined in src/app/store/ui.state.ts:116
|
||||||||
Select the snackbar state
Parameters :
Returns :
Snackbar
|
hasError | |||||||
hasError(undefined: StateContext<UIStateModel>, undefined: HasError)
|
|||||||
Decorators :
@Action(HasError)
|
|||||||
Defined in src/app/store/ui.state.ts:321
|
|||||||
Action to update error state. Close loading and open snackbar with appropriate message and type
Parameters :
Returns :
void
|
openBottomSheet | |||||||
openBottomSheet(undefined: StateContext<UIStateModel>, undefined: OpenBottomSheet)
|
|||||||
Decorators :
@Action(OpenBottomSheet)
|
|||||||
Defined in src/app/store/ui.state.ts:398
|
|||||||
Action to open bottom sheet. Accept the data (name of structure) First close the bottom sheet, incase it is open. Then dispatch new action to update bottom sheet data
Parameters :
Returns :
void
|
OpenBottomSheetDOI | |||||||
OpenBottomSheetDOI(undefined: StateContext<UIStateModel>, undefined: OpenBottomSheetDOI)
|
|||||||
Decorators :
@Action(OpenBottomSheetDOI)
|
|||||||
Defined in src/app/store/ui.state.ts:418
|
|||||||
Action to open bottom sheet DOI. Accept the data (name of structure) First close the bottom sheet Info, incase it is open. Second close the bottom sheet DOI, incase it is open. Then dispatch new action to update bottom sheet data DOI
Parameters :
Returns :
void
|
openCompare | |||||
openCompare(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(OpenCompare)
|
|||||
Defined in src/app/store/ui.state.ts:457
|
|||||
Action to open compare sidenav
Parameters :
Returns :
void
|
openLoading | |||||||
openLoading(undefined: StateContext<UIStateModel>, undefined: OpenLoading)
|
|||||||
Decorators :
@Action(OpenLoading)
|
|||||||
Defined in src/app/store/ui.state.ts:279
|
|||||||
Action to open loading. Set loading to true and text to text
Parameters :
Returns :
void
|
openSearch | |||||
openSearch(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(OpenSearch)
|
|||||
Defined in src/app/store/ui.state.ts:480
|
|||||
Parameters :
Returns :
void
|
openSnackbar | |||||||
openSnackbar(undefined: StateContext<UIStateModel>, undefined: OpenSnackbar)
|
|||||||
Decorators :
@Action(OpenSnackbar)
|
|||||||
Defined in src/app/store/ui.state.ts:237
|
|||||||
Action to open snackbar. Update the UI State by setting the snackbar state to true and text
Parameters :
Returns :
void
|
toggleControlPane | |||||
toggleControlPane(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(ToggleControlPane)
|
|||||
Defined in src/app/store/ui.state.ts:266
|
|||||
Action to toggle control pane by inverting the current state
Parameters :
Returns :
void
|
toggleDebugLogs | |||||
toggleDebugLogs(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(ToggleDebugLogs)
|
|||||
Defined in src/app/store/ui.state.ts:383
|
|||||
Action to toggle debug logs sidebar
Parameters :
Returns :
void
|
toggleIndentList | |||||
toggleIndentList(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(ToggleIndentList)
|
|||||
Defined in src/app/store/ui.state.ts:341
|
|||||
Action to toggle Indent list sidebar
Parameters :
Returns :
void
|
toggleReport | |||||
toggleReport(undefined: StateContext<UIStateModel>)
|
|||||
Decorators :
@Action(ToggleReport)
|
|||||
Defined in src/app/store/ui.state.ts:354
|
|||||
Action to toggle Report sidebar
Parameters :
Returns :
void
|
UpdateLoadingText | |||||||
UpdateLoadingText(undefined: StateContext<UIStateModel>, undefined: UpdateLoadingText)
|
|||||||
Decorators :
@Action(UpdateLoadingText)
|
|||||||
Defined in src/app/store/ui.state.ts:293
|
|||||||
Action to update loading text
Parameters :
Returns :
void
|
Public ga |
Type : GoogleAnalyticsService
|
Defined in src/app/store/ui.state.ts:107
|
Public store |
Type : Store
|
Defined in src/app/store/ui.state.ts:106
|
import { Injectable } from '@angular/core';
import { Action, Select, Selector, State, StateContext, Store } from '@ngxs/store';
import { GoogleAnalyticsService } from 'ngx-google-analytics';
import { ReportLog } from '../actions/logs.actions';
import { UpdateBottomSheetDOI, UpdateBottomSheetInfo } from '../actions/sheet.actions';
import { UpdateBottomSheetData } from '../actions/tree.actions';
import {
CloseBottomSheet,
CloseBottomSheetDOI,
CloseCompare,
CloseLoading,
CloseRightSideNav,
CloseSearch,
CloseSnackbar,
HasError,
OpenBottomSheet,
OpenBottomSheetDOI,
OpenCompare,
OpenLoading,
OpenSearch,
OpenSnackbar,
ToggleControlPane,
ToggleDebugLogs,
ToggleIndentList,
ToggleReport,
UpdateLoadingText,
} from '../actions/ui.actions';
import { GaAction, GaCategory } from '../models/ga.model';
import { LOG_ICONS, LOG_TYPES } from '../models/logs.model';
import { Error, SnackbarType } from '../models/response.model';
import { Snackbar } from '../models/ui.model';
import { TreeState } from './tree.state';
/** Interface to keep track of all UI elements */
export interface UIStateModel {
/**
* Keep track of the right sidebar
*/
rightSideNavOpen: boolean;
/**
* Keep track of the control pane on the left
*/
controlPaneOpen: boolean;
/**
* Is the UI in loading state
*/
loading: boolean;
/**
* Store the loading state
*/
loadingText: string;
/**
* Store UI in error state
*/
error: Error;
/**
* Sotre snackbar state
*/
snackbar: Snackbar;
/**
* Keep track of the indented list sidebar
*/
indentListOpen: boolean;
/**
* Keep track of the report sidebar
*/
reportOpen: boolean;
/**
* Keep track of the debug log sidebar
*/
debugLogOpen: boolean;
/**
* Keep track of the bottom sheet that shows info
*/
bottomSheetOpen: boolean;
/**
* Keep track of the compare sidebar
*/
compareOpen: boolean;
/**
* Keep track of the search panel state
*/
searchOpen: boolean;
}
@State<UIStateModel>({
name: 'uiState',
defaults: {
rightSideNavOpen: false,
controlPaneOpen: true,
loading: true,
loadingText: '',
error: {},
snackbar: { opened: false, text: '', type: SnackbarType.success },
indentListOpen: false,
reportOpen: false,
debugLogOpen: false,
bottomSheetOpen: false,
compareOpen: false,
searchOpen: false,
},
})
@Injectable()
export class UIState {
constructor(
public store: Store,
public ga: GoogleAnalyticsService,
) {}
/**
* Select the snackbar state
*
* @param state - UI State Model
*/
@Selector()
static getSnackbar(state: UIStateModel) {
return state.snackbar;
}
/**
* Select the loading state
*
* @param state - UI State Model
*/
@Selector()
static getLoading(state: UIStateModel) {
return state.loading;
}
/**
* Select the loading text
*
* @param state - UI State Model
*/
@Select()
static getLoadingText(state: UIStateModel) {
return state.loadingText;
}
/**
* Select control pane state
*
* @param state - UI State Model
*/
@Selector()
static getControlPaneState(state: UIStateModel) {
return state.controlPaneOpen;
}
/**
* Select the error state
*
* @param state - UI State Model
*/
@Selector()
static getError(state: UIStateModel) {
return {
error: state.error,
};
}
/**
* Select indented list sidenav state
*
* @param state - UI State Model
*/
@Selector()
static getIndentList(state: UIStateModel) {
return state.indentListOpen;
}
/**
* Select the report sidenav state
*
* @param state - UI State Model
*/
@Selector()
static getReport(state: UIStateModel) {
return state.reportOpen;
}
/**
* Select the right sidenav state
*
* @param state - UI State Model
*/
@Selector()
static getRightSideNav(state: UIStateModel) {
return state.rightSideNavOpen;
}
/**
* Select the debug sidenav state
*
* @param state - UI State Model
*/
@Selector()
static getDebugLog(state: UIStateModel) {
return state.debugLogOpen;
}
/**
* Select the bottom sheet state
*
* @param state - UI State Model
*/
@Selector()
static getBottomSheet(state: UIStateModel) {
return state.bottomSheetOpen;
}
/**
* Select the compare sidenav state
*
* @param state - UI State Model
*/
@Selector()
static getCompareState(state: UIStateModel) {
return state.compareOpen;
}
/**
* Select the search panel state
*
* @param state - UI State Model
*/
@Selector()
static getSearchState(state: UIStateModel) {
return state.searchOpen;
}
/**
* Action to open snackbar. Update the UI State by setting the
* snackbar state to true and text
*/
@Action(OpenSnackbar)
openSnackbar({ getState, setState }: StateContext<UIStateModel>, { text, type }: OpenSnackbar) {
const state = getState();
setState({
...state,
snackbar: { opened: true, text, type },
});
}
/**
* Action to close snackbar. Update the UI State by setting the
* snackbar state to false and success state
*/
@Action(CloseSnackbar)
closeSnackbar({ getState, setState }: StateContext<UIStateModel>) {
const state = getState();
setState({
...state,
snackbar: {
opened: false,
text: '',
type: SnackbarType.success,
},
});
}
/**
* Action to toggle control pane by inverting the current state
*/
@Action(ToggleControlPane)
toggleControlPane({ getState, setState }: StateContext<UIStateModel>) {
const state = getState();
setState({
...state,
controlPaneOpen: !state.controlPaneOpen,
});
this.ga.event(GaAction.TOGGLE, GaCategory.NAVBAR, 'Toggle Control Pane', undefined, getState().controlPaneOpen);
}
/**
* Action to open loading. Set loading to true and text to text
*/
@Action(OpenLoading)
openLoading({ getState, setState }: StateContext<UIStateModel>, { text }: OpenLoading) {
const state = getState();
setState({
...state,
loadingText: text,
loading: true,
error: {},
});
}
/**
* Action to update loading text
*/
@Action(UpdateLoadingText)
UpdateLoadingText({ getState, setState }: StateContext<UIStateModel>, { text }: UpdateLoadingText) {
const state = getState();
setState({
...state,
loadingText: text,
});
}
/**
* Action to close loading. Set loading to false and clear loading text
*/
@Action(CloseLoading)
closeLoading({ getState, setState, dispatch }: StateContext<UIStateModel>, { text }: CloseLoading) {
const state = getState();
setState({
...state,
loading: false,
loadingText: '',
});
dispatch(new OpenSnackbar(text ?? '', SnackbarType.success));
}
/**
* Action to update error state.
* Close loading and open snackbar with appropriate message and type
*/
@Action(HasError)
hasError({ getState, setState, dispatch }: StateContext<UIStateModel>, { error }: HasError) {
dispatch(new ReportLog(LOG_TYPES.MSG, error.msg ?? '', LOG_ICONS.error));
const state = getState();
setState({
...state,
error,
loading: false,
loadingText: '',
snackbar: {
opened: true,
text: error.msg ?? '',
type: SnackbarType.error,
},
});
}
/**
* Action to toggle Indent list sidebar
*/
@Action(ToggleIndentList)
toggleIndentList({ getState, setState }: StateContext<UIStateModel>) {
const state = getState();
setState({
...state,
indentListOpen: !state.indentListOpen,
});
this.ga.event(GaAction.TOGGLE, GaCategory.NAVBAR, 'Toggle Indent List', undefined, getState().indentListOpen);
}
/**
* Action to toggle Report sidebar
*/
@Action(ToggleReport)
toggleReport({ getState, setState }: StateContext<UIStateModel>) {
const state = getState();
setState({
...state,
reportOpen: !state.reportOpen,
});
this.ga.event(GaAction.TOGGLE, GaCategory.NAVBAR, 'Toggle Report', undefined, getState().reportOpen);
}
/**
* Action to close right side. Set Report, IL, Debug Log, Compare to false.
*/
@Action(CloseRightSideNav)
closeRightSideNav({ getState, setState }: StateContext<UIStateModel>) {
const state = getState();
setState({
...state,
indentListOpen: false,
reportOpen: false,
debugLogOpen: false,
compareOpen: false,
});
this.ga.event(GaAction.CLICK, GaCategory.NAVBAR, 'Close All Right-Sidenav Elements ', undefined, false);
}
/**
* Action to toggle debug logs sidebar
*/
@Action(ToggleDebugLogs)
toggleDebugLogs({ getState, setState }: StateContext<UIStateModel>) {
const state = getState();
setState({
...state,
debugLogOpen: !state.debugLogOpen,
});
this.ga.event(GaAction.TOGGLE, GaCategory.NAVBAR, 'Toggle Debug Logs', undefined, getState().debugLogOpen);
}
/**
* Action to open bottom sheet. Accept the data (name of structure)
* First close the bottom sheet, incase it is open.
* Then dispatch new action to update bottom sheet data
*/
@Action(OpenBottomSheet)
openBottomSheet({ getState, setState, dispatch }: StateContext<UIStateModel>, { data }: OpenBottomSheet) {
const state = getState();
dispatch(new CloseBottomSheet());
dispatch(new CloseBottomSheetDOI());
dispatch(new UpdateBottomSheetData(data)).subscribe((_unused) => {
setState({
...state,
bottomSheetOpen: true,
});
});
dispatch(new UpdateBottomSheetInfo(data));
}
/**
* Action to open bottom sheet DOI. Accept the data (name of structure)
* First close the bottom sheet Info, incase it is open.
* Second close the bottom sheet DOI, incase it is open.
* Then dispatch new action to update bottom sheet data DOI
*/
@Action(OpenBottomSheetDOI)
OpenBottomSheetDOI({ dispatch }: StateContext<UIStateModel>, { data }: OpenBottomSheetDOI) {
dispatch(new CloseBottomSheet());
dispatch(new CloseBottomSheetDOI());
dispatch(new UpdateBottomSheetDOI(data));
}
/**
* Action to close bottom sheet.
* Empty the bottom sheet data from the state
*/
@Action(CloseBottomSheetDOI)
closeBottomSheetDOI({ dispatch }: StateContext<UIStateModel>) {
dispatch(new UpdateBottomSheetData({}));
}
/**
* Action to close bottom sheet.
* Empty the bottom sheet data from the state
* Set the bottom sheet open variable to false
*/
@Action(CloseBottomSheet)
closeBottomSheet({ getState, setState, dispatch }: StateContext<UIStateModel>) {
dispatch(new UpdateBottomSheetData({}));
const view = this.store.selectSnapshot(TreeState.getVegaView);
if (Object.entries(view).length) {
view.signal('bimodal_text__click', {});
}
setState({
...getState(),
bottomSheetOpen: false,
});
}
/**
* Action to open compare sidenav
*/
@Action(OpenCompare)
openCompare({ getState, setState }: StateContext<UIStateModel>) {
const state = getState();
setState({
...state,
compareOpen: true,
});
this.ga.event(GaAction.CLICK, GaCategory.NAVBAR, 'Open Compare', undefined, getState().compareOpen);
}
/**
* Action to close compare sidenav
*/
@Action(CloseCompare)
closeCompare({ getState, setState }: StateContext<UIStateModel>) {
const state = getState();
setState({
...state,
compareOpen: false,
});
this.ga.event(GaAction.CLICK, GaCategory.NAVBAR, 'Close Compare', undefined, getState().compareOpen);
}
@Action(OpenSearch)
openSearch({ getState, setState }: StateContext<UIStateModel>) {
const state = getState();
setState({
...state,
searchOpen: true,
});
this.ga.event(GaAction.CLICK, GaCategory.NAVBAR, 'Open Search', undefined, getState().searchOpen);
}
@Action(CloseSearch)
closeSearch({ getState, setState }: StateContext<UIStateModel>) {
const state = getState();
setState({
...state,
searchOpen: false,
});
this.ga.event(GaAction.CLICK, GaCategory.NAVBAR, 'Close Search', undefined, getState().searchOpen);
}
}