2019-09-09 17:00:25 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="header">
|
|
|
|
<div class="header__content-holder">
|
2019-09-19 12:43:57 +01:00
|
|
|
<div class="header__content-holder__logo-area">
|
2019-10-25 10:53:35 +01:00
|
|
|
<StorjIcon
|
2020-03-05 14:23:56 +00:00
|
|
|
class="header__content-holder__logo"
|
|
|
|
alt="storj logo"
|
2020-02-26 11:03:47 +00:00
|
|
|
@click="onHeaderLogoClick"
|
2019-10-25 10:53:35 +01:00
|
|
|
/>
|
2020-03-05 14:23:56 +00:00
|
|
|
<img
|
|
|
|
src="@/../static/images/LogoWithoutText.png"
|
|
|
|
alt="storj logo"
|
|
|
|
class="header__content-holder__logo--small"
|
|
|
|
>
|
2019-09-19 12:43:57 +01:00
|
|
|
<div class="header__content-holder__logo-area__refresh-button" @click="onRefresh">
|
2019-10-25 10:53:35 +01:00
|
|
|
<RefreshIcon alt="refresh image"/>
|
2019-09-19 12:43:57 +01:00
|
|
|
</div>
|
2019-09-09 17:00:25 +01:00
|
|
|
</div>
|
2019-12-04 15:38:43 +00:00
|
|
|
<div class="header__content-holder__right-area">
|
|
|
|
<div class="header__content-holder__right-area__node-id-container">
|
|
|
|
<b class="header__content-holder__right-area__node-id-container__title">Node ID:</b>
|
|
|
|
<p class="header__content-holder__right-area__node-id-container__id">{{this.nodeId}}</p>
|
|
|
|
</div>
|
2020-01-29 15:22:34 +00:00
|
|
|
<div class="header__content-holder__right-area__bell-area" @click.stop="toggleNotificationsPopup">
|
2019-12-04 15:38:43 +00:00
|
|
|
<BellIcon />
|
2019-12-20 19:11:01 +00:00
|
|
|
<span
|
|
|
|
class="header__content-holder__right-area__bell-area__new-circle"
|
|
|
|
v-if="hasNewNotifications"
|
|
|
|
/>
|
2019-12-04 15:38:43 +00:00
|
|
|
</div>
|
2019-09-09 17:00:25 +01:00
|
|
|
</div>
|
2019-12-04 15:38:43 +00:00
|
|
|
<NotificationsPopup
|
|
|
|
v-if="isNotificationPopupShown"
|
|
|
|
class="header__content-holder__right-area__bell-area__popup"
|
|
|
|
v-click-outside="closeNotificationPopup"
|
|
|
|
/>
|
2019-09-09 17:00:25 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
|
|
|
|
2019-12-04 15:38:43 +00:00
|
|
|
import NotificationsPopup from '@/app/components/notifications/NotificationsPopup.vue';
|
|
|
|
|
|
|
|
import BellIcon from '@/../static/images/notifications/bell.svg';
|
2019-10-25 10:53:35 +01:00
|
|
|
import RefreshIcon from '@/../static/images/refresh.svg';
|
|
|
|
import StorjIcon from '@/../static/images/storjIcon.svg';
|
|
|
|
|
2020-01-29 15:22:34 +00:00
|
|
|
import { RouteConfig } from '@/app/router';
|
2019-09-09 17:00:25 +01:00
|
|
|
import { NODE_ACTIONS } from '@/app/store/modules/node';
|
2019-12-20 19:11:01 +00:00
|
|
|
import { NOTIFICATIONS_ACTIONS } from '@/app/store/modules/notifications';
|
2020-03-15 14:54:02 +00:00
|
|
|
import { PAYOUT_ACTIONS } from '@/app/store/modules/payout';
|
2019-12-20 19:11:01 +00:00
|
|
|
import { NotificationsCursor } from '@/app/types/notifications';
|
2019-09-09 17:00:25 +01:00
|
|
|
|
|
|
|
const {
|
|
|
|
GET_NODE_INFO,
|
|
|
|
SELECT_SATELLITE,
|
|
|
|
} = NODE_ACTIONS;
|
|
|
|
|
2019-10-25 10:53:35 +01:00
|
|
|
@Component({
|
|
|
|
components: {
|
2019-12-04 15:38:43 +00:00
|
|
|
NotificationsPopup,
|
2019-10-25 10:53:35 +01:00
|
|
|
StorjIcon,
|
|
|
|
RefreshIcon,
|
2019-12-04 15:38:43 +00:00
|
|
|
BellIcon,
|
2019-10-25 10:53:35 +01:00
|
|
|
},
|
|
|
|
})
|
2019-09-09 17:00:25 +01:00
|
|
|
export default class SNOHeader extends Vue {
|
2019-12-04 15:38:43 +00:00
|
|
|
public isNotificationPopupShown: boolean = false;
|
|
|
|
|
2019-12-20 19:11:01 +00:00
|
|
|
/**
|
|
|
|
* Lifecycle hook before render.
|
|
|
|
* Fetches first page of notifications.
|
|
|
|
*/
|
|
|
|
public beforeMount(): void {
|
|
|
|
try {
|
|
|
|
this.$store.dispatch(NODE_ACTIONS.GET_NODE_INFO);
|
|
|
|
this.$store.dispatch(NOTIFICATIONS_ACTIONS.GET_NOTIFICATIONS, new NotificationsCursor(1));
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public get nodeId(): string {
|
|
|
|
return this.$store.state.node.info.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get hasNewNotifications(): boolean {
|
|
|
|
return this.$store.state.notificationsModule.unreadCount > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* toggleNotificationPopup toggles NotificationPopup visibility.
|
|
|
|
*/
|
2020-01-29 15:22:34 +00:00
|
|
|
public toggleNotificationsPopup(): void {
|
|
|
|
/**
|
|
|
|
* Blocks opening popup in current route is /notifications.
|
|
|
|
*/
|
|
|
|
if (this.$route.name === RouteConfig.Notifications.name) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.isNotificationPopupShown = !this.isNotificationPopupShown;
|
2019-12-04 15:38:43 +00:00
|
|
|
}
|
|
|
|
|
2019-12-20 19:11:01 +00:00
|
|
|
/**
|
|
|
|
* closeNotificationPopup when clicking outside popup.
|
|
|
|
*/
|
2019-12-04 15:38:43 +00:00
|
|
|
public closeNotificationPopup(): void {
|
|
|
|
this.isNotificationPopupShown = false;
|
|
|
|
}
|
|
|
|
|
2020-02-26 11:03:47 +00:00
|
|
|
/**
|
|
|
|
* Refreshes page when on home page or relocates to home page from other location.
|
|
|
|
*/
|
|
|
|
public async onHeaderLogoClick(): Promise<void> {
|
|
|
|
const isCurrentLocationIsHomePage = this.$route.name === RouteConfig.Root.name;
|
|
|
|
|
|
|
|
if (isCurrentLocationIsHomePage) {
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.$router.replace('/');
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:00:25 +01:00
|
|
|
public async onRefresh(): Promise<void> {
|
|
|
|
const selectedSatellite = this.$store.state.node.selectedSatellite.id;
|
2019-09-13 17:06:04 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
await this.$store.dispatch(GET_NODE_INFO);
|
|
|
|
await this.$store.dispatch(SELECT_SATELLITE, selectedSatellite);
|
2020-03-15 14:54:02 +00:00
|
|
|
await this.$store.dispatch(PAYOUT_ACTIONS.GET_HELD_INFO, selectedSatellite);
|
|
|
|
await this.$store.dispatch(PAYOUT_ACTIONS.GET_TOTAL);
|
2019-09-13 17:06:04 +01:00
|
|
|
} catch (error) {
|
|
|
|
console.error(`${error.message} satellite data.`);
|
|
|
|
}
|
2019-09-09 17:00:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2019-10-11 17:28:47 +01:00
|
|
|
<style scoped lang="scss">
|
2019-09-09 17:00:25 +01:00
|
|
|
.header {
|
2020-03-05 14:23:56 +00:00
|
|
|
padding: 0 36px;
|
|
|
|
width: calc(100% - 72px);
|
2019-09-09 17:00:25 +01:00
|
|
|
height: 89px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
2019-10-28 13:19:57 +00:00
|
|
|
background-color: #fff;
|
2020-03-05 14:23:56 +00:00
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
z-index: 9999;
|
2019-09-09 17:00:25 +01:00
|
|
|
|
|
|
|
&__content-holder {
|
|
|
|
width: 822px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
2019-12-04 15:38:43 +00:00
|
|
|
position: relative;
|
2019-09-09 17:00:25 +01:00
|
|
|
|
2019-09-19 12:43:57 +01:00
|
|
|
&__logo-area {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2019-09-09 17:00:25 +01:00
|
|
|
|
2019-09-19 12:43:57 +01:00
|
|
|
&__refresh-button {
|
|
|
|
margin-left: 25px;
|
|
|
|
max-height: 42px;
|
2019-10-02 11:26:50 +01:00
|
|
|
cursor: pointer;
|
2019-09-09 17:00:25 +01:00
|
|
|
|
2019-10-02 11:26:50 +01:00
|
|
|
&:hover {
|
2019-09-09 17:00:25 +01:00
|
|
|
|
2019-10-02 11:26:50 +01:00
|
|
|
.refresh-button-svg-rect {
|
2019-10-28 13:19:57 +00:00
|
|
|
fill: #133e9c;
|
2019-09-19 12:43:57 +01:00
|
|
|
}
|
|
|
|
|
2019-10-02 11:26:50 +01:00
|
|
|
.refresh-button-svg-path {
|
2019-10-28 13:19:57 +00:00
|
|
|
fill: #fff;
|
2019-09-19 12:43:57 +01:00
|
|
|
}
|
2019-09-09 17:00:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-05 14:23:56 +00:00
|
|
|
&__logo {
|
2020-02-26 11:03:47 +00:00
|
|
|
cursor: pointer;
|
2020-03-05 14:23:56 +00:00
|
|
|
|
|
|
|
&--small {
|
|
|
|
display: none;
|
|
|
|
}
|
2020-02-26 11:03:47 +00:00
|
|
|
}
|
|
|
|
|
2019-12-04 15:38:43 +00:00
|
|
|
&__right-area {
|
2019-09-09 17:00:25 +01:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2019-12-04 15:38:43 +00:00
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
|
|
&__node-id-container {
|
|
|
|
color: #535f77;
|
|
|
|
height: 44px;
|
|
|
|
padding: 0 14px 0 14px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
border: 1px solid #e8e8e8;
|
|
|
|
border-radius: 12px;
|
|
|
|
font-size: 14px;
|
|
|
|
margin-right: 30px;
|
|
|
|
|
|
|
|
&__title {
|
|
|
|
min-width: 55px;
|
|
|
|
margin-right: 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&__id {
|
|
|
|
font-size: 11px;
|
|
|
|
}
|
2019-09-19 12:43:57 +01:00
|
|
|
}
|
2019-09-09 17:00:25 +01:00
|
|
|
|
2019-12-04 15:38:43 +00:00
|
|
|
&__bell-area {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
position: relative;
|
|
|
|
width: 26px;
|
|
|
|
height: 32px;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&__new-circle {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
display: inline-block;
|
|
|
|
width: 6px;
|
|
|
|
height: 6px;
|
|
|
|
border-radius: 50%;
|
|
|
|
background-color: #eb001b;
|
|
|
|
}
|
|
|
|
|
|
|
|
&__popup {
|
|
|
|
position: absolute;
|
|
|
|
top: 105px;
|
|
|
|
right: 0;
|
|
|
|
}
|
2019-09-09 17:00:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-05 14:23:56 +00:00
|
|
|
|
|
|
|
@media screen and (max-width: 780px) {
|
|
|
|
|
|
|
|
.header__content-holder {
|
|
|
|
|
|
|
|
&__logo {
|
|
|
|
order: 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
&__logo-area {
|
|
|
|
width: calc(50% + 63px);
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
&__refresh-button {
|
|
|
|
order: 1;
|
|
|
|
margin-left: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__right-area {
|
|
|
|
|
|
|
|
&__node-id-container {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (max-width: 600px) {
|
|
|
|
|
|
|
|
.header__content-holder {
|
|
|
|
|
|
|
|
&__logo-area {
|
|
|
|
width: calc(50% + 20px);
|
|
|
|
}
|
|
|
|
|
|
|
|
&__logo {
|
|
|
|
display: none;
|
|
|
|
|
|
|
|
&--small {
|
|
|
|
display: block;
|
|
|
|
order: 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (max-width: 600px) {
|
|
|
|
|
|
|
|
.header__content-holder__right-area__bell-area__popup {
|
|
|
|
position: fixed;
|
|
|
|
top: 89px;
|
|
|
|
right: 0;
|
|
|
|
left: 0;
|
|
|
|
}
|
|
|
|
}
|
2019-09-09 17:00:25 +01:00
|
|
|
</style>
|