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:
jwangyangls 2019-08-01 18:02:31 +08:00 committed by GitHub
commit 41df8f0fcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 6 deletions

View File

@ -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>

View File

@ -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;
}
}

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -331,7 +331,8 @@
"COPY_SUCCESS": "成功复制 '{{param}}' 的令牌",
"DELETION_TITLE": "删除账户确认",
"DELETION_SUMMARY": "你确认删除机器人账户 {{param}}?",
"PULL_IS_MUST" : "拉取权限默认选中且不可修改。"
"PULL_IS_MUST" : "拉取权限默认选中且不可修改。",
"EXPORT_TO_FILE" : "导出到文件中"
},
"GROUP": {
"GROUP": "组",