Skip to content

Commit

Permalink
support video (MWP)
Browse files Browse the repository at this point in the history
  • Loading branch information
khanzadimahdi committed Aug 18, 2024
1 parent 42127f3 commit 64ae6eb
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
6 changes: 4 additions & 2 deletions frontend/composables/dashboardArticles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function index(page: number) {
)
}

async function create(title: string, excerpt: string, body: string, tags: string[], publishedAt?: string, cover?: string) {
async function create(title: string, excerpt: string, body: string, tags: string[], publishedAt?: string, cover?: string, video?: string) {
return useUser().$fetch(
useApiUrlResolver().resolve("api/dashboard/articles"),
{
Expand All @@ -26,6 +26,7 @@ async function create(title: string, excerpt: string, body: string, tags: string
tags: tags,
published_at: publishedAt,
cover: cover,
video: video,
}
}
)
Expand All @@ -42,7 +43,7 @@ async function show(uuid: string) {
)
}

async function update(uuid: string, title: string, excerpt: string, body: string, tags: string[], publishedAt?: string, cover?: string) {
async function update(uuid: string, title: string, excerpt: string, body: string, tags: string[], publishedAt?: string, cover?: string, video?: string) {
return useUser().$fetch(
useApiUrlResolver().resolve(`api/dashboard/articles`),
{
Expand All @@ -57,6 +58,7 @@ async function update(uuid: string, title: string, excerpt: string, body: string
tags: tags,
published_at: publishedAt,
cover: cover,
video: video,
}
}
)
Expand Down
25 changes: 22 additions & 3 deletions frontend/pages/dashboard/articles/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,24 @@
</div>

<div>
<div @click.prevent="params.showFilePicker=true" class="image-picker"
<div @click.prevent="params.showFilePicker=true; params.pickCover=false;" class="image-picker"
:style="{ backgroundImage: `url('${ useFilesUrlResolver().resolve(params.cover) }')` }">
<small class="title">تصویر اصلی</small>
<div class="body">
<small class="fa fa-plus"></small>
</div>
</div>
</div>

<div>
<div @click.prevent="params.showFilePicker=true; params.pickCover=false;" class="image-picker"
:style="{ backgroundImage: `url('${ useFilesUrlResolver().resolve(params.video) }')` }">
<small class="title">ویدئو</small>
<div class="body">
<small class="fa fa-plus"></small>
</div>
</div>
</div>
</div>
<div class="card-footer">
<button :disabled="params.loading" type="submit" class="btn btn-primary rounded submit px-3">
Expand Down Expand Up @@ -108,8 +118,10 @@ const params = reactive({
tags: null,
publishedAt: null,
cover: null,
video: null,
loading: false,
showFilePicker: false,
pickCover: false,
})
// reflects the validation errors to corresponding html input.
Expand All @@ -132,11 +144,17 @@ function tags() {
function selectFile(uuids: string[]) {
params.showFilePicker = false
if (params.cover && params.cover.length == 0) {
if (uuids && uuids.length == 0) {
return
}
if (params.pickCover) {
params.cover = uuids[0]
return
}
params.cover = uuids[0]
params.video = uuids[0]
}
async function createArticle() {
Expand All @@ -150,6 +168,7 @@ async function createArticle() {
tags(),
params.publishedAt ? useTime().toISOString(params.publishedAt) : null,
params.cover || null,
params.video || null,
)
await navigateTo("/dashboard/articles")
Expand Down
26 changes: 23 additions & 3 deletions frontend/pages/dashboard/articles/edit/[uuid].vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,25 @@
</div>

<div>
<div @click.prevent="params.showFilePicker=true" class="image-picker"
<div @click.prevent="params.showFilePicker=true; params.pickCover=true;" class="image-picker"
:style="{ backgroundImage: `url('${ useFilesUrlResolver().resolve(params.cover) }')` }">
<small class="title">تصویر اصلی</small>
<div class="body">
<small class="fa fa-plus"></small>
</div>
</div>
</div>

<div>
<div @click.prevent="params.showFilePicker=true; params.pickCover=false;" class="image-picker"
:style="{ backgroundImage: `url('${ useFilesUrlResolver().resolve(params.video) }')` }">
<small class="title">ویدئو</small>
<div class="body">
<small class="fa fa-plus"></small>
</div>
</div>
</div>

</div>
<div class="card-footer">
<button :disabled="params.loading" type="submit" class="btn btn-primary rounded submit px-3">
Expand Down Expand Up @@ -109,8 +120,10 @@ const params = reactive({
tags: null,
publishedAt: null,
cover: null,
video: null,
loading: false,
showFilePicker: false,
pickCover: false,
})
// reflects the validation errors to corresponding html input.
Expand All @@ -135,11 +148,17 @@ function tags() {
function selectFile(uuids: string[]) {
params.showFilePicker = false
if (params.cover && params.cover.length == 0) {
if (uuids && uuids.length == 0) {
return
}
if (params.pickCover) {
params.cover = uuids[0]
return
}
params.cover = uuids[0]
params.video = uuids[0]
}
async function showArticle() {
Expand Down Expand Up @@ -174,6 +193,7 @@ async function updateArticle() {
tags(),
params.publishedAt ? useTime().toISOString(params.publishedAt) : null,
params.cover || null,
params.video || null,
)
} catch (error) {
console.log(error)
Expand Down

0 comments on commit 64ae6eb

Please sign in to comment.