Skip to content

Commit

Permalink
Merge pull request #160 from abes-esr/ITEM-325-Mettre-en-place-les-in…
Browse files Browse the repository at this point in the history
…dicateurs-de-dispo-des-applications

Item 325 mettre en place les indicateurs de dispo des applications
  • Loading branch information
pierre-maraval authored Oct 31, 2024
2 parents c5defa1 + a7ae3dc commit d44e92f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 24 deletions.
43 changes: 21 additions & 22 deletions src/components/Structure/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<a class="ma-2 text-white" v-bind="props" @mouseenter="getHealthOfServices" style="cursor: pointer;">Etat des serveurs</a>
</template>
<div style="display: flex; flex-direction: column;">
<v-chip class="ma-1" :color="healthServices['STATUT CBS'] ? 'green' : 'red'" variant="text"><v-icon icon="mdi-server" start></v-icon>CBS</v-chip>
<v-chip class="ma-1" :color="healthServices['STATUT BASE_XML'] ? 'green' : 'red'" variant="text"><v-icon icon="mdi-server" start></v-icon>XML</v-chip>
<v-chip class="ma-1" :color="healthServices['STATUT BASE_ITEM'] ? 'green' : 'red'" variant="text"><v-icon icon="mdi-server" start></v-icon>ITEM</v-chip>
<v-chip class="ma-1" :color="healthServices.STATUT_CBS ? 'green' : 'red'" variant="text"><v-icon icon="mdi-server" start></v-icon>CBS</v-chip>
<v-chip class="ma-1" :color="healthServices.STATUT_BASE_XML ? 'green' : 'red'" variant="text"><v-icon icon="mdi-server" start></v-icon>XML</v-chip>
<v-chip class="ma-1" :color="healthServices.STATUT_BASE_ITEM ? 'green' : 'red'" variant="text"><v-icon icon="mdi-server" start></v-icon>ITEM</v-chip>
</div>
</v-tooltip>
<v-tooltip location="top">
Expand All @@ -36,39 +36,38 @@
<script setup>
import {ref, computed, onMounted} from 'vue'
import itemService from '@/service/ItemService'
import statusService from "@/service/StatusService";
const currentYear = computed(() => new Date().getFullYear())
const test = ref(false)
const packageVersion = process.env.PACKAGE_VERSION.replaceAll('\"', '');
const backVersion = ref()
const healthServices = ref([{
'STATUT CBS':false,
'STATUT BASE_XML':false,
'STATUT BASE_ITEM':false
}])
const healthServices = ref({
STATUT_CBS:false,
STATUT_BASE_XML:false,
STATUT_BASE_ITEM:false
})
onMounted(async () => {
try {
const version = await itemService.getApplicationVersion()
let version = await itemService.getApplicationVersion()
backVersion.value = version.data
} catch (error) {
console.error('Erreur lors de la récupération de la version de l\'application :', error)
}
})
const getHealthOfServices = async () => {
try {
const response = await itemService.getHealthOfServices()
if (response.data) {
healthServices.value = response.data
}
} catch (error) {
healthServices.value = [{
'STATUT CBS':false,
'STATUT BASE_XML':false,
'STATUT BASE_ITEM':false
}]
console.error('Erreur lors de la récupération des statuts des services :', error)
}
statusService.getStatusBaseXML().then(isOk => {
healthServices.value.STATUT_BASE_XML = isOk;
})
statusService.getStatusCBS().then(isOk => {
healthServices.value.STATUT_CBS = isOk;
})
itemService.getHealthOfServices().then(isOk => {
healthServices.value.STATUT_BASE_ITEM = isOk;
})
}
</script>
7 changes: 5 additions & 2 deletions src/service/ItemService.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,11 @@ export class ItemService {
return this.client.get('applicationDetails');
}

getHealthOfServices(){
return this.client.get('applicationStatutServices')
async getHealthOfServices(){
return this.client.get('applicationStatutServices').then(response => {
console.log(response.data)
return response.data
})
}
}

Expand Down
27 changes: 27 additions & 0 deletions src/service/StatusService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import axios from 'axios';

export class StatusService {
constructor() {
this.client = axios.create({
baseURL: "https://api.uptimerobot.com/"
});
}

async getStatusBaseXML(){
let data = {"api_key":"ur707639-b082a50474d1cfbe940438bc", "monitors":"782344734"}
return this.client.post(`v2/getMonitors`,data).then(
response => {
return response.data.monitors[0].status === 2;
})
}

async getStatusCBS(){
let data = {"api_key":"ur707639-b082a50474d1cfbe940438bc", "monitors":"782344748"}
return this.client.post(`v2/getMonitors`,data).then(
response => {
return response.data.monitors[0].status === 2;
})
}
}

export default new StatusService()

0 comments on commit d44e92f

Please sign in to comment.