mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-26 20:42:43 +02:00
Fix message processing issue (#17609)
Signed-off-by: AllForNothing <sshijun@vmware.com> Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
303133f695
commit
cf5197246a
@ -23,6 +23,7 @@
|
|||||||
"plugin:prettier/recommended"
|
"plugin:prettier/recommended"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"no-console": ["error", { "allow": ["warn", "error"] }]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ mockApi.get('/', (req, res) => {
|
|||||||
mockApi.get(CURRENT_BASE_HREF + '/scanners', Controllers.getScanner);
|
mockApi.get(CURRENT_BASE_HREF + '/scanners', Controllers.getScanner);
|
||||||
|
|
||||||
mockApi.listen(3000, () => {
|
mockApi.listen(3000, () => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log('Api server listening on port 3000!');
|
console.log('Api server listening on port 3000!');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -81,12 +81,6 @@ export class ConfigService {
|
|||||||
new StringValueItem(fakePass, true);
|
new StringValueItem(fakePass, true);
|
||||||
// Keep the original copy of the data
|
// Keep the original copy of the data
|
||||||
this._originalConfig = clone(this._currentConfig);
|
this._originalConfig = clone(this._currentConfig);
|
||||||
// Handle read only
|
|
||||||
if (this._originalConfig?.read_only?.value) {
|
|
||||||
this.msgHandler.handleReadOnly();
|
|
||||||
} else {
|
|
||||||
this.msgHandler.clear();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
this.msgHandler.handleError(error);
|
this.msgHandler.handleError(error);
|
||||||
|
@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { SystemSettingsComponent } from './system-settings.component';
|
import { SystemSettingsComponent } from './system-settings.component';
|
||||||
import { ErrorHandler } from '../../../../shared/units/error-handler';
|
import { ErrorHandler } from '../../../../shared/units/error-handler';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { Configuration, NumberValueItem, StringValueItem } from '../config';
|
import { Configuration } from '../config';
|
||||||
import { SharedTestingModule } from '../../../../shared/shared.module';
|
import { SharedTestingModule } from '../../../../shared/shared.module';
|
||||||
import { ConfigService } from '../config.service';
|
import { ConfigService } from '../config.service';
|
||||||
import { AppConfigService } from '../../../../services/app-config.service';
|
import { AppConfigService } from '../../../../services/app-config.service';
|
||||||
@ -10,12 +10,6 @@ import { AppConfigService } from '../../../../services/app-config.service';
|
|||||||
describe('SystemSettingsComponent', () => {
|
describe('SystemSettingsComponent', () => {
|
||||||
let component: SystemSettingsComponent;
|
let component: SystemSettingsComponent;
|
||||||
let fixture: ComponentFixture<SystemSettingsComponent>;
|
let fixture: ComponentFixture<SystemSettingsComponent>;
|
||||||
const fakedErrorHandler = {
|
|
||||||
info() {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const fakeConfigService = {
|
const fakeConfigService = {
|
||||||
config: new Configuration(),
|
config: new Configuration(),
|
||||||
getConfig() {
|
getConfig() {
|
||||||
@ -51,7 +45,6 @@ describe('SystemSettingsComponent', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: AppConfigService, useValue: fakedAppConfigService },
|
{ provide: AppConfigService, useValue: fakedAppConfigService },
|
||||||
{ provide: ConfigService, useValue: fakeConfigService },
|
{ provide: ConfigService, useValue: fakeConfigService },
|
||||||
{ provide: ErrorHandler, useValue: fakedErrorHandler },
|
|
||||||
],
|
],
|
||||||
declarations: [SystemSettingsComponent],
|
declarations: [SystemSettingsComponent],
|
||||||
});
|
});
|
||||||
|
@ -6,10 +6,10 @@ import {
|
|||||||
getChanges,
|
getChanges,
|
||||||
isEmpty,
|
isEmpty,
|
||||||
} from '../../../../shared/units/utils';
|
} from '../../../../shared/units/utils';
|
||||||
import { ErrorHandler } from '../../../../shared/units/error-handler';
|
|
||||||
import { ConfigService } from '../config.service';
|
import { ConfigService } from '../config.service';
|
||||||
import { AppConfigService } from '../../../../services/app-config.service';
|
import { AppConfigService } from '../../../../services/app-config.service';
|
||||||
import { finalize } from 'rxjs/operators';
|
import { finalize } from 'rxjs/operators';
|
||||||
|
import { MessageHandlerService } from '../../../../shared/services/message-handler.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'system-settings',
|
selector: 'system-settings',
|
||||||
@ -30,7 +30,7 @@ export class SystemSettingsComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private appConfigService: AppConfigService,
|
private appConfigService: AppConfigService,
|
||||||
private errorHandler: ErrorHandler,
|
private errorHandler: MessageHandlerService,
|
||||||
private conf: ConfigService
|
private conf: ConfigService
|
||||||
) {
|
) {
|
||||||
this.downloadLink = CURRENT_BASE_HREF + '/systeminfo/getcert';
|
this.downloadLink = CURRENT_BASE_HREF + '/systeminfo/getcert';
|
||||||
@ -151,13 +151,16 @@ export class SystemSettingsComponent implements OnInit {
|
|||||||
.pipe(finalize(() => (this.onGoing = false)))
|
.pipe(finalize(() => (this.onGoing = false)))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: result => {
|
next: result => {
|
||||||
if (!isEmpty(changes)) {
|
|
||||||
// API should return the updated configurations here
|
// API should return the updated configurations here
|
||||||
// Unfortunately API does not do that
|
// Unfortunately API does not do that
|
||||||
// To refresh the view, we can clone the original data copy
|
// So we need to call update function again
|
||||||
// or force refresh by calling service.
|
|
||||||
// HERE we choose force way
|
|
||||||
this.conf.updateConfig();
|
this.conf.updateConfig();
|
||||||
|
// Handle read only
|
||||||
|
if (changes['read_only']) {
|
||||||
|
this.errorHandler.handleReadOnly();
|
||||||
|
} else {
|
||||||
|
this.errorHandler.clear();
|
||||||
|
}
|
||||||
// Reload bootstrap option
|
// Reload bootstrap option
|
||||||
this.appConfigService.load().subscribe(
|
this.appConfigService.load().subscribe(
|
||||||
() => {},
|
() => {},
|
||||||
@ -167,7 +170,6 @@ export class SystemSettingsComponent implements OnInit {
|
|||||||
error
|
error
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
this.errorHandler.info('CONFIG.SAVE_SUCCESS');
|
this.errorHandler.info('CONFIG.SAVE_SUCCESS');
|
||||||
},
|
},
|
||||||
error: error => {
|
error: error => {
|
||||||
|
@ -155,12 +155,12 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
|||||||
scanNow(): void {
|
scanNow(): void {
|
||||||
if (this.onSubmitting) {
|
if (this.onSubmitting) {
|
||||||
// Avoid duplicated submitting
|
// Avoid duplicated submitting
|
||||||
console.log('duplicated submit');
|
console.error('duplicated submit');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.repoName || !this.artifactDigest) {
|
if (!this.repoName || !this.artifactDigest) {
|
||||||
console.log('bad repository or tag');
|
console.error('bad repository or tag');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
|||||||
error => {
|
error => {
|
||||||
this.onSubmitting = false;
|
this.onSubmitting = false;
|
||||||
if (error && error.error && error.error.code === 409) {
|
if (error && error.error && error.error.code === 409) {
|
||||||
console.log(error.error.message);
|
console.error(error.error.message);
|
||||||
} else {
|
} else {
|
||||||
this.errorHandler.error(error);
|
this.errorHandler.error(error);
|
||||||
}
|
}
|
||||||
@ -272,11 +272,11 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
|||||||
stopScan() {
|
stopScan() {
|
||||||
if (this.onStopping) {
|
if (this.onStopping) {
|
||||||
// Avoid duplicated stopping command
|
// Avoid duplicated stopping command
|
||||||
console.log('duplicated stopping command');
|
console.error('duplicated stopping command');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.repoName || !this.artifactDigest) {
|
if (!this.repoName || !this.artifactDigest) {
|
||||||
console.log('bad repository or artifact');
|
console.error('bad repository or artifact');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.onStopping = true;
|
this.onStopping = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user