Skip to content

Commit

Permalink
Merge branch 'deployment-status-dashboard' into qos-dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenttaglia committed Oct 27, 2024
2 parents fc6fdd2 + 97e5b8e commit 61c15f8
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/layouts/default/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
QoS Dashboard
</v-list-item-title>
</v-list-item>
<v-list-item to="/status-dashboard">
<v-list-item-title>
Deployment Status Dashboard
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<v-btn
Expand All @@ -124,6 +129,7 @@
<v-list-item title="Offchain Sync Manager" to="/offchain-manager"></v-list-item>
<v-list-item title="Query Fee Dashboard" to="/query-dashboard"></v-list-item>
<v-list-item title="QoS Dashboard" to="/qos-dashboard"></v-list-item>
<v-list-item title="Deployment Status Dashboard" to="/status-dashboard"></v-list-item>
<v-list-item title="Settings" to="/settings"></v-list-item>
</v-list>
</v-navigation-drawer>
Expand Down
5 changes: 5 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ const routes = [
name: 'QoS Dashboard',
component: () => import('@/views/QosDashboard.vue'),
},
{
path: 'status-dashboard',
name: 'Status Dashboard',
component: () => import('@/views/DeploymentStatusDashboard.vue'),
}
],
},
]
Expand Down
7 changes: 7 additions & 0 deletions src/store/subgraphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ export const useSubgraphsStore = defineStore({
}
return selectedSubgraphs;
},
getDataDict: (state) => {
let dict = {};
state.subgraphs.forEach(
(el) => (dict[el.deployment.ipfsHash] = el)
);
return dict;
},
getSubgraphsDict: (state) => {
let dict = {};
state.getSubgraphs.forEach(
Expand Down
137 changes: 137 additions & 0 deletions src/views/DeploymentStatusDashboard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<template>
<v-confirm-edit v-model="statusUrl" @change="getStatus">
<template v-slot:default="{ model: proxyModel, save, cancel, isPristine, actions}">
<v-text-field
v-model="proxyModel.value"
label="Status Endpoint"
class="d-inline-block mx-4 mt-4"
style="width:50rem"
:append-inner-icon="isPristine ? '' : 'mdi-check'"
:clear-icon="isPristine ? '' : 'mdi-undo-variant'"
@click:append-inner="save"
@click:clear="cancel"
@keydown.enter="save"
clearable
hide-spin-buttons
></v-text-field>
<component :is="actions" v-if="false"></component>
</template>
</v-confirm-edit>
<v-data-table
:headers="headers"
:items="deploymentStatuses"
class="elevation-1"
mobile-breakpoint="0"
:loading="loading"
>
<template v-slot:item.deploymentStatus.blocksBehindChainhead="{ item }">
<StatusDropdown :item='item' />
</template>
</v-data-table>
</template>

<script setup>
import { ref, watch } from 'vue';
import { useSubgraphsStore } from '@/store/subgraphs';
import StatusDropdown from '@/components/StatusDropdown.vue';
import numeral from 'numeral';
const statusUrl = ref();
const deploymentStatuses = ref([]);
const subgraphStore = useSubgraphsStore();
const loading = ref(false);
watch(statusUrl, () => {
getStatus();
});
const headers = [
{
title: 'Status',
align: 'start',
key: 'deploymentStatus.blocksBehindChainhead',
},
{
title: 'Name',
key: 'deployment.versions[0].metadata.subgraphVersion.subgraph.metadata.displayName',
},
{
title: 'First Block',
key: 'deploymentStatus.chains[0].earliestBlock.number'
},
{
title: 'Last Block',
key: 'deploymentStatus.chains[0].latestBlock.number'
},
{
title: 'Chainhead Block',
key: 'deploymentStatus.chains[0].chainHeadBlock.number'
},
{
title: 'Health',
key: 'deploymentStatus.health'
},
{
title: 'Synced',
key: 'deploymentStatus.synced'
},
{
title: 'Completion',
key: 'deploymentStatus.completion'
},
{
title: 'Node',
key: 'deploymentStatus.node',
},
{
title: 'Deployment ID',
key: 'deploymentStatus.subgraph',
},
]
async function getStatus(){
loading.value = true;
const url = new URL('/status', statusUrl.value);
console.log(url.href);
await subgraphStore.fetchData();
fetch(url.href, {
method: "POST",
headers: {"Content-type": "application/json"},
body: JSON.stringify({query: "{ indexingStatuses { subgraph synced health fatalError{ message deterministic block{ hash number } } node chains{ latestBlock{number} chainHeadBlock{number} earliestBlock{number} } } }"}),
})
.then((res) => res.json())
.then((json) => {
console.log("SAVING STATUS")
console.log(json);
deploymentStatuses.value = [];
for(let i = 0; i < json.data.indexingStatuses.length; i++){
deploymentStatuses.value[i] = { deploymentStatus: json.data.indexingStatuses[i]};
if(deploymentStatuses.value[i].deploymentStatus.health == 'failed' && deploymentStatuses.value[i].deploymentStatus.fatalError && deploymentStatuses.value[i].deploymentStatus.fatalError.deterministic == false){
deploymentStatuses.value[i].deploymentStatus.icon = 'mdi-refresh';
deploymentStatuses.value[i].deploymentStatus.color = 'yellow';
}else if(deploymentStatuses.value[i].deploymentStatus.health == 'failed' && deploymentStatuses.value[i].deploymentStatus.fatalError && deploymentStatuses.value[i].deploymentStatus.fatalError.deterministic == true){
deploymentStatuses.value[i].deploymentStatus.icon = 'mdi-close';
deploymentStatuses.value[i].deploymentStatus.color = 'red';
}else if(deploymentStatuses.value[i].deploymentStatus.health == 'healthy' && deploymentStatuses.value[i].deploymentStatus.synced == true){
deploymentStatuses.value[i].deploymentStatus.icon = 'mdi-check';
deploymentStatuses.value[i].deploymentStatus.color = 'green';
}else if(deploymentStatuses.value[i].deploymentStatus.health == 'healthy' && deploymentStatuses.value[i].deploymentStatus.synced == false){
deploymentStatuses.value[i].deploymentStatus.icon = 'mdi-minus';
deploymentStatuses.value[i].deploymentStatus.color = 'blue'
}else{
deploymentStatuses.value[i].deploymentStatus.icon = 'mdi-help';
deploymentStatuses.value[i].deploymentStatus.color = 'default';
}
deploymentStatuses.value[i].deploymentStatus.blocksBehindChainhead = deploymentStatuses.value[i]?.deploymentStatus?.chains?.[0]?.chainHeadBlock?.number && deploymentStatuses.value[i].deploymentStatus?.chains?.[0]?.latestBlock?.number ? parseInt(deploymentStatuses.value[i].deploymentStatus?.chains[0].chainHeadBlock.number) - parseInt(deploymentStatuses.value[i].deploymentStatus.chains[0].latestBlock.number) : Number.MAX_SAFE_INTEGER;
deploymentStatuses.value[i].deployment = subgraphStore.getDataDict[deploymentStatuses.value[i].deploymentStatus.subgraph]?.deployment;
deploymentStatuses.value[i].deploymentStatus.completion = numeral((deploymentStatuses.value[i].deploymentStatus.chains?.[0]?.latestBlock?.number - deploymentStatuses.value[i].deploymentStatus.chains?.[0]?.earliestBlock?.number) / (deploymentStatuses.value[i].deploymentStatus.chains?.[0]?.chainHeadBlock?.number - deploymentStatuses.value[i].deploymentStatus.chains?.[0]?.earliestBlock?.number)).format('0.00%') || '-%';
}
console.log(deploymentStatuses);
loading.value = false;
}).catch((error) => {
console.error(error);
loading.value = false;
});
}
</script>

0 comments on commit 61c15f8

Please sign in to comment.