@journeyapps-labs/reactor-mod-data-browser 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/dist/@types/actions/connections/SetConnectionColorAction.d.ts +11 -0
- package/dist/@types/actions/saved-queries/OpenSavedQueryAction.d.ts +10 -0
- package/dist/@types/actions/saved-queries/RemoveSavedQueryAction.d.ts +9 -0
- package/dist/@types/core/AbstractConnection.d.ts +2 -0
- package/dist/@types/core/SchemaModelDefinition.d.ts +5 -0
- package/dist/@types/core/connection-colors.d.ts +10 -0
- package/dist/@types/core/query/StandardModelFields.d.ts +5 -0
- package/dist/@types/core/query/filters.d.ts +46 -5
- package/dist/@types/core/query/query-simple/SimplePage.d.ts +2 -0
- package/dist/@types/core/query/query-simple/SimpleQuery.d.ts +12 -3
- package/dist/@types/core/query/query-simple/SimpleQueryColumns.d.ts +12 -0
- package/dist/@types/core/query/query-simple/SimpleQueryFilterState.d.ts +37 -0
- package/dist/@types/core/query/query-simple/SimpleQueryPlanner.d.ts +4 -0
- package/dist/@types/core/query/query-simple/SimpleQuerySortState.d.ts +23 -0
- package/dist/@types/core/query/query-simple/SimpleQueryTypes.d.ts +24 -0
- package/dist/@types/core/query/widgets/ColumnDisplayWidget.d.ts +1 -0
- package/dist/@types/core/query/widgets/PeekRelationshipButton.d.ts +7 -0
- package/dist/@types/core/query/widgets/SmartColumnWidget.d.ts +3 -0
- package/dist/@types/core/query/widgets/SmartFilterWidget.d.ts +6 -0
- package/dist/@types/entities/ConnectionEntityDefinition.d.ts +2 -0
- package/dist/@types/entities/SavedQueryEntityDefinition.d.ts +8 -0
- package/dist/@types/entities.d.ts +2 -1
- package/dist/@types/forms/APIConnectionForm.d.ts +1 -0
- package/dist/@types/forms/TypeEngine.d.ts +3 -21
- package/dist/@types/forms/types/attachment-handler.d.ts +2 -0
- package/dist/@types/forms/types/boolean-handler.d.ts +2 -0
- package/dist/@types/forms/types/date-handler.d.ts +2 -0
- package/dist/@types/forms/types/filters/ClearableFilterFormDialogDirective.d.ts +10 -0
- package/dist/@types/forms/types/filters/ConditionalFilterForm.d.ts +23 -0
- package/dist/@types/forms/types/image-handler.d.ts +2 -0
- package/dist/@types/forms/types/location-handler.d.ts +2 -0
- package/dist/@types/forms/types/multiple-choice-handler.d.ts +2 -0
- package/dist/@types/forms/types/multiple-choice-integer-handler.d.ts +2 -0
- package/dist/@types/forms/types/number-handler.d.ts +2 -0
- package/dist/@types/forms/types/shared/type-handler.d.ts +37 -0
- package/dist/@types/forms/types/shared/ui.d.ts +768 -0
- package/dist/@types/forms/types/single-choice-handler.d.ts +2 -0
- package/dist/@types/forms/types/single-choice-integer-handler.d.ts +2 -0
- package/dist/@types/forms/types/text-handler.d.ts +3 -0
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/panels/_shared/SharedConnectionPanelFactory.d.ts +19 -0
- package/dist/@types/panels/_shared/SharedModelPanelFactory.d.ts +5 -2
- package/dist/@types/panels/query/QueryPanelFactory.d.ts +6 -2
- package/dist/@types/panels/query/TableControlsWidget.d.ts +2 -0
- package/dist/@types/panels/query/table-controls/ChangesControlsWidget.d.ts +8 -0
- package/dist/@types/panels/query/table-controls/FilterControlsWidget.d.ts +7 -0
- package/dist/@types/panels/query/table-controls/PageControlsWidget.d.ts +9 -0
- package/dist/@types/panels/query/table-controls/QueryControlsWidget.d.ts +11 -0
- package/dist/@types/panels/query/table-controls/SortChipWidget.d.ts +10 -0
- package/dist/@types/panels/query/table-controls/SortControlsWidget.d.ts +7 -0
- package/dist/@types/preferences/QueryControlPreferences.d.ts +7 -0
- package/dist/@types/stores/SavedQueryStore.d.ts +34 -0
- package/dist/@types/widgets/EmptyValueWidget.d.ts +7 -0
- package/dist/DataBrowserModule.js +21 -7
- package/dist/DataBrowserModule.js.map +1 -1
- package/dist/actions/connections/AddConnectionAction.js +2 -2
- package/dist/actions/connections/AddConnectionAction.js.map +1 -1
- package/dist/actions/connections/RemoveConnectionAction.js +2 -2
- package/dist/actions/connections/RemoveConnectionAction.js.map +1 -1
- package/dist/actions/connections/SetConnectionColorAction.js +63 -0
- package/dist/actions/connections/SetConnectionColorAction.js.map +1 -0
- package/dist/actions/saved-queries/OpenSavedQueryAction.js +58 -0
- package/dist/actions/saved-queries/OpenSavedQueryAction.js.map +1 -0
- package/dist/actions/saved-queries/RemoveSavedQueryAction.js +43 -0
- package/dist/actions/saved-queries/RemoveSavedQueryAction.js.map +1 -0
- package/dist/actions/schema-definitions/CreateModelAction.js +2 -2
- package/dist/actions/schema-definitions/CreateModelAction.js.map +1 -1
- package/dist/actions/schema-definitions/QuerySchemaModelAction.js +2 -2
- package/dist/actions/schema-definitions/QuerySchemaModelAction.js.map +1 -1
- package/dist/actions/schema-model/EditSchemaModelAction.js +2 -2
- package/dist/actions/schema-model/EditSchemaModelAction.js.map +1 -1
- package/dist/actions/schema-model/ViewSchemaModelAsJsonAction.js +2 -2
- package/dist/actions/schema-model/ViewSchemaModelAsJsonAction.js.map +1 -1
- package/dist/core/AbstractConnection.js +116 -90
- package/dist/core/AbstractConnection.js.map +1 -1
- package/dist/core/SchemaModelDefinition.js +14 -0
- package/dist/core/SchemaModelDefinition.js.map +1 -1
- package/dist/core/connection-colors.js +36 -0
- package/dist/core/connection-colors.js.map +1 -0
- package/dist/core/query/StandardModelFields.js +10 -0
- package/dist/core/query/StandardModelFields.js.map +1 -0
- package/dist/core/query/filters.js +86 -4
- package/dist/core/query/filters.js.map +1 -1
- package/dist/core/query/query-simple/SimplePage.js +2 -4
- package/dist/core/query/query-simple/SimplePage.js.map +1 -1
- package/dist/core/query/query-simple/SimpleQuery.js +64 -68
- package/dist/core/query/query-simple/SimpleQuery.js.map +1 -1
- package/dist/core/query/query-simple/SimpleQueryColumns.js +88 -0
- package/dist/core/query/query-simple/SimpleQueryColumns.js.map +1 -0
- package/dist/core/query/query-simple/SimpleQueryFilterState.js +136 -0
- package/dist/core/query/query-simple/SimpleQueryFilterState.js.map +1 -0
- package/dist/core/query/query-simple/SimpleQueryPlanner.js +14 -0
- package/dist/core/query/query-simple/SimpleQueryPlanner.js.map +1 -0
- package/dist/core/query/query-simple/SimpleQuerySortState.js +140 -0
- package/dist/core/query/query-simple/SimpleQuerySortState.js.map +1 -0
- package/dist/core/query/query-simple/SimpleQueryTypes.js +44 -0
- package/dist/core/query/query-simple/SimpleQueryTypes.js.map +1 -0
- package/dist/core/query/widgets/BelongsToDisplayWidget.js +14 -7
- package/dist/core/query/widgets/BelongsToDisplayWidget.js.map +1 -1
- package/dist/core/query/widgets/CellDisplayWidget.js +5 -9
- package/dist/core/query/widgets/CellDisplayWidget.js.map +1 -1
- package/dist/core/query/widgets/ColumnDisplayWidget.js +13 -12
- package/dist/core/query/widgets/ColumnDisplayWidget.js.map +1 -1
- package/dist/core/query/widgets/PeekRelationshipButton.js +128 -0
- package/dist/core/query/widgets/PeekRelationshipButton.js.map +1 -0
- package/dist/core/query/widgets/SmartColumnWidget.js +18 -3
- package/dist/core/query/widgets/SmartColumnWidget.js.map +1 -1
- package/dist/core/query/widgets/SmartFilterWidget.js +88 -51
- package/dist/core/query/widgets/SmartFilterWidget.js.map +1 -1
- package/dist/entities/ConnectionEntityDefinition.js +32 -7
- package/dist/entities/ConnectionEntityDefinition.js.map +1 -1
- package/dist/entities/SavedQueryEntityDefinition.js +68 -0
- package/dist/entities/SavedQueryEntityDefinition.js.map +1 -0
- package/dist/entities/SchemaModelDefinitionEntityDefinition.js +3 -1
- package/dist/entities/SchemaModelDefinitionEntityDefinition.js.map +1 -1
- package/dist/entities.js +1 -0
- package/dist/entities.js.map +1 -1
- package/dist/forms/APIConnectionForm.js +11 -2
- package/dist/forms/APIConnectionForm.js.map +1 -1
- package/dist/forms/TypeEngine.js +30 -306
- package/dist/forms/TypeEngine.js.map +1 -1
- package/dist/forms/types/attachment-handler.js +29 -0
- package/dist/forms/types/attachment-handler.js.map +1 -0
- package/dist/forms/types/boolean-handler.js +22 -0
- package/dist/forms/types/boolean-handler.js.map +1 -0
- package/dist/forms/types/date-handler.js +97 -0
- package/dist/forms/types/date-handler.js.map +1 -0
- package/dist/forms/types/filters/ClearableFilterFormDialogDirective.js +25 -0
- package/dist/forms/types/filters/ClearableFilterFormDialogDirective.js.map +1 -0
- package/dist/forms/types/filters/ConditionalFilterForm.js +87 -0
- package/dist/forms/types/filters/ConditionalFilterForm.js.map +1 -0
- package/dist/forms/types/image-handler.js +82 -0
- package/dist/forms/types/image-handler.js.map +1 -0
- package/dist/forms/types/location-handler.js +49 -0
- package/dist/forms/types/location-handler.js.map +1 -0
- package/dist/forms/types/multiple-choice-handler.js +37 -0
- package/dist/forms/types/multiple-choice-handler.js.map +1 -0
- package/dist/forms/types/multiple-choice-integer-handler.js +37 -0
- package/dist/forms/types/multiple-choice-integer-handler.js.map +1 -0
- package/dist/forms/types/number-handler.js +79 -0
- package/dist/forms/types/number-handler.js.map +1 -0
- package/dist/forms/types/shared/type-handler.js +2 -0
- package/dist/forms/types/shared/type-handler.js.map +1 -0
- package/dist/forms/types/shared/ui.js +33 -0
- package/dist/forms/types/shared/ui.js.map +1 -0
- package/dist/forms/types/single-choice-handler.js +41 -0
- package/dist/forms/types/single-choice-handler.js.map +1 -0
- package/dist/forms/types/single-choice-integer-handler.js +41 -0
- package/dist/forms/types/single-choice-integer-handler.js.map +1 -0
- package/dist/forms/types/text-handler.js +170 -0
- package/dist/forms/types/text-handler.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/panels/_shared/SharedConnectionPanelFactory.js +48 -0
- package/dist/panels/_shared/SharedConnectionPanelFactory.js.map +1 -0
- package/dist/panels/_shared/SharedModelPanelFactory.js +7 -2
- package/dist/panels/_shared/SharedModelPanelFactory.js.map +1 -1
- package/dist/panels/query/PageResultsWidget.js +28 -11
- package/dist/panels/query/PageResultsWidget.js.map +1 -1
- package/dist/panels/query/QueryPanelFactory.js +17 -2
- package/dist/panels/query/QueryPanelFactory.js.map +1 -1
- package/dist/panels/query/QueryPanelWidget.js +55 -9
- package/dist/panels/query/QueryPanelWidget.js.map +1 -1
- package/dist/panels/query/TableControlsWidget.js +29 -67
- package/dist/panels/query/TableControlsWidget.js.map +1 -1
- package/dist/panels/query/table-controls/ChangesControlsWidget.js +36 -0
- package/dist/panels/query/table-controls/ChangesControlsWidget.js.map +1 -0
- package/dist/panels/query/table-controls/FilterControlsWidget.js +106 -0
- package/dist/panels/query/table-controls/FilterControlsWidget.js.map +1 -0
- package/dist/panels/query/table-controls/PageControlsWidget.js +65 -0
- package/dist/panels/query/table-controls/PageControlsWidget.js.map +1 -0
- package/dist/panels/query/table-controls/QueryControlsWidget.js +85 -0
- package/dist/panels/query/table-controls/QueryControlsWidget.js.map +1 -0
- package/dist/panels/query/table-controls/SortChipWidget.js +75 -0
- package/dist/panels/query/table-controls/SortChipWidget.js.map +1 -0
- package/dist/panels/query/table-controls/SortControlsWidget.js +65 -0
- package/dist/panels/query/table-controls/SortControlsWidget.js.map +1 -0
- package/dist/preferences/QueryControlPreferences.js +28 -0
- package/dist/preferences/QueryControlPreferences.js.map +1 -0
- package/dist/stores/ConnectionStore.js +2 -0
- package/dist/stores/ConnectionStore.js.map +1 -1
- package/dist/stores/SavedQueryStore.js +131 -0
- package/dist/stores/SavedQueryStore.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/widgets/EmptyValueWidget.js +15 -0
- package/dist/widgets/EmptyValueWidget.js.map +1 -0
- package/dist-module/bundle.js +181 -51
- package/dist-module/bundle.js.map +1 -1
- package/package.json +13 -13
- package/src/DataBrowserModule.ts +21 -7
- package/src/actions/connections/AddConnectionAction.tsx +2 -2
- package/src/actions/connections/RemoveConnectionAction.tsx +2 -2
- package/src/actions/connections/SetConnectionColorAction.ts +52 -0
- package/src/actions/saved-queries/OpenSavedQueryAction.ts +43 -0
- package/src/actions/saved-queries/RemoveSavedQueryAction.ts +27 -0
- package/src/actions/schema-definitions/CreateModelAction.ts +9 -2
- package/src/actions/schema-definitions/QuerySchemaModelAction.ts +9 -2
- package/src/actions/schema-model/EditSchemaModelAction.ts +9 -2
- package/src/actions/schema-model/ViewSchemaModelAsJsonAction.ts +9 -2
- package/src/core/AbstractConnection.ts +7 -1
- package/src/core/SchemaModelDefinition.ts +16 -0
- package/src/core/connection-colors.ts +49 -0
- package/src/core/query/StandardModelFields.ts +9 -0
- package/src/core/query/filters.ts +121 -6
- package/src/core/query/query-simple/SimplePage.ts +4 -5
- package/src/core/query/query-simple/SimpleQuery.tsx +83 -86
- package/src/core/query/query-simple/SimpleQueryColumns.tsx +126 -0
- package/src/core/query/query-simple/SimpleQueryFilterState.ts +160 -0
- package/src/core/query/query-simple/SimpleQueryPlanner.ts +18 -0
- package/src/core/query/query-simple/SimpleQuerySortState.ts +133 -0
- package/src/core/query/query-simple/SimpleQueryTypes.ts +61 -0
- package/src/core/query/widgets/BelongsToDisplayWidget.tsx +19 -11
- package/src/core/query/widgets/CellDisplayWidget.tsx +5 -10
- package/src/core/query/widgets/ColumnDisplayWidget.tsx +24 -20
- package/src/core/query/widgets/PeekRelationshipButton.tsx +161 -0
- package/src/core/query/widgets/SmartColumnWidget.tsx +26 -4
- package/src/core/query/widgets/SmartFilterWidget.tsx +119 -69
- package/src/entities/ConnectionEntityDefinition.tsx +33 -4
- package/src/entities/SavedQueryEntityDefinition.ts +72 -0
- package/src/entities/SchemaModelDefinitionEntityDefinition.ts +5 -2
- package/src/entities.ts +2 -1
- package/src/forms/APIConnectionForm.tsx +15 -2
- package/src/forms/TypeEngine.tsx +35 -421
- package/src/forms/types/attachment-handler.tsx +35 -0
- package/src/forms/types/boolean-handler.tsx +28 -0
- package/src/forms/types/date-handler.tsx +125 -0
- package/src/forms/types/filters/ClearableFilterFormDialogDirective.ts +32 -0
- package/src/forms/types/filters/ConditionalFilterForm.tsx +109 -0
- package/src/forms/types/image-handler.tsx +90 -0
- package/src/forms/types/location-handler.tsx +53 -0
- package/src/forms/types/multiple-choice-handler.tsx +37 -0
- package/src/forms/types/multiple-choice-integer-handler.tsx +37 -0
- package/src/forms/types/number-handler.tsx +100 -0
- package/src/forms/types/shared/type-handler.ts +36 -0
- package/src/forms/types/shared/ui.tsx +40 -0
- package/src/forms/types/single-choice-handler.tsx +47 -0
- package/src/forms/types/single-choice-integer-handler.tsx +47 -0
- package/src/forms/types/text-handler.tsx +247 -0
- package/src/index.ts +1 -0
- package/src/panels/_shared/SharedConnectionPanelFactory.tsx +55 -0
- package/src/panels/_shared/SharedModelPanelFactory.tsx +8 -2
- package/src/panels/query/PageResultsWidget.tsx +40 -28
- package/src/panels/query/QueryPanelFactory.tsx +19 -2
- package/src/panels/query/QueryPanelWidget.tsx +64 -9
- package/src/panels/query/TableControlsWidget.tsx +42 -120
- package/src/panels/query/table-controls/ChangesControlsWidget.tsx +72 -0
- package/src/panels/query/table-controls/FilterControlsWidget.tsx +145 -0
- package/src/panels/query/table-controls/PageControlsWidget.tsx +97 -0
- package/src/panels/query/table-controls/QueryControlsWidget.tsx +127 -0
- package/src/panels/query/table-controls/SortChipWidget.tsx +119 -0
- package/src/panels/query/table-controls/SortControlsWidget.tsx +95 -0
- package/src/preferences/QueryControlPreferences.ts +34 -0
- package/src/stores/ConnectionStore.ts +2 -0
- package/src/stores/SavedQueryStore.ts +121 -0
- package/src/widgets/EmptyValueWidget.tsx +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@journeyapps-labs/reactor-mod-data-browser",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"typings": "./dist/@types/index",
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,29 +15,29 @@
|
|
|
15
15
|
"license": "Apache-2.0",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@emotion/styled": "^11.14.1",
|
|
18
|
-
"@fortawesome/react-fontawesome": "^3.
|
|
18
|
+
"@fortawesome/react-fontawesome": "^3.2.0",
|
|
19
19
|
"@journeyapps-labs/client-backend-v4": "1.0.0",
|
|
20
|
-
"@journeyapps-labs/common-ioc": "^1.0.
|
|
21
|
-
"@journeyapps-labs/common-sdk": "^1.0.
|
|
20
|
+
"@journeyapps-labs/common-ioc": "^1.0.1",
|
|
21
|
+
"@journeyapps-labs/common-sdk": "^1.0.3",
|
|
22
22
|
"@journeyapps-labs/common-utils": "^1.0.1",
|
|
23
|
-
"@journeyapps-labs/lib-reactor-data-layer": "
|
|
24
|
-
"@journeyapps-labs/reactor-mod": "
|
|
25
|
-
"@journeyapps-labs/reactor-mod-editor": "
|
|
23
|
+
"@journeyapps-labs/lib-reactor-data-layer": "1.0.10",
|
|
24
|
+
"@journeyapps-labs/reactor-mod": "5.0.0",
|
|
25
|
+
"@journeyapps-labs/reactor-mod-editor": "2.0.0",
|
|
26
26
|
"@journeyapps/db": "^8.1.1",
|
|
27
27
|
"@journeyapps/parser-schema": "^8.2.5",
|
|
28
|
-
"@projectstorm/react-workspaces-core": "4.2.
|
|
28
|
+
"@projectstorm/react-workspaces-core": "4.2.3",
|
|
29
29
|
"async": "^3.2.6",
|
|
30
|
-
"lodash": "^4.17.
|
|
30
|
+
"lodash": "^4.17.23",
|
|
31
31
|
"mobx": "^6.15.0",
|
|
32
32
|
"mobx-react": "^9.2.1",
|
|
33
|
-
"react": "19.2.
|
|
33
|
+
"react": "19.2.4",
|
|
34
34
|
"uuid": "^13.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
+
"@journeyapps-labs/lib-reactor-builder": "2.0.5",
|
|
37
38
|
"@types/async": "^3.2.25",
|
|
38
|
-
"@types/
|
|
39
|
-
"@
|
|
40
|
-
"@types/lodash": "^4.17.20",
|
|
39
|
+
"@types/lodash": "^4.17.24",
|
|
40
|
+
"@types/react": "^19.2.14",
|
|
41
41
|
"@types/uuid": "^11.0.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
package/src/DataBrowserModule.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractReactorModule, System, WorkspaceStore } from '@journeyapps-labs/reactor-mod';
|
|
1
|
+
import { AbstractReactorModule, ActionStore, PrefsStore, System, WorkspaceStore } from '@journeyapps-labs/reactor-mod';
|
|
2
2
|
import { Container } from '@journeyapps-labs/common-ioc';
|
|
3
3
|
import { ConnectionStore } from './stores/ConnectionStore';
|
|
4
4
|
import { ConnectionEntityDefinition } from './entities/ConnectionEntityDefinition';
|
|
@@ -6,6 +6,7 @@ import { ManualConnectionFactory } from './core/types/ManualConnectionFactory';
|
|
|
6
6
|
import { ConnectionFactoryEntityDefinition } from './entities/ConnectionFactoryEntityDefinition';
|
|
7
7
|
import { AddConnectionAction } from './actions/connections/AddConnectionAction';
|
|
8
8
|
import { RemoveConnectionAction } from './actions/connections/RemoveConnectionAction';
|
|
9
|
+
import { SetConnectionColorAction } from './actions/connections/SetConnectionColorAction';
|
|
9
10
|
import { SchemaModelDefinitionEntityDefinition } from './entities/SchemaModelDefinitionEntityDefinition';
|
|
10
11
|
import { QueryPanelFactory } from './panels/query/QueryPanelFactory';
|
|
11
12
|
import { QuerySchemaModelAction } from './actions/schema-definitions/QuerySchemaModelAction';
|
|
@@ -18,6 +19,11 @@ import { TypeEngine } from './forms/TypeEngine';
|
|
|
18
19
|
import { ViewSchemaModelAsJsonAction } from './actions/schema-model/ViewSchemaModelAsJsonAction';
|
|
19
20
|
import { ModelJsonPanelFactory } from './panels/model-json/ModelJsonPanelFactory';
|
|
20
21
|
import { SchemaModelIndexDefinition } from './entities/SchemaModelIndexDefinition';
|
|
22
|
+
import { SavedQueryStore } from './stores/SavedQueryStore';
|
|
23
|
+
import { SavedQueryEntityDefinition } from './entities/SavedQueryEntityDefinition';
|
|
24
|
+
import { OpenSavedQueryAction } from './actions/saved-queries/OpenSavedQueryAction';
|
|
25
|
+
import { RemoveSavedQueryAction } from './actions/saved-queries/RemoveSavedQueryAction';
|
|
26
|
+
import { registerQueryControlPreferences } from './preferences/QueryControlPreferences';
|
|
21
27
|
|
|
22
28
|
export class DataBrowserModule extends AbstractReactorModule {
|
|
23
29
|
constructor() {
|
|
@@ -28,6 +34,7 @@ export class DataBrowserModule extends AbstractReactorModule {
|
|
|
28
34
|
|
|
29
35
|
register(ioc: Container) {
|
|
30
36
|
const system = ioc.get(System);
|
|
37
|
+
const actionStore = ioc.get(ActionStore);
|
|
31
38
|
const workspaceStore = ioc.get(WorkspaceStore);
|
|
32
39
|
|
|
33
40
|
let connectionStore = new ConnectionStore();
|
|
@@ -35,14 +42,19 @@ export class DataBrowserModule extends AbstractReactorModule {
|
|
|
35
42
|
|
|
36
43
|
connectionStore.registerConnectionFactory(new ManualConnectionFactory());
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
actionStore.registerAction(new AddConnectionAction());
|
|
46
|
+
actionStore.registerAction(new RemoveConnectionAction());
|
|
47
|
+
actionStore.registerAction(new SetConnectionColorAction());
|
|
48
|
+
actionStore.registerAction(new QuerySchemaModelAction());
|
|
49
|
+
actionStore.registerAction(new CreateModelAction());
|
|
50
|
+
actionStore.registerAction(new EditSchemaModelAction());
|
|
51
|
+
actionStore.registerAction(new ViewSchemaModelAsJsonAction());
|
|
52
|
+
actionStore.registerAction(new OpenSavedQueryAction());
|
|
53
|
+
actionStore.registerAction(new RemoveSavedQueryAction());
|
|
44
54
|
|
|
45
55
|
system.addStore(ConnectionStore, connectionStore);
|
|
56
|
+
system.addStore(SavedQueryStore, new SavedQueryStore());
|
|
57
|
+
registerQueryControlPreferences(ioc.get(PrefsStore));
|
|
46
58
|
|
|
47
59
|
system.registerDefinition(new ConnectionEntityDefinition());
|
|
48
60
|
system.registerDefinition(new ConnectionFactoryEntityDefinition());
|
|
@@ -50,6 +62,7 @@ export class DataBrowserModule extends AbstractReactorModule {
|
|
|
50
62
|
system.registerDefinition(new SchemaModelObjectEntityDefinition());
|
|
51
63
|
system.registerDefinition(new SchemaModelIndexDefinition());
|
|
52
64
|
system.registerDefinition(new QueryEntityDefinition());
|
|
65
|
+
system.registerDefinition(new SavedQueryEntityDefinition());
|
|
53
66
|
|
|
54
67
|
workspaceStore.registerFactory(new QueryPanelFactory());
|
|
55
68
|
workspaceStore.registerFactory(new ModelPanelFactory());
|
|
@@ -58,5 +71,6 @@ export class DataBrowserModule extends AbstractReactorModule {
|
|
|
58
71
|
|
|
59
72
|
async init(ioc: Container): Promise<any> {
|
|
60
73
|
ioc.get(ConnectionStore).init();
|
|
74
|
+
ioc.get(SavedQueryStore).init();
|
|
61
75
|
}
|
|
62
76
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityAction, EntityActionEvent, inject, ioc
|
|
1
|
+
import { ActionStore, EntityAction, EntityActionEvent, inject, ioc } from '@journeyapps-labs/reactor-mod';
|
|
2
2
|
import { AbstractConnectionFactory } from '../../core/AbstractConnectionFactory';
|
|
3
3
|
import { DataBrowserEntities } from '../../entities';
|
|
4
4
|
import { ConnectionStore } from '../../stores/ConnectionStore';
|
|
@@ -28,6 +28,6 @@ export class AddConnectionAction extends EntityAction<AbstractConnectionFactory>
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
static get() {
|
|
31
|
-
return ioc.get(
|
|
31
|
+
return ioc.get(ActionStore).getActionByID<AddConnectionAction>(AddConnectionAction.ID);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityAction, EntityActionEvent, inject, ioc
|
|
1
|
+
import { ActionStore, EntityAction, EntityActionEvent, inject, ioc } from '@journeyapps-labs/reactor-mod';
|
|
2
2
|
import { DataBrowserEntities } from '../../entities';
|
|
3
3
|
import { ConnectionStore } from '../../stores/ConnectionStore';
|
|
4
4
|
import { AbstractConnection } from '../../core/AbstractConnection';
|
|
@@ -23,6 +23,6 @@ export class RemoveConnectionAction extends EntityAction<AbstractConnection> {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
static get() {
|
|
26
|
-
return ioc.get(
|
|
26
|
+
return ioc.get(ActionStore).getActionByID<RemoveConnectionAction>(RemoveConnectionAction.ID);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActionStore,
|
|
3
|
+
ComboBoxStore2,
|
|
4
|
+
EntityAction,
|
|
5
|
+
EntityActionEvent,
|
|
6
|
+
SimpleComboBoxDirective,
|
|
7
|
+
inject,
|
|
8
|
+
ioc
|
|
9
|
+
} from '@journeyapps-labs/reactor-mod';
|
|
10
|
+
import { AbstractConnection } from '../../core/AbstractConnection';
|
|
11
|
+
import { DataBrowserEntities } from '../../entities';
|
|
12
|
+
import { getConnectionColorComboBoxItems } from '../../core/connection-colors';
|
|
13
|
+
import { ConnectionStore } from '../../stores/ConnectionStore';
|
|
14
|
+
|
|
15
|
+
export class SetConnectionColorAction extends EntityAction<AbstractConnection> {
|
|
16
|
+
static ID = 'SET_CONNECTION_COLOR';
|
|
17
|
+
|
|
18
|
+
@inject(ComboBoxStore2)
|
|
19
|
+
accessor comboStore: ComboBoxStore2;
|
|
20
|
+
|
|
21
|
+
@inject(ConnectionStore)
|
|
22
|
+
accessor connectionStore: ConnectionStore;
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super({
|
|
26
|
+
id: SetConnectionColorAction.ID,
|
|
27
|
+
name: 'Set connection color',
|
|
28
|
+
icon: 'palette',
|
|
29
|
+
target: DataBrowserEntities.CONNECTION
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async fireEvent(event: EntityActionEvent<AbstractConnection>): Promise<any> {
|
|
34
|
+
const directive = await this.comboStore.show(
|
|
35
|
+
new SimpleComboBoxDirective({
|
|
36
|
+
title: 'Connection color',
|
|
37
|
+
event: event.position,
|
|
38
|
+
items: getConnectionColorComboBoxItems()
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
const selected = directive.getSelectedItem();
|
|
42
|
+
if (!selected?.key) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
event.targetEntity.color = selected.key;
|
|
46
|
+
this.connectionStore.save();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static get() {
|
|
50
|
+
return ioc.get(ActionStore).getActionByID<SetConnectionColorAction>(SetConnectionColorAction.ID);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActionStore,
|
|
3
|
+
EntityAction,
|
|
4
|
+
EntityActionEvent,
|
|
5
|
+
inject,
|
|
6
|
+
ioc,
|
|
7
|
+
WorkspaceStore
|
|
8
|
+
} from '@journeyapps-labs/reactor-mod';
|
|
9
|
+
import { DataBrowserEntities } from '../../entities';
|
|
10
|
+
import { SavedQueryEntity, SavedQueryStore } from '../../stores/SavedQueryStore';
|
|
11
|
+
import { QueryPanelModel } from '../../panels/query/QueryPanelFactory';
|
|
12
|
+
|
|
13
|
+
export class OpenSavedQueryAction extends EntityAction<SavedQueryEntity> {
|
|
14
|
+
static ID = 'OPEN_SAVED_QUERY';
|
|
15
|
+
|
|
16
|
+
@inject(WorkspaceStore)
|
|
17
|
+
accessor workspaceStore: WorkspaceStore;
|
|
18
|
+
|
|
19
|
+
@inject(SavedQueryStore)
|
|
20
|
+
accessor savedQueryStore: SavedQueryStore;
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super({
|
|
24
|
+
id: OpenSavedQueryAction.ID,
|
|
25
|
+
name: 'Open saved query',
|
|
26
|
+
icon: 'play',
|
|
27
|
+
target: DataBrowserEntities.SAVED_QUERY
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async fireEvent(event: EntityActionEvent<SavedQueryEntity>): Promise<any> {
|
|
32
|
+
const query = await this.savedQueryStore.loadSavedQuery(event.targetEntity.id);
|
|
33
|
+
if (!query) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
await query.load();
|
|
37
|
+
this.workspaceStore.addModel(new QueryPanelModel(query));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static get() {
|
|
41
|
+
return ioc.get(ActionStore).getActionByID<OpenSavedQueryAction>(OpenSavedQueryAction.ID);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ActionStore, EntityAction, EntityActionEvent, inject, ioc } from '@journeyapps-labs/reactor-mod';
|
|
2
|
+
import { DataBrowserEntities } from '../../entities';
|
|
3
|
+
import { SavedQueryEntity, SavedQueryStore } from '../../stores/SavedQueryStore';
|
|
4
|
+
|
|
5
|
+
export class RemoveSavedQueryAction extends EntityAction<SavedQueryEntity> {
|
|
6
|
+
static ID = 'REMOVE_SAVED_QUERY';
|
|
7
|
+
|
|
8
|
+
@inject(SavedQueryStore)
|
|
9
|
+
accessor savedQueryStore: SavedQueryStore;
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super({
|
|
13
|
+
id: RemoveSavedQueryAction.ID,
|
|
14
|
+
name: 'Delete saved query',
|
|
15
|
+
icon: 'trash',
|
|
16
|
+
target: DataBrowserEntities.SAVED_QUERY
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async fireEvent(event: EntityActionEvent<SavedQueryEntity>): Promise<any> {
|
|
21
|
+
await this.savedQueryStore.removeSavedQuery(event.targetEntity.id);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static get() {
|
|
25
|
+
return ioc.get(ActionStore).getActionByID<RemoveSavedQueryAction>(RemoveSavedQueryAction.ID);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ActionStore,
|
|
3
|
+
EntityAction,
|
|
4
|
+
EntityActionEvent,
|
|
5
|
+
inject,
|
|
6
|
+
ioc,
|
|
7
|
+
WorkspaceStore
|
|
8
|
+
} from '@journeyapps-labs/reactor-mod';
|
|
2
9
|
import { DataBrowserEntities } from '../../entities';
|
|
3
10
|
import { SchemaModelDefinition } from '../../core/SchemaModelDefinition';
|
|
4
11
|
import { ModelPanelModel } from '../../panels/model/ModelPanelFactory';
|
|
@@ -28,6 +35,6 @@ export class CreateModelAction extends EntityAction<SchemaModelDefinition> {
|
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
static get() {
|
|
31
|
-
return ioc.get(
|
|
38
|
+
return ioc.get(ActionStore).getActionByID<CreateModelAction>(CreateModelAction.ID);
|
|
32
39
|
}
|
|
33
40
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ActionStore,
|
|
3
|
+
EntityAction,
|
|
4
|
+
EntityActionEvent,
|
|
5
|
+
inject,
|
|
6
|
+
ioc,
|
|
7
|
+
WorkspaceStore
|
|
8
|
+
} from '@journeyapps-labs/reactor-mod';
|
|
2
9
|
import { DataBrowserEntities } from '../../entities';
|
|
3
10
|
import { SchemaModelDefinition } from '../../core/SchemaModelDefinition';
|
|
4
11
|
import { QueryPanelModel } from '../../panels/query/QueryPanelFactory';
|
|
@@ -31,6 +38,6 @@ export class QuerySchemaModelAction extends EntityAction<SchemaModelDefinition>
|
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
static get() {
|
|
34
|
-
return ioc.get(
|
|
41
|
+
return ioc.get(ActionStore).getActionByID<QuerySchemaModelAction>(QuerySchemaModelAction.ID);
|
|
35
42
|
}
|
|
36
43
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ActionStore,
|
|
3
|
+
EntityAction,
|
|
4
|
+
EntityActionEvent,
|
|
5
|
+
inject,
|
|
6
|
+
ioc,
|
|
7
|
+
WorkspaceStore
|
|
8
|
+
} from '@journeyapps-labs/reactor-mod';
|
|
2
9
|
import { DataBrowserEntities } from '../../entities';
|
|
3
10
|
import { SchemaModelObject } from '../../core/SchemaModelObject';
|
|
4
11
|
import { ModelPanelModel } from '../../panels/model/ModelPanelFactory';
|
|
@@ -28,6 +35,6 @@ export class EditSchemaModelAction extends EntityAction<SchemaModelObject> {
|
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
static get() {
|
|
31
|
-
return ioc.get(
|
|
38
|
+
return ioc.get(ActionStore).getActionByID<EditSchemaModelAction>(EditSchemaModelAction.ID);
|
|
32
39
|
}
|
|
33
40
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ActionStore,
|
|
3
|
+
EntityAction,
|
|
4
|
+
EntityActionEvent,
|
|
5
|
+
inject,
|
|
6
|
+
ioc,
|
|
7
|
+
WorkspaceStore
|
|
8
|
+
} from '@journeyapps-labs/reactor-mod';
|
|
2
9
|
import { DataBrowserEntities } from '../../entities';
|
|
3
10
|
import { SchemaModelObject } from '../../core/SchemaModelObject';
|
|
4
11
|
import { ModelJsonPanelModel } from '../../panels/model-json/ModelJsonPanelFactory';
|
|
@@ -28,6 +35,6 @@ export class ViewSchemaModelAsJsonAction extends EntityAction<SchemaModelObject>
|
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
static get() {
|
|
31
|
-
return ioc.get(
|
|
38
|
+
return ioc.get(ActionStore).getActionByID<ViewSchemaModelAsJsonAction>(ViewSchemaModelAsJsonAction.ID);
|
|
32
39
|
}
|
|
33
40
|
}
|
|
@@ -7,14 +7,17 @@ import { v4 } from 'uuid';
|
|
|
7
7
|
import { BaseObserver } from '@journeyapps-labs/common-utils';
|
|
8
8
|
import { Collection, LifecycleCollection } from '@journeyapps-labs/lib-reactor-data-layer';
|
|
9
9
|
import { when } from 'mobx';
|
|
10
|
+
import { observable } from 'mobx';
|
|
10
11
|
import { EntityDescription } from '@journeyapps-labs/reactor-mod';
|
|
11
12
|
import { V4BackendClient, V4Index, V4Indexes } from '@journeyapps-labs/client-backend-v4';
|
|
12
13
|
import { SchemaModelObject } from './SchemaModelObject';
|
|
14
|
+
import { getDefaultConnectionColor } from './connection-colors';
|
|
13
15
|
|
|
14
16
|
export interface AbstractConnectionSerialized {
|
|
15
17
|
factory: string;
|
|
16
18
|
id: string;
|
|
17
19
|
payload: any;
|
|
20
|
+
color?: string;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
export interface AbstractConnectionListener {
|
|
@@ -23,6 +26,7 @@ export interface AbstractConnectionListener {
|
|
|
23
26
|
|
|
24
27
|
export abstract class AbstractConnection extends BaseObserver<AbstractConnectionListener> {
|
|
25
28
|
id: string;
|
|
29
|
+
@observable accessor color: string;
|
|
26
30
|
|
|
27
31
|
schema_models_collection: Collection<ObjectType>;
|
|
28
32
|
schema_models: LifecycleCollection<ObjectType, SchemaModelDefinition>;
|
|
@@ -31,6 +35,7 @@ export abstract class AbstractConnection extends BaseObserver<AbstractConnection
|
|
|
31
35
|
constructor(public factory: AbstractConnectionFactory) {
|
|
32
36
|
super();
|
|
33
37
|
this.id = v4();
|
|
38
|
+
this.color = getDefaultConnectionColor(this.id);
|
|
34
39
|
this.schema_models_collection = new Collection();
|
|
35
40
|
this.schema_models = new LifecycleCollection({
|
|
36
41
|
collection: this.schema_models_collection,
|
|
@@ -124,7 +129,8 @@ export abstract class AbstractConnection extends BaseObserver<AbstractConnection
|
|
|
124
129
|
return {
|
|
125
130
|
id: this.id,
|
|
126
131
|
factory: this.factory.options.key,
|
|
127
|
-
payload: this._serialize()
|
|
132
|
+
payload: this._serialize(),
|
|
133
|
+
color: this.color
|
|
128
134
|
};
|
|
129
135
|
}
|
|
130
136
|
|
|
@@ -9,6 +9,7 @@ import { v4 } from 'uuid';
|
|
|
9
9
|
import { V4Index } from '@journeyapps-labs/client-backend-v4';
|
|
10
10
|
import { action, observable } from 'mobx';
|
|
11
11
|
import { IndexModel } from './IndexModel';
|
|
12
|
+
import { TypeEngine } from '../forms/TypeEngine';
|
|
12
13
|
|
|
13
14
|
export interface SchemaModelDefinitionListener {
|
|
14
15
|
resolved: (event: { object: SchemaModelObject }) => any;
|
|
@@ -169,4 +170,19 @@ export class SchemaModelDefinition
|
|
|
169
170
|
adapter: collection.adapter
|
|
170
171
|
});
|
|
171
172
|
}
|
|
173
|
+
|
|
174
|
+
getFilterableFields(typeEngine: TypeEngine): { key: string; label: string }[] {
|
|
175
|
+
return Object.values(this.definition.attributes)
|
|
176
|
+
.map((attribute) => {
|
|
177
|
+
const handler = typeEngine.getHandler(attribute.type);
|
|
178
|
+
if (!handler?.setupFilter) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
key: attribute.name,
|
|
183
|
+
label: attribute.label || attribute.name
|
|
184
|
+
};
|
|
185
|
+
})
|
|
186
|
+
.filter((value) => !!value);
|
|
187
|
+
}
|
|
172
188
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ComboBoxItem } from '@journeyapps-labs/reactor-mod';
|
|
2
|
+
|
|
3
|
+
export interface ConnectionColorOption {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const CONNECTION_COLOR_OPTIONS: ConnectionColorOption[] = [
|
|
9
|
+
{ key: '#00bcd4', label: 'Cyan' },
|
|
10
|
+
{ key: '#4caf50', label: 'Green' },
|
|
11
|
+
{ key: '#ff9800', label: 'Orange' },
|
|
12
|
+
{ key: '#e91e63', label: 'Pink' },
|
|
13
|
+
{ key: '#9c27b0', label: 'Purple' },
|
|
14
|
+
{ key: '#f44336', label: 'Red' },
|
|
15
|
+
{ key: '#2196f3', label: 'Blue' },
|
|
16
|
+
{ key: '#ffc107', label: 'Amber' }
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_CONNECTION_COLOR = CONNECTION_COLOR_OPTIONS[0].key;
|
|
20
|
+
|
|
21
|
+
export function getConnectionColorComboBoxItems(): ComboBoxItem[] {
|
|
22
|
+
return CONNECTION_COLOR_OPTIONS.map((option) => ({
|
|
23
|
+
key: option.key,
|
|
24
|
+
title: option.label,
|
|
25
|
+
icon: 'circle',
|
|
26
|
+
color: option.key
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getConnectionColorSetOptions(): Record<string, string> {
|
|
31
|
+
return CONNECTION_COLOR_OPTIONS.reduce(
|
|
32
|
+
(prev, option) => {
|
|
33
|
+
prev[option.key] = option.label;
|
|
34
|
+
return prev;
|
|
35
|
+
},
|
|
36
|
+
{} as Record<string, string>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function getDefaultConnectionColor(seed: string): string {
|
|
41
|
+
if (!seed) {
|
|
42
|
+
return DEFAULT_CONNECTION_COLOR;
|
|
43
|
+
}
|
|
44
|
+
let hash = 0;
|
|
45
|
+
for (let i = 0; i < seed.length; i++) {
|
|
46
|
+
hash = (hash * 31 + seed.charCodeAt(i)) >>> 0;
|
|
47
|
+
}
|
|
48
|
+
return CONNECTION_COLOR_OPTIONS[hash % CONNECTION_COLOR_OPTIONS.length].key;
|
|
49
|
+
}
|
|
@@ -1,30 +1,145 @@
|
|
|
1
1
|
import { Query, Variable } from '@journeyapps/db';
|
|
2
|
+
import { EntityLabel } from '@journeyapps-labs/reactor-mod';
|
|
3
|
+
import { BaseObserver } from '@journeyapps-labs/common-utils';
|
|
4
|
+
|
|
5
|
+
export interface AbstractFilterListener {
|
|
6
|
+
removeRequested: () => any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export abstract class AbstractFilter extends BaseObserver<AbstractFilterListener> {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
delete() {
|
|
15
|
+
this.iterateListeners((listener) => listener.removeRequested?.());
|
|
16
|
+
}
|
|
2
17
|
|
|
3
|
-
export abstract class AbstractFilter {
|
|
4
18
|
abstract augment(query: Query);
|
|
5
19
|
}
|
|
6
20
|
|
|
7
21
|
export enum Condition {
|
|
8
|
-
EQUALS = '='
|
|
22
|
+
EQUALS = '=',
|
|
23
|
+
NOT_EQUALS = '!=',
|
|
24
|
+
GREATER_THAN = '>',
|
|
25
|
+
GREATER_THAN_OR_EQUAL = '>=',
|
|
26
|
+
LESS_THAN = '<',
|
|
27
|
+
LESS_THAN_OR_EQUAL = '<=',
|
|
28
|
+
STARTS_WITH = 'starts with',
|
|
29
|
+
CONTAINS = 'contains'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export enum StatementMatch {
|
|
33
|
+
ANY = 'ANY',
|
|
34
|
+
ALL = 'ALL'
|
|
9
35
|
}
|
|
10
36
|
|
|
11
|
-
export
|
|
37
|
+
export enum FilterType {
|
|
38
|
+
SIMPLE = 'simple'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface SerializedStatement {
|
|
12
42
|
condition: Condition;
|
|
13
43
|
arg: any;
|
|
14
44
|
}
|
|
15
45
|
|
|
46
|
+
export interface SerializedSimpleFilter {
|
|
47
|
+
type: FilterType;
|
|
48
|
+
variable: string;
|
|
49
|
+
match?: StatementMatch;
|
|
50
|
+
statements: SerializedStatement[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class Statement {
|
|
54
|
+
constructor(
|
|
55
|
+
public condition: Condition,
|
|
56
|
+
public arg: any
|
|
57
|
+
) {}
|
|
58
|
+
|
|
59
|
+
serialize(): SerializedStatement {
|
|
60
|
+
return {
|
|
61
|
+
condition: this.condition,
|
|
62
|
+
arg: this.arg
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static deserialize(data: SerializedStatement): Statement {
|
|
67
|
+
if (
|
|
68
|
+
data.condition === Condition.EQUALS ||
|
|
69
|
+
data.condition === Condition.NOT_EQUALS ||
|
|
70
|
+
data.condition === Condition.GREATER_THAN ||
|
|
71
|
+
data.condition === Condition.GREATER_THAN_OR_EQUAL ||
|
|
72
|
+
data.condition === Condition.LESS_THAN ||
|
|
73
|
+
data.condition === Condition.LESS_THAN_OR_EQUAL ||
|
|
74
|
+
data.condition === Condition.STARTS_WITH ||
|
|
75
|
+
data.condition === Condition.CONTAINS
|
|
76
|
+
) {
|
|
77
|
+
return new Statement(data.condition, data.arg);
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`Unsupported statement condition: ${data.condition}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getMetadataLabel(): EntityLabel {
|
|
83
|
+
return {
|
|
84
|
+
label: this.condition,
|
|
85
|
+
value: `${this.arg}`
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
16
90
|
export class SimpleFilter extends AbstractFilter {
|
|
91
|
+
readonly type = FilterType.SIMPLE;
|
|
92
|
+
public statements: Statement[];
|
|
93
|
+
public match: StatementMatch;
|
|
94
|
+
|
|
17
95
|
constructor(
|
|
18
|
-
|
|
19
|
-
|
|
96
|
+
variable: Variable,
|
|
97
|
+
statements: (Statement | SerializedStatement)[],
|
|
98
|
+
match: StatementMatch = StatementMatch.ANY
|
|
20
99
|
) {
|
|
21
100
|
super();
|
|
101
|
+
this.variable = variable;
|
|
102
|
+
this.match = match;
|
|
103
|
+
this.statements = (statements || []).map((statement) => {
|
|
104
|
+
if (statement instanceof Statement) {
|
|
105
|
+
return statement;
|
|
106
|
+
}
|
|
107
|
+
return Statement.deserialize(statement);
|
|
108
|
+
});
|
|
22
109
|
}
|
|
23
110
|
|
|
111
|
+
public variable: Variable;
|
|
112
|
+
|
|
24
113
|
augment(query: Query) {
|
|
114
|
+
const separator = this.match === StatementMatch.ALL ? ' and ' : ' or ';
|
|
25
115
|
return query.where(
|
|
26
|
-
this.statements.map((s) => `${this.variable.name} ${s.condition} ?`).join(
|
|
116
|
+
this.statements.map((s) => `${this.variable.name} ${s.condition} ?`).join(separator),
|
|
27
117
|
...this.statements.map((s) => s.arg)
|
|
28
118
|
);
|
|
29
119
|
}
|
|
120
|
+
|
|
121
|
+
serialize(): SerializedSimpleFilter {
|
|
122
|
+
return {
|
|
123
|
+
type: this.type,
|
|
124
|
+
variable: this.variable.name,
|
|
125
|
+
match: this.match,
|
|
126
|
+
statements: this.statements.map((statement) => statement.serialize())
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static deserialize(variable: Variable, data: SerializedSimpleFilter): SimpleFilter {
|
|
131
|
+
return new SimpleFilter(variable, data?.statements || [], data?.match || StatementMatch.ANY);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static canDeserialize(data: any): data is SerializedSimpleFilter {
|
|
135
|
+
return !!data && (data.type == null || data.type === FilterType.SIMPLE);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
getMetadata() {
|
|
139
|
+
if (!this.statements || this.statements.length === 0) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return this.statements.map((statement) => statement.getMetadataLabel());
|
|
144
|
+
}
|
|
30
145
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Page, PageOptions } from '../Page';
|
|
2
2
|
import { AbstractFilter } from '../filters';
|
|
3
|
+
import { SimpleQuerySort } from './SimpleQueryTypes';
|
|
4
|
+
import { applyFiltersAndSorts } from './SimpleQueryPlanner';
|
|
3
5
|
|
|
4
6
|
export interface SimplePageOptions extends PageOptions {
|
|
5
7
|
offset: number;
|
|
6
8
|
limit: number;
|
|
7
9
|
filters: AbstractFilter[];
|
|
10
|
+
sorts?: SimpleQuerySort[];
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
export class SimplePage extends Page {
|
|
@@ -15,11 +18,7 @@ export class SimplePage extends Page {
|
|
|
15
18
|
async load() {
|
|
16
19
|
this.loading = true;
|
|
17
20
|
let collection = await this.options.definition.getCollection();
|
|
18
|
-
let query = collection.all();
|
|
19
|
-
|
|
20
|
-
this.options2.filters.forEach((f) => {
|
|
21
|
-
query = f.augment(query);
|
|
22
|
-
});
|
|
21
|
+
let query = applyFiltersAndSorts(collection.all(), this.options2.filters, this.options2.sorts || []);
|
|
23
22
|
|
|
24
23
|
this.models = await this.options.definition.executeQuery(
|
|
25
24
|
query.limit(this.options2.limit).skip(this.options2.offset)
|