Various changes to adhere to new api

This commit is contained in:
rijkvanzanten
2020-07-10 15:14:45 -04:00
parent a01442d154
commit 5448b4fa76
7 changed files with 9 additions and 18 deletions

View File

@@ -29,5 +29,5 @@ export default defineDisplay(({ i18n }) => ({
default_value: false,
},
],
fields: ['id', 'avatar.data', 'first_name', 'last_name'],
fields: ['id', 'avatar.id', 'first_name', 'last_name'],
}));

View File

@@ -299,7 +299,7 @@ export default defineComponent({
try {
const response = await api.get(`/users/${props.primaryKey}`, {
params: {
fields: ['role.name', 'avatar.data'],
fields: ['role.name', 'avatar.id'],
},
});

View File

@@ -23,9 +23,7 @@ export type Role = {
};
export type Avatar = {
data: {
thumbnails: Thumbnail[];
};
id: string;
};
type Thumbnail = {

View File

@@ -69,6 +69,7 @@ import { defineComponent, PropType, computed, ref, watch } from '@vue/compositio
import { Activity } from './types';
import format from 'date-fns/format';
import i18n from '@/lang';
import getRootPath from '@/utils/get-root-path';
import api from '@/api';
import localizedFormat from '@/utils/localized-format';
@@ -111,10 +112,7 @@ export default defineComponent({
const avatarSource = computed(() => {
if (!props.activity.action_by?.avatar) return null;
return (
props.activity.action_by.avatar.data.thumbnails.find((thumb) => thumb.key === 'directus-small-crop')
?.url || null
);
return getRootPath() + `assets/${props.activity.action_by.avatar.id}?key=directus-small-cover`;
});
const { confirmDelete, deleting, remove } = useDelete();

View File

@@ -77,7 +77,6 @@ export default defineComponent({
'filter[collection][eq]': collection,
'filter[item][eq]': primaryKey,
'filter[action][in]': 'comment',
'filter[comment_deleted_on][null]': 1,
sort: '-id', // directus_activity has auto increment and is therefore in chronological order
fields: [
'id',
@@ -86,9 +85,8 @@ export default defineComponent({
'action_by.id',
'action_by.first_name',
'action_by.last_name',
'action_by.avatar.data',
'action_by.avatar.id',
'comment',
'edited_on',
],
},
});

View File

@@ -38,6 +38,7 @@
<script lang="ts">
import { defineComponent, computed, ref } from '@vue/composition-api';
import useUserStore from '@/stores/user/';
import getRootPath from '../../../../utils/get-root-path';
export default defineComponent({
setup() {
@@ -49,11 +50,7 @@ export default defineComponent({
if (userStore.state.currentUser === null) return null;
if (userStore.state.currentUser.avatar === null) return null;
const thumbnail = userStore.state.currentUser.avatar.data.thumbnails.find((thumb) => {
return thumb.key === 'directus-medium-crop';
});
return thumbnail?.url || null;
return getRootPath() + `assets/${userStore.state.currentUser.avatar.id}?key=directus-medium-cover`;
});
const userProfileLink = computed<string>(() => {

View File

@@ -86,7 +86,7 @@ export default defineComponent({
try {
const response = await api.get(`/users/${props.user}`, {
params: {
fields: ['first_name', 'last_name', 'avatar.data', 'role.name', 'status', 'email'],
fields: ['first_name', 'last_name', 'avatar.id', 'role.name', 'status', 'email'],
},
});
data.value = response.data.data;