Skip to content

Commit b6ff6bd

Browse files
authored
Merge branch 'main' into feature/configuration
2 parents d805928 + 151f7ba commit b6ff6bd

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

.dockerignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
**/.env.local
33
.env*
44
.dockerignore
5-
.git
6-
.gitignore
75
**/node_modules/
86
api/public
7+
.dockerignore
8+
.git
9+
.gitignore
10+
node_modules/
911
dist/
1012
.history/
1113
.github/

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ RUN npm run build
88

99
# Stage 2: Serve the application with Nginx
1010
FROM nginx:1.27 as production-stage
11+
1112
COPY --from=build-stage /app/dist /usr/share/nginx/html
1213
COPY --from=build-stage /app/dist/assets/app-config.js /usr/share/nginx/html-template/app-config.template.js
1314
COPY ./docker-entrypoint.d/*.sh /docker-entrypoint.d/

public/assets/app-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ window._ENV_ = {
1010

1111
if(window._ENV_.VUE_APP_GITHUB_TOKEN) {
1212
console.warn('Using hardcoded token. This is not recommended for production.');
13-
}
13+
}

src/api/ExtractSeats.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,29 @@ export const getSeatsApi = async (): Promise<Seat[]> => {
5252
page: page
5353
}
5454
});
55+
5556
seatsData = seatsData.concat(response.data.seats.map((item: any) => new Seat(item)));
57+
58+
// Calculate the total pages
59+
const totalSeats = response.data.total_seats;
60+
const totalPages = Math.ceil(totalSeats / perPage);
61+
62+
// Fetch the remaining pages
63+
for (page = 2; page <= totalPages; page++) {
64+
response = await axios.get(`${config.github.apiUrl}/copilot/billing/seats`, {
65+
headers: {
66+
Accept: "application/vnd.github+json",
67+
Authorization: `Bearer ${config.github.token}`,
68+
"X-GitHub-Api-Version": "2022-11-28",
69+
},
70+
params: {
71+
per_page: perPage,
72+
page: page
73+
}
74+
});
75+
76+
seatsData = seatsData.concat(response.data.seats.map((item: any) => new Seat(item)));
77+
}
5678
}
5779
return seatsData;
5880
}

src/components/MainComponent.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,21 @@ export default defineComponent({
8888
},
8989
data () {
9090
return {
91-
tabItems: ['languages', 'editors', 'copilot chat','seat analysis' , 'api response'],
91+
tabItems: ['languages', 'editors', 'copilot chat', 'api response'],
9292
tab: null
9393
}
9494
},
9595
created() {
9696
this.tabItems.unshift(this.itemName);
97+
if (config.scope.type === 'organization') {
98+
// get the last item in the array,which is 'api response'
99+
//and add 'seat analysis' before it
100+
let lastItem = this.tabItems.pop();
101+
this.tabItems.push('seat analysis');
102+
if (lastItem) {
103+
this.tabItems.push(lastItem);
104+
}
105+
}
97106
},
98107
setup() {
99108
const metricsReady = ref(false);

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const githubOrgName = env.VUE_APP_GITHUB_ORG;
2323
const githubEntName = env.VUE_APP_GITHUB_ENT;
2424
const baseApi = env.VUE_APP_GITHUB_API;
2525

26+
2627
let scopeName: string;
2728
if (scopeType === 'organization') {
2829
scopeName = githubOrgName;
@@ -58,7 +59,6 @@ if (!config.mockedData && !config.github.token && !config.github.baseApi) {
5859
export default config;
5960

6061
interface Config {
61-
/** Flag to use mocked data only */
6262
mockedData: boolean;
6363
scope: {
6464
type: 'organization' | 'enterprise';

0 commit comments

Comments
 (0)