1 import { AfterViewChecked, ChangeDetectorRef, Component, OnInit } from '@angular/core';
2 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
3 import { RgwRealmService } from '~/app/shared/api/rgw-realm.service';
4 import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
5 import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
6 import { NotificationService } from '~/app/shared/services/notification.service';
7 import { RgwRealm } from '../models/rgw-multisite';
8 import { Icons } from '~/app/shared/enum/icons.enum';
11 selector: 'cd-rgw-multisite-export',
12 templateUrl: './rgw-multisite-export.component.html',
13 styleUrls: ['./rgw-multisite-export.component.scss']
15 export class RgwMultisiteExportComponent implements OnInit, AfterViewChecked {
16 exportTokenForm: CdFormGroup;
18 realmList: RgwRealm[];
25 public activeModal: NgbActiveModal,
26 public rgwRealmService: RgwRealmService,
27 public actionLabels: ActionLabelsI18n,
28 public notificationService: NotificationService,
29 private readonly changeDetectorRef: ChangeDetectorRef
35 this.exportTokenForm = new CdFormGroup({});
39 this.activeModal.close();
43 this.rgwRealmService.getRealmTokens().subscribe((data: object[]) => {
46 var base64Matcher = new RegExp(
47 '^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$'
49 this.realms.forEach((realmInfo: any) => {
50 if (base64Matcher.test(realmInfo.token)) {
51 this.tokenValid = true;
53 this.tokenValid = false;
59 ngAfterViewChecked(): void {
60 this.changeDetectorRef.detectChanges();