Skip to content

Commit

Permalink
Merge pull request #177 from inab/login_branch
Browse files Browse the repository at this point in the history
ADD status to test
  • Loading branch information
JessicaFM authored Feb 26, 2025
2 parents ea44bf0 + 34d8ec3 commit a709d7c
Show file tree
Hide file tree
Showing 9 changed files with 790 additions and 2 deletions.
Binary file added assets/images/status/status_error.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/status/status_error_png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/status/status_ok.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/status/status_ok_png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,11 @@ async function search() {
searchList.value = [];
const searchFilter = metricDataList.value.filter((metric) => {
return metric.title
if(metric.title) {
return metric.title
.toLowerCase()
.includes(searchMetric.value.toLowerCase());
}
});
loadingInput.value = false;
isShowSearchTable.value = true;
Expand Down
5 changes: 4 additions & 1 deletion components/Header/HeaderMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
</li>
</ul>
</li>
<li>
<NavbarStatus />
</li>
</ul>
</div>
<div class="nav-list-items-direct top-full hidden sm:flex">
Expand Down Expand Up @@ -168,6 +171,7 @@ import { useRouter } from "vue-router";
import subMenuEntriesObservatory from "./HeaderMenu/subMenuEntriesObservatory";
import subMenuEntriesAbout from "./HeaderMenu/subMenuEntriesAbout";
import { activeTabIndex } from '@/components/Common/state.js';
import NavbarStatus from "@/components/status/NavbarStatus";
const router = useRouter();
Expand Down Expand Up @@ -281,7 +285,6 @@ function handleLogout() {
}
function getUserNameIcon() {
console.log(data.value)
if (data?.value?.user?.name) {
return data.value.user.name;
}
Expand Down
137 changes: 137 additions & 0 deletions components/status/NavbarStatus.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<template>
<div
class="nav-link flex md:inline-flex items-center hover:bg-gray-50 space-x-2"
>
<div class="">
<NuxtLink v-if="globalStatus" to="/status/" title="Server status is OK">
<span class="status-ok" alt="Server status is OK"
><font-awesome-icon :icon="['fas', 'signal']"
/></span>
</NuxtLink>
<NuxtLink v-else to="/status/" title="There is an error in some service">
<span class="status-error" alt="Server status error"
><font-awesome-icon :icon="['fas', 'signal']"
/></span>
</NuxtLink>
</div>
</div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from "vue";
const runtimeConfig = useRuntimeConfig();
const vreServicesUrl = `${runtimeConfig.public.VRE_URI}`;
const scientificUrl = `${runtimeConfig.public.SCIENTIFIC_SERVICE_URL}`;
const keycloakUrl = `${runtimeConfig.public.KEYCLOAK_HOST}`;
const observatoryUrl = `${runtimeConfig.public.OBSERVATORY_API_URL}`;
const isVreServicesUp = ref(null);
const isScientificServicesUp = ref(null);
const isKeycloakServiceUp = ref(null);
const isObservatoryServiceUp = ref(null);
const globalStatus = computed(() => {
if (
isVreServicesUp.value &&
isScientificServicesUp.value &&
isKeycloakServiceUp.value &&
isObservatoryServiceUp.value
) {
return true;
}
return false;
});
const checkVreServices = async () => {
return fetch(`https://api.allorigins.win/raw?url=${vreServicesUrl}`, {
method: "GET",
headers: {
"Content-Type": "text/html",
},
})
.then(async (response) => {
const text = await response.text();
isVreServicesUp.value = response.ok && text.trim().length > 0;
})
.catch((error) => {
return false;
});
};
const checkScientificServices = async () => {
return fetch(`https://api.allorigins.win/raw?url=${scientificUrl}`, {
method: "GET",
headers: {
"Content-Type": "text/html",
},
})
.then(async (response) => {
const text = await response.text();
isScientificServicesUp.value = response.ok && text.trim().length > 0;
})
.catch((error) => {
console.log("Error on fetch");
return false;
});
};
const checkKeycloakServices = async () => {
return fetch(`https://thingproxy.freeboard.io/fetch/${keycloakUrl}`, {
method: "GET",
headers: {
"Content-Type": "text/html",
},
})
.then(async (response) => {
const text = await response.text();
isKeycloakServiceUp.value = response.ok && text.trim().length > 0;
})
.catch((error) => {
return false;
});
};
const checkObservatoryServices = async () => {
return fetch(`${observatoryUrl}/stats/tools/count_total`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
})
.then(async (response) => {
const text = await response.json();
isObservatoryServiceUp.value = response.ok && text.length > 0;
})
.catch((error) => {
console.log("Observatory error: ", error);
return false;
});
};
onMounted(() => {
checkVreServices();
checkScientificServices();
checkObservatoryServices();
checkKeycloakServices();
});
</script>

<style scoped lang="scss">
.status-ok {
color: #a0c878;
}
.status-error {
color: #e52020;
animation: pulseanim 1.7s 3 ease-in-out;
}
@keyframes pulseanim {
0% {
transform: scale(0);
opacity: 0.8;
}
100% {
transform: scale(1);
opacity: 0;
}
}
</style>
70 changes: 70 additions & 0 deletions components/status/StatusTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<template>
<div class="status-table">
<UTable
:columns="columns"
:rows="services"
:loading="isTableLoading"
:loading-state="{
icon: 'i-heroicons-arrow-path-20-solid',
label: 'Loading...',
}"
:progress="{ color: 'primary', animation: 'carousel' }"
>
<template #service-data="{ row }">
<span v-if="row.status" class="status-ok">
<font-awesome-icon :icon="['fas', 'circle-check']" />
</span>
<span v-else class="status-error">
<font-awesome-icon :icon="['fas', 'triangle-exclamation']" />
</span>
{{ row.service }}
</template>
<template #status-data="{ row }">
{{ row.status ? "Operational" : "Down" }}
</template>
<template #response-data="{ row }">
{{ row.response }}
</template>
<template #page-data="{ row }">
<a target="_blank" :href="row.page">{{ row.page }}</a>
</template>
</UTable>
</div>
</template>

<script setup lang="ts">
defineProps<{
services: any,
isTableLoading: boolean
}>();
const columns = [
{
key: "service",
label: "Service",
},
{
key: "status",
label: "Status",
},
{
key: "response",
label: "Response time (ms)",
},
{
key: "page",
label: "Go to page",
},
];
</script>
<style scoped lang="scss">
.status-ok {
color: #a0c878;
}
.status-error {
color: #e52020;
}
.status-table {
padding: 30px 0 50px;
}
</style>
Loading

0 comments on commit a709d7c

Please sign in to comment.