Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
delOperate(user: User) {
// init operation info
let operMessage = new OperateInfo();
operMessage.name = 'OPERATION.DELETE_USER';
operMessage.data.id = user.user_id;
operMessage.state = OperationState.progressing;
operMessage.data.name = user.username;
this.operationService.publishInfo(operMessage);
if (this.isMySelf(user.user_id)) {
this.translate.get('BATCH.DELETED_FAILURE').subscribe(res => {
operateChanges(operMessage, OperationState.failure, res);
});
return null;
}
return this.userService.deleteUser(user.user_id).then(() => {
this.translate.get('BATCH.DELETED_SUCCESS').subscribe(res => {
operateChanges(operMessage, OperationState.success);
});
}).catch(error => {
deleteVersion(version: HelmChartVersion): Observable {
// init operation info
let operateMsg = new OperateInfo();
operateMsg.name = "OPERATION.DELETE_CHART_VERSION";
operateMsg.data.id = version.digest;
operateMsg.state = OperationState.progressing;
operateMsg.data.name = `${version.name}:${version.version}`;
this.operationService.publishInfo(operateMsg);
return this.helmChartService
.deleteChartVersion(this.projectName, this.chartName, version.version)
.pipe(map(
() => operateChanges(operateMsg, OperationState.success),
catchError( error => {
const message = errorHandFn(error);
this.translateService.get(message).subscribe(res =>
operateChanges(operateMsg, OperationState.failure, res)
);
return observableThrowError(message);
}
)));
}
let GroupAdders$ = this.selectedGroups.map(group => {
let operMessage = new OperateInfo();
operMessage.name = 'OPERATION.ADD_GROUP';
operMessage.data.id = group.id;
operMessage.state = OperationState.progressing;
operMessage.data.name = group.group_name;
this.operationService.publishInfo(operMessage);
return this.memberService
.addGroupMember(this.projectId, group, this.selectedRole).pipe(
mergeMap(response => {
return this.translateService.get("BATCH.DELETED_SUCCESS").pipe(
mergeMap(res => {
operateChanges(operMessage, OperationState.success);
return observableOf(res);
})); }),
catchError(
error => {
const message = errorHandFn(error);
this.translateService.get(message).subscribe(res =>
operateChanges(operMessage, OperationState.failure, res)
);
let obs = this.selectedGroups.map(group => {
let operMessage = new OperateInfo();
operMessage.name = 'OPERATION.DELETE_GROUP';
operMessage.data.id = group.id;
operMessage.state = OperationState.progressing;
operMessage.data.name = group.group_name;
this.operationService.publishInfo(operMessage);
return this.groupService
.deleteGroup(group.id)
.pipe(flatMap(response => {
return this.translate.get("BATCH.DELETED_SUCCESS").pipe(flatMap(res => {
operateChanges(operMessage, OperationState.success);
return of(res);
}));
}))
.pipe(catchError(error => {
const message = errorHandFn(error);
this.translateService.get(message).subscribe(res =>
operateChanges(operMessage, OperationState.failure, res)
);
let deleteMember = (projectId: number, member: Member) => {
let operMessage = new OperateInfo();
operMessage.name = 'OPERATION.DELETE_MEMBER';
operMessage.data.id = member.id;
operMessage.state = OperationState.progressing;
operMessage.data.name = member.entity_name;
this.operationService.publishInfo(operMessage);
if (member.entity_type === 'u' && member.entity_id === this.currentUser.user_id) {
this.translate.get("BATCH.DELETED_FAILURE").subscribe(res => {
operateChanges(operMessage, OperationState.failure, res);
});
return null;
}
return this.memberService
.deleteMember(projectId, member.id)
.pipe(map(response => {
this.translate.get("BATCH.DELETED_SUCCESS").subscribe(res => {
operateChanges(operMessage, OperationState.success);
});
deleteChart(chartName: string): Observable {
let operateMsg = new OperateInfo();
operateMsg.name = "OPERATION.DELETE_CHART";
operateMsg.data.id = chartName;
operateMsg.state = OperationState.progressing;
operateMsg.data.name = chartName;
this.operationService.publishInfo(operateMsg);
return this.helmChartService.deleteHelmChart(this.projectName, chartName)
.pipe(map(
() => operateChanges(operateMsg, OperationState.success),
catchError( error => {
const message = errorHandFn(error);
this.translateService.get(message).subscribe(res =>
operateChanges(operateMsg, OperationState.failure, res)
);
return observableThrowError(message);
}
)));
}