Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jameswain committed Mar 14, 2023
1 parent 9076192 commit 26ebb97
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# Development Environment - 开发环境

- node: v16.13.1
- npm: v8.1.2
- Operating System - 系统: MacOS

# GitLab Pipelines

:us: This extension can monitor 20 GitLab Pipelines in Realtime
Expand Down Expand Up @@ -40,3 +34,10 @@
创建 [Gitlab Personal Access Token](https://docs.gitlab.com/ce/user/profile/personal_access_tokens.html) 如下图所示:

![](https://img.ikstatic.cn/MTYzMzg3NDU5MzA1NSM2ODQjanBn.jpg)


# Development Environment - 开发环境

- node: v16.13.1
- npm: v8.1.2
- Operating System - 系统: MacOS
22 changes: 13 additions & 9 deletions src/pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,20 @@ export const getExtensionSettings = async (domain: string) => {

const createGitLabClient = (apiUrl: string, project: string, token: string): any => {
const url = (_: any) => `${apiUrl}/projects/${encodeURIComponent(project)}${_}`;
return (endpoint: string) => {
return async (endpoint: string) => {
const uri = url(endpoint);
return axios({
url: uri,
headers: {
'PRIVATE-TOKEN': token
}
}).then(res => {
return (res.data || []);
})
try {
const { data } = await axios({
url: uri,
headers: {
'PRIVATE-TOKEN': token
}
});
return data || [];
} catch (e) {{
console.error(e);
return [];
}}
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/tree-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,29 @@ export class TreeViewProvider implements TreeDataProvider<TreeItem> {
}
}

let index = 0;
export async function updatePipelinesStatus(tvp: TreeViewProvider, config: any) {
index = (index + 1) % 100;
const arrLastPipelines = await getRunningPipelines(config);
const icon = config.icon || {};
const MAP_CION = {
'success': icon.success || ['✅'],
'manual': icon.manual || ['🚥'],
'skipped': icon.skipped || ['🚆'],
'running': icon.running || ['🕘'],
'running': icon.running || ['🏃🏼', '🏃🏼‍♂️', '🏃🏼'],
'failed': icon.failed || ['❌'],
'canceled': icon.canceled || ['⛔️']
'canceled': icon.canceled || ['⛔️'],
'pending': icon.pending || ['⌛️']
};
pipelines = arrLastPipelines.map(async (pipeline: any) => {
const job = await getCurrentRunningJob({ ...config, pipeline });
const status = job.name ? `[${job.name}]` : pipeline.status;
// @ts-ignore
const arrIcon = MAP_CION[pipeline.status] || [];
return createMenu({
label: `${arrIcon[0] || ''} ${pipeline.id} - ${status} - ${pipeline.ref}`,
label: `${arrIcon[index % arrIcon.length] || ''} ${pipeline.id} - ${status} - ${pipeline.ref}`,
arguments: [pipeline.web_url]
})
});
});
tvp.refresh();
}

0 comments on commit 26ebb97

Please sign in to comment.