5
5
<v-icon >mdi-github</v-icon >
6
6
</v-btn >
7
7
8
- <v-toolbar-title class =" toolbar-title" >Copilot Metrics Viewer | {{ capitalizedItemName }} : {{ displayedViewName }}</v-toolbar-title >
8
+ <v-toolbar-title class =" toolbar-title" >Copilot Metrics Viewer | {{ capitalizedItemName }} : {{ displayedViewName }} {{ teamName }}
9
+
10
+ </v-toolbar-title >
9
11
<h2 class =" error-message" > {{ mockedDataMessage }} </h2 >
10
12
<v-spacer ></v-spacer >
11
13
12
14
<template v-slot :extension >
15
+
13
16
<v-tabs v-model =" tab" align-tabs =" title" >
14
17
<v-tab v-for =" item in tabItems" :key =" item" :value =" item" >
15
18
{{ item }}
16
19
</v-tab >
17
20
</v-tabs >
21
+
18
22
</template >
23
+
19
24
</v-toolbar >
20
25
21
26
<!-- API Error Message -->
45
50
<script lang='ts'>
46
51
import { defineComponent , ref } from ' vue'
47
52
import { getMetricsApi } from ' ../api/GitHubApi' ;
53
+ import { getTeamMetricsApi } from ' ../api/GitHubApi' ;
48
54
import { getSeatsApi } from ' ../api/ExtractSeats' ;
49
55
import { Metrics } from ' ../model/Metrics' ;
50
56
import { Seat } from " ../model/Seat" ;
@@ -82,6 +88,15 @@ export default defineComponent({
82
88
isScopeOrganization() {
83
89
return config .scope .type === ' organization' ;
84
90
},
91
+ teamName(){
92
+ var teamName;
93
+ if (config .github .team && config .github .team .trim () !== ' ' ) {
94
+ teamName = " | Team : " + config .github .team ;
95
+ } else {
96
+ teamName = ' ' ;
97
+ }
98
+ return teamName ;
99
+ },
85
100
mockedDataMessage() {
86
101
return config .mockedData ? ' Using mock data - see README if unintended' : ' ' ;
87
102
}
@@ -112,35 +127,70 @@ export default defineComponent({
112
127
// API Error Message
113
128
const apiError = ref <string | undefined >(undefined );
114
129
115
- getMetricsApi ().then (data => {
130
+
131
+ if (config .github .team && config .github .team .trim () !== ' ' ) {
132
+ getTeamMetricsApi ().then (data => {
116
133
metrics .value = data ;
117
134
118
135
// Set metricsReady to true after the call completes.
119
136
metricsReady .value = true ;
120
-
137
+
121
138
}).catch (error => {
122
- console .log (error );
123
- // Check the status code of the error response
124
- if (error .response && error .response .status ) {
125
- switch (error .response .status ) {
126
- case 401 :
127
- apiError .value = ' 401 Unauthorized access - check if your token in the .env file is correct.' ;
128
- break ;
129
- case 404 :
130
- apiError .value = ` 404 Not Found - is the ${config .scope .type } '${config .scope .name }' correct? ` ;
131
- break ;
132
- default :
133
- apiError .value = error .message ;
134
- break ;
139
+ console .log (error );
140
+ // Check the status code of the error response
141
+ if (error .response && error .response .status ) {
142
+ switch (error .response .status ) {
143
+ case 401 :
144
+ apiError .value = ' 401 Unauthorized access - check if your token in the .env file is correct.' ;
145
+ break ;
146
+ case 404 :
147
+ apiError .value = ` 404 Not Found - is the ${config .scope .type } '${config .scope .name }' correct? ` ;
148
+ break ;
149
+ default :
150
+ apiError .value = error .message ;
151
+ break ;
152
+ }
153
+ } else {
154
+ // Update apiError with the error message
155
+ apiError .value = error .message ;
135
156
}
136
- } else {
137
- // Update apiError with the error message
138
- apiError .value = error .message ;
157
+ // Add a new line to the apiError message
158
+ apiError .value += ' <br> If .env file is modified, restart the app for the changes to take effect.' ;
159
+
160
+ });
139
161
}
140
- // Add a new line to the apiError message
141
- apiError .value += ' <br> If .env file is modified, restart the app for the changes to take effect.' ;
142
-
143
- });
162
+
163
+ if (metricsReady .value === false ) {
164
+ getMetricsApi ().then (data => {
165
+ metrics .value = data ;
166
+
167
+ // Set metricsReady to true after the call completes.
168
+ metricsReady .value = true ;
169
+
170
+ }).catch (error => {
171
+ console .log (error );
172
+ // Check the status code of the error response
173
+ if (error .response && error .response .status ) {
174
+ switch (error .response .status ) {
175
+ case 401 :
176
+ apiError .value = ' 401 Unauthorized access - check if your token in the .env file is correct.' ;
177
+ break ;
178
+ case 404 :
179
+ apiError .value = ` 404 Not Found - is the ${config .scope .type } '${config .scope .name }' correct? ` ;
180
+ break ;
181
+ default :
182
+ apiError .value = error .message ;
183
+ break ;
184
+ }
185
+ } else {
186
+ // Update apiError with the error message
187
+ apiError .value = error .message ;
188
+ }
189
+ // Add a new line to the apiError message
190
+ apiError .value += ' <br> If .env file is modified, restart the app for the changes to take effect.' ;
191
+
192
+ });
193
+ }
144
194
145
195
getSeatsApi ().then (data => {
146
196
seats .value = data ;
@@ -187,4 +237,5 @@ export default defineComponent({
187
237
.error-message {
188
238
color : red ;
189
239
}
240
+
190
241
</style >
0 commit comments