web/storagenode: sno types/store/api refactoring
WHAT: node store, api, types refactoring; service creation; minor payout store changes; Change-Id: I5c52740730db49bc16393b07858354a2914846fb
This commit is contained in:
parent
3ba52b25a9
commit
dbaf8b6c0d
6
web/storagenode/package-lock.json
generated
6
web/storagenode/package-lock.json
generated
@ -5312,9 +5312,9 @@
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001048",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001048.tgz",
|
||||
"integrity": "sha512-g1iSHKVxornw0K8LG9LLdf+Fxnv7T1Z+mMsf0/YYLclQX4Cd522Ap0Lrw6NFqHgezit78dtyWxzlV2Xfc7vgRg==",
|
||||
"version": "1.0.30001150",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001150.tgz",
|
||||
"integrity": "sha512-kiNKvihW0m36UhAFnl7bOAv0i1K1f6wpfVtTF5O5O82XzgtBnb05V0XeV3oZ968vfg2sRNChsHw8ASH2hDfoYQ==",
|
||||
"dev": true
|
||||
},
|
||||
"capture-exit": {
|
||||
|
@ -35,7 +35,7 @@ import { Component, Vue } from 'vue-property-decorator';
|
||||
|
||||
import DisqualifyIcon from '@/../static/images/disqualify.svg';
|
||||
|
||||
import { SatelliteScores } from '@/storagenode/satellite';
|
||||
import { SatelliteScores } from '@/storagenode/sno/sno';
|
||||
|
||||
@Component({
|
||||
components: { DisqualifyIcon },
|
||||
|
@ -24,7 +24,7 @@ import { ChartData } from '@/app/types/chartData';
|
||||
import { Tooltip, TooltipParams } from '@/app/types/tooltip';
|
||||
import { ChartUtils } from '@/app/utils/chart';
|
||||
import { formatBytes } from '@/app/utils/converter';
|
||||
import { BandwidthUsed } from '@/storagenode/satellite';
|
||||
import { BandwidthUsed } from '@/storagenode/sno/sno';
|
||||
|
||||
/**
|
||||
* stores bandwidth data for bandwidth chart's tooltip
|
||||
|
@ -24,7 +24,7 @@ import { ChartData } from '@/app/types/chartData';
|
||||
import { Tooltip, TooltipParams } from '@/app/types/tooltip';
|
||||
import { ChartUtils } from '@/app/utils/chart';
|
||||
import { formatBytes } from '@/app/utils/converter';
|
||||
import { Stamp } from '@/storagenode/satellite';
|
||||
import { Stamp } from '@/storagenode/sno/sno';
|
||||
|
||||
/**
|
||||
* stores stamp data for disc space chart's tooltip
|
||||
|
@ -24,7 +24,7 @@ import { ChartData } from '@/app/types/chartData';
|
||||
import { Tooltip, TooltipParams } from '@/app/types/tooltip';
|
||||
import { ChartUtils } from '@/app/utils/chart';
|
||||
import { formatBytes } from '@/app/utils/converter';
|
||||
import { EgressUsed } from '@/storagenode/satellite';
|
||||
import { EgressUsed } from '@/storagenode/sno/sno';
|
||||
|
||||
/**
|
||||
* stores egress data for egress bandwidth chart's tooltip
|
||||
|
@ -24,7 +24,7 @@ import { ChartData } from '@/app/types/chartData';
|
||||
import { Tooltip, TooltipParams } from '@/app/types/tooltip';
|
||||
import { ChartUtils } from '@/app/utils/chart';
|
||||
import { formatBytes } from '@/app/utils/converter';
|
||||
import { IngressUsed } from '@/storagenode/satellite';
|
||||
import { IngressUsed } from '@/storagenode/sno/sno';
|
||||
|
||||
/**
|
||||
* stores ingress data for ingress bandwidth chart's tooltip
|
||||
|
@ -175,7 +175,7 @@ import LargeSuspensionIcon from '@/../static/images/largeSuspend.svg';
|
||||
import { RouteConfig } from '@/app/router';
|
||||
import { APPSTATE_ACTIONS } from '@/app/store/modules/appState';
|
||||
import { formatBytes } from '@/app/utils/converter';
|
||||
import { SatelliteInfo } from '@/storagenode/dashboard';
|
||||
import { SatelliteInfo } from '@/storagenode/sno/sno';
|
||||
|
||||
/**
|
||||
* Checks class holds info for Checks entity.
|
||||
|
@ -53,7 +53,7 @@ import DropdownArrowIcon from '@/../static/images/dropdownArrow.svg';
|
||||
import EyeIcon from '@/../static/images/Eye.svg';
|
||||
|
||||
import { APPSTATE_ACTIONS } from '@/app/store/modules/appState';
|
||||
import { SatelliteInfo } from '@/storagenode/dashboard';
|
||||
import { SatelliteInfo } from '@/storagenode/sno/sno';
|
||||
|
||||
import SatelliteSelectionDropdown from './SatelliteSelectionDropdown.vue';
|
||||
|
||||
|
@ -32,8 +32,8 @@ import { APPSTATE_ACTIONS } from '@/app/store/modules/appState';
|
||||
import { NODE_ACTIONS } from '@/app/store/modules/node';
|
||||
import { PAYOUT_ACTIONS } from '@/app/store/modules/payout';
|
||||
import { PayoutInfoRange } from '@/app/types/payout';
|
||||
import { SatelliteInfo } from '@/storagenode/dashboard';
|
||||
import { PayoutPeriod } from '@/storagenode/payouts/payouts';
|
||||
import { SatelliteInfo } from '@/storagenode/sno/sno';
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
|
@ -68,7 +68,7 @@ import DisqualificationIcon from '@/../static/images/disqualify.svg';
|
||||
import EyeIcon from '@/../static/images/Eye.svg';
|
||||
import SuspensionIcon from '@/../static/images/suspend.svg';
|
||||
|
||||
import { SatelliteInfo } from '@/storagenode/dashboard';
|
||||
import { SatelliteInfo } from '@/storagenode/sno/sno';
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
|
@ -127,7 +127,8 @@ import { APPSTATE_ACTIONS } from '@/app/store/modules/appState';
|
||||
import {
|
||||
BANDWIDTH_DOWNLOAD_PRICE_PER_TB,
|
||||
BANDWIDTH_REPAIR_PRICE_PER_TB,
|
||||
DISK_SPACE_PRICE_PER_TB, PAYOUT_ACTIONS,
|
||||
DISK_SPACE_PRICE_PER_TB,
|
||||
PAYOUT_ACTIONS,
|
||||
} from '@/app/store/modules/payout';
|
||||
import {
|
||||
monthNames,
|
||||
@ -195,7 +196,6 @@ export default class EstimationArea extends Vue {
|
||||
const lastMonthDate = new Date();
|
||||
lastMonthDate.setMonth(lastMonthDate.getUTCMonth() - 1);
|
||||
|
||||
|
||||
const selectedPeriod: PayoutInfoRange = this.$store.state.payoutModule.periodRange;
|
||||
const lastMonthPayoutPeriod = new PayoutPeriod(lastMonthDate.getUTCFullYear(), lastMonthDate.getUTCMonth());
|
||||
const isLastPeriodSelected: boolean = !selectedPeriod.start && selectedPeriod.end.period === lastMonthPayoutPeriod.period;
|
||||
|
@ -102,7 +102,6 @@ export default class PayoutPeriodCalendar extends Vue {
|
||||
const lastMonthDate = new Date();
|
||||
lastMonthDate.setMonth(lastMonthDate.getUTCMonth() - 1);
|
||||
|
||||
|
||||
const selectedPeriod: PayoutInfoRange = this.$store.state.payoutModule.periodRange;
|
||||
const lastMonthPayoutPeriod = new PayoutPeriod(lastMonthDate.getUTCFullYear(), lastMonthDate.getUTCMonth());
|
||||
const isLastPeriodSelected: boolean = !selectedPeriod.start && selectedPeriod.end.period === lastMonthPayoutPeriod.period;
|
||||
|
@ -5,33 +5,42 @@ import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
|
||||
import { newNotificationsModule } from '@/app/store/modules/notifications';
|
||||
import { makePayoutModule } from '@/app/store/modules/payout';
|
||||
import { newPayoutModule } from '@/app/store/modules/payout';
|
||||
import { NotificationsHttpApi } from '@/storagenode/api/notifications';
|
||||
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
||||
import { SNOApi } from '@/storagenode/api/storagenode';
|
||||
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
||||
import { NotificationsService } from '@/storagenode/notifications/service';
|
||||
import { PayoutService } from '@/storagenode/payouts/service';
|
||||
import { StorageNodeService } from '@/storagenode/sno/service';
|
||||
|
||||
import { appStateModule } from './modules/appState';
|
||||
import { makeNodeModule } from './modules/node';
|
||||
import { newNodeModule } from './modules/node';
|
||||
|
||||
const notificationsApi = new NotificationsHttpApi();
|
||||
const notificationsService = new NotificationsService(notificationsApi);
|
||||
const payoutApi = new PayoutHttpApi();
|
||||
const payoutService = new PayoutService(payoutApi);
|
||||
const nodeApi = new SNOApi();
|
||||
const nodeApi = new StorageNodeApi();
|
||||
const nodeService = new StorageNodeService(nodeApi);
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
export class StoreModule<S> {
|
||||
public state: S;
|
||||
public mutations: any;
|
||||
public actions: any;
|
||||
public getters?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* storage node store (vuex)
|
||||
*/
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
node: makeNodeModule(nodeApi),
|
||||
node: newNodeModule(nodeService),
|
||||
appStateModule,
|
||||
notificationsModule: newNotificationsModule(notificationsService),
|
||||
payoutModule: makePayoutModule(payoutApi, payoutService),
|
||||
payoutModule: newPayoutModule(payoutService),
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -1,19 +1,21 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
import { StoreModule } from '@/app/store';
|
||||
import { StorageNodeState } from '@/app/types/sno';
|
||||
import { Duration, millisecondsInSecond, secondsInMinute } from '@/app/utils/duration';
|
||||
import { getMonthsBeforeNow } from '@/app/utils/payout';
|
||||
import { SNOApi } from '@/storagenode/api/storagenode';
|
||||
import { Dashboard, SatelliteInfo } from '@/storagenode/dashboard';
|
||||
import { StorageNodeService } from '@/storagenode/sno/service';
|
||||
import {
|
||||
BandwidthUsed,
|
||||
EgressUsed,
|
||||
IngressUsed,
|
||||
Checks,
|
||||
Dashboard,
|
||||
Node,
|
||||
Satellite,
|
||||
SatelliteInfo,
|
||||
Satellites,
|
||||
SatelliteScores,
|
||||
Stamp,
|
||||
} from '@/storagenode/satellite';
|
||||
Traffic,
|
||||
Utilization,
|
||||
} from '@/storagenode/sno/sno';
|
||||
|
||||
export const NODE_MUTATIONS = {
|
||||
POPULATE_STORE: 'POPULATE_STORE',
|
||||
@ -37,77 +39,35 @@ const {
|
||||
SET_DAILY_DATA,
|
||||
} = NODE_MUTATIONS;
|
||||
|
||||
const statusThreshHoldMinutes = 120;
|
||||
const STATUS_TRESHHOLD_MINUTES: number = 120;
|
||||
|
||||
export function makeNodeModule(api: SNOApi) {
|
||||
export function newNodeModule(service: StorageNodeService): StoreModule<StorageNodeState> {
|
||||
return {
|
||||
state: {
|
||||
info: {
|
||||
id: '',
|
||||
status: StatusOffline,
|
||||
lastPinged: new Date(),
|
||||
startedAt: new Date(),
|
||||
version: '',
|
||||
allowedVersion: '',
|
||||
wallet: '',
|
||||
isLastVersion: false,
|
||||
},
|
||||
utilization: {
|
||||
bandwidth: {
|
||||
used: 0,
|
||||
},
|
||||
diskSpace: {
|
||||
used: 0,
|
||||
available: 1,
|
||||
trash: 0,
|
||||
},
|
||||
},
|
||||
satellites: new Array<SatelliteInfo>(),
|
||||
disqualifiedSatellites: new Array<SatelliteInfo>(),
|
||||
suspendedSatellites: new Array<SatelliteInfo>(),
|
||||
selectedSatellite: {
|
||||
id: null,
|
||||
disqualified: null,
|
||||
joinDate: new Date(),
|
||||
},
|
||||
bandwidthChartData: new Array<BandwidthUsed>(),
|
||||
egressChartData: new Array<EgressUsed>(),
|
||||
ingressChartData: new Array<IngressUsed>(),
|
||||
storageChartData: new Array<Stamp>(),
|
||||
storageSummary: 0,
|
||||
bandwidthSummary: 0,
|
||||
egressSummary: 0,
|
||||
ingressSummary: 0,
|
||||
satellitesScores: new Array<SatelliteScores>(),
|
||||
checks: {
|
||||
uptime: 0,
|
||||
audit: 0,
|
||||
suspension: 0,
|
||||
},
|
||||
},
|
||||
state: new StorageNodeState(),
|
||||
mutations: {
|
||||
[POPULATE_STORE](state: any, nodeInfo: Dashboard): void {
|
||||
state.info.id = nodeInfo.nodeID;
|
||||
state.info.isLastVersion = nodeInfo.isUpToDate;
|
||||
state.info.version = nodeInfo.version;
|
||||
state.info.allowedVersion = nodeInfo.allowedVersion;
|
||||
state.info.wallet = nodeInfo.wallet;
|
||||
state.utilization.diskSpace.used = nodeInfo.diskSpace.used;
|
||||
state.utilization.diskSpace.available = nodeInfo.diskSpace.available;
|
||||
state.utilization.diskSpace.trash = nodeInfo.diskSpace.trash;
|
||||
state.utilization.bandwidth.used = nodeInfo.bandwidth.used;
|
||||
const minutesPassed = Duration.difference(new Date(), new Date(nodeInfo.lastPinged)) / millisecondsInSecond / secondsInMinute;
|
||||
const status = minutesPassed < STATUS_TRESHHOLD_MINUTES ? StatusOnline : StatusOffline;
|
||||
state.info = new Node(
|
||||
nodeInfo.nodeID,
|
||||
status,
|
||||
nodeInfo.lastPinged,
|
||||
nodeInfo.startedAt,
|
||||
nodeInfo.version,
|
||||
nodeInfo.allowedVersion,
|
||||
nodeInfo.wallet,
|
||||
nodeInfo.isUpToDate,
|
||||
);
|
||||
|
||||
state.utilization = new Utilization(
|
||||
new Traffic(nodeInfo.bandwidth.used),
|
||||
new Traffic(nodeInfo.diskSpace.used, nodeInfo.diskSpace.available, nodeInfo.diskSpace.trash),
|
||||
);
|
||||
|
||||
state.disqualifiedSatellites = nodeInfo.satellites.filter((satellite: SatelliteInfo) => satellite.disqualified);
|
||||
state.suspendedSatellites = nodeInfo.satellites.filter((satellite: SatelliteInfo) => satellite.suspended);
|
||||
|
||||
state.satellites = nodeInfo.satellites || [];
|
||||
|
||||
state.info.startedAt = nodeInfo.startedAt;
|
||||
state.info.lastPinged = nodeInfo.lastPinged;
|
||||
|
||||
const minutesPassed = Duration.difference(new Date(), new Date(nodeInfo.lastPinged)) / millisecondsInSecond / secondsInMinute;
|
||||
|
||||
state.info.status = minutesPassed < statusThreshHoldMinutes ? StatusOnline : StatusOffline;
|
||||
state.satellites = nodeInfo.satellites;
|
||||
},
|
||||
[SELECT_SATELLITE](state: any, satelliteInfo: Satellite): void {
|
||||
const selectedSatellite = state.satellites.find(satellite => satelliteInfo.id === satellite.id);
|
||||
@ -116,24 +76,24 @@ export function makeNodeModule(api: SNOApi) {
|
||||
return;
|
||||
}
|
||||
|
||||
state.selectedSatellite = {
|
||||
id: satelliteInfo.id,
|
||||
disqualified: selectedSatellite.disqualified,
|
||||
joinDate: satelliteInfo.joinDate,
|
||||
url: selectedSatellite.url,
|
||||
suspended: selectedSatellite.suspended,
|
||||
};
|
||||
state.selectedSatellite = new SatelliteInfo(
|
||||
satelliteInfo.id,
|
||||
selectedSatellite.url,
|
||||
selectedSatellite.disqualified,
|
||||
selectedSatellite.suspended,
|
||||
satelliteInfo.joinDate,
|
||||
);
|
||||
|
||||
state.checks.audit = parseFloat(parseFloat(`${satelliteInfo.audit.score * 100}`).toFixed(1));
|
||||
state.checks.uptime = satelliteInfo.uptime.totalCount === 0 ? 100 : satelliteInfo.uptime.successCount / satelliteInfo.uptime.totalCount * 100;
|
||||
state.checks.suspension = satelliteInfo.audit.unknownScore * 100;
|
||||
state.checks = new Checks(satelliteInfo.uptime, satelliteInfo.audit);
|
||||
},
|
||||
[SELECT_ALL_SATELLITES](state: any, satelliteInfo: Satellites): void {
|
||||
state.selectedSatellite = {
|
||||
id: '',
|
||||
disqualified: null,
|
||||
joinDate: satelliteInfo.joinDate,
|
||||
};
|
||||
state.selectedSatellite = new SatelliteInfo(
|
||||
'',
|
||||
'',
|
||||
null,
|
||||
null,
|
||||
satelliteInfo.joinDate,
|
||||
);
|
||||
state.satellitesScores = satelliteInfo.satellitesScores;
|
||||
},
|
||||
[SET_DAILY_DATA](state: any, satelliteInfo: Satellite): void {
|
||||
@ -149,17 +109,17 @@ export function makeNodeModule(api: SNOApi) {
|
||||
},
|
||||
actions: {
|
||||
[NODE_ACTIONS.GET_NODE_INFO]: async function ({commit}: any): Promise<void> {
|
||||
const response = await api.dashboard();
|
||||
const dashboard = await service.dashboard();
|
||||
|
||||
commit(NODE_MUTATIONS.POPULATE_STORE, response);
|
||||
commit(NODE_MUTATIONS.POPULATE_STORE, dashboard);
|
||||
},
|
||||
[NODE_ACTIONS.SELECT_SATELLITE]: async function ({commit}, id?: string): Promise<void> {
|
||||
let response: Satellite | Satellites;
|
||||
if (id) {
|
||||
response = await api.satellite(id);
|
||||
response = await service.satellite(id);
|
||||
commit(NODE_MUTATIONS.SELECT_SATELLITE, response);
|
||||
} else {
|
||||
response = await api.satellites();
|
||||
response = await service.satellites();
|
||||
commit(NODE_MUTATIONS.SELECT_ALL_SATELLITES, response);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (C) 2020 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
import { StoreModule } from '@/app/store';
|
||||
import {
|
||||
PayoutInfoRange,
|
||||
PayoutState,
|
||||
@ -9,7 +10,6 @@ import { TB } from '@/app/utils/converter';
|
||||
import { getHeldPercentage } from '@/app/utils/payout';
|
||||
import {
|
||||
EstimatedPayout,
|
||||
PayoutApi,
|
||||
PayoutPeriod,
|
||||
SatelliteHeldHistory,
|
||||
SatellitePayoutForPeriod,
|
||||
@ -50,10 +50,9 @@ export const DISK_SPACE_PRICE_PER_TB = 150;
|
||||
/**
|
||||
* creates notifications module with all dependencies
|
||||
*
|
||||
* @param api - payments api
|
||||
* @param service - payments service
|
||||
*/
|
||||
export function makePayoutModule(api: PayoutApi, service: PayoutService) {
|
||||
export function newPayoutModule(service: PayoutService): StoreModule<PayoutState> {
|
||||
return {
|
||||
state: new PayoutState(),
|
||||
mutations: {
|
||||
|
36
web/storagenode/src/app/types/sno.ts
Normal file
36
web/storagenode/src/app/types/sno.ts
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2020 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
import {
|
||||
BandwidthUsed,
|
||||
Checks,
|
||||
EgressUsed,
|
||||
IngressUsed,
|
||||
Node,
|
||||
SatelliteInfo,
|
||||
SatelliteScores,
|
||||
Stamp,
|
||||
Utilization,
|
||||
} from '@/storagenode/sno/sno';
|
||||
|
||||
/**
|
||||
* Holds all node module state.
|
||||
*/
|
||||
export class StorageNodeState {
|
||||
public info: Node = new Node();
|
||||
public utilization: Utilization = new Utilization();
|
||||
public satellites: SatelliteInfo[] = [];
|
||||
public disqualifiedSatellites: SatelliteInfo[] = [];
|
||||
public suspendedSatellites: SatelliteInfo[] = [];
|
||||
public selectedSatellite: SatelliteInfo = new SatelliteInfo();
|
||||
public bandwidthChartData: BandwidthUsed[] = [];
|
||||
public egressChartData: EgressUsed[] = [];
|
||||
public ingressChartData: IngressUsed[] = [];
|
||||
public storageChartData: Stamp[] = [];
|
||||
public storageSummary: number = 0;
|
||||
public bandwidthSummary: number = 0;
|
||||
public egressSummary: number = 0;
|
||||
public ingressSummary: number = 0;
|
||||
public satellitesScores: SatelliteScores[] = [];
|
||||
public checks: Checks = new Checks();
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
// See LICENSE for copying information.
|
||||
|
||||
import { GB, KB, MB, PB, TB } from '@/app/utils/converter';
|
||||
import { BandwidthUsed, Stamp } from '@/storagenode/satellite';
|
||||
import { BandwidthUsed, Stamp } from '@/storagenode/sno/sno';
|
||||
|
||||
const shortMonthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
|
||||
|
||||
|
@ -1,47 +1,39 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
import { BandwidthInfo, Dashboard, DiskSpaceInfo, SatelliteInfo } from '@/storagenode/dashboard';
|
||||
import {
|
||||
BandwidthUsed,
|
||||
Egress,
|
||||
EgressUsed,
|
||||
Ingress,
|
||||
IngressUsed,
|
||||
Dashboard,
|
||||
Metric,
|
||||
Satellite,
|
||||
SatelliteByDayInfo,
|
||||
SatelliteInfo,
|
||||
Satellites,
|
||||
SatelliteScores,
|
||||
Stamp,
|
||||
} from '@/storagenode/satellite';
|
||||
Traffic,
|
||||
} from '@/storagenode/sno/sno';
|
||||
import { HttpClient } from '@/storagenode/utils/httpClient';
|
||||
|
||||
/**
|
||||
* Implementation for HTTP GET requests
|
||||
* @param url - holds url of request target
|
||||
* @throws Error - holds error message if request wasn't successful
|
||||
* Used to get dashboard and satellite data from json.
|
||||
*/
|
||||
async function httpGet(url): Promise<Response> {
|
||||
const response = await fetch(url);
|
||||
export class StorageNodeApi {
|
||||
private readonly client: HttpClient = new HttpClient();
|
||||
private readonly ROOT_PATH: string = '/api/sno';
|
||||
|
||||
if (response.ok) {
|
||||
return response;
|
||||
}
|
||||
|
||||
throw new Error(response.statusText);
|
||||
}
|
||||
|
||||
/**
|
||||
* used to get dashboard and satellite data from json
|
||||
*/
|
||||
export class SNOApi {
|
||||
/**
|
||||
* parses dashboard data from json
|
||||
* @returns dashboard - new dashboard instance filled with data from json
|
||||
* Gets dashboard data from server.
|
||||
* @returns dashboard - new dashboard instance filled with data from json.
|
||||
*/
|
||||
public async dashboard(): Promise<Dashboard> {
|
||||
const json = await (await httpGet('/api/sno')).json();
|
||||
const response = await this.client.get(this.ROOT_PATH);
|
||||
|
||||
const satellitesJson = json.satellites || [];
|
||||
if (!response.ok) {
|
||||
throw new Error('can not get node information');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
const satellitesJson = data.satellites || [];
|
||||
|
||||
const satellites: SatelliteInfo[] = satellitesJson.map((satellite: any) => {
|
||||
const disqualified: Date | null = satellite.disqualified ? new Date(satellite.disqualified) : null;
|
||||
@ -50,72 +42,86 @@ export class SNOApi {
|
||||
return new SatelliteInfo(satellite.id, satellite.url, disqualified, suspended);
|
||||
});
|
||||
|
||||
const diskSpace: DiskSpaceInfo = new DiskSpaceInfo(json.diskSpace.used, json.diskSpace.available, json.diskSpace.trash);
|
||||
const bandwidth: BandwidthInfo = new BandwidthInfo(json.bandwidth.used);
|
||||
const diskSpace: Traffic = new Traffic(data.diskSpace.used, data.diskSpace.available, data.diskSpace.trash);
|
||||
const bandwidth: Traffic = new Traffic(data.bandwidth.used);
|
||||
|
||||
return new Dashboard(json.nodeID, json.wallet, satellites, diskSpace, bandwidth,
|
||||
new Date(json.lastPinged), new Date(json.startedAt), json.version, json.allowedVersion, json.upToDate);
|
||||
return new Dashboard(data.nodeID, data.wallet, satellites, diskSpace, bandwidth,
|
||||
new Date(data.lastPinged), new Date(data.startedAt), data.version, data.allowedVersion, data.upToDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses satellite data from json
|
||||
* @returns satellite - new satellite instance filled with data from json
|
||||
* Gets satellite data from server.
|
||||
* @returns satellite - new satellite instance filled with data from json.
|
||||
*/
|
||||
public async satellite(id: string): Promise<Satellite> {
|
||||
const url = `/api/sno/satellite/${id}`;
|
||||
const url = `${this.ROOT_PATH}/satellite/${id}`;
|
||||
|
||||
const json = await (await httpGet(url)).json();
|
||||
const response = await this.client.get(url);
|
||||
|
||||
const satelliteByDayInfo = new SatelliteByDayInfo(json);
|
||||
if (!response.ok) {
|
||||
throw new Error('can not get satellite information');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
const satelliteByDayInfo = new SatelliteByDayInfo(data);
|
||||
|
||||
const audit: Metric = new Metric(
|
||||
json.audit.totalCount,
|
||||
json.audit.successCount,
|
||||
json.audit.alpha,
|
||||
json.audit.beta,
|
||||
json.audit.unknownAlpha,
|
||||
json.audit.unknownBeta,
|
||||
json.audit.score,
|
||||
json.audit.unknownScore,
|
||||
data.audit.totalCount,
|
||||
data.audit.successCount,
|
||||
data.audit.alpha,
|
||||
data.audit.beta,
|
||||
data.audit.unknownAlpha,
|
||||
data.audit.unknownBeta,
|
||||
data.audit.score,
|
||||
data.audit.unknownScore,
|
||||
);
|
||||
|
||||
const uptime: Metric = new Metric(
|
||||
json.uptime.totalCount,
|
||||
json.uptime.successCount,
|
||||
json.uptime.alpha,
|
||||
json.uptime.beta,
|
||||
json.uptime.unknownAlpha,
|
||||
json.uptime.unknownBeta,
|
||||
json.uptime.score,
|
||||
json.uptime.unknownScore,
|
||||
data.uptime.totalCount,
|
||||
data.uptime.successCount,
|
||||
data.uptime.alpha,
|
||||
data.uptime.beta,
|
||||
data.uptime.unknownAlpha,
|
||||
data.uptime.unknownBeta,
|
||||
data.uptime.score,
|
||||
data.uptime.unknownScore,
|
||||
);
|
||||
|
||||
return new Satellite(
|
||||
json.id,
|
||||
data.id,
|
||||
satelliteByDayInfo.storageDaily,
|
||||
satelliteByDayInfo.bandwidthDaily,
|
||||
satelliteByDayInfo.egressDaily,
|
||||
satelliteByDayInfo.ingressDaily,
|
||||
json.storageSummary,
|
||||
json.bandwidthSummary,
|
||||
json.egressSummary,
|
||||
json.ingressSummary,
|
||||
data.storageSummary,
|
||||
data.bandwidthSummary,
|
||||
data.egressSummary,
|
||||
data.ingressSummary,
|
||||
audit,
|
||||
uptime,
|
||||
new Date(json.nodeJoinedAt),
|
||||
new Date(data.nodeJoinedAt),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses data for all satellites from json
|
||||
* @returns satellites - new satellites instance filled with data from json
|
||||
* Gets data for all satellites from server.
|
||||
* @returns satellites - new satellites instance filled with data from json.
|
||||
*/
|
||||
public async satellites(): Promise<Satellites> {
|
||||
const json = await (await httpGet('/api/sno/satellites')).json();
|
||||
const url = `${this.ROOT_PATH}/satellites`;
|
||||
|
||||
const satelliteByDayInfo = new SatelliteByDayInfo(json);
|
||||
const response = await this.client.get(url);
|
||||
|
||||
const satellitesScores = json.audits.map(scoreInfo => {
|
||||
if (!response.ok) {
|
||||
throw new Error('can not get all satellites information');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
const satelliteByDayInfo = new SatelliteByDayInfo(data);
|
||||
|
||||
const satellitesScores = data.audits.map(scoreInfo => {
|
||||
return new SatelliteScores(
|
||||
scoreInfo.satelliteName,
|
||||
scoreInfo.auditScore,
|
||||
@ -129,50 +135,12 @@ export class SNOApi {
|
||||
satelliteByDayInfo.bandwidthDaily,
|
||||
satelliteByDayInfo.egressDaily,
|
||||
satelliteByDayInfo.ingressDaily,
|
||||
json.storageSummary,
|
||||
json.bandwidthSummary,
|
||||
json.egressSummary,
|
||||
json.ingressSummary,
|
||||
new Date(json.earliestJoinedAt),
|
||||
data.storageSummary,
|
||||
data.bandwidthSummary,
|
||||
data.egressSummary,
|
||||
data.ingressSummary,
|
||||
new Date(data.earliestJoinedAt),
|
||||
satellitesScores,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SatelliteByDayInfo holds by day bandwidth metrics.
|
||||
*/
|
||||
class SatelliteByDayInfo {
|
||||
public storageDaily: Stamp[];
|
||||
public bandwidthDaily: BandwidthUsed[];
|
||||
public egressDaily: EgressUsed[];
|
||||
public ingressDaily: IngressUsed[];
|
||||
|
||||
public constructor(json) {
|
||||
const storageDailyJson = json.storageDaily || [];
|
||||
const bandwidthDailyJson = json.bandwidthDaily || [];
|
||||
|
||||
this.storageDaily = storageDailyJson.map((stamp: any) => {
|
||||
return new Stamp(stamp.atRestTotal, new Date(stamp.intervalStart));
|
||||
});
|
||||
|
||||
this.bandwidthDaily = bandwidthDailyJson.map((bandwidth: any) => {
|
||||
const egress = new Egress(bandwidth.egress.audit, bandwidth.egress.repair, bandwidth.egress.usage);
|
||||
const ingress = new Ingress(bandwidth.ingress.repair, bandwidth.ingress.usage);
|
||||
|
||||
return new BandwidthUsed(egress, ingress, new Date(bandwidth.intervalStart));
|
||||
});
|
||||
|
||||
this.egressDaily = bandwidthDailyJson.map((bandwidth: any) => {
|
||||
const egress = new Egress(bandwidth.egress.audit, bandwidth.egress.repair, bandwidth.egress.usage);
|
||||
|
||||
return new EgressUsed(egress, new Date(bandwidth.intervalStart));
|
||||
});
|
||||
|
||||
this.ingressDaily = bandwidthDailyJson.map((bandwidth: any) => {
|
||||
const ingress = new Ingress(bandwidth.ingress.repair, bandwidth.ingress.usage);
|
||||
|
||||
return new IngressUsed(ingress, new Date(bandwidth.intervalStart));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
/**
|
||||
* Dashboard encapsulates dashboard stale data
|
||||
*/
|
||||
export class Dashboard {
|
||||
public constructor(
|
||||
public nodeID: string,
|
||||
public wallet: string,
|
||||
public satellites: SatelliteInfo[],
|
||||
public diskSpace: DiskSpaceInfo,
|
||||
public bandwidth: BandwidthInfo,
|
||||
public lastPinged: Date,
|
||||
public startedAt: Date,
|
||||
public version: string,
|
||||
public allowedVersion: string,
|
||||
public isUpToDate: boolean,
|
||||
) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* SatelliteInfo encapsulates satellite ID, URL and disqualification
|
||||
*/
|
||||
export class SatelliteInfo {
|
||||
public constructor(
|
||||
public id: string = '',
|
||||
public url: string = '',
|
||||
public disqualified: Date | null = null,
|
||||
public suspended: Date | null = null,
|
||||
) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* DiskSpaceInfo stores all info about storage node disk space usage
|
||||
*/
|
||||
export class DiskSpaceInfo {
|
||||
public constructor(
|
||||
public used: number = 0,
|
||||
public available: number = 0,
|
||||
public trash: number = 0,
|
||||
) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* BandwidthInfo stores all info about storage node bandwidth usage
|
||||
*/
|
||||
export class BandwidthInfo {
|
||||
public constructor(
|
||||
public used: number,
|
||||
) { }
|
||||
}
|
@ -254,7 +254,6 @@ export class PreviousMonthEstimatedPayout {
|
||||
) {}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contains payout information for payout history table.
|
||||
*/
|
||||
|
39
web/storagenode/src/storagenode/sno/service.ts
Normal file
39
web/storagenode/src/storagenode/sno/service.ts
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2020 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
||||
import { Dashboard, Satellite, Satellites } from '@/storagenode/sno/sno';
|
||||
|
||||
/**
|
||||
* SNOService is used to store and handle node information.
|
||||
* SNOService exposes a business logic related to node.
|
||||
*/
|
||||
export class StorageNodeService {
|
||||
private readonly node: StorageNodeApi;
|
||||
|
||||
public constructor(api: StorageNodeApi) {
|
||||
this.node = api;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dashboard data from server.
|
||||
*/
|
||||
public async dashboard(): Promise<Dashboard> {
|
||||
return await this.node.dashboard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets satellite data from server.
|
||||
* @param id - satellite id
|
||||
*/
|
||||
public async satellite(id: string): Promise<Satellite> {
|
||||
return await this.node.satellite(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all satellites data from server.
|
||||
*/
|
||||
public async satellites(): Promise<Satellites> {
|
||||
return await this.node.satellites();
|
||||
}
|
||||
}
|
@ -1,6 +1,94 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// Copyright (C) 2020 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
import { StatusOffline } from '@/app/store/modules/node';
|
||||
|
||||
/**
|
||||
* Hold common node information.
|
||||
*/
|
||||
export class Node {
|
||||
public constructor(
|
||||
public id: string = '',
|
||||
public status: string = StatusOffline,
|
||||
public lastPinged: Date = new Date(),
|
||||
public startedAt: Date = new Date(),
|
||||
public version: string = '',
|
||||
public allowedVersion: string = '',
|
||||
public wallet: string = '',
|
||||
public isLastVersion: boolean = false,
|
||||
) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds traffic usage information by type.
|
||||
*/
|
||||
export class Utilization {
|
||||
public constructor(
|
||||
public bandwidth: Traffic = new Traffic(),
|
||||
public diskSpace: Traffic = new Traffic(),
|
||||
) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds traffic usage information.
|
||||
*/
|
||||
export class Traffic {
|
||||
public constructor(
|
||||
public used: number = 0,
|
||||
public available: number = 1,
|
||||
public trash: number = 0,
|
||||
) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds uptime, audit and suspension checks.
|
||||
*/
|
||||
export class Checks {
|
||||
public uptime: number = 0;
|
||||
public audit: number = 0;
|
||||
public suspension: number = 0;
|
||||
|
||||
public constructor(
|
||||
uptime: Metric = new Metric(),
|
||||
audit: Metric = new Metric(),
|
||||
) {
|
||||
this.audit = parseFloat(parseFloat(`${audit.score * 100}`).toFixed(1));
|
||||
this.uptime = uptime.totalCount === 0 ? 100 : uptime.successCount / uptime.totalCount * 100;
|
||||
this.suspension = audit.unknownScore * 100;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashboard encapsulates dashboard stale data.
|
||||
*/
|
||||
export class Dashboard {
|
||||
public constructor(
|
||||
public nodeID: string,
|
||||
public wallet: string,
|
||||
public satellites: SatelliteInfo[],
|
||||
public diskSpace: Traffic,
|
||||
public bandwidth: Traffic,
|
||||
public lastPinged: Date,
|
||||
public startedAt: Date,
|
||||
public version: string,
|
||||
public allowedVersion: string,
|
||||
public isUpToDate: boolean,
|
||||
) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* SatelliteInfo encapsulates satellite ID, URL, join date and disqualification.
|
||||
*/
|
||||
export class SatelliteInfo {
|
||||
public constructor(
|
||||
public id: string = '',
|
||||
public url: string = '',
|
||||
public disqualified: Date | null = null,
|
||||
public suspended: Date | null = null,
|
||||
public joinDate: Date = new Date(),
|
||||
) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Satellite encapsulates satellite related data
|
||||
*/
|
||||
@ -100,7 +188,7 @@ export class BandwidthUsed {
|
||||
*/
|
||||
public summary(): number {
|
||||
return this.egress.audit + this.egress.repair + this.egress.usage +
|
||||
this.ingress.repair + this.ingress.usage;
|
||||
this.ingress.repair + this.ingress.usage;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,7 +285,6 @@ export class Satellites {
|
||||
) {}
|
||||
}
|
||||
|
||||
// TODO: move and create domain types.
|
||||
/**
|
||||
* Holds information about audit and suspension scores by satellite.
|
||||
*/
|
||||
@ -264,3 +351,41 @@ export class Score {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SatelliteByDayInfo holds by day bandwidth metrics.
|
||||
*/
|
||||
export class SatelliteByDayInfo {
|
||||
public storageDaily: Stamp[];
|
||||
public bandwidthDaily: BandwidthUsed[];
|
||||
public egressDaily: EgressUsed[];
|
||||
public ingressDaily: IngressUsed[];
|
||||
|
||||
public constructor(json) {
|
||||
const storageDailyJson = json.storageDaily || [];
|
||||
const bandwidthDailyJson = json.bandwidthDaily || [];
|
||||
|
||||
this.storageDaily = storageDailyJson.map((stamp: any) => {
|
||||
return new Stamp(stamp.atRestTotal, new Date(stamp.intervalStart));
|
||||
});
|
||||
|
||||
this.bandwidthDaily = bandwidthDailyJson.map((bandwidth: any) => {
|
||||
const egress = new Egress(bandwidth.egress.audit, bandwidth.egress.repair, bandwidth.egress.usage);
|
||||
const ingress = new Ingress(bandwidth.ingress.repair, bandwidth.ingress.usage);
|
||||
|
||||
return new BandwidthUsed(egress, ingress, new Date(bandwidth.intervalStart));
|
||||
});
|
||||
|
||||
this.egressDaily = bandwidthDailyJson.map((bandwidth: any) => {
|
||||
const egress = new Egress(bandwidth.egress.audit, bandwidth.egress.repair, bandwidth.egress.usage);
|
||||
|
||||
return new EgressUsed(egress, new Date(bandwidth.intervalStart));
|
||||
});
|
||||
|
||||
this.ingressDaily = bandwidthDailyJson.map((bandwidth: any) => {
|
||||
const ingress = new Ingress(bandwidth.ingress.repair, bandwidth.ingress.usage);
|
||||
|
||||
return new IngressUsed(ingress, new Date(bandwidth.intervalStart));
|
||||
});
|
||||
}
|
||||
}
|
@ -5,16 +5,18 @@ import Vuex from 'vuex';
|
||||
|
||||
import AllSatellitesAuditsArea from '@/app/components/AllSatellitesAuditsArea.vue';
|
||||
|
||||
import { makeNodeModule, NODE_ACTIONS, NODE_MUTATIONS } from '@/app/store/modules/node';
|
||||
import { SNOApi } from '@/storagenode/api/storagenode';
|
||||
import { Satellites, SatelliteScores } from '@/storagenode/satellite';
|
||||
import { newNodeModule, NODE_ACTIONS } from '@/app/store/modules/node';
|
||||
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
||||
import { StorageNodeService } from '@/storagenode/sno/service';
|
||||
import { Satellites, SatelliteScores } from '@/storagenode/sno/sno';
|
||||
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Vuex);
|
||||
|
||||
const nodeApi = new SNOApi();
|
||||
const nodeModule = makeNodeModule(nodeApi);
|
||||
const nodeApi = new StorageNodeApi();
|
||||
const nodeService = new StorageNodeService(nodeApi);
|
||||
const nodeModule = newNodeModule(nodeService);
|
||||
|
||||
const store = new Vuex.Store({ modules: { node: nodeModule }});
|
||||
|
||||
|
@ -5,16 +5,18 @@ import Vuex from 'vuex';
|
||||
|
||||
import DiskStatChart from '@/app/components/DiskStatChart.vue';
|
||||
|
||||
import { makeNodeModule, NODE_ACTIONS } from '@/app/store/modules/node';
|
||||
import { SNOApi } from '@/storagenode/api/storagenode';
|
||||
import { BandwidthInfo, Dashboard, DiskSpaceInfo, SatelliteInfo } from '@/storagenode/dashboard';
|
||||
import { newNodeModule, NODE_ACTIONS } from '@/app/store/modules/node';
|
||||
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
||||
import { StorageNodeService } from '@/storagenode/sno/service';
|
||||
import { Dashboard, SatelliteInfo, Traffic } from '@/storagenode/sno/sno';
|
||||
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Vuex);
|
||||
|
||||
const nodeApi = new SNOApi();
|
||||
const nodeModule = makeNodeModule(nodeApi);
|
||||
const nodeApi = new StorageNodeApi();
|
||||
const nodeService = new StorageNodeService(nodeApi);
|
||||
const nodeModule = newNodeModule(nodeService);
|
||||
|
||||
const store = new Vuex.Store({ modules: { node: nodeModule }});
|
||||
|
||||
@ -43,8 +45,8 @@ describe('DiskStatChart', (): void => {
|
||||
new SatelliteInfo('3', 'url1', null, null),
|
||||
new SatelliteInfo('4', 'url2', new Date(2020, 1, 1), new Date(2020, 0, 1)),
|
||||
],
|
||||
new DiskSpaceInfo(550000, 1000000, 22000),
|
||||
new BandwidthInfo(50),
|
||||
new Traffic(550000, 1000000, 22000),
|
||||
new Traffic(50),
|
||||
new Date(),
|
||||
new Date(2019, 3, 1),
|
||||
'0.1.1',
|
||||
|
@ -5,7 +5,7 @@ import VueClipboard from 'vue-clipboard2';
|
||||
|
||||
import SatelliteSelectionDropdownItem from '@/app/components/SatelliteSelectionDropdownItem.vue';
|
||||
|
||||
import { SatelliteInfo } from '@/storagenode/dashboard';
|
||||
import { SatelliteInfo } from '@/storagenode/sno/sno';
|
||||
import { createLocalVue, mount, shallowMount } from '@vue/test-utils';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
|
@ -7,14 +7,22 @@ import Vuex from 'vuex';
|
||||
import EstimationPeriodDropdown from '@/app/components/payments/EstimationPeriodDropdown.vue';
|
||||
|
||||
import { appStateModule } from '@/app/store/modules/appState';
|
||||
import { makeNodeModule, NODE_MUTATIONS } from '@/app/store/modules/node';
|
||||
import { SNOApi } from '@/storagenode/api/storagenode';
|
||||
import { BandwidthInfo, Dashboard, DiskSpaceInfo, SatelliteInfo } from '@/storagenode/dashboard';
|
||||
import { Metric, Satellite, Stamp } from '@/storagenode/satellite';
|
||||
import { newNodeModule, NODE_MUTATIONS } from '@/app/store/modules/node';
|
||||
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
||||
import { StorageNodeService } from '@/storagenode/sno/service';
|
||||
import {
|
||||
Dashboard,
|
||||
Metric,
|
||||
Satellite,
|
||||
SatelliteInfo,
|
||||
Stamp,
|
||||
Traffic,
|
||||
} from '@/storagenode/sno/sno';
|
||||
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
||||
|
||||
const nodeApi = new SNOApi();
|
||||
const nodeModule = makeNodeModule(nodeApi);
|
||||
const nodeApi = new StorageNodeApi();
|
||||
const nodeService = new StorageNodeService(nodeApi);
|
||||
const nodeModule = newNodeModule(nodeService);
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Vuex);
|
||||
@ -59,8 +67,8 @@ describe('EstimationPeriodDropdown', (): void => {
|
||||
new SatelliteInfo('3', 'url1', null, null),
|
||||
new SatelliteInfo('4', 'url2', new Date(), new Date(2020, 0, 1)),
|
||||
],
|
||||
new DiskSpaceInfo(99, 100, 4),
|
||||
new BandwidthInfo(50),
|
||||
new Traffic(99, 100, 4),
|
||||
new Traffic(50),
|
||||
new Date(),
|
||||
new Date(),
|
||||
'0.1.1',
|
||||
|
@ -5,7 +5,7 @@ import Vuex from 'vuex';
|
||||
|
||||
import HeldHistoryAllStatsTable from '@/app/components/payments/HeldHistoryAllStatsTable.vue';
|
||||
|
||||
import { makePayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { newPayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
||||
import { SatelliteHeldHistory } from '@/storagenode/payouts/payouts';
|
||||
import { PayoutService } from '@/storagenode/payouts/service';
|
||||
@ -20,7 +20,7 @@ localVue.filter('centsToDollars', (cents: number): string => {
|
||||
|
||||
const payoutApi = new PayoutHttpApi();
|
||||
const payoutService = new PayoutService(payoutApi);
|
||||
const payoutModule = makePayoutModule(payoutApi, payoutService);
|
||||
const payoutModule = newPayoutModule(payoutService);
|
||||
|
||||
const store = new Vuex.Store({ modules: { payoutModule }});
|
||||
|
||||
|
@ -5,7 +5,7 @@ import Vuex from 'vuex';
|
||||
|
||||
import HeldHistoryArea from '@/app/components/payments/HeldHistoryArea.vue';
|
||||
|
||||
import { makePayoutModule } from '@/app/store/modules/payout';
|
||||
import { newPayoutModule } from '@/app/store/modules/payout';
|
||||
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
||||
import { PayoutService } from '@/storagenode/payouts/service';
|
||||
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
||||
@ -15,7 +15,7 @@ localVue.use(Vuex);
|
||||
|
||||
const payoutApi = new PayoutHttpApi();
|
||||
const payoutService = new PayoutService(payoutApi);
|
||||
const payoutModule = makePayoutModule(payoutApi, payoutService);
|
||||
const payoutModule = newPayoutModule(payoutService);
|
||||
|
||||
const store = new Vuex.Store({ modules: { payoutModule }});
|
||||
|
||||
|
@ -5,7 +5,7 @@ import Vuex from 'vuex';
|
||||
|
||||
import HeldHistoryMonthlyBreakdownTable from '@/app/components/payments/HeldHistoryMonthlyBreakdownTable.vue';
|
||||
|
||||
import { makePayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { newPayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
||||
import { SatelliteHeldHistory } from '@/storagenode/payouts/payouts';
|
||||
import { PayoutService } from '@/storagenode/payouts/service';
|
||||
@ -20,7 +20,7 @@ localVue.filter('centsToDollars', (cents: number): string => {
|
||||
|
||||
const payoutApi = new PayoutHttpApi();
|
||||
const payoutService = new PayoutService(payoutApi);
|
||||
const payoutModule = makePayoutModule(payoutApi, payoutService);
|
||||
const payoutModule = newPayoutModule(payoutService);
|
||||
|
||||
const store = new Vuex.Store({ modules: { payoutModule }});
|
||||
|
||||
@ -36,8 +36,6 @@ describe('HeldHistoryMonthlyBreakdownTable', (): void => {
|
||||
localVue,
|
||||
});
|
||||
|
||||
|
||||
|
||||
await store.commit(PAYOUT_MUTATIONS.SET_HELD_HISTORY, [
|
||||
new SatelliteHeldHistory('1', 'name1', 1, 50000, 0, 0, 0, testJoinAt),
|
||||
new SatelliteHeldHistory('2', 'name2', 5, 50000, 422280, 0, 0 , testJoinAt),
|
||||
|
@ -8,12 +8,13 @@ import Vuex from 'vuex';
|
||||
import PayoutHistoryPeriodDropdown from '@/app/components/payments/PayoutHistoryPeriodDropdown.vue';
|
||||
|
||||
import { appStateModule } from '@/app/store/modules/appState';
|
||||
import { makeNodeModule, NODE_MUTATIONS } from '@/app/store/modules/node';
|
||||
import { makePayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { newNodeModule, NODE_MUTATIONS } from '@/app/store/modules/node';
|
||||
import { newPayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
||||
import { SNOApi } from '@/storagenode/api/storagenode';
|
||||
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
||||
import { PayoutService } from '@/storagenode/payouts/service';
|
||||
import { Satellites } from '@/storagenode/satellite';
|
||||
import { StorageNodeService } from '@/storagenode/sno/service';
|
||||
import { Satellites } from '@/storagenode/sno/sno';
|
||||
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
||||
|
||||
let clickOutsideEvent: EventListener;
|
||||
@ -42,9 +43,10 @@ localVue.directive('click-outside', {
|
||||
|
||||
const payoutApi = new PayoutHttpApi();
|
||||
const payoutService = new PayoutService(payoutApi);
|
||||
const payoutModule = makePayoutModule(payoutApi, payoutService);
|
||||
const nodeApi = new SNOApi();
|
||||
const nodeModule = makeNodeModule(nodeApi);
|
||||
const payoutModule = newPayoutModule(payoutService);
|
||||
const nodeApi = new StorageNodeApi();
|
||||
const nodeService = new StorageNodeService(nodeApi);
|
||||
const nodeModule = newNodeModule(nodeService);
|
||||
|
||||
const store = new Vuex.Store({ modules: { payoutModule, node: nodeModule, appStateModule }});
|
||||
|
||||
|
@ -5,7 +5,7 @@ import Vuex from 'vuex';
|
||||
|
||||
import PayoutHistoryTable from '@/app/components/payments/PayoutHistoryTable.vue';
|
||||
|
||||
import { makePayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { newPayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
||||
import { SatellitePayoutForPeriod } from '@/storagenode/payouts/payouts';
|
||||
import { PayoutService } from '@/storagenode/payouts/service';
|
||||
@ -20,7 +20,7 @@ localVue.filter('centsToDollars', (cents: number): string => {
|
||||
|
||||
const payoutApi = new PayoutHttpApi();
|
||||
const payoutService = new PayoutService(payoutApi);
|
||||
const payoutModule = makePayoutModule(payoutApi, payoutService);
|
||||
const payoutModule = newPayoutModule(payoutService);
|
||||
|
||||
const store = new Vuex.Store({ modules: { payoutModule }});
|
||||
|
||||
|
@ -5,7 +5,7 @@ import Vuex from 'vuex';
|
||||
|
||||
import PayoutHistoryTableItem from '@/app/components/payments/PayoutHistoryTableItem.vue';
|
||||
|
||||
import { makePayoutModule } from '@/app/store/modules/payout';
|
||||
import { newPayoutModule } from '@/app/store/modules/payout';
|
||||
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
||||
import { SatellitePayoutForPeriod } from '@/storagenode/payouts/payouts';
|
||||
import { PayoutService } from '@/storagenode/payouts/service';
|
||||
@ -20,7 +20,7 @@ localVue.filter('centsToDollars', (cents: number): string => {
|
||||
|
||||
const payoutApi = new PayoutHttpApi();
|
||||
const payoutService = new PayoutService(payoutApi);
|
||||
const payoutModule = makePayoutModule(payoutApi, payoutService);
|
||||
const payoutModule = newPayoutModule(payoutService);
|
||||
|
||||
const store = new Vuex.Store({ modules: { payoutModule }});
|
||||
|
||||
|
@ -5,13 +5,14 @@ import Vuex from 'vuex';
|
||||
|
||||
import TotalHeldArea from '@/app/components/payments/TotalHeldArea.vue';
|
||||
|
||||
import { makeNodeModule, NODE_MUTATIONS } from '@/app/store/modules/node';
|
||||
import { makePayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { newNodeModule, NODE_MUTATIONS } from '@/app/store/modules/node';
|
||||
import { newPayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
||||
import { SNOApi } from '@/storagenode/api/storagenode';
|
||||
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
||||
import { Paystub, TotalHeldAndPaid } from '@/storagenode/payouts/payouts';
|
||||
import { PayoutService } from '@/storagenode/payouts/service';
|
||||
import { Metric, Satellite, Stamp } from '@/storagenode/satellite';
|
||||
import { StorageNodeService } from '@/storagenode/sno/service';
|
||||
import { Metric, Satellite, Stamp } from '@/storagenode/sno/sno';
|
||||
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
@ -23,9 +24,10 @@ localVue.filter('centsToDollars', (cents: number): string => {
|
||||
|
||||
const payoutApi = new PayoutHttpApi();
|
||||
const payoutService = new PayoutService(payoutApi);
|
||||
const payoutModule = makePayoutModule(payoutApi, payoutService);
|
||||
const nodeApi = new SNOApi();
|
||||
const nodeModule = makeNodeModule(nodeApi);
|
||||
const payoutModule = newPayoutModule(payoutService);
|
||||
const nodeApi = new StorageNodeApi();
|
||||
const nodeService = new StorageNodeService(nodeApi);
|
||||
const nodeModule = newNodeModule(nodeService);
|
||||
|
||||
const store = new Vuex.Store({ modules: { payoutModule, node: nodeModule }});
|
||||
|
||||
|
@ -5,7 +5,7 @@ import Vuex from 'vuex';
|
||||
|
||||
import TotalPayoutArea from '@/app/components/TotalPayoutArea.vue';
|
||||
|
||||
import { makePayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { newPayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
||||
import { Paystub, TotalHeldAndPaid } from '@/storagenode/payouts/payouts';
|
||||
import { PayoutService } from '@/storagenode/payouts/service';
|
||||
@ -20,7 +20,7 @@ localVue.filter('centsToDollars', (cents: number): string => {
|
||||
|
||||
const payoutApi = new PayoutHttpApi();
|
||||
const payoutService = new PayoutService(payoutApi);
|
||||
const payoutModule = makePayoutModule(payoutApi, payoutService);
|
||||
const payoutModule = newPayoutModule(payoutService);
|
||||
|
||||
const store = new Vuex.Store({ modules: { payoutModule }});
|
||||
|
||||
|
@ -3,31 +3,30 @@
|
||||
|
||||
import Vuex from 'vuex';
|
||||
|
||||
import { makeNodeModule, NODE_ACTIONS, NODE_MUTATIONS, StatusOnline } from '@/app/store/modules/node';
|
||||
import { SNOApi } from '@/storagenode/api/storagenode';
|
||||
import {
|
||||
BandwidthInfo,
|
||||
Dashboard,
|
||||
DiskSpaceInfo,
|
||||
SatelliteInfo,
|
||||
} from '@/storagenode/dashboard';
|
||||
import { newNodeModule, NODE_ACTIONS, NODE_MUTATIONS, StatusOnline } from '@/app/store/modules/node';
|
||||
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
||||
import { StorageNodeService } from '@/storagenode/sno/service';
|
||||
import {
|
||||
BandwidthUsed,
|
||||
Dashboard,
|
||||
Egress,
|
||||
EgressUsed,
|
||||
Ingress,
|
||||
IngressUsed,
|
||||
Metric,
|
||||
Satellite,
|
||||
Satellites, SatelliteScores,
|
||||
Stamp,
|
||||
} from '@/storagenode/satellite';
|
||||
SatelliteInfo,
|
||||
Satellites,
|
||||
SatelliteScores,
|
||||
Stamp, Traffic,
|
||||
} from '@/storagenode/sno/sno';
|
||||
import { createLocalVue } from '@vue/test-utils';
|
||||
|
||||
const Vue = createLocalVue();
|
||||
|
||||
const nodeApi = new SNOApi();
|
||||
const nodeModule = makeNodeModule(nodeApi);
|
||||
const nodeApi = new StorageNodeApi();
|
||||
const nodeService = new StorageNodeService(nodeApi);
|
||||
const nodeModule = newNodeModule(nodeService);
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
@ -48,8 +47,8 @@ describe('mutations', () => {
|
||||
new SatelliteInfo('3', 'url1', null, null),
|
||||
new SatelliteInfo('4', 'url2', new Date(2020, 1, 1), new Date(2020, 0, 1)),
|
||||
],
|
||||
new DiskSpaceInfo(99, 100, 5),
|
||||
new BandwidthInfo(50),
|
||||
new Traffic(99, 100, 5),
|
||||
new Traffic(50),
|
||||
new Date(),
|
||||
new Date(2019, 3, 1),
|
||||
'0.1.1',
|
||||
@ -188,8 +187,8 @@ describe('actions', () => {
|
||||
new SatelliteInfo('3', 'url1', null, null),
|
||||
new SatelliteInfo('4', 'url2', new Date(2020, 1, 1), new Date(2020, 0, 1)),
|
||||
],
|
||||
new DiskSpaceInfo(99, 100, 1),
|
||||
new BandwidthInfo(50),
|
||||
new Traffic(99, 100, 1),
|
||||
new Traffic(50),
|
||||
new Date(),
|
||||
new Date(2019, 3, 1),
|
||||
'0.1.1',
|
||||
@ -332,8 +331,8 @@ describe('getters', () => {
|
||||
new SatelliteInfo('3', 'url1', null, null),
|
||||
new SatelliteInfo('4', 'url2', firstTestDate, new Date(2020, 0, 1)),
|
||||
],
|
||||
new DiskSpaceInfo(99, 100, 4),
|
||||
new BandwidthInfo(50),
|
||||
new Traffic(99, 100, 4),
|
||||
new Traffic(50),
|
||||
new Date(),
|
||||
firstTestDate,
|
||||
'0.1.1',
|
||||
|
@ -3,12 +3,12 @@
|
||||
|
||||
import Vuex from 'vuex';
|
||||
|
||||
import { makeNodeModule } from '@/app/store/modules/node';
|
||||
import { makePayoutModule, PAYOUT_ACTIONS, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { newNodeModule } from '@/app/store/modules/node';
|
||||
import { newPayoutModule, PAYOUT_ACTIONS, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
||||
import { PayoutInfoRange } from '@/app/types/payout';
|
||||
import { getHeldPercentage, getMonthsBeforeNow } from '@/app/utils/payout';
|
||||
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
||||
import { SNOApi } from '@/storagenode/api/storagenode';
|
||||
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
||||
import {
|
||||
EstimatedPayout,
|
||||
PayoutPeriod,
|
||||
@ -20,15 +20,17 @@ import {
|
||||
TotalPaystubForPeriod,
|
||||
} from '@/storagenode/payouts/payouts';
|
||||
import { PayoutService } from '@/storagenode/payouts/service';
|
||||
import { StorageNodeService } from '@/storagenode/sno/service';
|
||||
import { createLocalVue } from '@vue/test-utils';
|
||||
|
||||
const Vue = createLocalVue();
|
||||
const payoutApi = new PayoutHttpApi();
|
||||
const payoutService = new PayoutService(payoutApi);
|
||||
const payoutModule = makePayoutModule(payoutApi, payoutService);
|
||||
const payoutModule = newPayoutModule(payoutService);
|
||||
|
||||
const nodeApi = new SNOApi();
|
||||
const nodeModule = makeNodeModule(nodeApi);
|
||||
const nodeApi = new StorageNodeApi();
|
||||
const nodeService = new StorageNodeService(nodeApi);
|
||||
const nodeModule = newNodeModule(nodeService);
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user