Skip to content

Commit 7adc741

Browse files
authored
Merge pull request #1 from spikeninja/dev
feat: 1.0.1 version
2 parents 7c808df + 15e8ad3 commit 7adc741

File tree

5 files changed

+38
-20
lines changed

5 files changed

+38
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nuxt-app",
33
"private": true,
44
"type": "module",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"scripts": {
77
"build": "nuxt build",
88
"dev": "nuxt dev",

src/components/header.vue

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@
33
<header>
44
<nav class="navbar navbar-expand-lg bg-light">
55
<div class="container-fluid">
6-
<NuxtLink to="/">Taskiq Admin</NuxtLink>
7-
<div class="collapse navbar-collapse" id="navbarSupportedContent">
8-
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
9-
<li class="nav-item">
10-
<NuxtLink class="nav-link" to="/tasks">Home</NuxtLink>
11-
</li>
12-
<li class="nav-item">
13-
<NuxtLink class="nav-link" to="/tasks">Tasks</NuxtLink>
14-
</li>
15-
</ul>
16-
</div>
6+
<NuxtLink class="no-underline" to="/"><h3>Taskiq Admin</h3></NuxtLink>
177
</div>
188
</nav>
199
</header>

src/pages/tasks/index.vue

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script setup lang="ts">
2+
import { formatDate } from "~/utils"
3+
24
const route = useRoute()
35
const router = useRouter()
46
@@ -29,6 +31,13 @@ const { data } = useAsyncData(
2931
3032
const totalPages = computed(() => Math.ceil((data.value?.count || 0) / perPage))
3133
34+
function limitText(text: string, length: number) {
35+
if (text.length > length) {
36+
return text.slice(0, length).trim() + "..."
37+
}
38+
return text
39+
}
40+
3241
function handleNext() {
3342
router.push({
3443
path: "/tasks",
@@ -87,7 +96,7 @@ function handlePrev() {
8796
</thead>
8897
<tbody>
8998
<tr v-if="data" v-for="task in data.tasks">
90-
<td>{{ task.name }}</td>
99+
<td class="task-name-td">{{ task.name }}</td>
91100
<td>
92101
<NuxtLink :to="{ name: 'tasks-id', params: { id: task.id } }">
93102
{{ task.id }}
@@ -106,10 +115,10 @@ function handlePrev() {
106115
</span>
107116
</td>
108117
<td>{{ task.args }}</td>
109-
<td>{{ task.kwargs }}</td>
118+
<td>{{ limitText(JSON.stringify(task.kwargs), 50) }}</td>
110119
<td>{{ task.returnValue }}</td>
111-
<td>{{ task.startedAt }}</td>
112-
<td>{{ task.finishedAt }}</td>
120+
<td>{{ formatDate(task.startedAt) }}</td>
121+
<td>{{ task.finishedAt ? formatDate(task.finishedAt) : null }}</td>
113122
<td>{{ task.executionTime }}</td>
114123
<td>{{ task.worker }}</td>
115124
</tr>
@@ -128,7 +137,9 @@ function handlePrev() {
128137
>Previous</span
129138
>
130139
</li>
131-
<span>{{ page }} / {{ totalPages }}</span>
140+
<div class="flex justify-center items-center px-2">
141+
<span>{{ page }} / {{ totalPages }}</span>
142+
</div>
132143
<li class="page-item">
133144
<span
134145
@click="handleNext"
@@ -142,3 +153,10 @@ function handlePrev() {
142153
</div>
143154
</div>
144155
</template>
156+
<style scoped>
157+
.task-name-td {
158+
max-width: 300px;
159+
overflow-x: scroll;
160+
scrollbar-width: thin;
161+
}
162+
</style>

src/server/db/schema.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ export const tasksTable = sqliteTable(
1212
executionTime: real("execution_time"),
1313
startedAt: int("started_at", { mode: "timestamp" }).notNull(),
1414
finishedAt: int("finished_at", { mode: "timestamp" }),
15-
args: text({ mode: "json" }),
16-
kwargs: text({ mode: "json" }),
17-
returnValue: text("return_value", { mode: "json" }),
15+
args: text({ mode: "json" }).$type<Array<any>>(),
16+
kwargs: text({ mode: "json" }).$type<Record<string, any>>(),
17+
returnValue: text("return_value", { mode: "json" }).$type<
18+
Record<string, any>
19+
>(),
1820
},
1921
(t) => ({
2022
idxStartedAt: index("idx_tasks__started_at").on(t.startedAt),

src/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import dayjs from "dayjs"
2+
import utc from "dayjs/plugin/utc"
3+
4+
dayjs.extend(utc)
5+
6+
export const formatDate = (date: string) => {
7+
return dayjs.utc(date).local().format("MMM D, YYYY hh:mm A")
8+
}

0 commit comments

Comments
 (0)