Skip to content

Commit 3130cb7

Browse files
authored
Merge pull request #661 from Adamant-im/fix/service-nodes-tab
Fix: service nodes tab
2 parents 43dd79f + 48d9f57 commit 3130cb7

File tree

9 files changed

+49
-10
lines changed

9 files changed

+49
-10
lines changed

src/components/SendFundsForm.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
<script>
190190
import { adm } from '@/lib/nodes'
191191
import klyIndexer from '@/lib/nodes/kly-indexer'
192-
import { AllNodesOfflineError } from '@/lib/nodes/utils/errors'
192+
import { AllNodesDisabledError, AllNodesOfflineError } from '@/lib/nodes/utils/errors'
193193
import { PendingTransactionError } from '@/lib/pending-transactions'
194194
import axios from 'axios'
195195
import { nextTick } from 'vue'
@@ -755,6 +755,10 @@ export default {
755755
message = this.$t('errors.all_nodes_offline', {
756756
crypto: error.nodeLabel.toUpperCase()
757757
})
758+
} else if (error instanceof AllNodesDisabledError) {
759+
message = this.$t('errors.all_nodes_disabled', {
760+
crypto: error.nodeLabel.toUpperCase()
761+
})
758762
} else if (error instanceof PendingTransactionError) {
759763
message = this.$t('transfer.error_pending_transaction', {
760764
crypto: error.crypto

src/components/nodes/hooks/useNodeStatus.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ function getNodeStatusTitle(node: NodeStatusResult, t: VueI18nTranslation) {
2222
sync: 'nodes.sync',
2323
unsupported_version: 'nodes.unsupported'
2424
}
25-
const i18nKey = i18n[node.status]
26-
27-
return t(i18nKey)
25+
if (node.status === 'online') {
26+
return i18n[node.status]
27+
} else {
28+
const i18nKey = i18n[node.status]
29+
return t(i18nKey)
30+
}
2831
}
2932

3033
function getNodeStatusDetail(

src/components/nodes/services/ServiceNodesTableItem.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<NodeColumn>
1212
<NodeUrl :node="node" />
13+
<NodeVersion v-if="node.version && active" :node="node" />
1314
</NodeColumn>
1415

1516
<NodeColumn ping :colspan="isUnsupported ? 2 : 1">
@@ -28,6 +29,7 @@ import NodeColumn from '@/components/nodes/components/NodeColumn.vue'
2829
import NodeLabel from '@/components/nodes/components/NodeLabel.vue'
2930
import NodeStatus from '@/components/nodes/components/NodeStatus.vue'
3031
import NodeStatusCheckbox from '@/components/nodes/components/NodeStatusCheckbox.vue'
32+
import NodeVersion from '@/components/nodes/components/NodeVersion.vue'
3133
3234
const className = 'nodes-table-item'
3335
const classes = {
@@ -39,6 +41,7 @@ const classes = {
3941
4042
export default {
4143
components: {
44+
NodeVersion,
4245
NodeColumn,
4346
NodeStatus,
4447
NodeLabel,

src/lib/nodes/eth-indexer/EthIndexer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ export class EthIndexer extends Node<AxiosInstance> {
3939
}
4040

4141
private async fetchServiceInfo(): Promise<{ height: number }> {
42-
const [{ max }] = await this.request('GET /max_block')
42+
const [{ max, version }] = await this.request('GET /max_block')
4343
this.height = max
44+
this.version = version
4445

4546
return {
4647
height: this.height

src/lib/nodes/eth-indexer/types/api/endpoints.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type Endpoints = {
1717
result: [
1818
{
1919
max: number
20+
version: string
2021
}
2122
]
2223
}

src/lib/nodes/rate-info-service/RateInfoService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { NODE_LABELS } from '@/lib/nodes/constants'
55
import { RateInfoResponse } from '@/lib/nodes/rate-info-service/types/RateInfoResponse'
66
import { RateHistoryInfoResponse } from '@/lib/nodes/rate-info-service/types/RateHistoryInfoResponse'
77
import { GetHistoryParams } from '@/lib/nodes/rate-info-service/types/GetHistoryParams'
8+
import { normalizeHeight } from './utils'
89

910
export class RateInfoService extends Node<AxiosInstance> {
1011
constructor(url: string) {
@@ -31,9 +32,10 @@ export class RateInfoService extends Node<AxiosInstance> {
3132
protected async checkHealth(): Promise<HealthcheckResult> {
3233
const start = Date.now()
3334
const response = await this.getAllRates()
35+
this.height = normalizeHeight(response.date)
3436
return {
3537
ping: Date.now() - start,
36-
height: response.date
38+
height: this.height
3739
}
3840
}
3941
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Normalize the height to 8 digits.
3+
* Rounds the timestamp to seconds and removes the first two digits.
4+
* @param timestamp Timestamp in milliseconds
5+
*/
6+
export const normalizeHeight = (timestamp: number) => {
7+
if (!timestamp) return 0
8+
9+
return Number(
10+
Math.ceil(timestamp / 1000)
11+
.toString()
12+
.substring(2)
13+
)
14+
}

src/locales/ru.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@
190190
"service": "Сервис",
191191
"socket": "Сокеты",
192192
"tabs": {
193-
"adm_nodes": "ADM ноды",
194-
"coin_nodes": "Coin ноды",
195-
"service_nodes": "Сервис ноды"
193+
"adm_nodes": "Узлы ADM",
194+
"coin_nodes": "Крипто-ноды",
195+
"service_nodes": "Крипто-сервисы"
196196
},
197197
"unsupported": "Не поддерживается",
198198
"unsupported_reason_protocol": "HTTP не поддерживается",

src/views/Transactions.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import AppToolbarCentered from '@/components/AppToolbarCentered.vue'
4343
import InlineSpinner from '@/components/InlineSpinner.vue'
4444
import TransactionListItem from '@/components/TransactionListItem.vue'
4545
import { isStringEqualCI } from '@/lib/textHelpers'
46+
import { AllNodesDisabledError, AllNodesOfflineError } from '@/lib/nodes/utils/errors'
4647
4748
export default {
4849
components: {
@@ -183,8 +184,18 @@ export default {
183184
})
184185
.catch((err) => {
185186
this.isRejected = true
187+
let message = err.message
188+
if (err instanceof AllNodesOfflineError) {
189+
message = this.$t('errors.all_nodes_offline', {
190+
crypto: err.nodeLabel.toUpperCase()
191+
})
192+
} else if (err instanceof AllNodesDisabledError) {
193+
message = this.$t('errors.all_nodes_disabled', {
194+
crypto: err.nodeLabel.toUpperCase()
195+
})
196+
}
186197
this.$store.dispatch('snackbar/show', {
187-
message: err.message
198+
message: message
188199
})
189200
})
190201
}

0 commit comments

Comments
 (0)