mirror of
https://github.com/goharbor/harbor
synced 2025-05-18 14:26:50 +00:00
Merge pull request #8524 from jwangyangls/add-robot-to-file
Add download button that it can download the message of robot to local file when click it
This commit is contained in:
commit
41df8f0fcd
@ -128,6 +128,7 @@
|
||||
(onCopyError)="onCpError($event)" inputSize="50" headerTitle=""
|
||||
defaultValue="{{robotToken}}" class="copy-input"></hbr-copy-input>
|
||||
</div>
|
||||
<a [href]="downLoadHref" [download]="downLoadFileName"><button class="btn mr-0" (click)="closeModal()">{{'ROBOT_ACCOUNT.EXPORT_TO_FILE' | translate}}</button></a>
|
||||
</section>
|
||||
</div>
|
||||
</clr-modal>
|
@ -17,6 +17,7 @@ import { TranslateService } from "@ngx-translate/core";
|
||||
import { ErrorHandler } from "@harbor/ui";
|
||||
import { MessageHandlerService } from "../../../shared/message-handler/message-handler.service";
|
||||
import { InlineAlertComponent } from "../../../shared/inline-alert/inline-alert.component";
|
||||
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
||||
|
||||
@Component({
|
||||
selector: "add-robot",
|
||||
@ -28,6 +29,8 @@ export class AddRobotComponent implements OnInit, OnDestroy {
|
||||
copyToken: boolean;
|
||||
robotToken: string;
|
||||
robotAccount: string;
|
||||
downLoadFileName: string = '';
|
||||
downLoadHref: SafeUrl = '';
|
||||
isSubmitOnGoing = false;
|
||||
closable: boolean = false;
|
||||
staticBackdrop: boolean = true;
|
||||
@ -50,7 +53,8 @@ export class AddRobotComponent implements OnInit, OnDestroy {
|
||||
private translate: TranslateService,
|
||||
private errorHandler: ErrorHandler,
|
||||
private cdr: ChangeDetectorRef,
|
||||
private messageHandlerService: MessageHandlerService
|
||||
private messageHandlerService: MessageHandlerService,
|
||||
private sanitizer: DomSanitizer
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@ -148,6 +152,10 @@ export class AddRobotComponent implements OnInit, OnDestroy {
|
||||
this.createSuccess = res;
|
||||
});
|
||||
this.addRobotOpened = false;
|
||||
// export to token file
|
||||
const downLoadUrl = `data:text/json;charset=utf-8, ${encodeURIComponent(JSON.stringify(response))}`;
|
||||
this.downLoadHref = this.sanitizer.bypassSecurityTrustUrl(downLoadUrl);
|
||||
this.downLoadFileName = `${response.name}.json`;
|
||||
},
|
||||
error => {
|
||||
this.isSubmitOnGoing = false;
|
||||
@ -197,4 +205,8 @@ export class AddRobotComponent implements OnInit, OnDestroy {
|
||||
this.messageHandlerService.showSuccess(res);
|
||||
});
|
||||
}
|
||||
|
||||
closeModal() {
|
||||
this.copyToken = false;
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +332,8 @@
|
||||
"COPY_SUCCESS": "Copy token successfully of '{{param}}'",
|
||||
"DELETION_TITLE": "Confirm removal of robot accounts",
|
||||
"DELETION_SUMMARY": "Do you want to delete robot accounts {{param}}?",
|
||||
"PULL_IS_MUST" : "Pull permission is checked by default and can not be modified."
|
||||
"PULL_IS_MUST" : "Pull permission is checked by default and can not be modified.",
|
||||
"EXPORT_TO_FILE" : "export to file"
|
||||
},
|
||||
"GROUP": {
|
||||
"GROUP": "Group",
|
||||
|
@ -333,7 +333,8 @@
|
||||
"COPY_SUCCESS": "Copy token successfully of '{{param}}'",
|
||||
"DELETION_TITLE": "Confirm removal of robot accounts",
|
||||
"DELETION_SUMMARY": "Do you want to delete robot accounts {{param}}?",
|
||||
"PULL_IS_MUST" : "Pull permission is checked by default and can not be modified."
|
||||
"PULL_IS_MUST" : "Pull permission is checked by default and can not be modified.",
|
||||
"EXPORT_TO_FILE" : "export to file"
|
||||
},
|
||||
"GROUP": {
|
||||
"GROUP": "Group",
|
||||
|
@ -325,7 +325,8 @@
|
||||
"COPY_SUCCESS": "Copy token successfully of '{{param}}'",
|
||||
"DELETION_TITLE": "confirmer l'enlèvement des comptes du robot ",
|
||||
"DELETION_SUMMARY": "Voulez-vous supprimer la règle {{param}}?",
|
||||
"PULL_IS_MUST" : "Pull permission is checked by default and can not be modified."
|
||||
"PULL_IS_MUST" : "Pull permission is checked by default and can not be modified.",
|
||||
"EXPORT_TO_FILE" : "export to file"
|
||||
},
|
||||
"GROUP": {
|
||||
"Group": "Group",
|
||||
|
@ -330,7 +330,8 @@
|
||||
"COPY_SUCCESS": "Copy token successfully of '{{param}}'",
|
||||
"DELETION_TITLE": "Confirmar a remoção do robô Contas",
|
||||
"DELETION_SUMMARY": "Você quer remover a regra {{param}}?",
|
||||
"PULL_IS_MUST" : "Pull permission is checked by default and can not be modified."
|
||||
"PULL_IS_MUST" : "Pull permission is checked by default and can not be modified.",
|
||||
"EXPORT_TO_FILE" : "export to file"
|
||||
},
|
||||
"GROUP": {
|
||||
"GROUP": "Grupo",
|
||||
|
@ -331,7 +331,8 @@
|
||||
"COPY_SUCCESS": "成功复制 '{{param}}' 的令牌",
|
||||
"DELETION_TITLE": "删除账户确认",
|
||||
"DELETION_SUMMARY": "你确认删除机器人账户 {{param}}?",
|
||||
"PULL_IS_MUST" : "拉取权限默认选中且不可修改。"
|
||||
"PULL_IS_MUST" : "拉取权限默认选中且不可修改。",
|
||||
"EXPORT_TO_FILE" : "导出到文件中"
|
||||
},
|
||||
"GROUP": {
|
||||
"GROUP": "组",
|
||||
|
Loading…
x
Reference in New Issue
Block a user