Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAndBear committed Sep 24, 2024
1 parent 10a8675 commit bdc93cf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
33 changes: 24 additions & 9 deletions packages/web-app-activities/src/components/ActivityItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@
<div>activity unknown</div>
<div class="oc-text-truncate">
<resource-list-item v-if="resource" :resource="resource" :is-resource-clickable="false" />
<div v-if="resourceDeleted" class="oc-text-muted oc-flex oc-flex-middle oc-p-xs">
<oc-icon name="delete-bin" />
<div
v-if="resourceNotAccessible"
class="oc-text-muted oc-flex oc-flex-middle oc-p-xs"
v-oc-tooltip="$gettext('The resource is unavailable, it may have been deleted.')"
>
<oc-icon name="eye-off" />
<span class="oc-ml-s" v-text="activity.template.variables.resource.name" />
</div>
</div>
<div><span v-text="modifiedDateTime"></span></div>
<div><span v-text="recordedDateTime" /></div>
</div>
</template>

<script lang="ts">
import { computed, defineComponent, onMounted, PropType, ref, unref } from 'vue'
import { Activity } from '@ownclouders/web-client/src/graph/generated'
import { DateTime } from 'luxon'
import { formatDateFromDateTime, ResourceListItem, useClientService } from '@ownclouders/web-pkg'
import {
formatDateFromDateTime,
formatRelativeDateFromDateTime,
ResourceListItem,
useClientService
} from '@ownclouders/web-pkg'
import { useGettext } from 'vue3-gettext'
import { Resource } from '@ownclouders/web-client'
Expand All @@ -37,10 +46,16 @@ export default defineComponent({
const clientService = useClientService()
const { current: currentLanguage } = useGettext()
const resource = ref<Resource>()
const resourceDeleted = ref(false)
const resourceNotAccessible = ref(false)
const modifiedDateTime = computed(() => {
const recordedDateTime = computed(() => {
const dateTime = DateTime.fromISO(props.activity.times.recordedTime)
const isWithinLastHour = dateTime > DateTime.now().minus({ hour: 1 })
if (isWithinLastHour) {
return formatRelativeDateFromDateTime(dateTime, currentLanguage)
}
return formatDateFromDateTime(dateTime, currentLanguage)
})
Expand All @@ -51,14 +66,14 @@ export default defineComponent({
{ fileId: props.activity.template.variables.resource.id }
)
} catch (e) {
resourceDeleted.value = true
resourceNotAccessible.value = true
}
})
return {
modifiedDateTime,
recordedDateTime,
resource,
resourceDeleted
resourceNotAccessible
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-activities/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineWebApplication({
name: $gettext('Activities'),
id: APPID,
icon: 'pulse',
color: '#ff6961'
color: '#887ef1'
}

const routes: RouteRecordRaw[] = [
Expand Down
13 changes: 0 additions & 13 deletions packages/web-app-activities/src/views/ActivityList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,6 @@ export default defineComponent({
}
acc[date].push(activity)
// TODO: Remove mock data
const date2 = DateTime.fromISO(activity.times.recordedTime).minus({ day: 1 }).toISODate()
if (!acc[date2]) {
acc[date2] = []
}
acc[date2].push(activity)
const date3 = DateTime.fromISO(activity.times.recordedTime).minus({ day: 2 }).toISODate()
if (!acc[date3]) {
acc[date3] = []
}
acc[date3].push(activity)
return acc
}, {})
})
Expand Down
4 changes: 2 additions & 2 deletions packages/web-app-activities/src/views/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ export default defineComponent({
})
const loadActivitiesTask = useTask(function* (signal) {
const filters = []
const filters = ['sort:desc']
if (unref(locationQuery)) {
filters.push(`itemid:${unref(locationQuery)}`)
}
activities.value = yield* call(
clientService.graphAuthenticated.activities.listActivities(filters.join(' AND '), {
clientService.graphAuthenticated.activities.listActivities(`${filters.join(' AND ')}`, {
signal
})
)
Expand Down

0 comments on commit bdc93cf

Please sign in to comment.