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>
|
2020-09-09 19:25:59 +01:00
|
|
|
<div class="dashboard">
|
2019-04-05 16:08:14 +01:00
|
|
|
<div v-if="isLoading" class="loading-overlay active">
|
2021-08-10 14:14:37 +01:00
|
|
|
<LoaderImage class="loading-icon" />
|
2019-04-05 16:08:14 +01:00
|
|
|
</div>
|
2021-02-22 17:53:54 +00:00
|
|
|
<div v-if="isBetaSatellite" class="dashboard__beta-banner">
|
|
|
|
<p class="dashboard__beta-banner__message">
|
2021-08-10 14:14:37 +01:00
|
|
|
Thanks for testing the {{ satelliteName }} Beta satellite | Data may be deleted during this beta | Submit testing feedback
|
2021-03-11 15:05:06 +00:00
|
|
|
<a class="dashboard__beta-banner__message__link" :href="betaFeedbackURL" target="_blank" rel="noopener noreferrer">here</a>
|
|
|
|
| Request support
|
|
|
|
<a class="dashboard__beta-banner__message__link" :href="betaSupportURL" target="_blank" rel="noopener noreferrer">here</a>
|
2021-02-22 17:53:54 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
2020-09-09 19:25:59 +01:00
|
|
|
<div v-if="!isLoading" class="dashboard__wrap">
|
2021-08-10 14:14:37 +01:00
|
|
|
<PaidTierBar v-if="!creditCards.length && !isOnboardingTour" :open-add-p-m-modal="togglePMModal" />
|
|
|
|
<DashboardHeader />
|
2020-09-09 19:25:59 +01:00
|
|
|
<div class="dashboard__wrap__main-area">
|
2021-08-10 14:14:37 +01:00
|
|
|
<NavigationArea class="regular-navigation" />
|
2020-09-09 19:25:59 +01:00
|
|
|
<div class="dashboard__wrap__main-area__content">
|
2021-08-10 14:14:37 +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>
|
2021-08-10 14:14:37 +01:00
|
|
|
<AddPaymentMethodModal v-if="isAddPMModal" :on-close="togglePMModal" />
|
2018-11-14 14:00:01 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2019-09-09 11:33:39 +01:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
|
|
|
|
2021-07-01 20:47:41 +01:00
|
|
|
import AddPaymentMethodModal from '@/components/account/billing/paidTier/AddPaymentMethodModal.vue';
|
2021-06-30 17:47:47 +01:00
|
|
|
import PaidTierBar from '@/components/account/billing/paidTier/PaidTierBar.vue';
|
2019-09-26 14:36:12 +01:00
|
|
|
import DashboardHeader from '@/components/header/HeaderArea.vue';
|
2019-09-09 11:33:39 +01:00
|
|
|
import NavigationArea from '@/components/navigation/NavigationArea.vue';
|
|
|
|
|
2021-06-01 11:47:45 +01:00
|
|
|
import LoaderImage from '@/../static/images/common/loader.svg';
|
|
|
|
|
2019-10-23 18:33:24 +01:00
|
|
|
import { ErrorUnauthorized } from '@/api/errors/ErrorUnauthorized';
|
2019-09-09 11:33:39 +01:00
|
|
|
import { RouteConfig } from '@/router';
|
2020-11-16 17:35:07 +00:00
|
|
|
import { ACCESS_GRANTS_ACTIONS } from '@/store/modules/accessGrants';
|
2021-07-01 20:47:41 +01:00
|
|
|
import { PAYMENTS_ACTIONS, PAYMENTS_MUTATIONS } from '@/store/modules/payments';
|
2019-09-09 11:33:39 +01:00
|
|
|
import { PROJECTS_ACTIONS } from '@/store/modules/projects';
|
|
|
|
import { USER_ACTIONS } from '@/store/modules/users';
|
2021-07-08 23:46:14 +01:00
|
|
|
import { CreditCard } from '@/types/payments';
|
2019-09-09 11:33:39 +01:00
|
|
|
import { Project } from '@/types/projects';
|
2021-06-09 16:13:19 +01:00
|
|
|
import { APP_STATE_ACTIONS } from '@/utils/constants/actionNames';
|
2019-09-09 11:33:39 +01:00
|
|
|
import { AppState } from '@/utils/constants/appStateEnum';
|
2020-09-18 12:26:24 +01:00
|
|
|
import { LocalData } from '@/utils/localData';
|
2020-09-04 14:58:50 +01:00
|
|
|
import { MetaUtils } from '@/utils/meta';
|
2019-09-09 11:33:39 +01:00
|
|
|
|
2019-10-23 18:33:24 +01:00
|
|
|
const {
|
|
|
|
SETUP_ACCOUNT,
|
2021-07-08 23:46:14 +01:00
|
|
|
GET_CREDIT_CARDS,
|
2019-10-23 18:33:24 +01:00
|
|
|
} = PAYMENTS_ACTIONS;
|
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
@Component({
|
|
|
|
components: {
|
|
|
|
NavigationArea,
|
|
|
|
DashboardHeader,
|
2021-06-01 11:47:45 +01:00
|
|
|
LoaderImage,
|
2021-06-30 17:47:47 +01:00
|
|
|
PaidTierBar,
|
2021-07-01 20:47:41 +01:00
|
|
|
AddPaymentMethodModal,
|
2019-09-13 15:58:18 +01:00
|
|
|
},
|
2019-09-09 11:33:39 +01:00
|
|
|
})
|
2019-09-26 14:36:12 +01:00
|
|
|
export default class DashboardArea extends Vue {
|
2020-12-15 18:48:34 +00:00
|
|
|
/**
|
|
|
|
* Lifecycle hook before initial render.
|
|
|
|
* Sets access grants web worker.
|
|
|
|
*/
|
2021-02-15 13:06:47 +00:00
|
|
|
public async beforeMount(): Promise<void> {
|
2020-12-15 18:48:34 +00:00
|
|
|
try {
|
2021-02-15 13:06:47 +00:00
|
|
|
await this.$store.dispatch(ACCESS_GRANTS_ACTIONS.STOP_ACCESS_GRANTS_WEB_WORKER);
|
|
|
|
await this.$store.dispatch(ACCESS_GRANTS_ACTIONS.SET_ACCESS_GRANTS_WEB_WORKER);
|
2020-12-15 18:48:34 +00:00
|
|
|
} catch (error) {
|
2021-02-15 13:06:47 +00:00
|
|
|
await this.$notify.error(`Unable to set access grants wizard. ${error.message}`);
|
2020-12-15 18:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Lifecycle hook after initial render.
|
|
|
|
* Pre fetches user`s and project information.
|
|
|
|
*/
|
2019-09-27 15:41:04 +01:00
|
|
|
public async mounted(): Promise<void> {
|
|
|
|
try {
|
2020-12-15 18:48:34 +00:00
|
|
|
await this.$store.dispatch(USER_ACTIONS.GET);
|
2019-09-27 15:41:04 +01:00
|
|
|
} catch (error) {
|
2020-02-03 16:55:44 +00:00
|
|
|
if (!(error instanceof ErrorUnauthorized)) {
|
|
|
|
await this.$store.dispatch(APP_STATE_ACTIONS.CHANGE_STATE, AppState.ERROR);
|
|
|
|
await this.$notify.error(error.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(async () => await this.$router.push(RouteConfig.Login.path), 1000);
|
2019-09-27 15:41:04 +01:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2019-09-09 11:33:39 +01:00
|
|
|
|
2019-11-04 10:54:25 +00:00
|
|
|
try {
|
|
|
|
await this.$store.dispatch(SETUP_ACCOUNT);
|
2020-04-22 17:21:12 +01:00
|
|
|
} catch (error) {
|
|
|
|
await this.$notify.error(`Unable to setup account. ${error.message}`);
|
|
|
|
}
|
|
|
|
|
2021-07-08 23:46:14 +01:00
|
|
|
try {
|
|
|
|
await this.$store.dispatch(GET_CREDIT_CARDS);
|
|
|
|
} catch (error) {
|
|
|
|
await this.$notify.error(`Unable to get credit cards. ${error.message}`);
|
|
|
|
}
|
|
|
|
|
2019-09-27 15:41:04 +01:00
|
|
|
let projects: Project[] = [];
|
2019-09-09 11:33:39 +01:00
|
|
|
|
2019-09-27 15:41:04 +01:00
|
|
|
try {
|
|
|
|
projects = await this.$store.dispatch(PROJECTS_ACTIONS.FETCH);
|
|
|
|
} catch (error) {
|
2019-10-28 17:33:06 +00:00
|
|
|
await this.$notify.error(error.message);
|
2019-09-09 11:33:39 +01:00
|
|
|
|
2019-09-27 15:41:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-09-09 11:33:39 +01:00
|
|
|
|
2020-04-22 17:21:12 +01:00
|
|
|
if (!projects.length) {
|
2020-04-30 21:35:09 +01:00
|
|
|
await this.$store.dispatch(APP_STATE_ACTIONS.CHANGE_STATE, AppState.LOADED);
|
2020-02-18 15:48:19 +00:00
|
|
|
|
|
|
|
try {
|
2020-12-04 15:38:28 +00:00
|
|
|
await this.$router.push(RouteConfig.OnboardingTour.with(RouteConfig.OverviewStep).path);
|
2020-02-18 15:48:19 +00:00
|
|
|
} catch (error) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-18 12:26:24 +01:00
|
|
|
this.selectProject(projects);
|
2019-09-09 11:33:39 +01:00
|
|
|
|
2019-09-27 15:41:04 +01:00
|
|
|
await this.$store.dispatch(APP_STATE_ACTIONS.CHANGE_STATE, AppState.LOADED);
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
2019-09-05 09:41:39 +01:00
|
|
|
|
2021-07-01 20:47:41 +01:00
|
|
|
/**
|
|
|
|
* Opens add payment method modal.
|
|
|
|
*/
|
|
|
|
public togglePMModal(): void {
|
|
|
|
this.$store.commit(PAYMENTS_MUTATIONS.TOGGLE_IS_ADD_PM_MODAL_SHOWN);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if add payment method modal is shown.
|
|
|
|
*/
|
|
|
|
public get isAddPMModal(): boolean {
|
|
|
|
return this.$store.state.paymentsModule.isAddPMModalShown;
|
|
|
|
}
|
|
|
|
|
2021-06-30 17:47:47 +01:00
|
|
|
/**
|
2021-07-08 23:46:14 +01:00
|
|
|
* Returns credit cards from store.
|
2021-06-30 17:47:47 +01:00
|
|
|
*/
|
2021-07-08 23:46:14 +01:00
|
|
|
public get creditCards(): CreditCard[] {
|
|
|
|
return this.$store.state.paymentsModule.creditCards;
|
2021-06-30 17:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if current route is onboarding tour.
|
|
|
|
*/
|
|
|
|
public get isOnboardingTour(): boolean {
|
|
|
|
return this.$route.path.includes(RouteConfig.OnboardingTour.path);
|
|
|
|
}
|
|
|
|
|
2021-03-11 15:05:06 +00:00
|
|
|
/**
|
|
|
|
* Returns satellite name from store (config).
|
|
|
|
*/
|
|
|
|
public get satelliteName(): string {
|
|
|
|
return MetaUtils.getMetaContent('satellite-name');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns feedback URL from config for beta satellites.
|
|
|
|
*/
|
|
|
|
public get betaFeedbackURL(): string {
|
|
|
|
return MetaUtils.getMetaContent('beta-satellite-feedback-url');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns support URL from config for beta satellites.
|
|
|
|
*/
|
|
|
|
public get betaSupportURL(): string {
|
|
|
|
return MetaUtils.getMetaContent('beta-satellite-support-url');
|
|
|
|
}
|
|
|
|
|
2021-02-22 17:53:54 +00:00
|
|
|
/**
|
2021-02-23 17:26:24 +00:00
|
|
|
* Indicates if satellite is in beta.
|
2021-02-22 17:53:54 +00:00
|
|
|
*/
|
|
|
|
public get isBetaSatellite(): boolean {
|
2021-02-23 17:26:24 +00:00
|
|
|
return this.$store.state.appStateModule.isBetaSatellite;
|
2021-02-22 17:53:54 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Indicates if loading screen is active.
|
|
|
|
*/
|
2019-09-09 11:33:39 +01:00
|
|
|
public get isLoading(): boolean {
|
|
|
|
return this.$store.state.appStateModule.appState.fetchState === AppState.LOADING;
|
|
|
|
}
|
2020-08-04 18:36:49 +01:00
|
|
|
|
2020-09-18 12:26:24 +01:00
|
|
|
/**
|
|
|
|
* Checks if stored project is in fetched projects array and selects it.
|
|
|
|
* Selects first fetched project if check is not successful.
|
|
|
|
* @param fetchedProjects - fetched projects array
|
|
|
|
*/
|
|
|
|
private selectProject(fetchedProjects: Project[]): void {
|
|
|
|
const storedProjectID = LocalData.getSelectedProjectId();
|
|
|
|
const isProjectInFetchedProjects = fetchedProjects.some(project => project.id === storedProjectID);
|
|
|
|
if (storedProjectID && isProjectInFetchedProjects) {
|
|
|
|
this.storeProject(storedProjectID);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Length of fetchedProjects array is checked before selectProject() function call.
|
|
|
|
this.storeProject(fetchedProjects[0].id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores project to vuex store and browser's local storage.
|
|
|
|
* @param projectID - project id string
|
|
|
|
*/
|
|
|
|
private storeProject(projectID: string): void {
|
|
|
|
this.$store.dispatch(PROJECTS_ACTIONS.SELECT, projectID);
|
|
|
|
LocalData.setSelectedProjectId(projectID);
|
|
|
|
}
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
2018-11-14 14:00:01 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2020-08-20 20:38:17 +01:00
|
|
|
.loading-overlay {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
2021-06-09 16:13:19 +01:00
|
|
|
background-color: rgba(134, 134, 148, 0.3);
|
2020-08-20 20:38:17 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
.loading-overlay.active {
|
|
|
|
visibility: visible;
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
|
2021-06-01 11:47:45 +01:00
|
|
|
.loading-icon {
|
|
|
|
width: 100px;
|
|
|
|
height: 100px;
|
|
|
|
}
|
|
|
|
|
2020-09-09 19:25:59 +01:00
|
|
|
.dashboard {
|
2019-10-28 15:59:19 +00:00
|
|
|
height: 100%;
|
|
|
|
background-color: #f5f6fa;
|
2020-08-20 20:38:17 +01:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2018-11-19 15:32:50 +00:00
|
|
|
|
2021-02-22 17:53:54 +00:00
|
|
|
&__beta-banner {
|
|
|
|
width: calc(100% - 60px);
|
|
|
|
padding: 0 30px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
font-family: 'font_regular', sans-serif;
|
|
|
|
background-color: red;
|
|
|
|
|
|
|
|
&__message {
|
|
|
|
font-weight: normal;
|
|
|
|
font-size: 14px;
|
2021-03-11 15:05:06 +00:00
|
|
|
line-height: 16px;
|
2021-02-22 17:53:54 +00:00
|
|
|
color: #fff;
|
2021-03-11 15:05:06 +00:00
|
|
|
|
|
|
|
&__link {
|
|
|
|
font-size: 14px;
|
|
|
|
line-height: 16px;
|
|
|
|
color: #fff;
|
|
|
|
text-decoration: underline;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
}
|
2021-02-22 17:53:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-05 16:39:03 +00:00
|
|
|
&__wrap {
|
|
|
|
display: flex;
|
2020-09-09 19:25:59 +01:00
|
|
|
flex-direction: column;
|
2020-08-20 20:38:17 +01:00
|
|
|
height: 100%;
|
2019-03-26 16:56:38 +00:00
|
|
|
|
2020-09-09 19:25:59 +01:00
|
|
|
&__main-area {
|
2019-03-26 16:56:38 +00:00
|
|
|
display: flex;
|
2020-08-20 20:38:17 +01:00
|
|
|
height: 100%;
|
|
|
|
|
2020-09-09 19:25:59 +01:00
|
|
|
&__content {
|
2020-08-20 20:38:17 +01:00
|
|
|
overflow-y: scroll;
|
2020-09-09 19:25:59 +01:00
|
|
|
height: calc(100vh - 62px);
|
|
|
|
width: 100%;
|
2021-06-09 16:13:19 +01:00
|
|
|
position: relative;
|
2020-08-20 20:38:17 +01:00
|
|
|
}
|
2019-03-26 16:56:38 +00:00
|
|
|
}
|
2018-12-05 16:39:03 +00:00
|
|
|
}
|
2020-08-04 18:36:49 +01:00
|
|
|
}
|
|
|
|
|
2020-02-27 18:28:11 +00:00
|
|
|
@media screen and (max-width: 1280px) {
|
2019-10-28 15:59:19 +00:00
|
|
|
|
2020-09-09 19:25:59 +01:00
|
|
|
.regular-navigation {
|
2019-09-20 11:21:22 +01:00
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
2019-03-26 16:56:38 +00:00
|
|
|
</style>
|