Skip to content

Commit

Permalink
FIX: Row state fetching fix (#1798)
Browse files Browse the repository at this point in the history
* Some screens could not be loaded because of an exception when fetching row states
* It is possible to adjust debouncing delay via RowStatesDebouncingDelayMilliSeconds in appsettings.json
  • Loading branch information
JindrichSusen committed Aug 11, 2023
1 parent fc37073 commit 84b4638
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions backend/Origam.Server/Common/PortalResult.cs
Expand Up @@ -144,5 +144,6 @@ public int MaxRequestLength
public IFilteringConfig FilteringConfig { get; set; }

public string InitialScreenId { get; set; }
public int RowStatesDebouncingDelayMilliSeconds { get; set; }
}
}
1 change: 1 addition & 0 deletions backend/Origam.Server/Configuration/HtmlClientConfig.cs
Expand Up @@ -3,5 +3,6 @@
public class HtmlClientConfig
{
public bool ShowToolTipsForMemoFieldsOnly { get; set; }
public int RowStatesDebouncingDelayMilliSeconds { get; set; } = 200;
}
}
1 change: 1 addition & 0 deletions backend/Origam.Server/Controller/UIServiceController.cs
Expand Up @@ -1217,6 +1217,7 @@ private void AddConfigData(PortalResult result)
: chatConfig.ChatRefreshInterval;
result.CustomAssetsRoute = customAssetsConfig.RouteToCustomAssetsFolder;
result.ShowToolTipsForMemoFieldsOnly = htmlClientConfig.ShowToolTipsForMemoFieldsOnly;
result.RowStatesDebouncingDelayMilliSeconds = htmlClientConfig.RowStatesDebouncingDelayMilliSeconds;
result.FilteringConfig = clientFilteringConfig;
}
}
Expand Down
3 changes: 2 additions & 1 deletion backend/Origam.Server/TemplateFiles/_appsettings.json
Expand Up @@ -142,7 +142,8 @@
]
},
"HtmlClientConfig":{
"ShowToolTipsForMemoFieldsOnly" : "false"
"ShowToolTipsForMemoFieldsOnly" : "false",
"RowStatesDebouncingDelayMilliSeconds": 200
},
"Logging": {
"LogLevel": {
Expand Down
13 changes: 9 additions & 4 deletions frontend-html/src/model/entities/RowState.ts
Expand Up @@ -28,6 +28,7 @@ import { handleError } from "model/actions/handleError";
import { flashColor2htmlColor } from "@origam/utils";
import { visibleRowsChanged } from "gui/Components/ScreenElements/Table/TableRendering/renderTable";
import { getDataSource } from "model/selectors/DataSources/getDataSource";
import { CancellablePromise } from "mobx/lib/api/flow";

const defaultRowStatesToFetch = 100;

Expand All @@ -41,8 +42,10 @@ export class RowState implements IRowState {
suppressWorkingStatus: boolean = false;
visibleRowIds: string[] = [];

constructor(data: IRowStateData) {
Object.assign(this, data);
constructor(debouncingDelayMilliSeconds?: number) {
this.triggerLoadDebounced = _.debounce(
this.triggerLoadImm,
debouncingDelayMilliSeconds == undefined ? 200 : debouncingDelayMilliSeconds);
visibleRowsChanged.subscribe((visibleRows) => {
const dataSource = getDataSource(this);
if (!visibleRows || dataSource.identifier !== visibleRows.dataSourceId) {
Expand Down Expand Up @@ -77,7 +80,9 @@ export class RowState implements IRowState {
}
return this.visibleRowIds.length === 0
? Array.from(this.requests.values()).slice(-defaultRowStatesToFetch)
: this.visibleRowIds.map(rowId => this.requests.get(rowId)!);
: this.visibleRowIds
.map(rowId => this.requests.get(rowId))
.filter(x => x !== undefined) as unknown as IterableIterator<RowStateRequest>;
}

*triggerLoad(loadAll: boolean): any {
Expand Down Expand Up @@ -139,7 +144,7 @@ export class RowState implements IRowState {
this.temporaryRequestsValues = undefined;
}
}
triggerLoadDebounced = _.debounce(this.triggerLoadImm, 200);
triggerLoadDebounced: any;

getValue(rowId: string) {
if (!this.requests.has(rowId)) {
Expand Down
Expand Up @@ -550,6 +550,7 @@ export class WorkbenchLifecycle implements IWorkbenchLifecycle {
showWorkQueues: portalInfo.workQueueListRefreshInterval > 0,
helpUrl: portalInfo.helpUrl,
showToolTipsForMemoFieldsOnly: portalInfo.showToolTipsForMemoFieldsOnly,
rowStatesDebouncingDelayMilliSeconds: portalInfo.rowStatesDebouncingDelayMilliSeconds,
filterConfig: {
caseSensitive: portalInfo.filteringConfig.caseSensitive,
accentSensitive: portalInfo.filteringConfig.accentSensitive
Expand Down
1 change: 1 addition & 0 deletions frontend-html/src/model/entities/types/IPortalSettings.ts
Expand Up @@ -24,5 +24,6 @@ export interface IPortalSettings {
showWorkQueues: boolean;
helpUrl: string;
showToolTipsForMemoFieldsOnly: boolean;
rowStatesDebouncingDelayMilliSeconds: number;
filterConfig: IFilterConfig;
}
4 changes: 3 additions & 1 deletion frontend-html/src/xmlInterpreters/screenXml.ts
Expand Up @@ -95,6 +95,7 @@ import { getMomentFormat, replaceDefaultDateFormats } from "./getMomentFormat";
import { getTablePanelView } from "../model/selectors/TablePanelView/getTablePanelView";
import { isMobileLayoutActive } from "model/selectors/isMobileLayoutActive";
import { ScreenFocusManager } from "model/entities/ScreenFocusManager";
import { getWorkbenchLifecycle } from "model/selectors/getWorkbenchLifecycle";


function getPropertyParameters(node: any) {
Expand Down Expand Up @@ -223,6 +224,7 @@ export function*interpretScreenXml(
isLazyLoading: boolean
) {
const workbench = getWorkbench(formScreenLifecycle);
const workbenchLifeCycle = getWorkbenchLifecycle(formScreenLifecycle);
const $workbench = scopeFor(workbench);
const panelConfigurations = new Map<string, IPanelConfiguration>(
panelConfigurationsRaw.map((pcr: any) => [
Expand Down Expand Up @@ -331,7 +333,7 @@ export function*interpretScreenXml(
// isSessioned: windowXml.attributes.UseSession,
dataSources: dataSourcesXml.elements.map((dataSource: any) => {
return new DataSource({
rowState: new RowState({}),
rowState: new RowState(workbenchLifeCycle.portalSettings?.rowStatesDebouncingDelayMilliSeconds),
entity: dataSource.attributes.Entity,
dataStructureEntityId: dataSource.attributes.DataStructureEntityId,
identifier: dataSource.attributes.Identifier,
Expand Down

0 comments on commit 84b4638

Please sign in to comment.