Skip to content

Commit

Permalink
Merge pull request #129 from xbgmsharp/mobile-ux
Browse files Browse the repository at this point in the history
UX: /log is now log-map, moorage name in title, duration formatting, links on cards
  • Loading branch information
xbgmsharp authored May 6, 2024
2 parents 7c15ef0 + 6471056 commit 6d122b3
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/components/maps/leafletMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
<tr><td>Time</td><td>${time}</td></tr>
<tr><td>Distance</td><td>${distance}</td></tr>
<tr><td>Duration</td><td>${duration} hours</td></tr>
<tr><td>Speed Ave/Max</td><td>${avg_speed} / ${max_speed}</td></tr>
<tr><td>Wind Speed Max</td><td>${max_wind}</td></tr>
<tr><td>Speed</td><td>avg ${avg_speed} / max ${max_speed}</td></tr>
<tr><td>Wind</td><td>max ${max_wind}</td></tr>
</tbody></table></br>
<a href="/timelapse/${feature.properties.id}">Replay</a>
</div>`
Expand Down
4 changes: 2 additions & 2 deletions src/components/maps/leafletMapMoorages.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@
<tr><td>Time</td><td>${time}</td></tr>
<tr><td>Distance</td><td>${distance}</td></tr>
<tr><td>Duration</td><td>${duration} hours</td></tr>
<tr><td>Speed Ave/Max</td><td>${avg_speed} / ${max_speed}</td></tr>
<tr><td>Wind Speed Max</td><td>${max_wind}</td></tr>
<tr><td>Speed</td><td>avg ${avg_speed} / max ${max_speed}</td></tr>
<tr><td>Wind</td><td>max ${max_wind}</td></tr>
</tbody></table></br>
<a href="/timelapse/${feature.properties.id}">Replay</a>
</div>`
Expand Down
28 changes: 23 additions & 5 deletions src/pages/logs-book/List.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<template>
<div>
<va-card>
<va-card-title>{{ $t('moorages.arrivals-departures.title') }}</va-card-title>
<va-card-title>
<template v-if="filter_moorage_id"> {{ $t('moorages.arrivals-departures.title') }} {{ moorageName }} </template>
<template v-else> {{ $t('logs.list.title') }} {{ vesselName }}</template>
</va-card-title>
<va-card-content>
<template v-if="apiError">
<va-alert color="danger" outline class="mb-4">{{ $t('api.error') }}: {{ apiError }}</va-alert>
Expand All @@ -27,13 +30,13 @@
>
<template #cell(name)="{ value, rowData }">
<template v-if="isLoggedIn">
<router-link class="va-link link" :to="{ name: 'log-details', params: { id: rowData.id } }">
<router-link class="va-link link" :to="{ name: 'log-map', params: { id: rowData.id } }">
{{ value }}
</router-link> </template
><template v-else>
<router-link
class="va-link link"
:to="{ name: 'log-details', params: { boat: publicVessel, id: rowData.id } }"
:to="{ name: 'log-map', params: { boat: publicVessel, id: rowData.id } }"
>
{{ value }}
</router-link>
Expand Down Expand Up @@ -112,6 +115,8 @@
import { useRoute } from 'vue-router'
import { useGlobalStore } from '../../stores/global-store'
const { isLoggedIn, publicVessel, instagram, website } = useGlobalStore()
import { useVesselStore } from '../../stores/vessel-store'
const { vesselName, vesselType } = useVesselStore()
import logsData from '../../data/logs.json'
const CacheStore = useCacheStore()
Expand Down Expand Up @@ -148,6 +153,7 @@
const isBusy = ref(false)
const apiError = ref(null)
const rowsData = ref([])
const moorageName = ref(null) // will be assigned from stays data
const perPage = ref(20)
const currentPage = ref(1)
const columns = ref([
Expand All @@ -156,8 +162,8 @@
{ key: 'to', label: t('logs.list.to'), sortable: true },
{ key: 'fromTime', label: t('logs.list.from_time'), sortable: true },
{ key: 'toTime', label: t('logs.list.to_time'), sortable: true },
{ key: 'distance', label: t('logs.log.distance'), sortable: true, sortingFn: utils.sortNum, tdAlign: 'right' },
{ key: 'duration', label: t('logs.log.duration'), sortable: true, sortingFn: utils.sortNum, tdAlign: 'right' },
{ key: 'distance', label: t('logs.log.distance_nm'), sortable: true, sortingFn: utils.sortNum, tdAlign: 'right' },
{ key: 'duration', label: t('logs.log.duration_h'), sortable: true, sortingFn: utils.sortNum, tdAlign: 'right' },
//{ key: 'action', label: t('logs.log.action') },
])
const filter = reactive(getDefaultFilter())
Expand Down Expand Up @@ -225,6 +231,18 @@
rowsData.value.splice(0, rowsData.value.length || [])
rowsData.value.push(...response)
console.log('Logs list', rowsData.value)
// if logs for specific moorage, get moorage name from first log
if (filter_moorage_id) {
const firstItem = items.value[0]
if (firstItem) {
if (firstItem.fromMoorageId == filter_moorage_id) {
moorageName.value = firstItem.from
} else if (firstItem.toMoorageId == filter_moorage_id) {
moorageName.value = firstItem.to
}
}
}
} else {
throw { response }
}
Expand Down
6 changes: 4 additions & 2 deletions src/pages/logs-book/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@
to: row.to,
fromTime: row.started,
toTime: row.ended,
distance: distanceFormat(row.distance),
duration: durationFormatHours(row.duration),
distance: row.distance,
distance_nm: distanceFormat(row.distance),
duration: row.duration,
duration_h: durationFormatHours(row.duration),
fromMoorageId: row._from_moorage_id,
toMoorageId: row._to_moorage_id,
}))
Expand Down
51 changes: 46 additions & 5 deletions src/pages/logs-book/widgets/Cards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import { PropType } from 'vue'
import { Log } from '../types'
import { useI18n } from 'vue-i18n'
import { dateFormatUTC } from '../../../utils/dateFormatter.js'
import { dateFormatUTC, durationI18nDaysHours } from '../../../utils/dateFormatter.js'
import { distanceFormatMiles } from '../../../utils/distanceFormatter.js'
import { useGlobalStore } from '../../../stores/global-store'
const { isLoggedIn, publicVessel } = useGlobalStore()
const { t } = useI18n()
Expand Down Expand Up @@ -102,13 +103,53 @@
</h4>
<div class="grid grid-cols-2 gap-1 items-center justify-center text-center">
<span class="label">{{ t('logs.log.distance') }}: </span>
<span class="value">{{ log.distance }} {{ t('units.distance.miles') }}</span>
<span class="value">
<template v-if="isLoggedIn">
<router-link class="va-link link" :to="{ name: 'log-map', params: { id: log.id } }">
{{ distanceFormatMiles(log.distance) }}
</router-link> </template
><template v-else>
<router-link
class="va-link link"
:to="{ name: 'log-map', params: { boat: publicVessel, id: log.id } }"
>
{{ distanceFormatMiles(log.distance) }}
</router-link>
</template>
</span>
<span class="label">{{ t('logs.log.duration') }}: </span>
<span class="value">{{ log.duration }} {{ t('units.time.hours') }} </span>
<span class="value">
<template v-if="isLoggedIn">
<router-link class="va-link link" :to="{ name: 'log-map', params: { id: log.id } }">
{{ durationI18nDaysHours(log.duration) }}
</router-link> </template
><template v-else>
<router-link
class="va-link link"
:to="{ name: 'log-map', params: { boat: publicVessel, id: log.id } }"
>
{{ durationI18nDaysHours(log.duration) }}
</router-link>
</template>
</span>
<span class="label">{{ t('logs.log.from') }}: </span>
<span class="value">{{ log.from }}</span>
<span class="value">
<router-link
class="va-link link"
:to="{ name: 'moorage-details', params: { id: log.fromMoorageId || 0 } }"
>
{{ log.from }}
</router-link>
</span>
<span class="label">{{ t('logs.log.to') }}: </span>
<span class="value">{{ log.to }}</span>
<span class="value">
<router-link
class="va-link link"
:to="{ name: 'moorage-details', params: { id: log.toMoorageId || 0 } }"
>
{{ log.to }}
</router-link>
</span>
</div>
</div>
</div>
Expand Down
14 changes: 10 additions & 4 deletions src/pages/logs-book/widgets/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
{ label: t('logs.list.to'), key: 'to', sortable: true },
{ label: t('logs.list.from_time'), key: 'fromTime', sortable: true },
{ label: t('logs.list.to_time'), key: 'toTime', sortable: true },
{ label: t('logs.log.distance_nm'), key: 'distance', sortable: true, sortingFn: utils.sortNum, tdAlign: 'right' },
{ label: t('logs.log.duration_h'), key: 'duration', sortable: true, sortingFn: utils.sortNum, tdAlign: 'right' },
{
label: t('logs.log.distance_nm'),
key: 'distance_nm',
sortable: true,
sortingFn: utils.sortNum,
tdAlign: 'right',
},
{ label: t('logs.log.duration_h'), key: 'duration_h', sortable: true, sortingFn: utils.sortNum, tdAlign: 'right' },
{ label: ' ', key: 'actions' },
])
Expand Down Expand Up @@ -94,10 +100,10 @@
<template #cell(toTime)="{ value }">
{{ dateFormatUTC(value) }}
</template>
<template #cell(distance)="{ value }">
<template #cell(distance_nm)="{ value }">
{{ value }}
</template>
<template #cell(duration)="{ value }"> {{ value }} </template>
<template #cell(duration_d)="{ value }"> {{ value }} </template>
<template #cell(actions)="{ rowData: log }">
<div class="flex gap-2 justify-end">
<va-dropdown class="">
Expand Down
4 changes: 2 additions & 2 deletions src/pages/moorages/Details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<dt class="flex xs12 md6 pa-2 va-text-bold">{{ $t('moorages.moorage.stayed_at') }}</dt>
<dd class="flex xs12 md6 pa-2">
<router-link class="va-link link" :to="{ name: 'moorage-stays', params: { id: item.id } }">
{{ durationFormatDays(item.total_duration) }} {{ durationI18nDays(item.total_duration) }}
{{ durationI18nDaysHours(item.total_duration) }}
</router-link>
</dd>
<dt class="flex xs12 md6 pa-2 va-text-bold">{{ $t('moorages.moorage.arrivals') }}</dt>
Expand Down Expand Up @@ -120,7 +120,7 @@
import Map from '../../components/maps/leafletMapMoorages.vue'
import { asBusy } from '../../utils/handleExports'
import StayAt from '../../components/SelectStayAt.vue'
import { durationFormatDays, durationI18nDays } from '../../utils/dateFormatter.js'
import { durationFormatDays, durationI18nDaysHours } from '../../utils/dateFormatter.js'
import { useModal, useToast } from 'vuestic-ui'
const { confirm } = useModal()
const { init: initToast } = useToast()
Expand Down
8 changes: 4 additions & 4 deletions src/pages/stats/Stats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<td>
<router-link
class="va-link link"
:to="{ name: 'log-details', params: { id: stats_logs.max_speed_id } }"
:to="{ name: 'log-map', params: { id: stats_logs.max_speed_id } }"
>
{{ speedFormatKnots(stats_logs.max_speed) }}
</router-link>
Expand All @@ -112,7 +112,7 @@
<td>
<router-link
class="va-link link"
:to="{ name: 'log-details', params: { id: stats_logs.max_wind_speed_id } }"
:to="{ name: 'log-map', params: { id: stats_logs.max_wind_speed_id } }"
>
{{ speedFormatKnots(stats_logs.max_wind_speed) }}
</router-link>
Expand All @@ -123,14 +123,14 @@
<td>
<router-link
class="va-link link"
:to="{ name: 'log-details', params: { id: stats_logs.max_distance_id } }"
:to="{ name: 'log-map', params: { id: stats_logs.max_distance_id } }"
>
{{ distanceFormatMiles(stats_logs.max_distance) }}
</router-link>
/
<router-link
class="va-link link"
:to="{ name: 'log-details', params: { id: stats_logs.max_duration_id } }"
:to="{ name: 'log-map', params: { id: stats_logs.max_duration_id } }"
>
{{ durationFormatHours(stats_logs.max_duration) }}
{{ durationI18nHours(stats_logs.max_duration) }}
Expand Down
9 changes: 4 additions & 5 deletions src/pages/stays/Details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
</dd>
<dt class="flex xs12 md6 pa-2 va-text-bold">{{ $t('stays.stay.duration') }}</dt>
<dd class="flex xs12 md6 pa-2">
{{ durationFormatHours(item.duration) }} {{ durationI18nHours(item.duration) }} /
{{ durationI18nDays(item.duration) }}
{{ durationI18nDaysHours(item.duration) }}
</dd>
<dt class="flex xs12 md6 pa-2 va-text-bold">{{ $t('stays.stay.stayed_at') }}</dt>
<dd class="flex">
Expand Down Expand Up @@ -89,7 +88,7 @@
</dd>
<dt class="flex xs12 md6 pa-2 va-text-bold">{{ $t('stays.stay.arrival') }}</dt>
<dd class="flex xs12 md6 pa-2">
<router-link class="link" :to="{ name: 'log-details', params: { id: item.arrived_log_id } }">
<router-link class="link" :to="{ name: 'log-map', params: { id: item.arrived_log_id } }">
{{ dateFormatUTC(item.arrived) }}
</router-link>
</dd>
Expand All @@ -104,7 +103,7 @@
</dd>
<dt class="flex xs12 md6 pa-2 va-text-bold">{{ $t('stays.stay.departure') }}</dt>
<dd class="flex xs12 md6 pa-2">
<router-link class="link" :to="{ name: 'log-details', params: { id: item.departed_log_id } }">
<router-link class="link" :to="{ name: 'log-map', params: { id: item.departed_log_id } }">
{{ dateFormatUTC(item.departed) }}
</router-link>
</dd>
Expand Down Expand Up @@ -142,7 +141,7 @@
import { useRoute } from 'vue-router'
import PostgSail from '../../services/api-client'
import { useCacheStore } from '../../stores/cache-store'
import { dateFormatUTC, durationFormatHours, durationI18nHours, durationI18nDays } from '../../utils/dateFormatter.js'
import { dateFormatUTC, durationI18nDaysHours } from '../../utils/dateFormatter.js'
import Map from '../../components/maps/leafletMapMoorages.vue'
import { asBusy } from '../../utils/handleExports'
import StayAt from '../../components/SelectStayAt.vue'
Expand Down
4 changes: 2 additions & 2 deletions src/pages/stays/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<router-link
v-if="typeof rowData.departed_log_id !== 'undefined'"
class="va-link link"
:to="{ name: 'log-details', params: { id: rowData.departed_log_id || 0 } }"
:to="{ name: 'log-map', params: { id: rowData.departed_log_id || 0 } }"
>
{{ dateFormatUTC(value) }}
</router-link>
Expand All @@ -71,7 +71,7 @@
<router-link
v-if="typeof rowData.arrived_log_id !== 'undefined'"
class="va-link link"
:to="{ name: 'log-details', params: { id: rowData.arrived_log_id || 0 } }"
:to="{ name: 'log-map', params: { id: rowData.arrived_log_id || 0 } }"
>
{{ dateFormatUTC(value) }}
</router-link>
Expand Down
12 changes: 8 additions & 4 deletions src/pages/stays/Moorage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</va-card-content>
</va-card>
<va-card class="mb-3">
<va-card-title>{{ $t('stays.moorage.title') }}</va-card-title>
<va-card-title>{{ $t('stays.moorage.title') }} {{ moorageName }}</va-card-title>
<va-card-content>
<template v-if="apiError">
<va-alert color="danger" outline class="mb-4">{{ $t('api.error') }}: {{ apiError }}</va-alert>
Expand Down Expand Up @@ -51,12 +51,12 @@
class="datatable"
>
<template #cell(arrived)="{ value, rowData }">
<router-link class="va-link link" :to="{ name: 'log-details', params: { id: rowData.arrived_id } }">
<router-link class="va-link link" :to="{ name: 'log-map', params: { id: rowData.arrived_id } }">
{{ dateFormatUTC(value) }}
</router-link>
</template>
<template #cell(departed)="{ value, rowData }">
<router-link class="va-link link" :to="{ name: 'log-details', params: { id: rowData.departed_id } }">
<router-link class="va-link link" :to="{ name: 'log-map', params: { id: rowData.departed_id } }">
{{ dateFormatUTC(value) }}
</router-link>
</template>
Expand Down Expand Up @@ -125,6 +125,7 @@
const isBusy = ref(false)
const apiError = ref(null)
const rowsData = ref([])
const moorageName = ref(null) // will be assigned from stays data
const perPage = ref(20)
const currentPage = ref(1)
const columns = ref([
Expand Down Expand Up @@ -203,7 +204,7 @@
const pages = computed(() => {
return Math.ceil(items.value.length / perPage.value)
})
// TODO Default sort on duration
onMounted(async () => {
isBusy.value = true
apiError.value = null
Expand All @@ -215,6 +216,9 @@
rowsData.value.splice(0, rowsData.value.length || [])
rowsData.value.push(...response)
console.log('Moorages Stays List rowsData:', rowsData.value)
if (rowsData.value[0].name) {
moorageName.value = rowsData.value[0].name
}
} else {
throw { response }
}
Expand Down
14 changes: 7 additions & 7 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ const routes: Array<RouteRecordRaw> = [
component: () => import('../pages/logs-book/Page.vue'),
meta: { isPublic: true, type: 'public_logs_list' },
},
{
name: 'log-details',
path: 'log/:id(\\d+)',
component: () => import('../pages/logs-book/Details.vue'),
meta: { isPublic: true, type: 'public_logs' },
},
// {
// name: 'log-details',
// path: 'log/:id(\\d+)',
// component: () => import('../pages/logs-book/Details.vue'),
// meta: { isPublic: true, type: 'public_logs' },
// },
{
name: 'log-map',
path: 'logmap/:id(\\d+)',
path: 'log/:id(\\d+)',
component: () => import('../pages/logs-book/DetailsMap.vue'),
meta: { isPublic: true, type: 'public_logs' },
},
Expand Down
Loading

0 comments on commit 6d122b3

Please sign in to comment.