Skip to content
Snippets Groups Projects
Commit 4eaaf895 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] overview now displays UID

parent fc89dadc
Branches
No related tags found
No related merge requests found
......@@ -244,5 +244,6 @@ type Query {
stopAndResetData: Boolean!
startNode: Boolean!
synchronize(url: String!): Boolean
uid(pub: String!): String
}
import {Server} from 'duniter/server'
export function gqlUid(server: Server) {
return async (_: any, params: { pub: string }) => {
const idty = await server.dal.getWrittenIdtyByPubkey(params.pub)
if (idty) {
return idty.uid
}
return null
}
}
......@@ -10,6 +10,7 @@ import {Querable, querablep} from 'duniter/app/lib/common-libs/querable'
import {NodeState, SoftVersions} from '../../common/types'
import {SyncProgress, SyncEnding} from '../../common/dto'
import {WS2PConnection} from 'duniter/app/modules/ws2p/lib/WS2PConnection'
import {gqlUid} from './queries/gql-uid'
export const pubsub = new PubSub();
......@@ -232,7 +233,9 @@ export function plugModule(server: Server, startServices: () => Promise<void>, s
})
syncPromise = querablep(sync.syncPromise)
}
},
uid: gqlUid(server)
},
Subscription: {
......
......@@ -35,16 +35,35 @@
import Vue from 'vue';
import {Prop} from 'vue-property-decorator';
const LABEL_LENGTH = 8
@Component({})
export default class extends Vue {
@Prop(String) label
@Prop(String) pubkey
@Prop(Number) type
@Prop(Number) number
@Prop(Number) forkLevel
uid = ''
get bgColor() {
const rgb = Math.min(240, 120 + this.forkLevel * 1)
const rgb = Math.min(240, 90 + this.forkLevel * 10)
return 'rgb(' + rgb + ',' + rgb + ',' + rgb + ')'
}
async mounted() {
this.uid = await this.$webmin.uid(this.pubkey)
}
get label() {
if (this.uid) {
const overflow = this.uid.length - LABEL_LENGTH
return overflow >= 0
? this.uid.substr(0, LABEL_LENGTH - 2) + '..'
: this.uid.padEnd(LABEL_LENGTH, ' ')
}
return '*' + this.pubkey.substr(0, LABEL_LENGTH - 1)
}
}
</script>
......@@ -276,4 +276,20 @@ export class WebminService {
})
.result()
}
async uid(pub: string) {
const res = await this.getApollo()
.watchQuery({
query: gql`
query ($pub: String!){
uid(pub: $pub)
}
`,
variables: {
pub
},
})
.result()
return res.data.uid
}
}
......@@ -38,8 +38,8 @@
</div>
<div class="col">
<ForkNode
v-for="node in networkForkView" v-bind:key="node.pubkey"
:label="node.label"
v-for="node in networkForkView" v-bind:key="node.pub"
:pubkey="node.pub"
:type="node.fork"
:number="node.forkNumber"
:forkLevel="node.forkLevel"
......@@ -144,7 +144,7 @@
currentSecond: { bs: string, count: number }
netViewKeys: string[] = []
netPubkeys: string[] = []
networkForkView: { label: string, fork: number }[] = []
networkForkView: { pub: string, fork: number }[] = []
theNetView: { [bs: string]: number } = {}
nodes: { name: string }[] = Array.from({ length: 30 }).map((v, i) => ({ name: `Node#${i}` }))
......@@ -236,7 +236,7 @@
this.networkForkView = this.netPubkeys.map(pub => {
return {
label: pub.substr(0, 8),
pub,
fork: this.headsByNode[pub] === this.currentBest.bs ? 0 : (this.headsByNode[pub] === this.currentSecond.bs ? 1 : 2),
forkLevel: parseInt(String(this.currentBest.bs)) - parseInt(String(this.headsByNode[pub])),
forkNumber: parseInt(String(this.headsByNode[pub]))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment