updated css
This commit is contained in:
@@ -183,7 +183,7 @@ const handleClickItem = (item: string) => {
|
|||||||
.button {
|
.button {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-family: var(--header-font-family);
|
font-family: var(--header-font-family);
|
||||||
font-weight: 800;
|
font-weight: 600;
|
||||||
padding: 12px 32px 12px 32px;
|
padding: 12px 32px 12px 32px;
|
||||||
border: 0;
|
border: 0;
|
||||||
background-color: var(--base-color-light);
|
background-color: var(--base-color-light);
|
||||||
@@ -283,7 +283,8 @@ const handleClickItem = (item: string) => {
|
|||||||
|
|
||||||
&.light {
|
&.light {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
color: #095589;
|
// color: #095589;
|
||||||
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.primary {
|
&.primary {
|
||||||
@@ -294,5 +295,10 @@ const handleClickItem = (item: string) => {
|
|||||||
&.secondary {
|
&.secondary {
|
||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.danger {
|
||||||
|
background-color: var(--danger-color-light);
|
||||||
|
color: var(--base-color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -10,26 +10,26 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
label="Upload Media" />
|
label="Upload Media" />
|
||||||
<SMInput
|
<SMInput
|
||||||
v-model="search"
|
v-model="itemSearch"
|
||||||
label="Search"
|
label="Search"
|
||||||
style="max-width: 350px"
|
style="max-width: 350px"
|
||||||
@keyup.enter="handleClickSearch">
|
@keyup.enter="handleSearch">
|
||||||
<template #append>
|
<template #append>
|
||||||
<SMButton
|
<SMButton
|
||||||
type="primary"
|
type="primary"
|
||||||
label="Search"
|
label="Search"
|
||||||
icon="search-outline"
|
icon="search-outline"
|
||||||
@click="handleClickSearch" />
|
@click="handleSearch" />
|
||||||
</template>
|
</template>
|
||||||
</SMInput>
|
</SMInput>
|
||||||
</SMToolbar>
|
</SMToolbar>
|
||||||
<SMLoading large v-if="pageLoading" />
|
<SMLoading large v-if="itemsLoading" />
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<SMPagination
|
<SMPagination
|
||||||
v-if="items.length < totalFound"
|
v-if="items.length < itemsTotal"
|
||||||
v-model="page"
|
v-model="itemsPage"
|
||||||
:total="totalFound"
|
:total="itemsTotal"
|
||||||
:per-page="perPage" />
|
:per-page="itemsPerPage" />
|
||||||
<SMNoItems v-if="items.length == 0" text="No Media Found" />
|
<SMNoItems v-if="items.length == 0" text="No Media Found" />
|
||||||
<SMTable
|
<SMTable
|
||||||
v-else
|
v-else
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
delete: 'Delete',
|
delete: 'Delete',
|
||||||
}"
|
}"
|
||||||
size="medium"
|
size="medium"
|
||||||
@click="handleClick(item, $event)"></SMButton>
|
@click="handleActionButton(item, $event)"></SMButton>
|
||||||
</template>
|
</template>
|
||||||
</SMTable>
|
</SMTable>
|
||||||
</template>
|
</template>
|
||||||
@@ -62,7 +62,7 @@ import SMDialogConfirm from "../../components/dialogs/SMDialogConfirm.vue";
|
|||||||
import SMButton from "../../components/SMButton.vue";
|
import SMButton from "../../components/SMButton.vue";
|
||||||
import SMToolbar from "../../components/SMToolbar.vue";
|
import SMToolbar from "../../components/SMToolbar.vue";
|
||||||
import { api } from "../../helpers/api";
|
import { api } from "../../helpers/api";
|
||||||
import { Media } from "../../helpers/api.types";
|
import { Media, MediaCollection } from "../../helpers/api.types";
|
||||||
import { SMDate } from "../../helpers/datetime";
|
import { SMDate } from "../../helpers/datetime";
|
||||||
import { bytesReadable } from "../../helpers/types";
|
import { bytesReadable } from "../../helpers/types";
|
||||||
import { useToastStore } from "../../store/ToastStore";
|
import { useToastStore } from "../../store/ToastStore";
|
||||||
@@ -77,12 +77,13 @@ import { updateRouterParams } from "../../helpers/url";
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const toastStore = useToastStore();
|
const toastStore = useToastStore();
|
||||||
const pageLoading = ref(true);
|
|
||||||
const search = ref(route.query.search || "");
|
|
||||||
const items = ref([]);
|
const items = ref([]);
|
||||||
const totalFound = ref(0);
|
const itemsLoading = ref(true);
|
||||||
const perPage = 25;
|
const itemSearch = ref((route.query.search as string) || "");
|
||||||
const page = ref(parseInt((route.query.page as string) || "1"));
|
const itemsTotal = ref(0);
|
||||||
|
const itemsPerPage = 25;
|
||||||
|
const itemsPage = ref(parseInt((route.query.page as string) || "1"));
|
||||||
|
|
||||||
const headers = [
|
const headers = [
|
||||||
{ text: "Name", value: "title", sortable: true },
|
{ text: "Name", value: "title", sortable: true },
|
||||||
@@ -91,62 +92,70 @@ const headers = [
|
|||||||
{ text: "Actions", value: "actions" },
|
{ text: "Actions", value: "actions" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const handleClickSearch = () => {
|
/**
|
||||||
page.value = 1;
|
* Watch if page number changes.
|
||||||
|
*/
|
||||||
|
watch(itemsPage, () => {
|
||||||
|
handleLoad();
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle searching for item.
|
||||||
|
*/
|
||||||
|
const handleSearch = () => {
|
||||||
|
itemsPage.value = 1;
|
||||||
handleLoad();
|
handleLoad();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClick = (item, extra: string): void => {
|
/**
|
||||||
if (extra.length == 0) {
|
* Handle user selecting option in action button.
|
||||||
|
*
|
||||||
|
* @param {Media} item The media item.
|
||||||
|
* @param {string} extra The option selected.
|
||||||
|
* @param option
|
||||||
|
*/
|
||||||
|
const handleActionButton = (item: Media, option: string): void => {
|
||||||
|
if (option.length == 0) {
|
||||||
handleEdit(item);
|
handleEdit(item);
|
||||||
} else if (extra.toLowerCase() == "download") {
|
} else if (option.toLowerCase() == "download") {
|
||||||
handleDownload(item);
|
handleDownload(item);
|
||||||
} else if (extra.toLowerCase() == "delete") {
|
} else if (option.toLowerCase() == "delete") {
|
||||||
handleDelete(item);
|
handleDelete(item);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Watch if page number changes.
|
* Handle loading the page and list
|
||||||
*/
|
*/
|
||||||
watch(page, () => {
|
|
||||||
handleLoad();
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleLoad = async () => {
|
const handleLoad = async () => {
|
||||||
pageLoading.value = true;
|
itemsLoading.value = true;
|
||||||
items.value = [];
|
items.value = [];
|
||||||
totalFound.value = 0;
|
itemsTotal.value = 0;
|
||||||
|
|
||||||
let routerParams = {
|
updateRouterParams(router, {
|
||||||
search: search.value as string,
|
search: itemSearch.value,
|
||||||
page: page.value == 1 ? "" : page.value.toString(),
|
page: itemsPage.value == 1 ? "" : itemsPage.value.toString(),
|
||||||
};
|
});
|
||||||
updateRouterParams(router, routerParams);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let params = {
|
let params = {
|
||||||
page: page.value,
|
page: itemsPage.value,
|
||||||
limit: perPage,
|
limit: itemsPerPage,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (search.value.length > 0) {
|
if (itemSearch.value.length > 0) {
|
||||||
params[
|
params[
|
||||||
"filter"
|
"filter"
|
||||||
] = `title:${search.value},OR,name:${search.value},OR,description:${search.value}`;
|
] = `title:${itemSearch.value},OR,name:${itemSearch.value},OR,description:${itemSearch.value}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = await api.get({
|
let result = await api.get({
|
||||||
url: "/media",
|
url: "/media",
|
||||||
params: params,
|
params: params,
|
||||||
});
|
});
|
||||||
if (!res.data.media) {
|
|
||||||
throw new Error("The server is currently not available");
|
|
||||||
}
|
|
||||||
|
|
||||||
items.value = [];
|
const data = result.data as MediaCollection;
|
||||||
|
data.media.forEach(async (row) => {
|
||||||
res.data.media.forEach(async (row) => {
|
|
||||||
if (row.created_at !== "undefined") {
|
if (row.created_at !== "undefined") {
|
||||||
row.created_at = new SMDate(row.created_at, {
|
row.created_at = new SMDate(row.created_at, {
|
||||||
format: "ymd",
|
format: "ymd",
|
||||||
@@ -163,24 +172,27 @@ const handleLoad = async () => {
|
|||||||
items.value.push(row);
|
items.value.push(row);
|
||||||
});
|
});
|
||||||
|
|
||||||
totalFound.value = res.data.total;
|
itemsTotal.value = data.total;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.status != 404) {
|
if (error.status != 404) {
|
||||||
toastStore.addToast({
|
toastStore.addToast({
|
||||||
title: "Server Error",
|
title: "Server Error",
|
||||||
content: error.message,
|
content:
|
||||||
//"An error occurred retrieving the list from the server.",
|
"An error occurred retrieving the list from the server.",
|
||||||
type: "danger",
|
type: "danger",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
pageLoading.value = false;
|
itemsLoading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleLoad();
|
/**
|
||||||
|
* User requests to edit the item
|
||||||
const handleEdit = (item) => {
|
*
|
||||||
|
* @param {Media} item The media item.
|
||||||
|
*/
|
||||||
|
const handleEdit = (item: Media) => {
|
||||||
router.push({ name: "dashboard-media-edit", params: { id: item.id } });
|
router.push({ name: "dashboard-media-edit", params: { id: item.id } });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -203,9 +215,9 @@ const handleDelete = async (item: Media) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result) {
|
if (result == true) {
|
||||||
try {
|
try {
|
||||||
let r = await api.delete({
|
await api.delete({
|
||||||
url: "/media/{id}",
|
url: "/media/{id}",
|
||||||
params: {
|
params: {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
@@ -230,9 +242,16 @@ const handleDelete = async (item: Media) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDownload = (item) => {
|
/**
|
||||||
|
* Handle the user requesting to download the item.
|
||||||
|
*
|
||||||
|
* @param {Media} item The media item.
|
||||||
|
*/
|
||||||
|
const handleDownload = (item: Media) => {
|
||||||
window.open(`${item.url}?download=1`, "_blank");
|
window.open(`${item.url}?download=1`, "_blank");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleLoad();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
Reference in New Issue
Block a user