mirror of
https://github.com/goharbor/harbor
synced 2025-04-15 08:21:31 +00:00
Merge pull request #3102 from steven-zou/master
Fix projetcId not ready and ca download link issues
This commit is contained in:
commit
749435ccf3
|
@ -21,7 +21,7 @@ export const SYSTEM_SETTINGS_HTML: string = `
|
|||
</div>
|
||||
<div class="form-group" *ngIf="canDownloadCert">
|
||||
<label for="certDownloadLink" class="required">{{'CONFIG.ROOT_CERT' | translate}}</label>
|
||||
<a #certDownloadLink href="/api/systeminfo/getcert" target="_blank">{{'CONFIG.ROOT_CERT_LINK' | translate}}</a>
|
||||
<a #certDownloadLink [href]="downloadLink" target="_blank">{{'CONFIG.ROOT_CERT_LINK' | translate}}</a>
|
||||
<a href="javascript:void(0)" role="tooltip" aria-haspopup="true" class="tooltip tooltip-top-right">
|
||||
<clr-icon shape="info-circle" class="info-tips-icon" size="24"></clr-icon>
|
||||
<span class="tooltip-content">{{'CONFIG.TOOLTIP.ROOT_CERT_DOWNLOAD' | translate}}</span>
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core';
|
||||
import { Component, Input, Output, EventEmitter, ViewChild, Inject } from '@angular/core';
|
||||
import { NgForm } from '@angular/forms';
|
||||
|
||||
import { SYSTEM_SETTINGS_HTML } from './system-settings.component.html';
|
||||
import { Configuration } from '../config';
|
||||
import { REGISTRY_CONFIG_STYLES } from '../registry-config.component.css';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../../service.config';
|
||||
|
||||
@Component({
|
||||
selector: 'system-settings',
|
||||
|
@ -12,6 +13,7 @@ import { REGISTRY_CONFIG_STYLES } from '../registry-config.component.css';
|
|||
})
|
||||
export class SystemSettingsComponent {
|
||||
config: Configuration;
|
||||
downloadLink: string = "/api/systeminfo/getcert";
|
||||
@Output() configChange: EventEmitter<Configuration> = new EventEmitter<Configuration>();
|
||||
|
||||
@Input()
|
||||
|
@ -42,4 +44,10 @@ export class SystemSettingsComponent {
|
|||
get canDownloadCert(): boolean {
|
||||
return this.hasAdminRole && this.hasCAFile;
|
||||
}
|
||||
|
||||
constructor( @Inject(SERVICE_CONFIG) private configInfo: IServiceConfig) {
|
||||
if (this.configInfo && this.configInfo.systemInfoEndpoint) {
|
||||
this.downloadLink = this.configInfo.systemInfoEndpoint + "/getcert";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,27 +2,27 @@ export const LIST_REPLICATION_RULE_TEMPLATE: string = `
|
|||
<div>
|
||||
<clr-datagrid [clrDgLoading]="loading">
|
||||
<clr-dg-column [clrDgField]="'name'">{{'REPLICATION.NAME' | translate}}</clr-dg-column>
|
||||
<clr-dg-column [clrDgField]="'project_name'" *ngIf="projectScope">{{'REPLICATION.PROJECT' | translate}}</clr-dg-column>
|
||||
<clr-dg-column [clrDgField]="'project_name'" *ngIf="!projectScope">{{'REPLICATION.PROJECT' | translate}}</clr-dg-column>
|
||||
<clr-dg-column [clrDgField]="'description'">{{'REPLICATION.DESCRIPTION' | translate}}</clr-dg-column>
|
||||
<clr-dg-column [clrDgField]="'target_name'">{{'REPLICATION.DESTINATION_NAME' | translate}}</clr-dg-column>
|
||||
<clr-dg-column [clrDgSortBy]="startTimeComparator">{{'REPLICATION.LAST_START_TIME' | translate}}</clr-dg-column>
|
||||
<clr-dg-column [clrDgSortBy]="enabledComparator">{{'REPLICATION.ACTIVATION' | translate}}</clr-dg-column>
|
||||
<clr-dg-placeholder>{{'REPLICATION.PLACEHOLDER' | translate }}</clr-dg-placeholder>
|
||||
<clr-dg-row *clrDgItems="let p of changedRules" [clrDgItem]="p" (click)="selectRule(p)" [style.backgroundColor]="(!projectScope && withReplicationJob && selectedId === p.id) ? '#eee' : ''">
|
||||
<clr-dg-row *clrDgItems="let p of changedRules" [clrDgItem]="p" (click)="selectRule(p)" [style.backgroundColor]="(projectScope && withReplicationJob && selectedId === p.id) ? '#eee' : ''">
|
||||
<clr-dg-action-overflow *ngIf="!readonly">
|
||||
<button class="action-item" (click)="editRule(p)">{{'REPLICATION.EDIT_POLICY' | translate}}</button>
|
||||
<button class="action-item" (click)="toggleRule(p)">{{ (p.enabled === 0 ? 'REPLICATION.ENABLE' : 'REPLICATION.DISABLE') | translate}}</button>
|
||||
<button class="action-item" (click)="deleteRule(p)">{{'REPLICATION.DELETE_POLICY' | translate}}</button>
|
||||
</clr-dg-action-overflow>
|
||||
<clr-dg-cell>
|
||||
<ng-template [ngIf]="projectScope">
|
||||
<ng-template [ngIf]="!projectScope">
|
||||
<a href="javascript:void(0)" (click)="redirectTo(p)">{{p.name}}</a>
|
||||
</ng-template>
|
||||
<ng-template [ngIf]="!projectScope">
|
||||
<ng-template [ngIf]="projectScope">
|
||||
{{p.name}}
|
||||
</ng-template>
|
||||
</clr-dg-cell>
|
||||
<clr-dg-cell *ngIf="projectScope">{{p.project_name}}</clr-dg-cell>
|
||||
<clr-dg-cell *ngIf="!projectScope">{{p.project_name}}</clr-dg-cell>
|
||||
<clr-dg-cell>{{p.description ? p.description : '-'}}</clr-dg-cell>
|
||||
<clr-dg-cell>{{p.target_name}}</clr-dg-cell>
|
||||
<clr-dg-cell>
|
||||
|
|
|
@ -11,7 +11,19 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
import { Component, Input, Output, OnInit, EventEmitter, ViewChild, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
Input,
|
||||
Output,
|
||||
OnInit,
|
||||
EventEmitter,
|
||||
ViewChild,
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
OnChanges,
|
||||
SimpleChange,
|
||||
SimpleChanges
|
||||
} from '@angular/core';
|
||||
|
||||
import { ReplicationService } from '../service/replication.service';
|
||||
import { ReplicationRule } from '../service/interface';
|
||||
|
@ -36,10 +48,10 @@ import { LIST_REPLICATION_RULE_TEMPLATE } from './list-replication-rule.componen
|
|||
template: LIST_REPLICATION_RULE_TEMPLATE,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class ListReplicationRuleComponent implements OnInit {
|
||||
export class ListReplicationRuleComponent implements OnInit, OnChanges {
|
||||
|
||||
nullTime: string = '0001-01-01T00:00:00Z';
|
||||
|
||||
|
||||
@Input() projectId: number;
|
||||
@Input() selectedId: number | string;
|
||||
@Input() withReplicationJob: boolean;
|
||||
|
@ -53,7 +65,7 @@ export class ListReplicationRuleComponent implements OnInit {
|
|||
@Output() toggleOne = new EventEmitter<ReplicationRule>();
|
||||
@Output() redirect = new EventEmitter<ReplicationRule>();
|
||||
|
||||
projectScope: boolean;
|
||||
projectScope: boolean = false;
|
||||
|
||||
rules: ReplicationRule[];
|
||||
changedRules: ReplicationRule[];
|
||||
|
@ -64,7 +76,7 @@ export class ListReplicationRuleComponent implements OnInit {
|
|||
|
||||
@ViewChild('deletionConfirmDialog')
|
||||
deletionConfirmDialog: ConfirmationDialogComponent;
|
||||
|
||||
|
||||
startTimeComparator: Comparator<ReplicationRule> = new CustomComparator<ReplicationRule>('start_time', 'date');
|
||||
enabledComparator: Comparator<ReplicationRule> = new CustomComparator<ReplicationRule>('enabled', 'number');
|
||||
|
||||
|
@ -72,56 +84,72 @@ export class ListReplicationRuleComponent implements OnInit {
|
|||
private replicationService: ReplicationService,
|
||||
private translateService: TranslateService,
|
||||
private errorHandler: ErrorHandler,
|
||||
private ref: ChangeDetectorRef) {
|
||||
setInterval(()=>ref.markForCheck(), 500);
|
||||
private ref: ChangeDetectorRef) {
|
||||
setInterval(() => ref.markForCheck(), 500);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.projectScope = (!this.projectId);
|
||||
this.retrieveRules();
|
||||
//Global scope
|
||||
if (!this.projectScope) {
|
||||
this.retrieveRules();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
let proIdChange: SimpleChange = changes["projectId"];
|
||||
if (proIdChange) {
|
||||
if (proIdChange.currentValue !== proIdChange.previousValue) {
|
||||
if (proIdChange.currentValue) {
|
||||
this.projectId = proIdChange.currentValue;
|
||||
this.projectScope = true; //Scope is project, not global list
|
||||
//Initially load the replication rule data
|
||||
this.retrieveRules();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
retrieveRules(ruleName: string = ''): void {
|
||||
this.loading = true;
|
||||
toPromise<ReplicationRule[]>(this.replicationService
|
||||
.getReplicationRules(this.projectId, ruleName))
|
||||
.then(rules=>{
|
||||
this.rules = rules || [];
|
||||
if(this.rules && this.rules.length > 0) {
|
||||
this.selectedId = this.rules[0].id || '';
|
||||
this.selectOne.emit(this.rules[0]);
|
||||
}
|
||||
this.changedRules = this.rules;
|
||||
this.loading = false;
|
||||
}
|
||||
).catch(error=>{
|
||||
this.errorHandler.error(error);
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
.getReplicationRules(this.projectId, ruleName))
|
||||
.then(rules => {
|
||||
this.rules = rules || [];
|
||||
if (this.rules && this.rules.length > 0) {
|
||||
this.selectedId = this.rules[0].id || '';
|
||||
this.selectOne.emit(this.rules[0]);
|
||||
}
|
||||
this.changedRules = this.rules;
|
||||
this.loading = false;
|
||||
}
|
||||
).catch(error => {
|
||||
this.errorHandler.error(error);
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
filterRuleStatus(status: string) {
|
||||
if(status === 'all') {
|
||||
if (status === 'all') {
|
||||
this.changedRules = this.rules;
|
||||
} else {
|
||||
this.changedRules = this.rules.filter(policy=>policy.enabled === +status);
|
||||
this.changedRules = this.rules.filter(policy => policy.enabled === +status);
|
||||
}
|
||||
}
|
||||
|
||||
toggleConfirm(message: ConfirmationAcknowledgement) {
|
||||
if(message &&
|
||||
message.source === ConfirmationTargets.TOGGLE_CONFIRM &&
|
||||
if (message &&
|
||||
message.source === ConfirmationTargets.TOGGLE_CONFIRM &&
|
||||
message.state === ConfirmationState.CONFIRMED) {
|
||||
let rule: ReplicationRule = message.data;
|
||||
if(rule) {
|
||||
if (rule) {
|
||||
rule.enabled = rule.enabled === 0 ? 1 : 0;
|
||||
toPromise<any>(this.replicationService
|
||||
.enableReplicationRule(rule.id || '', rule.enabled))
|
||||
.then(() =>
|
||||
.then(() =>
|
||||
this.translateService.get('REPLICATION.TOGGLED_SUCCESS')
|
||||
.subscribe(res=>this.errorHandler.info(res)))
|
||||
.subscribe(res => this.errorHandler.info(res)))
|
||||
.catch(error => this.errorHandler.error(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,13 +161,13 @@ export class ListReplicationRuleComponent implements OnInit {
|
|||
.deleteReplicationRule(message.data))
|
||||
.then(() => {
|
||||
this.translateService.get('REPLICATION.DELETED_SUCCESS')
|
||||
.subscribe(res=>this.errorHandler.info(res));
|
||||
.subscribe(res => this.errorHandler.info(res));
|
||||
this.reload.emit(true);
|
||||
})
|
||||
.catch(error => {
|
||||
if(error && error.status === 412) {
|
||||
if (error && error.status === 412) {
|
||||
this.translateService.get('REPLICATION.FAILED_TO_DELETE_POLICY_ENABLED')
|
||||
.subscribe(res=>this.errorHandler.error(res));
|
||||
.subscribe(res => this.errorHandler.error(res));
|
||||
} else {
|
||||
this.errorHandler.error(error);
|
||||
}
|
||||
|
@ -163,7 +191,7 @@ export class ListReplicationRuleComponent implements OnInit {
|
|||
toggleRule(rule: ReplicationRule) {
|
||||
let toggleConfirmMessage: ConfirmationMessage = new ConfirmationMessage(
|
||||
rule.enabled === 1 ? 'REPLICATION.TOGGLE_DISABLE_TITLE' : 'REPLICATION.TOGGLE_ENABLE_TITLE',
|
||||
rule.enabled === 1 ? 'REPLICATION.CONFIRM_TOGGLE_DISABLE_POLICY': 'REPLICATION.CONFIRM_TOGGLE_ENABLE_POLICY',
|
||||
rule.enabled === 1 ? 'REPLICATION.CONFIRM_TOGGLE_DISABLE_POLICY' : 'REPLICATION.CONFIRM_TOGGLE_ENABLE_POLICY',
|
||||
rule.name || '',
|
||||
rule,
|
||||
ConfirmationTargets.TOGGLE_CONFIRM
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
"clarity-icons": "^0.9.8",
|
||||
"clarity-ui": "^0.9.8",
|
||||
"core-js": "^2.4.1",
|
||||
"harbor-ui": "0.4.46",
|
||||
"harbor-ui": "0.4.52",
|
||||
"intl": "^1.2.5",
|
||||
"mutationobserver-shim": "^0.3.2",
|
||||
"ngx-cookie": "^1.0.0",
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
<div class="dropdown-menu">
|
||||
<a href="javascript:void(0)" clrDropdownItem (click)="openAccountSettingsModal()">{{'ACCOUNT_SETTINGS.PROFILE' | translate}}</a>
|
||||
<a *ngIf="canChangePassword" href="javascript:void(0)" clrDropdownItem (click)="openChangePwdModal()">{{'ACCOUNT_SETTINGS.CHANGE_PWD' | translate}}</a>
|
||||
<a *ngIf="canDownloadCert" href="/api/systeminfo/getcert" clrDropdownItem target="_blank">{{'ACCOUNT_SETTINGS.ROOT_CERT' | translate}}</a>
|
||||
<a href="javascript:void(0)" clrDropdownItem (click)="openAboutDialog()">{{'ACCOUNT_SETTINGS.ABOUT' | translate}}</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="javascript:void(0)" clrDropdownItem (click)="logOut()">{{'ACCOUNT_SETTINGS.LOGOUT' | translate}}</a>
|
||||
|
|
Loading…
Reference in New Issue
Block a user