Start table view
This commit is contained in:
parent
3bfe09817b
commit
feeee20bfe
@ -8,15 +8,19 @@ import io.ktor.response.*
|
|||||||
import io.ktor.routing.*
|
import io.ktor.routing.*
|
||||||
import org.kodein.di.Kodein
|
import org.kodein.di.Kodein
|
||||||
import org.kodein.di.generic.instance
|
import org.kodein.di.generic.instance
|
||||||
|
import kotlin.system.measureTimeMillis
|
||||||
|
|
||||||
fun Routing.notes(kodein: Kodein) {
|
fun Routing.notes(kodein: Kodein) {
|
||||||
val notesService by kodein.instance<NotesService>()
|
val notesService by kodein.instance<NotesService>()
|
||||||
|
|
||||||
authenticate {
|
authenticate {
|
||||||
get("/notes") {
|
get("/notes") {
|
||||||
val userId = call.userId()
|
val time = measureTimeMillis {
|
||||||
val notes = notesService.getNotes(userId)
|
val userId = call.userId()
|
||||||
call.respond(notes)
|
val notes = notesService.getNotes(userId)
|
||||||
|
call.respond(notes)
|
||||||
|
}
|
||||||
|
application.log.info("Time taken: $time ms")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,27 +2,34 @@
|
|||||||
<v-card
|
<v-card
|
||||||
class="d-flex flex-column"
|
class="d-flex flex-column"
|
||||||
:class="{ hover: hover }"
|
:class="{ hover: hover }"
|
||||||
|
d
|
||||||
height="100%"
|
height="100%"
|
||||||
:color="hover ? 'blue lighten-3' : 'white'"
|
:color="hover ? 'blue lighten-4' : ''"
|
||||||
:elevation="hover ? 12 : 2"
|
:elevation="hover ? 12 : 2"
|
||||||
>
|
>
|
||||||
<div class="mb-auto">
|
<div class="mb-auto">
|
||||||
<v-card-title>{{ title }}</v-card-title>
|
<v-list-item three-line>
|
||||||
|
<v-list-item-content>
|
||||||
<div class="tags">
|
<div class="overline mb-4">
|
||||||
<v-chip
|
Last updated {{ updatedAt }}
|
||||||
v-for="tag in tags"
|
</div>
|
||||||
:key="tag"
|
<v-list-item-title class="headline mb-1">
|
||||||
active
|
<h2 class="title primary--text">{{ title }}</h2>
|
||||||
color="secondary"
|
</v-list-item-title>
|
||||||
>{{ tag }}</v-chip
|
</v-list-item-content>
|
||||||
>
|
</v-list-item>
|
||||||
</div>
|
<v-card-actions>
|
||||||
</div>
|
<div class="tags">
|
||||||
|
<v-chip
|
||||||
<div v-if="updatedAt" class="mt-auto">
|
v-for="tag in tags"
|
||||||
<v-divider />
|
:key="tag"
|
||||||
<v-card-subtitle>Last updated {{ updatedAt }}</v-card-subtitle>
|
active
|
||||||
|
color="secondary"
|
||||||
|
>
|
||||||
|
{{ tag }}
|
||||||
|
</v-chip>
|
||||||
|
</div>
|
||||||
|
</v-card-actions>
|
||||||
</div>
|
</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<v-btn to="/" text rounded>Simple Notes</v-btn>
|
<v-btn to="/" text rounded>Simple Notes</v-btn>
|
||||||
<v-spacer />
|
<v-spacer />
|
||||||
<v-btn to="/notes" class="mr-2" text rounded>My notes</v-btn>
|
<v-btn to="/notes" class="mr-2" text rounded>My notes</v-btn>
|
||||||
<v-btn v-if="this.$store.state.auth.loggedIn" outline>
|
<v-btn v-if="this.$store.state.auth.loggedIn" outlined>
|
||||||
Welcome {{ this.$store.state.auth.user.username }}
|
Welcome {{ this.$store.state.auth.user.username }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn v-else to="/account" text rounded>Account</v-btn>
|
<v-btn v-else to="/account" text rounded>Account</v-btn>
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
cols="12"
|
cols="12"
|
||||||
sm="6"
|
sm="6"
|
||||||
md="4"
|
md="4"
|
||||||
xl="3"
|
lg="3"
|
||||||
class="viewer"
|
class="viewer"
|
||||||
>
|
>
|
||||||
<v-hover v-slot:default="{ hover }">
|
<v-hover v-slot:default="{ hover }">
|
||||||
|
|||||||
98
frontend/pages/table.vue
Normal file
98
frontend/pages/table.vue
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<template>
|
||||||
|
<v-data-table
|
||||||
|
:headers="headers"
|
||||||
|
:items="notes"
|
||||||
|
:loading="loading"
|
||||||
|
loading-text="Loading notes..."
|
||||||
|
class="elevation-1 mt-10"
|
||||||
|
disable-sort
|
||||||
|
>
|
||||||
|
<template v-slot:top>
|
||||||
|
<v-toolbar flat color="secondary">
|
||||||
|
<h2 class="title white--text">
|
||||||
|
Notes
|
||||||
|
</h2>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-btn to="/create" outlined dark>
|
||||||
|
New Note
|
||||||
|
</v-btn>
|
||||||
|
</v-toolbar>
|
||||||
|
</template>
|
||||||
|
<template v-slot:item.updatedAt="{ item }">
|
||||||
|
{{ format(item.updatedAt) }}
|
||||||
|
</template>
|
||||||
|
<template v-slot:item.tags="{ item }">
|
||||||
|
<div class="tags">
|
||||||
|
<v-chip
|
||||||
|
v-for="tag in item.tags"
|
||||||
|
:key="tag"
|
||||||
|
active
|
||||||
|
color="secondary"
|
||||||
|
>
|
||||||
|
{{ tag }}
|
||||||
|
</v-chip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-slot:item.actions="{ item }">
|
||||||
|
<v-icon
|
||||||
|
small
|
||||||
|
color="accent"
|
||||||
|
dark
|
||||||
|
class="mr-2"
|
||||||
|
@click="editItem(item)"
|
||||||
|
>
|
||||||
|
mdi-pencil
|
||||||
|
</v-icon>
|
||||||
|
<v-icon small color="accent" dark @click="deleteItem(item)">
|
||||||
|
mdi-delete
|
||||||
|
</v-icon>
|
||||||
|
</template>
|
||||||
|
<template v-slot:no-data>
|
||||||
|
<v-btn color="primary" @click="initialize">Reset</v-btn>
|
||||||
|
</template>
|
||||||
|
</v-data-table>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { format } from 'timeago.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Notes',
|
||||||
|
title: 'Notes',
|
||||||
|
data: () => ({
|
||||||
|
loading: true,
|
||||||
|
notes: [],
|
||||||
|
headers: [
|
||||||
|
{ text: 'Title', align: 'start', value: 'title' },
|
||||||
|
{ text: 'Last updated', value: 'updatedAt', align: 'end' },
|
||||||
|
{ text: 'Tags', value: 'tags' },
|
||||||
|
{ text: 'Actions', value: 'actions' },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
mounted() {
|
||||||
|
this.$axios.get('/notes').then((e) => {
|
||||||
|
this.notes = e.data
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
editItem(item) {},
|
||||||
|
deleteItem(item) {},
|
||||||
|
format,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.tags {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags .v-chip {
|
||||||
|
margin: 4px 8px 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-card.hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
x
Reference in New Issue
Block a user