Skip to content

Commit

Permalink
use tags from get samples
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Sep 12, 2024
1 parent aa3604a commit 0c2145e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/api/backend-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface sample_t {
tokens: number;
blindAnnotationLevel: number;
treeByUser: { [key: string]: number };
tags: { [key: string]: number };
}

//// GREW
Expand Down
32 changes: 11 additions & 21 deletions src/components/project/StatisticsProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,22 @@
</q-card>
</div>
<div class="row justify-between q-gutter-md">
<q-card v-if="projectUsedTags.length" flat bordered class="col">
<q-card v-if="projectTags.length" flat bordered class="col">
<q-card-section class="q-gutter-md">
<div class="text-h6">
{{ $t('projectStats.usedTags') }}
</div>
<q-separator />
<div class="row q-gutter-x-md">
<q-chip v-for="tag in projectUsedTags" outline color="primary" size="sm" :label="tag"/>
<q-chip v-for="tag in projectTags" outline color="primary" size="sm" :label="tag"/>
</div>
</q-card-section>
</q-card>
</div>
<q-separator />
</template>
<script lang="ts">
import { statProject_t } from 'src/api/backend-types';
import { statProject_t, sample_t } from 'src/api/backend-types';
import { notifyError } from 'src/utils/notify';
import { timeAgo } from 'src/utils/timeAgoUtils';
import { defineComponent, PropType } from 'vue';
Expand All @@ -143,10 +143,8 @@ export default defineComponent({
};
const topUserProgress: number = 0;
const topUserProgressLabel: string = '';
const projectUsedTags: string[] = [];
return {
projectStat,
projectUsedTags,
topUserProgress,
topUserProgressLabel,
}
Expand All @@ -156,14 +154,18 @@ export default defineComponent({
type: String as PropType<string>,
required: true,
},
sampleNames: {
type: Array as PropType<string[]>,
samples: {
type: Array as PropType<sample_t[]>,
required: true,
}
},
mounted() {
this.getStatistics();
this.getProjectTags();
},
computed: {
projectTags() {
return this.samples.map((sample) => Object.keys(sample.tags)).reduce((a: string[], b: string[]) => [...a, ...b], []);
}
},
methods: {
timeAgo(secsAgo: number) {
Expand All @@ -183,19 +185,7 @@ export default defineComponent({
notifyError({ error: `Error while loading project statistics ${error}` });
});
},
getProjectTags() {
const data = { sampleNames: this.sampleNames}
api
.getProjectTags(this.projectName, data)
.then((response) => {
this.projectUsedTags = response.data;
})
.catch((error) => {
notifyError({ error: `Error happened while loading project tags: ${error}` });
})
}
}
})
});
</script>
2 changes: 1 addition & 1 deletion src/pages/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<q-separator />
</q-card-section>
<q-card-section class="q-gutter-md">
<StatisticsProject v-if="sampleNames.length" :project-name="projectName" :sample-names="sampleNames"></StatisticsProject>
<StatisticsProject v-if="sampleNames.length" :project-name="projectName" :samples="samples"></StatisticsProject>
</q-card-section>
<q-card-section>
<div class="row q-gutter-md" style="justify-content: right">
Expand Down

0 comments on commit 0c2145e

Please sign in to comment.