storj/web/satellite/src/views/Dashboard.vue

125 lines
3.7 KiB
Vue
Raw Normal View History

2019-01-24 20:15:10 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
<template>
<div class="dashboard-container">
<div class="dashboard-container__wrap">
<NavigationArea />
2019-03-26 16:56:38 +00:00
<div class="dashboard-container__wrap__column">
<DashboardHeader />
<div class="dashboard-container__main-area">
<router-view />
</div>
</div>
</div>
<ProjectCreationSuccessPopup/>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import DashboardHeader from '@/components/header/Header.vue';
import NavigationArea from '@/components/navigation/NavigationArea.vue';
import { removeToken, setToken } from '@/utils/tokenManager';
import {
NOTIFICATION_ACTIONS,
PROJETS_ACTIONS,
PM_ACTIONS,
USER_ACTIONS,
2019-04-05 12:24:34 +01:00
API_KEYS_ACTIONS,
PROJECT_USAGE_ACTIONS
} from '@/utils/constants/actionNames';
import ROUTES from '@/utils/constants/routerConstants';
import ProjectCreationSuccessPopup from '@/components/project/ProjectCreationSuccessPopup.vue';
@Component({
beforeMount: async function() {
// TODO: should place here some animation while all needed data is fetching
let response: RequestResponse<User> = await this.$store.dispatch(USER_ACTIONS.GET);
if (!response.isSuccess) {
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, response.errorMessage);
this.$router.push(ROUTES.LOGIN);
removeToken();
return;
}
let getProjectsResponse: RequestResponse<Project[]> = await this.$store.dispatch(PROJETS_ACTIONS.FETCH);
if (!getProjectsResponse.isSuccess || getProjectsResponse.data.length < 1) {
return;
}
this.$store.dispatch(PROJETS_ACTIONS.SELECT, getProjectsResponse.data[0].id);
if (!this.$store.getters.selectedProject.id) return;
this.$store.dispatch(PM_ACTIONS.SET_SEARCH_QUERY, '');
const projectMembersResponse = await this.$store.dispatch(PM_ACTIONS.FETCH);
if (!projectMembersResponse.isSuccess) {
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, 'Unable to fetch project members');
}
const keysResponse = await this.$store.dispatch(API_KEYS_ACTIONS.FETCH);
if (!keysResponse.isSuccess) {
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, 'Unable to fetch api keys');
}
2019-04-05 12:24:34 +01:00
const currentDate = new Date();
const previousDate = new Date();
previousDate.setMonth(currentDate.getMonth() - 1);
const usageResponse = await this.$store.dispatch(PROJECT_USAGE_ACTIONS.FETCH, {startDate: previousDate, endDate: currentDate});
if (!usageResponse.isSuccess) {
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, 'Unable to fetch project usage');
}
},
components: {
ProjectCreationSuccessPopup,
NavigationArea,
DashboardHeader
}
})
export default class Dashboard extends Vue {
}
</script>
<style scoped lang="scss">
.dashboard-container {
position: fixed;
max-width: 100%;
width: 100%;
height: 100%;
left: 0;
top: 0;
background-color: #F5F6FA;
z-index: 10;
&__wrap {
display: flex;
2019-03-26 16:56:38 +00:00
&__column {
display: flex;
flex-direction: column;
width: 100%;
}
}
&__main-area {
position: relative;
width: 100%;
height: 100%;
}
}
@media screen and (max-width: 720px) {
.dashboard-container {
&__main-area{
left: 60px;
}
}
}
2019-03-26 16:56:38 +00:00
</style>