Files
Modrinth-plus/pages/dashboard/projects.vue

158 lines
3.1 KiB
Vue
Raw Normal View History

2020-06-29 11:56:46 +03:00
<template>
2020-07-14 16:42:46 +03:00
<div class="content">
2020-06-29 11:56:46 +03:00
<h2>My projects</h2>
2020-07-14 16:42:46 +03:00
<div class="section-header">
<h3>Mods</h3>
<nuxt-link class="create-button" to="/mod/create"
2020-10-03 22:55:58 -07:00
>Create a new mod</nuxt-link
>
2020-07-14 16:42:46 +03:00
</div>
2020-06-29 11:56:46 +03:00
<table>
<thead>
<tr>
2020-07-14 16:42:46 +03:00
<th></th>
2020-06-29 11:56:46 +03:00
<th>Name</th>
<th>Role</th>
<th>Status</th>
<th>Downloads</th>
<th>Last updated</th>
</tr>
</thead>
<tbody>
2020-10-11 22:46:26 -07:00
<tr v-for="mod in mods" :key="mod.id">
2020-06-29 11:56:46 +03:00
<td>
2020-10-11 22:46:26 -07:00
<img class="rounded-md" :src="mod.icon_url" />
2020-06-29 11:56:46 +03:00
</td>
2020-10-21 13:43:49 -07:00
<td>
<nuxt-link :to="'/mod/' + mod.id">
{{ mod.title }}
</nuxt-link>
</td>
2020-06-29 11:56:46 +03:00
<td>Owner</td>
<td>
<span v-if="mod.status === 'approved'" class="badge green">
Approved
</span>
<span v-if="mod.status === 'rejected'" class="badge red">
Rejected
</span>
<span v-if="mod.status === 'draft'" class="badge yellow">
Draft
</span>
<span v-if="mod.status === 'processing'" class="badge yellow">
Processing
</span>
<span v-if="mod.status === 'unlisted'" class="badge gray">
Unlisted
</span>
<span v-if="mod.status === 'unknown'" class="badge gray">
Unknown
</span>
</td>
2020-10-11 22:46:26 -07:00
<td>{{ mod.downloads }}</td>
<td>{{ $dayjs(mod.published).format('YYYY-MM-DD') }}</td>
2020-06-29 11:56:46 +03:00
</tr>
</tbody>
</table>
2020-07-14 16:42:46 +03:00
</div>
2020-06-29 11:56:46 +03:00
</template>
2020-10-11 22:46:26 -07:00
<script>
import axios from 'axios'
export default {
async fetch() {
try {
2020-10-12 22:33:56 -07:00
let res = await axios.get(
`https://api.modrinth.com/api/v1/user/${this.$auth.user.id}/mods`
2020-10-11 22:46:26 -07:00
)
2020-10-12 22:33:56 -07:00
if (res.data) {
res = await axios.get(
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}`
)
this.mods = res.data
}
2020-10-11 22:46:26 -07:00
} catch (err) {}
},
data() {
return {
mods: [],
}
},
}
</script>
2020-10-21 13:43:49 -07:00
<style lang="scss" scoped>
2020-07-14 16:42:46 +03:00
.section-header {
display: flex;
margin-bottom: 1rem;
2020-06-29 11:56:46 +03:00
2020-07-14 16:42:46 +03:00
& > * {
margin-right: 1rem;
2020-06-29 11:56:46 +03:00
}
}
2020-10-03 22:55:58 -07:00
.create-button {
margin: auto 0;
padding: 4px 20px;
border-radius: 5px;
color: var(--color-grey-5);
background-color: var(--color-grey-1);
}
2020-06-29 11:56:46 +03:00
table {
background: var(--color-bg);
border-collapse: collapse;
border-radius: 0.5rem;
box-shadow: 0 2px 3px 1px var(--color-grey-2);
2020-07-14 16:42:46 +03:00
table-layout: fixed;
2020-06-29 11:56:46 +03:00
width: 100%;
* {
2020-07-14 16:42:46 +03:00
text-align: left;
2020-06-29 11:56:46 +03:00
}
tr:not(:last-child),
tr:first-child {
th,
td {
border-bottom: 1px solid var(--color-grey-2);
}
}
th,
td {
2020-07-14 16:42:46 +03:00
&:first-child {
text-align: center;
width: 5%;
}
&:nth-child(2) {
padding-left: 0;
width: 30%;
}
2020-06-29 11:56:46 +03:00
}
th {
color: #718096;
font-size: 0.8rem;
letter-spacing: 0.02rem;
margin-bottom: 0.5rem;
margin-top: 1.5rem;
2020-07-14 16:42:46 +03:00
padding: 1rem 1rem;
2020-06-29 11:56:46 +03:00
text-transform: uppercase;
}
td {
2020-07-14 16:42:46 +03:00
padding: 0.25rem 1rem;
2020-06-29 11:56:46 +03:00
2020-07-14 16:42:46 +03:00
img {
height: 3rem;
width: 3rem;
2020-06-29 11:56:46 +03:00
}
}
}
</style>