Browse Source

Update peer repo with latest API changes

pull/14938/head
Michael Klein 2 years ago committed by Michael Klein
parent
commit
454424145a
  1. 14
      ui/packages/consul-ui/app/models/peer.js
  2. 28
      ui/packages/consul-ui/app/services/repository/peer.js
  3. 9
      ui/packages/consul-ui/mock-api/v1/peerings

14
ui/packages/consul-ui/app/models/peer.js

@ -16,7 +16,17 @@ export default class Peer extends Model {
@attr('string') Name;
@attr('string') State;
@attr('string') ID;
@attr('number') ImportedServiceCount;
@attr('number') ExportedServiceCount;
@attr() ImportedServices;
@attr() ExportedServices;
@attr('date') LastHeartbeat;
@attr('date') LastReceive;
@attr('date') LastSend;
@attr() PeerServerAddresses;
get ImportedServiceCount() {
return this.ImportedServices.length;
}
get ExportedServiceCount() {
return this.ExportedServices.length;
}
}

28
ui/packages/consul-ui/app/services/repository/peer.js

@ -1,6 +1,22 @@
import RepositoryService from 'consul-ui/services/repository';
import dataSource from 'consul-ui/decorators/data-source';
function normalizePeerPayload(peerPayload, dc, partition) {
const {
StreamStatus: { LastHeartbeat, LastReceive, LastSend, ImportedServices, ExportedServices },
} = peerPayload;
return {
...peerPayload,
LastHeartbeat,
LastReceive,
LastSend,
ImportedServices,
ExportedServices,
Datacenter: dc,
Partition: partition,
};
}
export default class PeerService extends RepositoryService {
getModelName() {
return 'peer';
@ -39,11 +55,7 @@ export default class PeerService extends RepositoryService {
},
body: body.map((item) => {
return cache(
{
...item,
Datacenter: dc,
Partition: partition,
},
normalizePeerPayload(item),
(uri) => uri`peer:///${partition}/${ns}/${dc}/peer/${item.Name}`
);
}),
@ -80,11 +92,7 @@ export default class PeerService extends RepositoryService {
uri: uri,
},
body: cache(
{
...body,
Datacenter: dc,
Partition: partition,
},
normalizePeerPayload(body),
(uri) => uri`peer:///${partition}/${ns}/${dc}/peer/${body.Name}`
),
};

9
ui/packages/consul-ui/mock-api/v1/peerings

@ -18,8 +18,13 @@
'TERMINATED',
'UNDEFINED'
])}",
"ImportedServiceCount": ${fake.random.number({min: 0, max: 4000})},
"ExportedServiceCount": ${fake.random.number({min: 0, max: 4000})},
"StreamStatus": {
"LastHeartbeat": "${fake.date.past(10).toISOString()}",
"LastReceive": "${fake.date.past(10).toISOString()}",
"LastSend": "${fake.date.past(10).toISOString()}",
"ExportedServices": ["${`export-service-${i}`}"],
"ImportedServices": ["${`import-service-${i}`}"]
},
"PeerID": "${id}",
"PeerServerName": "${fake.internet.domainName()}",
"PeerServerAddresses": [

Loading…
Cancel
Save