Skip to content

Commit

Permalink
mob next [ci-skip] [ci skip] [skip ci]
Browse files Browse the repository at this point in the history
lastFile:frontend/src/components/DataStoreKeyList.vue
  • Loading branch information
rouk1 committed Sep 10, 2024
1 parent 0b7db29 commit 1747261
Show file tree
Hide file tree
Showing 22 changed files with 146 additions and 807 deletions.
45 changes: 11 additions & 34 deletions frontend/src/components/DataStoreCanvas.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<script setup lang="ts">
import { computed } from "vue";
import CrossValidationResultsWidget from "@/components/CrossValidationResultsWidget.vue";
import DataFrameWidget from "@/components/DataFrameWidget.vue";
import DataStoreCard from "@/components/DataStoreCard.vue";
import HtmlSnippetWidget from "@/components/HtmlSnippetWidget.vue";
import ImageWidget from "@/components/ImageWidget.vue";
import MarkdownWidget from "@/components/MarkdownWidget.vue";
import type { KeyLayoutSize, KeyMoveDirection } from "@/models";
import { useReportStore } from "@/stores/useReportStore";
import { useReportStore } from "@/stores/report";
const reportStore = useReportStore();
// const items = computed(() => {
Expand Down Expand Up @@ -58,11 +55,10 @@ const props = defineProps({
:key="key"
:title="key.toString()"
subtitle="FIXME"
:class="'FIXME'"
:showButtons="props.showCardButtons"
:can-move-up="true"
:can-move-down="true"
class="canvas-element"
class="canvas-element large"
@layout-changed="onLayoutChange(key.toString(), $event)"
@position-changed="onPositionChanged(key.toString(), $event)"
@card-removed="onCardRemoved(key.toString())"
Expand All @@ -74,41 +70,22 @@ const props = defineProps({
/>
<ImageWidget
v-if="
item_type === 'media' && media_type &&
item_type === 'media' &&
media_type &&
['image/svg+xml', 'image/png', 'image/jpeg', 'image/webp'].includes(media_type)
"
:mime-type="media_type"
:base64-src="serialized"
:alt="key.toString()"
/>
<ImageWidget
v-if="type === 'matplotlib_figure'"
mime-type="image/svg+xml"
:base64-src="data"
:alt="key.toString()"
/>
<MarkdownWidget
v-if="
[
'boolean',
'integer',
'number',
'string',
'any',
'array',
'date',
'datetime',
'markdown',
'numpy_array',
].includes(type!)
"
:source="data"
<MarkdownWidget v-if="['json', 'numpy_array'].includes(item_type)" :source="serialized" />
<HtmlSnippetWidget
v-if="'media' === item_type && media_type === 'text/html'"
:src="serialized"
/>
<HtmlSnippetWidget v-if="['html', 'sklearn_model'].includes(type!)" :src="data" />
<CrossValidationResultsWidget
v-if="type === 'cv_results'"
:roc_curve_spec="data.roc_curve_spec"
:cv_results_table="data.cv_results_table"
<HtmlSnippetWidget
v-if="'sklearn_base_estimator' === item_type && media_type === 'text/html'"
:src="serialized.html"
/>
</DataStoreCard>
</div>
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/DataStoreKey.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import type { IPayloadItemMetadata } from "@/models";
import { useReportStore } from "@/stores/useReportStore";
import { type ReportItemMetadata } from "@/models";
import { useReportStore } from "@/stores/report";
import { formatDistance } from "date-fns";
const props = defineProps<{ itemKey: string; metadata?: IPayloadItemMetadata }>();
const reportsStore = useReportStore();
const props = defineProps<{ itemKey: string; metadata?: ReportItemMetadata }>();
const reportStore = useReportStore();
const isDraggable = ref(false);
function addKey() {
reportsStore.displayKey(props.itemKey);
reportStore.displayKey(props.itemKey);
}
function onDragStart(event: DragEvent) {
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/components/DataStoreKeyList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import DataStoreKey from "@/components/DataStoreKey.vue";
import { useReportStore } from "@/stores/useReportStore";
import { useReportStore } from "@/stores/report";
const reportsStore = useReportStore();
const props = defineProps<{ icon: string; title: string; keys: string[] }>();
Expand All @@ -11,12 +11,7 @@ const props = defineProps<{ icon: string; title: string; keys: string[] }>();
<div class="data-store-list-item">
<h2><span :class="props.icon"></span>{{ props.title }}</h2>
<div class="keys">
<DataStoreKey
v-for="key in props.keys"
:key="key"
:item-key="key"
metadata="FIXME"
/>
<DataStoreKey v-for="key in props.keys" :key="key" :item-key="key" />
</div>
</div>
</template>
Expand Down
58 changes: 0 additions & 58 deletions frontend/src/components/FileTree.vue

This file was deleted.

110 changes: 0 additions & 110 deletions frontend/src/components/FileTreeItem.vue

This file was deleted.

5 changes: 4 additions & 1 deletion frontend/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ export interface ReportItem {
serialized: any;
}

export type Report = { [key: string]: ReportItem };
export interface ReportItemMetadata {
created_at: Date;
updated_at: Date;
}
4 changes: 2 additions & 2 deletions frontend/src/services/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Report } from "@/models";
import type { ReportItem } from "@/models";

const { protocol, hostname, port: windowPort } = window.location;
// In the general case we expect the webapp to run at the same port as the API
Expand All @@ -14,7 +14,7 @@ function reportError(message: string) {
console.error(message);
}

export async function fetchReport(): Promise<Report | null> {
export async function fetchReport(): Promise<{ [key: string]: ReportItem } | null> {
try {
const r = await fetch(`${BASE_URL}/skores/`);
if (r.status == 200) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createPinia } from "pinia";
import { createApp } from "vue";

import App from "@/ShareApp.vue";
import { useReportStore } from "./stores/useReportStore";
import { useReportStore } from "@/stores/report";

export default function share() {
const app = createApp(App);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { defineStore } from "pinia";
import { ref, shallowRef } from "vue";

import { type KeyLayoutSize, type KeyMoveDirection, type Layout, type Report } from "@/models";
import { type KeyLayoutSize, type KeyMoveDirection, type Layout, type ReportItem } from "@/models";
import { fetchReport } from "@/services/api";
import { poll, swapItemsInArray } from "@/services/utils";

export const useReportStore = defineStore("reports", () => {
// this object is not deeply reactive as it may be very large
const report = shallowRef<Report | null>(null);
const report = shallowRef<{ [key: string]: ReportItem } | null>(null);
const layout = ref<Layout>([]);

/**
Expand Down Expand Up @@ -113,7 +113,7 @@ export const useReportStore = defineStore("reports", () => {
}
}

function setReport(r: Report) {
function setReport(r: { [key: string]: ReportItem }) {
report.value = r;
// FIXME setup layout
}
Expand Down
Loading

0 comments on commit 1747261

Please sign in to comment.