268 lines
6.9 KiB
Vue
268 lines
6.9 KiB
Vue
|
<template>
|
||
|
<div class="dashboard">
|
||
|
<div class="editmode-tiles">
|
||
|
<new-item-tile title="New Application" v-if="editMode" @click="openNewApp" />
|
||
|
<new-item-tile title="New App Category" v-if="editMode" @click="openNewAppCat" />
|
||
|
<new-item-tile title="New Bookmark" v-if="editMode" @click="openNewBookmark" />
|
||
|
<new-item-tile title="New Bookmark Category" v-if="editMode" @click="openNewBookmarkCat" />
|
||
|
</div>
|
||
|
<div class="container" v-if="appsForCategory(null).length > 0 || editMode">
|
||
|
<h1>APPLICATIONS</h1>
|
||
|
<div class="app-tiles">
|
||
|
<application-tile
|
||
|
@clicked="appTileClicked"
|
||
|
v-for="app in appsForCategory(null)"
|
||
|
:appData="app"
|
||
|
:key="app.id"
|
||
|
/>
|
||
|
<application-modal
|
||
|
:open="appOpen"
|
||
|
:data="editApp"
|
||
|
:categories="applicationCategories"
|
||
|
@close="closeNewApp"
|
||
|
@update="reload"
|
||
|
/>
|
||
|
<application-category-modal
|
||
|
:open="appCatOpen"
|
||
|
:data="editAppCat"
|
||
|
@close="closeNewAppCat"
|
||
|
@update="reload"
|
||
|
/>
|
||
|
<bookmark-modal
|
||
|
:open="bookmarkOpen"
|
||
|
:data="editBookmark"
|
||
|
:categories="bookmarkCategories"
|
||
|
@close="closeBookmark"
|
||
|
@update="reload"
|
||
|
/>
|
||
|
<bookmark-category-modal
|
||
|
:open="bookmarkCatOpen"
|
||
|
:data="editBookmarkCat"
|
||
|
@close="closeNewBookmarkCat"
|
||
|
@update="reload"
|
||
|
/>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="container" v-for="cat in applicationCategories" :key="cat.id">
|
||
|
<h1 @click="appCatClicked(cat)">
|
||
|
<font-awesome-icon v-if="cat.glyph" :icon="cat.glyph" />
|
||
|
{{cat.categoryName}}
|
||
|
</h1>
|
||
|
<div class="app-tiles">
|
||
|
<application-tile
|
||
|
@clicked="appTileClicked"
|
||
|
v-for="app in appsForCategory(cat.id)"
|
||
|
:appData="app"
|
||
|
:key="app.id"
|
||
|
/>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="container">
|
||
|
<h1 class="bookmark">BOOKMARKS</h1>
|
||
|
<div class="bookmark-container">
|
||
|
<div class="bookmark-category">
|
||
|
<h2>UNCATEGORZED</h2>
|
||
|
<bookmark-tile
|
||
|
v-for="bm in bookmarksForCategory(null)"
|
||
|
:key="bm.id"
|
||
|
:bookmark="bm"
|
||
|
@clicked="bookmarkClicked"
|
||
|
/>
|
||
|
</div>
|
||
|
<div class="bookmark-category" v-for="cat in bookmarkCategories" :key="cat.id">
|
||
|
<h2 @click="bookmarkCatClicked(cat)">
|
||
|
<font-awesome-icon v-if="cat.glyph" :icon="cat.glyph" />
|
||
|
{{cat.categoryName}}
|
||
|
</h2>
|
||
|
<bookmark-tile
|
||
|
@clicked="bookmarkClicked"
|
||
|
v-for="bm in bookmarksForCategory(cat.id)"
|
||
|
:key="bm.id"
|
||
|
:bookmark="bm"
|
||
|
/>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<edit-mode-button :editMode="editMode" @click="toggleEdit" />
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import axios from "axios";
|
||
|
import ApplicationTile from "../components/ApplicationTile.vue";
|
||
|
import ApplicationModal from "../components/ApplicationModal.vue";
|
||
|
import ApplicationCategoryModal from "../components/ApplicationCategoryModal.vue";
|
||
|
import EditModeButton from "../components/EditModeButton.vue";
|
||
|
import NewItemTile from "../components/NewItemTile.vue";
|
||
|
import BookmarkModal from "../components/BookmarkModal.vue";
|
||
|
import BookmarkTile from "../components/BookmarkTile.vue";
|
||
|
import BookmarkCategoryModal from "../components/BookmarkCategoryModal.vue";
|
||
|
|
||
|
export default {
|
||
|
name: "Dashboard",
|
||
|
methods: {
|
||
|
appsForCategory(catId) {
|
||
|
return this.applications.filter((i) => i.applicationCategoryId === catId);
|
||
|
},
|
||
|
bookmarksForCategory(catId) {
|
||
|
return this.bookmarks.filter((i) => i.bookmarkCategoryId === catId);
|
||
|
},
|
||
|
openNewApp() {
|
||
|
this.editApp = {};
|
||
|
this.appOpen = true;
|
||
|
},
|
||
|
openNewBookmark() {
|
||
|
this.bookmarkOpen = true;
|
||
|
},
|
||
|
closeNewApp() {
|
||
|
this.editApp = {};
|
||
|
this.appOpen = false;
|
||
|
},
|
||
|
closeBookmark() {
|
||
|
this.editBookmark = {};
|
||
|
this.bookmarkOpen = false;
|
||
|
},
|
||
|
openNewAppCat() {
|
||
|
this.appCatOpen = true;
|
||
|
this.editAppCat = {};
|
||
|
},
|
||
|
closeNewAppCat() {
|
||
|
this.editAppCat = {};
|
||
|
this.appCatOpen = false;
|
||
|
},
|
||
|
openNewBookmarkCat() {
|
||
|
this.bookmarkCatOpen = true;
|
||
|
},
|
||
|
closeNewBookmarkCat() {
|
||
|
this.editBookmarkCat = {};
|
||
|
this.bookmarkCatOpen = false;
|
||
|
},
|
||
|
toggleEdit() {
|
||
|
this.editMode = !this.editMode;
|
||
|
},
|
||
|
appTileClicked(e, app) {
|
||
|
if (this.editMode) {
|
||
|
this.editApp = app;
|
||
|
this.appOpen = true;
|
||
|
} else {
|
||
|
window.open(app.url);
|
||
|
}
|
||
|
},
|
||
|
appCatClicked(cat) {
|
||
|
if (this.editMode) {
|
||
|
this.editAppCat = cat;
|
||
|
this.appCatOpen = true;
|
||
|
}
|
||
|
},
|
||
|
bookmarkCatClicked(cat) {
|
||
|
if (this.editMode) {
|
||
|
this.editBookmarkCat = cat;
|
||
|
this.bookmarkCatOpen = true;
|
||
|
}
|
||
|
},
|
||
|
bookmarkClicked(bm) {
|
||
|
if (this.editMode) {
|
||
|
this.editBookmark = bm;
|
||
|
this.bookmarkOpen = true;
|
||
|
} else {
|
||
|
window.open(bm.url);
|
||
|
}
|
||
|
},
|
||
|
async reload() {
|
||
|
this.applications = (await axios.get("/api/applications")).data.items;
|
||
|
this.applicationCategories = (
|
||
|
await axios.get("/api/application_categories")
|
||
|
).data.items;
|
||
|
this.bookmarks = (await axios.get("/api/bookmarks")).data.items;
|
||
|
this.bookmarkCategories = (
|
||
|
await axios.get("/api/bookmark_categories")
|
||
|
).data.items;
|
||
|
this.editApp = {};
|
||
|
this.newAppOpen = false;
|
||
|
this.appCatOpen = false;
|
||
|
this.bookmarkCatOpen = false;
|
||
|
this.bookmarkOpen = false;
|
||
|
this.editAppCat = {};
|
||
|
},
|
||
|
},
|
||
|
components: {
|
||
|
ApplicationTile,
|
||
|
ApplicationModal,
|
||
|
ApplicationCategoryModal,
|
||
|
EditModeButton,
|
||
|
NewItemTile,
|
||
|
BookmarkModal,
|
||
|
BookmarkTile,
|
||
|
BookmarkCategoryModal,
|
||
|
},
|
||
|
data() {
|
||
|
return {
|
||
|
editMode: false,
|
||
|
applications: [],
|
||
|
applicationCategories: [],
|
||
|
appOpen: false,
|
||
|
appCatOpen: false,
|
||
|
bookmarkOpen: false,
|
||
|
bookmarkCatOpen: false,
|
||
|
editApp: {},
|
||
|
editAppCat: {},
|
||
|
editBookmark: {},
|
||
|
editBookmarkCat: {},
|
||
|
bookmarks: [],
|
||
|
bookmarkCategories: [],
|
||
|
};
|
||
|
},
|
||
|
async mounted() {
|
||
|
this.reload();
|
||
|
},
|
||
|
};
|
||
|
</script>
|
||
|
|
||
|
<style scope>
|
||
|
h1 {
|
||
|
margin-top: 0px;
|
||
|
font-weight: bold;
|
||
|
line-height: 1;
|
||
|
margin-bottom: 5px;
|
||
|
padding-left: 25px;
|
||
|
font-size: 24px;
|
||
|
}
|
||
|
h2 {
|
||
|
color: #fff;
|
||
|
font-size: 18px;
|
||
|
text-transform: uppercase;
|
||
|
padding-left: 25px;
|
||
|
font-weight: bold;
|
||
|
margin-bottom: 5px;
|
||
|
}
|
||
|
h2 svg {
|
||
|
margin-right: 5px;
|
||
|
}
|
||
|
.app-tiles {
|
||
|
display: grid;
|
||
|
grid-template-columns: repeat(4, 25%);
|
||
|
}
|
||
|
.container {
|
||
|
padding: 10px 50px;
|
||
|
width: 1000px;
|
||
|
margin: auto auto;
|
||
|
}
|
||
|
.dashboard {
|
||
|
margin-top: 150px;
|
||
|
}
|
||
|
.editmode-tiles {
|
||
|
display: flex;
|
||
|
padding: 10px 50px;
|
||
|
width: 1000px;
|
||
|
margin: 15px auto;
|
||
|
flex-direction: row;
|
||
|
justify-content: space-between;
|
||
|
}
|
||
|
.bookmark-container {
|
||
|
display: grid;
|
||
|
grid-template-columns: repeat(4, 1fr);
|
||
|
}
|
||
|
</style>
|