diff --git a/packages/ui/certd-client/src/api/service.ts b/packages/ui/certd-client/src/api/service.ts
index 6a27fb9f3..02b4a99df 100644
--- a/packages/ui/certd-client/src/api/service.ts
+++ b/packages/ui/certd-client/src/api/service.ts
@@ -136,27 +136,29 @@ function createService() {
*/
function createRequestFunction(service: any) {
return function (config: any) {
- const configDefault = {
+ const configDefault: any = {
headers: {
"Content-Type": get(config, "headers.Content-Type", "application/json"),
} as any,
timeout: 30000,
baseURL: env.API,
data: {},
+ params: {},
};
const projectStore = useProjectStore();
- if (projectStore.isEnterprise && !config.url.startsWith("/sys") && !config.url.startsWith("http")) {
- configDefault.headers["project-id"] = projectStore.currentProjectId;
- }
-
const userStore = useUserStore();
const token = userStore.getToken;
if (token != null) {
// @ts-ignore
configDefault.headers.Authorization = token;
}
- return service(Object.assign(configDefault, config));
+ Object.assign(configDefault, config);
+
+ if (projectStore.isEnterprise && !config.url.startsWith("/sys") && !config.url.startsWith("http")) {
+ configDefault.params.projectId = projectStore.currentProjectId;
+ }
+ return service(configDefault);
};
}
diff --git a/packages/ui/certd-client/src/components/index.ts b/packages/ui/certd-client/src/components/index.ts
index fdb3d94a5..418472789 100644
--- a/packages/ui/certd-client/src/components/index.ts
+++ b/packages/ui/certd-client/src/components/index.ts
@@ -17,6 +17,8 @@ import NotificationSelector from "../views/certd/notification/notification-selec
import EmailSelector from "./email-selector/index.vue";
import ValidTimeFormat from "./valid-time-format.vue";
import ProjectSelector from "./project-selector/index.vue";
+import ProjectCurrent from "./project-selector/project-current.vue";
+
export default {
install(app: any) {
app.component(
@@ -47,5 +49,6 @@ export default {
app.use(vip);
app.use(Plugins);
app.component("ProjectSelector", ProjectSelector);
+ app.component("ProjectCurrent", ProjectCurrent);
},
};
diff --git a/packages/ui/certd-client/src/components/project-selector/project-current.vue b/packages/ui/certd-client/src/components/project-selector/project-current.vue
new file mode 100644
index 000000000..5ca94cf6b
--- /dev/null
+++ b/packages/ui/certd-client/src/components/project-selector/project-current.vue
@@ -0,0 +1,28 @@
+
+
+
+
+ 当前项目:{{ projectStore.currentProject?.name || "..." }}
+
+
+
+
+
diff --git a/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue b/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue
index abd8eecc1..8455eb7db 100644
--- a/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue
+++ b/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue
@@ -35,6 +35,11 @@
+
+
+
+
+
diff --git a/packages/ui/certd-server/src/controller/user/dashboard/statistic-controller.ts b/packages/ui/certd-server/src/controller/user/dashboard/statistic-controller.ts
index f41bf0778..970ffb035 100644
--- a/packages/ui/certd-server/src/controller/user/dashboard/statistic-controller.ts
+++ b/packages/ui/certd-server/src/controller/user/dashboard/statistic-controller.ts
@@ -46,14 +46,15 @@ export class StatisticController extends BaseController {
@Post('/count', { summary: Constants.per.authOnly })
public async count() {
- const pipelineCount = await this.pipelineService.count({ userId: this.getUserId() });
- const pipelineStatusCount = await this.pipelineService.statusCount({ userId: this.getUserId() });
- const pipelineEnableCount = await this.pipelineService.enableCount({ userId: this.getUserId() });
+ const {userId,projectId} = await this.getProjectUserIdRead();
+ const pipelineCount = await this.pipelineService.count({ userId,projectId });
+ const pipelineStatusCount = await this.pipelineService.statusCount({ userId,projectId });
+ const pipelineEnableCount = await this.pipelineService.enableCount({ userId,projectId });
- const historyCount = await this.historyService.countPerDay({ userId: this.getUserId(), days: 7 });
- const expiringList = await this.pipelineService.latestExpiringList({ userId: this.getUserId(), count: 5 });
+ const historyCount = await this.historyService.countPerDay({ userId,projectId, days: 7 });
+ const expiringList = await this.pipelineService.latestExpiringList({ userId,projectId, count: 5 });
- const certCount = await this.certInfoService.count({ userId: this.getUserId() });
+ const certCount = await this.certInfoService.count({ userId,projectId });
const count: UserStatisticCount = {
pipelineCount,
diff --git a/packages/ui/certd-server/src/modules/monitor/service/cert-info-service.ts b/packages/ui/certd-server/src/modules/monitor/service/cert-info-service.ts
index 32f8b31b4..190840966 100644
--- a/packages/ui/certd-server/src/modules/monitor/service/cert-info-service.ts
+++ b/packages/ui/certd-server/src/modules/monitor/service/cert-info-service.ts
@@ -191,11 +191,12 @@ export class CertInfoService extends BaseService {
});
}
- async count({ userId }: { userId: number }) {
+ async count({ userId,projectId }: { userId: number,projectId?:number }) {
const total = await this.repository.count({
where: {
userId,
expiresTime: Not(IsNull()),
+ projectId,
},
});
@@ -203,6 +204,7 @@ export class CertInfoService extends BaseService {
where: {
userId,
expiresTime: LessThan(new Date().getTime()),
+ projectId,
},
});
@@ -210,6 +212,7 @@ export class CertInfoService extends BaseService {
where: {
userId,
expiresTime: Between(new Date().getTime(), new Date().getTime() + 15 * 24 * 60 * 60 * 1000),
+ projectId,
},
});
diff --git a/packages/ui/certd-server/src/modules/pipeline/service/history-service.ts b/packages/ui/certd-server/src/modules/pipeline/service/history-service.ts
index 296569c07..4cc1a1b2d 100644
--- a/packages/ui/certd-server/src/modules/pipeline/service/history-service.ts
+++ b/packages/ui/certd-server/src/modules/pipeline/service/history-service.ts
@@ -183,7 +183,7 @@ export class HistoryService extends BaseService {
}
}
- async countPerDay(param: { days: number; userId?: any }) {
+ async countPerDay(param: { days: number; userId?: any,projectId?:number }) {
const todayEnd = dayjs().endOf('day');
const where: any = {
createTime: MoreThan(todayEnd.add(-param.days, 'day').toDate()),
@@ -191,6 +191,9 @@ export class HistoryService extends BaseService {
if (param.userId > 0) {
where.userId = param.userId;
}
+ if (param.projectId > 0) {
+ where.projectId = param.projectId;
+ }
const result = await this.getRepository()
.createQueryBuilder('main')
.select(`${this.dbAdapter.date('main.createTime')} AS date`) // 将UNIX时间戳转换为日期
diff --git a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts
index aee1395c4..a7a939f48 100644
--- a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts
+++ b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts
@@ -824,35 +824,39 @@ export class PipelineService extends BaseService {
await this.historyLogService.addOrUpdate(logEntity);
}
- async count(param: { userId?: any }) {
+ async count(param: { userId?: any,projectId?:number }) {
const count = await this.repository.count({
where: {
- userId: param.userId
+ userId: param.userId,
+ projectId: param.projectId,
+ isTemplate: false
}
});
return count;
}
- async statusCount(param: { userId?: any } = {}) {
+ async statusCount(param: { userId?: any,projectId?:number } = {}) {
const statusCount = await this.repository
.createQueryBuilder()
.select("status")
.addSelect("count(1)", "count")
.where({
- userId: param.userId
+ userId: param.userId,
+ projectId: param.projectId
})
.groupBy("status")
.getRawMany();
return statusCount;
}
- async enableCount(param: { userId?: any } = {}) {
+ async enableCount(param: { userId?: any,projectId?:number } = {}) {
const statusCount = await this.repository
.createQueryBuilder()
.select("disabled")
.addSelect("count(1)", "count")
.where({
- userId: param.userId
+ userId: param.userId,
+ projectId: param.projectId
})
.groupBy("disabled")
.getRawMany();
@@ -866,7 +870,7 @@ export class PipelineService extends BaseService {
return result;
}
- async latestExpiringList({ userId }: any) {
+ async latestExpiringList({ userId,projectId }: any) {
let list = await this.repository.find({
select: {
id: true,
@@ -875,7 +879,8 @@ export class PipelineService extends BaseService {
},
where: {
userId,
- disabled: false
+ disabled: false,
+ projectId
}
});
await this.fillLastVars(list);