Skip to content

Commit 60d1c42

Browse files
committed
Create filters widget. Fix filters.
1 parent 368ad67 commit 60d1c42

File tree

24 files changed

+775
-14
lines changed

24 files changed

+775
-14
lines changed

packages/app/default/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
"org.eclipse.daanse.board.app.ui.vue.widget.vanta": "^0.0.1-next.1",
136136
"org.eclipse.daanse.board.app.ui.vue.widget.video": "^0.0.1-next.1",
137137
"org.eclipse.daanse.board.app.ui.vue.widget.wrapper": "^0.0.1-next.1",
138+
"org.eclipse.daanse.board.app.ui.vue.widget.xmla.filters": "^0.0.1-next.1",
138139
"pinia": "^3.0.1",
139140
"vue": "^3.5.13",
140141
"vue-grid-layout": "^2.4.0",

packages/app/default/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ import 'org.eclipse.daanse.board.app.ui.vue.datasource.ogcsta'
146146
import 'org.eclipse.daanse.board.app.ui.vue.widget.map'
147147
import 'org.eclipse.daanse.board.app.ui.vue.plugins.geojson_renderer'
148148
import 'org.eclipse.daanse.board.app.ui.vue.widget.weather'
149+
import 'org.eclipse.daanse.board.app.ui.vue.widget.xmla.filters'
149150
import 'org.eclipse.daanse.board.app.ui.vue.eventmanager'
150151

151152
import 'org.eclipse.daanse.board.app.lib.variables'

packages/lib/connection/xmla/src/classes/xml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class XMLAApi {
8383
Statement: '',
8484
},
8585
Properties: {
86-
PropertieList: {
86+
PropertyList: {
8787
LocaleIdentifier: '1033',
8888
},
8989
},

packages/lib/datasource/xmla/src/classes/index.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ export interface SecurityOptions {
5050
password?: string
5151
}
5252

53+
export interface FilterChangePayload {
54+
area: 'rows' | 'columns' | 'filters'
55+
filters: any
56+
id: string
57+
}
58+
5359
export class XmlaStore extends BaseDatasource {
5460
private connection: any
5561
private requestParams: XMLARequestParams = {
@@ -230,7 +236,7 @@ export class XmlaStore extends BaseDatasource {
230236
this.requestParams.measures,
231237
{},
232238
properties,
233-
[],
239+
this.requestParams.filters,
234240
levels,
235241
)
236242

@@ -260,6 +266,18 @@ export class XmlaStore extends BaseDatasource {
260266
return connectionRepository.getConnection(this.connection)
261267
}
262268

269+
changeFilters(e: FilterChangePayload) {
270+
console.log('event in the datasource', e);
271+
272+
const originalItem = this.requestParams[e.area].find(
273+
(item) => item.id === e.id
274+
);
275+
276+
if (originalItem) {
277+
originalItem.filters = e.filters;
278+
}
279+
}
280+
263281
callEvent(event: string, params: any) {
264282
switch (event) {
265283
case 'expand':
@@ -268,6 +286,9 @@ export class XmlaStore extends BaseDatasource {
268286
case 'collapse':
269287
this.collapse(params)
270288
break
289+
case 'filterChange':
290+
this.changeFilters(params)
291+
break
271292
default:
272293
console.warn('Event is not available for this type of store')
273294
}

packages/ui/vue/common/xmla/src/Filters/FilterTreeView.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Contributors:
1515
import { useFilterTreeDataSource } from "../Composables/filterTreeDataSource";
1616
import { useSearchResultTreeData } from "../Composables/searchResultTreeData";
1717
import { debounce } from "lodash";
18-
import { computed, ref, watch } from "vue";
18+
import { computed, onMounted, ref, watch } from "vue";
1919
2020
type RootHierarchy = any;
2121
@@ -95,7 +95,7 @@ const multipleChoise = ref(
9595
const singleSelection = ref({ id: null });
9696
9797
// expose resetSelection as function
98-
function resetSelection() {
98+
const resetSelection = () => {
9999
singleSelection.value = { id: null };
100100
}
101101
defineExpose({ resetSelection });
@@ -147,6 +147,12 @@ const emptySelection = computed(() => {
147147
function selectFilter(e: any) {
148148
singleSelection.value = e;
149149
}
150+
151+
onMounted(() => {
152+
if (props.rootHierarchy.filters.enabled && !props.rootHierarchy.filters.multipleChoise && props.rootHierarchy.filters.selectedItem?.id) {
153+
singleSelection.value = props.rootHierarchy.filters.selectedItem;
154+
}
155+
})
150156
</script>
151157
<template>
152158
<div class="flex" style="flex-direction: column; width: 100%">

packages/ui/vue/common/xmla/src/Modals/FiltersModal.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ const setSelection = ({
102102
};
103103
104104
function ok() {
105+
const composedFilters = filterConfigured.value;
106+
107+
if (filterConfigured.value.enabled && !filterConfigured.value.multipleChoise && !filterConfigured.value.selectedItem.id) {
108+
close({
109+
filters: {
110+
enabled: false
111+
}
112+
})
113+
}
114+
105115
close({ filters: filterConfigured.value });
106116
}
107117
@@ -110,7 +120,8 @@ function cancel() {
110120
}
111121
112122
function resetSelection() {
113-
filterTreeView.value?.resetSelection();
123+
const exposed = filterTreeView.value?.$.exposed as any;
124+
exposed['resetSelection']();
114125
}
115126
</script>
116127

packages/ui/vue/common/xmla/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
import MetadataTree from './MetadataTree/MetadataTree.vue'
1515
import QueryDesigner from './QueryDesigner/QueryDesigner.vue'
1616
import PivotTable from './PivotTable/PivotTable.vue'
17+
import FiltersModal from './Modals/FiltersModal.vue'
1718

18-
export { MetadataTree, QueryDesigner, PivotTable }
19+
export { MetadataTree, QueryDesigner, PivotTable, FiltersModal }

packages/ui/vue/composables/src/useDatasourceRepository.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ export interface IVueDatasourceRepository {
2929
) => Promise<void>
3030
update: (oldVal: string, newVal: string) => void
3131
getDataWithOptions: (options?: any) => Promise<void>
32+
getDatasourceInstance: () => any
3233
}
3334

3435
export function useDatasourceRepository(
3536
dataSourceId: Ref<string>,
3637
type: string,
3738
data: Ref<any>,
39+
subscriptions: Array<() => any> = [],
3840
): IVueDatasourceRepository {
3941
const instance = getCurrentInstance()
4042
const container = instance?.appContext.config.globalProperties
@@ -139,24 +141,44 @@ export function useDatasourceRepository(
139141
try {
140142
const oldDataSource = datasourceRepository.getDatasource(oldVal)
141143
oldDataSource.unsubscribe(getData)
144+
subscriptions.forEach(fn => {
145+
oldDataSource.unsubscribe(fn);
146+
});
142147
} catch (e) {
143148
console.warn(e)
144149
}
145150
try {
146151
const dataSource = datasourceRepository.getDatasource(newVal)
147152
// TODO: fix duplicate subscription
148153
dataSource.subscribe(()=>getData())
154+
subscriptions.forEach(fn => {
155+
dataSource.subscribe(fn);
156+
})
149157
} catch (e) {
150158
console.warn(e)
151159
}
152160
}
153161

162+
const getDatasourceInstance = () => {
163+
try {
164+
const dataSource = datasourceRepository.getDatasource(dataSourceId.value)
165+
return dataSource
166+
}
167+
catch (e) {
168+
console.warn(e)
169+
return null
170+
}
171+
}
172+
154173
onMounted(() => {
155174
getData()
156175

157176
try {
158177
const dataSource = datasourceRepository.getDatasource(dataSourceId.value)
159178
dataSource.subscribe(getData)
179+
subscriptions.forEach(fn => {
180+
dataSource.subscribe(fn);
181+
})
160182
} catch (e) {
161183
console.warn(e)
162184
}
@@ -166,6 +188,9 @@ export function useDatasourceRepository(
166188
try {
167189
const dataSource = datasourceRepository.getDatasource(dataSourceId.value)
168190
dataSource.unsubscribe(getData)
191+
subscriptions.forEach(fn => {
192+
dataSource.unsubscribe(fn);
193+
})
169194
} catch (e) {
170195
console.warn(e)
171196
}
@@ -176,5 +201,6 @@ export function useDatasourceRepository(
176201
callEvent,
177202
update,
178203
getDataWithOptions,
204+
getDatasourceInstance,
179205
}
180206
}

packages/ui/vue/widget/icon/src/gen/IconClickPayload.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2025 Contributors to the Eclipse Foundation.
2+
Copyright (c) 2023 Contributors to the Eclipse Foundation.
33
This program and the accompanying materials are made
44
available under the terms of the Eclipse Public License 2.0
55
which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -9,10 +9,24 @@ Contributors: Smart City Jena
99
1010
*/
1111

12-
import { Payload } from 'org.eclipse.daanse.board.app.lib.events'
13-
import { Documentation, Attribute, ModelClass } from 'org.eclipse.daanse.board.app.lib.annotations'
12+
/*
13+
* This is generated code! Please note, that on code generation, these line are erased and generated again.
14+
* If you modify this file, it is possible that you changes will be lost!!!
15+
*
16+
* This method uses JSON playload, to load an EPackage.
17+
*
18+
* @generated
19+
*/
20+
21+
/*
22+
* Generate classes and enums for TypeScript
23+
* Default values are set. The '_type' parameter is generated for the
24+
* Serialization to a backend.
25+
*/
26+
import {Payload} from 'org.eclipse.daanse.board.app.lib.events'
27+
import {Documentation, Attribute, ModelClass, Reference, Enum} from 'org.eclipse.daanse.board.app.lib.annotations'
1428

15-
@ModelClass({ type: 'http://org.eclipse.daanse.board.app.ui.vue.widget.icon#//IconClickPayload' })
29+
@ModelClass({type:'http://org.eclipse.daanse.board.app.ui.vue.widget.icon#//IconClickPayload'})
1630
export class IconClickPayload extends Payload {
1731

1832
@Documentation("Name of the clicked icon.")

packages/ui/vue/widget/map/src/gen/MapSettings.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,5 @@ export class MapSettings {
6161
@Attribute() enableClustering?: boolean;
6262

6363
@Documentation("Color used to highlight selected Things on the map (default: #ff0000)")
64-
@Attribute() selectionHighlightColor?: string = "#ff0000";
65-
66-
@Documentation("ID of the currently selected Thing (persisted across mode switches)")
67-
@Attribute() selectedThingId?: string | null;
64+
@Attribute() selectionHighlightColor: string = "#ff0000";
6865
}

0 commit comments

Comments
 (0)