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">
|
2019-04-05 16:08:14 +01:00
|
|
|
<div v-if="isLoading" class="loading-overlay active">
|
|
|
|
<img src="../../static/images/register/Loading.gif">
|
|
|
|
</div>
|
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">
|
2019-07-05 14:49:10 +01:00
|
|
|
<router-view />
|
2019-03-26 16:56:38 +00:00
|
|
|
</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">
|
2019-04-05 16:08:14 +01:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
2019-08-21 15:07:49 +01:00
|
|
|
import DashboardHeader from '@/components/header/Header.vue';
|
|
|
|
import NavigationArea from '@/components/navigation/NavigationArea.vue';
|
|
|
|
import ProjectCreationSuccessPopup from '@/components/project/ProjectCreationSuccessPopup.vue';
|
2019-04-05 16:08:14 +01:00
|
|
|
import {
|
|
|
|
API_KEYS_ACTIONS,
|
|
|
|
APP_STATE_ACTIONS,
|
|
|
|
NOTIFICATION_ACTIONS,
|
|
|
|
PM_ACTIONS,
|
2019-08-21 15:07:49 +01:00
|
|
|
PROJECT_PAYMENT_METHODS_ACTIONS,
|
2019-07-18 14:39:39 +01:00
|
|
|
} from '@/utils/constants/actionNames';
|
2019-08-19 19:12:23 +01:00
|
|
|
import { USER_ACTIONS } from '@/store/modules/users';
|
2019-08-21 15:07:49 +01:00
|
|
|
import { BUCKET_ACTIONS } from '@/store/modules/buckets';
|
|
|
|
import { AppState } from '@/utils/constants/appStateEnum';
|
2019-08-19 12:20:38 +01:00
|
|
|
import { AuthToken } from '@/utils/authToken';
|
2019-07-18 14:39:39 +01:00
|
|
|
import { Project } from '@/types/projects';
|
2019-08-28 10:53:53 +01:00
|
|
|
import { RouteConfig } from '@/router';
|
2019-08-22 17:03:13 +01:00
|
|
|
import { PROJECTS_ACTIONS } from '@/store/modules/projects';
|
2019-08-28 10:53:53 +01:00
|
|
|
import { PROJECT_USAGE_ACTIONS } from '@/store/modules/usage';
|
2019-04-05 16:08:14 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
mounted: async function() {
|
|
|
|
setTimeout(async () => {
|
2019-08-14 19:11:18 +01:00
|
|
|
try {
|
2019-08-28 10:53:53 +01:00
|
|
|
await this.$store.dispatch(USER_ACTIONS.GET);
|
2019-08-14 19:11:18 +01:00
|
|
|
} catch (error) {
|
2019-08-28 14:08:19 +01:00
|
|
|
await this.$store.dispatch(APP_STATE_ACTIONS.CHANGE_STATE, AppState.ERROR);
|
|
|
|
await this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, error.message);
|
|
|
|
await this.$router.push(RouteConfig.Login.path);
|
2019-07-22 10:46:26 +01:00
|
|
|
AuthToken.remove();
|
2019-04-05 16:08:14 +01:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2018-12-24 12:52:52 +00:00
|
|
|
|
2019-08-22 17:03:13 +01:00
|
|
|
let projects: Project[] = [];
|
|
|
|
|
|
|
|
try {
|
|
|
|
projects = await this.$store.dispatch(PROJECTS_ACTIONS.FETCH);
|
|
|
|
} catch (error) {
|
|
|
|
await this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, error.message);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!projects.length) {
|
|
|
|
await this.$store.dispatch(APP_STATE_ACTIONS.CHANGE_STATE, AppState.LOADED_EMPTY);
|
2019-01-09 15:40:21 +00:00
|
|
|
|
2019-08-29 15:41:27 +01:00
|
|
|
if (!(this as any).isCurrentRouteIsAccount()) {
|
|
|
|
await this.$router.push(RouteConfig.ProjectOverview.path);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.$router.push(RouteConfig.ProjectOverview.path);
|
2019-04-05 16:08:14 +01:00
|
|
|
}
|
2019-01-09 15:40:21 +00:00
|
|
|
|
2019-08-22 17:03:13 +01:00
|
|
|
await this.$store.dispatch(PROJECTS_ACTIONS.SELECT, projects[0].id);
|
2019-01-09 15:40:21 +00:00
|
|
|
|
2019-04-11 02:27:55 +01:00
|
|
|
await this.$store.dispatch(PM_ACTIONS.SET_SEARCH_QUERY, '');
|
2019-08-20 13:57:43 +01:00
|
|
|
try {
|
|
|
|
await this.$store.dispatch(PM_ACTIONS.FETCH, 1);
|
2019-08-30 12:34:51 +01:00
|
|
|
} catch (error) {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, `Unable to fetch project members. ${error.message}`);
|
2019-04-05 16:08:14 +01:00
|
|
|
}
|
2019-01-09 15:40:21 +00:00
|
|
|
|
2019-08-19 11:00:38 +01:00
|
|
|
try {
|
|
|
|
await this.$store.dispatch(API_KEYS_ACTIONS.FETCH);
|
2019-08-30 12:34:51 +01:00
|
|
|
} catch (error) {
|
2019-04-05 16:08:14 +01:00
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, 'Unable to fetch api keys');
|
|
|
|
}
|
2019-01-09 15:40:21 +00:00
|
|
|
|
2019-08-28 10:53:53 +01:00
|
|
|
try {
|
|
|
|
await this.$store.dispatch(PROJECT_USAGE_ACTIONS.FETCH_CURRENT_ROLLUP);
|
2019-08-30 12:34:51 +01:00
|
|
|
} catch (error) {
|
|
|
|
await this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, `Unable to fetch project usage. ${error.message}`);
|
2019-04-05 16:08:14 +01:00
|
|
|
}
|
2019-04-05 12:24:34 +01:00
|
|
|
|
2019-08-21 15:07:49 +01:00
|
|
|
try {
|
|
|
|
await this.$store.dispatch(BUCKET_ACTIONS.FETCH, 1);
|
|
|
|
} catch (error) {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, 'Unable to fetch buckets: ' + error.message);
|
2019-05-16 11:43:46 +01:00
|
|
|
}
|
|
|
|
|
2019-07-10 21:29:26 +01:00
|
|
|
const paymentMethodsResponse = await this.$store.dispatch(PROJECT_PAYMENT_METHODS_ACTIONS.FETCH);
|
|
|
|
if (!paymentMethodsResponse.isSuccess) {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, 'Unable to fetch payment methods: ' + paymentMethodsResponse.errorMessage);
|
|
|
|
}
|
|
|
|
|
2019-04-05 16:08:14 +01:00
|
|
|
this.$store.dispatch(APP_STATE_ACTIONS.CHANGE_STATE, AppState.LOADED);
|
|
|
|
}, 800);
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isLoading: function() {
|
|
|
|
return this.$store.state.appStateModule.appState.fetchState === AppState.LOADING;
|
2019-08-29 15:41:27 +01:00
|
|
|
},
|
|
|
|
isCurrentRouteIsAccount: function(): boolean {
|
|
|
|
const segments = this.$route.path.split('/').map(segment => segment.toLowerCase());
|
|
|
|
|
|
|
|
return segments.includes(RouteConfig.Account.name.toLowerCase());
|
2019-04-05 12:24:34 +01:00
|
|
|
}
|
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
|
|
|
}
|
2019-07-10 10:55:40 +01:00
|
|
|
|
2018-11-23 15:48:11 +00:00
|
|
|
@media screen and (max-width: 720px) {
|
|
|
|
.dashboard-container {
|
|
|
|
&__main-area{
|
|
|
|
left: 60px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-10 10:55:40 +01:00
|
|
|
|
2019-04-05 16:08:14 +01:00
|
|
|
.loading-overlay {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
left: 0;
|
|
|
|
height: 100vh;
|
|
|
|
z-index: 100;
|
|
|
|
background-color: rgba(134, 134, 148, 1);
|
|
|
|
visibility: hidden;
|
|
|
|
opacity: 0;
|
|
|
|
-webkit-transition: all 0.5s linear;
|
|
|
|
-moz-transition: all 0.5s linear;
|
|
|
|
-o-transition: all 0.5s linear;
|
|
|
|
transition: all 0.5s linear;
|
|
|
|
|
|
|
|
img {
|
|
|
|
z-index: 200;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.loading-overlay.active {
|
|
|
|
visibility: visible;
|
|
|
|
opacity: 1;
|
|
|
|
}
|
2019-03-26 16:56:38 +00:00
|
|
|
</style>
|