-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
53 lines (44 loc) · 1.65 KB
/
Copy pathapp.ts
File metadata and controls
53 lines (44 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { isJsonEqual } from '@milaboratories/helpers';
import { getDefaultBlockLabel, platforma } from '@platforma-open/milaboratories.vj-usage.model';
import { defineAppV3 } from '@platforma-sdk/ui-vue';
import { computed, watchEffect } from 'vue';
import JUsage from './pages/JUsage.vue';
import VJUsage from './pages/VJUsage.vue';
import VUsage from './pages/VUsage.vue';
import { useIsSingleCell, useScChainOptions } from './utils';
export const sdkPlugin = defineAppV3(platforma, (app) => {
app.model.data.customBlockLabel ??= '';
syncDefaultBlockLabel(app.model);
return {
routes: {
'/': () => VUsage,
'/jUsage': () => JUsage,
'/vjUsage': () => VJUsage,
},
};
});
export const useApp = sdkPlugin.useApp;
type AppModel = ReturnType<typeof useApp>['model'];
function syncDefaultBlockLabel(model: AppModel) {
const isSingleCell = useIsSingleCell(() => model.outputs.datasetSpec);
const scChainOptions = useScChainOptions(() => model.outputs.datasetSpec);
const datasetLabel = computed(() => {
if (!model.data.datasetRef) return;
return model.outputs.datasetOptions
?.find((option) => isJsonEqual(option.ref, model.data.datasetRef))
?.label;
});
// Get chain label for single-cell datasets
const chainLabel = computed(() => {
if (!isSingleCell.value) return;
return scChainOptions.value?.find((o) => o.value === model.data.scChain)?.label;
});
watchEffect(() => {
model.data.defaultBlockLabel = getDefaultBlockLabel({
datasetLabel: datasetLabel.value,
allele: model.data.allele ?? false,
isSingleCell: isSingleCell.value,
chainLabel: chainLabel.value,
});
});
}