From 97f480df6c5c042d5e0f6176377ecd1a6eba5a1f Mon Sep 17 00:00:00 2001 From: Marcio Tedesco Date: Mon, 25 Dec 2023 10:54:55 -0500 Subject: [PATCH] Delete HelloWorld.vue and add error handling to MetricsViewer.vue --- src/components/HelloWorld.vue | 61 -------------------------------- src/components/MetricsViewer.vue | 61 +++++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 74 deletions(-) delete mode 100644 src/components/HelloWorld.vue diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue deleted file mode 100644 index 5b06cac2..00000000 --- a/src/components/HelloWorld.vue +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - diff --git a/src/components/MetricsViewer.vue b/src/components/MetricsViewer.vue index 248dcb72..02c8ee34 100644 --- a/src/components/MetricsViewer.vue +++ b/src/components/MetricsViewer.vue @@ -2,18 +2,21 @@

GitHub Copilot Business Metrics Viewer

-

Acceptance rate (%)

- + +
+
+

Acceptance rate (%)

+ -

Total Suggestions Count | Total Acceptances Count

- +

Total Suggestions Count | Total Acceptances Count

+ -

Total Lines Suggested | Total Lines Accepted

- - -

Total Active Users

- +

Total Lines Suggested | Total Lines Accepted

+ +

Total Active Users

+ +
@@ -68,13 +71,17 @@ export default defineComponent({ //Total Active Users const totalActiveUsersChartData = ref<{ labels: string[]; datasets: any[] }>({ labels: [], datasets: [] }); + // API Error Message + const apiError = ref(null); + + const chartOptions = { responsive: true, maintainAspectRatio: true, layout: { padding: { - left: 40, - right: 40, + left: 150, + right: 150, top: 20, bottom: 40 } @@ -173,9 +180,37 @@ export default defineComponent({ } ] }; + }).catch(error => { + console.log(error); + // Check the status code of the error response + if (error.response && error.response.status) { + switch (error.response.status) { + case 401: + apiError.value = '401 Unauthorized access - check if your token in the .env file is correct.'; + break; + case 404: + apiError.value = `404 Not Found - is the organization '${process.env.VUE_APP_GITHUB_ORG}' correct?`; + break; + default: + apiError.value = error.message; + break; + } + } else { + // Update apiError with the error message + apiError.value = error.message; + } + // Add a new line to the apiError message + apiError.value += '
If .env file is modified, restart the changes to take effect.'; + }); - return { totalSuggestionsAndAcceptanceChartData, chartData, chartOptions, totalActiveUsersChartData, totalActiveUsersChartOptions, acceptanceRateChartData }; + return { totalSuggestionsAndAcceptanceChartData, chartData, chartOptions, totalActiveUsersChartData, totalActiveUsersChartOptions, acceptanceRateChartData, apiError }; } }); - \ No newline at end of file + + + \ No newline at end of file