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