Files
cloudron-box/dashboard/src/components/Index.vue

89 lines
2.0 KiB
Vue
Raw Normal View History

2024-11-01 14:16:09 +01:00
<template>
<div>
2024-12-27 22:25:00 +01:00
<Notification />
2024-12-29 00:36:48 +01:00
<AppsView v-if="view === VIEWS.APPS" />
2025-01-05 22:47:50 +01:00
<AppstoreView v-if="view === VIEWS.APPSTORE" />
2024-12-26 12:19:48 +01:00
<SupportView v-if="view === VIEWS.SUPPORT" />
<VolumesView v-if="view === VIEWS.VOLUMES" />
2024-11-01 14:16:09 +01:00
</div>
</template>
<script>
2024-12-27 22:25:00 +01:00
import { Notification } from 'pankow';
2024-12-29 00:36:48 +01:00
import AppsView from './AppsView.vue';
2025-01-05 22:47:50 +01:00
import AppstoreView from './AppstoreView.vue';
2024-11-01 14:16:09 +01:00
import SupportView from './SupportView.vue';
2024-12-26 12:19:48 +01:00
import VolumesView from './VolumesView.vue';
2024-11-01 14:16:09 +01:00
2025-01-03 15:06:41 +01:00
import ProfileModel from '../models/ProfileModel.js';
const API_ORIGIN = import.meta.env.VITE_API_ORIGIN ? import.meta.env.VITE_API_ORIGIN : window.location.origin;
2024-11-01 14:16:09 +01:00
const VIEWS = {
2024-12-29 00:36:48 +01:00
APPS: 'apps',
2025-01-05 22:47:50 +01:00
APPSTORE: 'appstore',
2024-12-26 12:19:48 +01:00
SUPPORT: 'support',
VOLUMES: 'volumes',
2024-11-01 14:16:09 +01:00
};
export default {
name: 'Index',
components: {
2024-12-29 00:36:48 +01:00
AppsView,
2025-01-05 22:47:50 +01:00
AppstoreView,
2024-12-27 22:25:00 +01:00
Notification,
2024-12-26 12:19:48 +01:00
SupportView,
VolumesView,
2024-11-01 14:16:09 +01:00
},
data() {
return {
VIEWS,
accessToken: localStorage.token,
2025-01-03 15:06:41 +01:00
profile: {},
2024-11-01 14:16:09 +01:00
view: ''
};
},
methods: {
},
async mounted() {
if (!localStorage.token) {
console.error('Set localStorage.token');
return;
}
2025-01-03 15:06:41 +01:00
const profileModel = ProfileModel.create(API_ORIGIN, localStorage.token);
this.profile = await profileModel.get();
2024-11-01 14:16:09 +01:00
const that = this;
function onHashChange() {
const view = location.hash.slice(2);
2024-12-29 00:36:48 +01:00
if (view === VIEWS.APPS) {
that.view = VIEWS.APPS;
} else if (view.indexOf(VIEWS.APPSTORE) === 0) {
2025-01-05 22:47:50 +01:00
that.view = VIEWS.APPSTORE;
2024-12-29 00:36:48 +01:00
} else if (view === VIEWS.SUPPORT) {
2024-11-01 14:16:09 +01:00
that.view = VIEWS.SUPPORT;
2024-12-26 12:19:48 +01:00
} else if (view === VIEWS.VOLUMES) {
that.view = VIEWS.VOLUMES;
2024-11-01 14:16:09 +01:00
} else {
that.view = '';
}
2024-12-28 12:07:48 +01:00
// hack for layout to avoid consuming space if vue view is not active
document.getElementById('app').style.height = that.view ? 'auto' : '0';
2024-11-01 14:16:09 +01:00
}
window.addEventListener('hashchange', onHashChange);
onHashChange();
}
};
</script>
<style>
</style>