2
2
<div >
3
3
<h1 >GitHub Copilot Business Metrics Viewer</h1 >
4
4
5
- <h2 >Acceptance rate (%)</h2 >
6
- <Bar :data =" acceptanceRateChartData" :options =" chartOptions" />
5
+ <!-- API Error Message -->
6
+ <div v-if =" apiError" class =" error-message" v-html =" apiError" ></div >
7
+ <div v-if =" !apiError" >
8
+ <h2 >Acceptance rate (%)</h2 >
9
+ <Bar :data =" acceptanceRateChartData" :options =" chartOptions" />
7
10
8
- <h2 >Total Suggestions Count | Total Acceptances Count</h2 >
9
- <Line :data =" totalSuggestionsAndAcceptanceChartData" :options =" chartOptions" />
11
+ <h2 >Total Suggestions Count | Total Acceptances Count</h2 >
12
+ <Line :data =" totalSuggestionsAndAcceptanceChartData" :options =" chartOptions" />
10
13
11
- <h2 >Total Lines Suggested | Total Lines Accepted</h2 >
12
- <Line :data =" chartData" :options =" chartOptions" />
13
-
14
- <h2 >Total Active Users</h2 >
15
- <Bar :data =" totalActiveUsersChartData" :options =" totalActiveUsersChartOptions" />
14
+ <h2 >Total Lines Suggested | Total Lines Accepted</h2 >
15
+ <Line :data =" chartData" :options =" chartOptions" />
16
16
17
+ <h2 >Total Active Users</h2 >
18
+ <Bar :data =" totalActiveUsersChartData" :options =" totalActiveUsersChartOptions" />
19
+ </div >
17
20
</div >
18
21
</template >
19
22
@@ -68,13 +71,17 @@ export default defineComponent({
68
71
// Total Active Users
69
72
const totalActiveUsersChartData = ref <{ labels: string []; datasets: any [] }>({ labels: [], datasets: [] });
70
73
74
+ // API Error Message
75
+ const apiError = ref <string | null >(null );
76
+
77
+
71
78
const chartOptions = {
72
79
responsive: true ,
73
80
maintainAspectRatio: true ,
74
81
layout: {
75
82
padding: {
76
- left: 40 ,
77
- right: 40 ,
83
+ left: 150 ,
84
+ right: 150 ,
78
85
top: 20 ,
79
86
bottom: 40
80
87
}
@@ -173,9 +180,37 @@ export default defineComponent({
173
180
}
174
181
]
175
182
};
183
+ }).catch (error => {
184
+ console .log (error );
185
+ // Check the status code of the error response
186
+ if (error .response && error .response .status ) {
187
+ switch (error .response .status ) {
188
+ case 401 :
189
+ apiError .value = ' 401 Unauthorized access - check if your token in the .env file is correct.' ;
190
+ break ;
191
+ case 404 :
192
+ apiError .value = ` 404 Not Found - is the organization '${process .env .VUE_APP_GITHUB_ORG }' correct? ` ;
193
+ break ;
194
+ default :
195
+ apiError .value = error .message ;
196
+ break ;
197
+ }
198
+ } else {
199
+ // Update apiError with the error message
200
+ apiError .value = error .message ;
201
+ }
202
+ // Add a new line to the apiError message
203
+ apiError .value += ' <br> If .env file is modified, restart the changes to take effect.' ;
204
+
176
205
});
177
206
178
- return { totalSuggestionsAndAcceptanceChartData , chartData , chartOptions , totalActiveUsersChartData , totalActiveUsersChartOptions , acceptanceRateChartData };
207
+ return { totalSuggestionsAndAcceptanceChartData , chartData , chartOptions , totalActiveUsersChartData , totalActiveUsersChartOptions , acceptanceRateChartData , apiError };
179
208
}
180
209
});
181
- </script >
210
+ </script >
211
+
212
+ <style scoped>
213
+ .error-message {
214
+ color : red ;
215
+ }
216
+ </style >
0 commit comments