-
diff --git a/src/portal/lib/src/config/project-quotas/edit-project-quotas/edit-project-quotas.component.scss b/src/portal/lib/src/config/project-quotas/edit-project-quotas/edit-project-quotas.component.scss
index 024a058d63..0baa3e3541 100644
--- a/src/portal/lib/src/config/project-quotas/edit-project-quotas/edit-project-quotas.component.scss
+++ b/src/portal/lib/src/config/project-quotas/edit-project-quotas/edit-project-quotas.component.scss
@@ -1,21 +1,25 @@
-
::ng-deep .modal-dialog {
width: 25rem;
}
+
.modal-body {
padding-top: 0.8rem;
overflow-y: visible;
overflow-x: visible;
+
.clr-form-compact {
div.form-group {
padding-left: 8.5rem;
+
.mr-3px {
margin-right: 3px;
}
+
.quota-input {
width: 2rem;
padding-right: 0.8rem;
}
+
.select-div {
width: 2.5rem;
@@ -51,6 +55,22 @@
width: 9rem;
}
+::ng-deep {
+ .progress {
+ &.warning>progress {
+ color: orange;
+
+ &::-webkit-progress-value {
+ background-color: orange;
+ }
+
+ &::-moz-progress-bar {
+ background-color: orange;
+ }
+ }
+ }
+}
+
.progress-label {
position: absolute;
right: -2.3rem;
diff --git a/src/portal/lib/src/config/project-quotas/edit-project-quotas/edit-project-quotas.component.ts b/src/portal/lib/src/config/project-quotas/edit-project-quotas/edit-project-quotas.component.ts
index a0e435c915..1a9e6cd4e3 100644
--- a/src/portal/lib/src/config/project-quotas/edit-project-quotas/edit-project-quotas.component.ts
+++ b/src/portal/lib/src/config/project-quotas/edit-project-quotas/edit-project-quotas.component.ts
@@ -6,13 +6,10 @@ import {
OnInit,
} from '@angular/core';
import { NgForm, Validators } from '@angular/forms';
-import { ActivatedRoute } from "@angular/router";
-
-import { TranslateService } from '@ngx-translate/core';
import { InlineAlertComponent } from '../../../inline-alert/inline-alert.component';
-import { QuotaUnits, QuotaUnlimited } from "../../../shared/shared.const";
+import { QuotaUnits, QuotaUnlimited, QUOTA_DANGER_COEFFICIENT, QUOTA_WARNING_COEFFICIENT } from "../../../shared/shared.const";
import { clone, getSuitableUnit, getByte, GetIntegerAndUnit, validateLimit } from '../../../utils';
import { EditQuotaQuotaInterface, QuotaHardLimitInterface } from '../../../service';
@@ -47,9 +44,9 @@ export class EditProjectQuotasComponent implements OnInit {
@ViewChild('quotaForm')
currentForm: NgForm;
@Output() confirmAction = new EventEmitter();
- constructor(
- private translateService: TranslateService,
- private route: ActivatedRoute) { }
+ quotaDangerCoefficient: number = QUOTA_DANGER_COEFFICIENT;
+ quotaWarningCoefficient: number = QUOTA_WARNING_COEFFICIENT;
+ constructor() { }
ngOnInit() {
}
@@ -134,10 +131,18 @@ export class EditProjectQuotasComponent implements OnInit {
}
return 0;
}
- getDangerStyle(limit: number | string, used: number | string, unit?: string) {
+ isDangerColor(limit: number | string, used: number | string, unit?: string) {
if (unit) {
- return limit !== QuotaUnlimited ? +used / getByte(+limit, unit) > 0.9 : false;
+ return limit !== QuotaUnlimited ? +used / getByte(+limit, unit) >= this.quotaDangerCoefficient : false;
}
- return limit !== QuotaUnlimited ? +used / +limit > 0.9 : false;
+ return limit !== QuotaUnlimited ? +used / +limit >= this.quotaDangerCoefficient : false;
+ }
+ isWarningColor(limit: number | string, used: number | string, unit?: string) {
+ if (unit) {
+ return limit !== QuotaUnlimited ?
+ +used / getByte(+limit, unit) >= this.quotaWarningCoefficient && +used / getByte(+limit, unit) <= this.quotaDangerCoefficient : false;
+ }
+ return limit !== QuotaUnlimited ?
+ +used / +limit >= this.quotaWarningCoefficient && +used / +limit <= this.quotaDangerCoefficient : false;
}
}
diff --git a/src/portal/lib/src/config/project-quotas/project-quotas.component.html b/src/portal/lib/src/config/project-quotas/project-quotas.component.html
index 6f9e9cad2c..22af1333d7 100644
--- a/src/portal/lib/src/config/project-quotas/project-quotas.component.html
+++ b/src/portal/lib/src/config/project-quotas/project-quotas.component.html
@@ -37,7 +37,9 @@
0.9:false">
+ [class.danger]="quota.hard.count!==-1?quota.used.count/quota.hard.count>quotaDangerCoefficient:false"
+ [class.warning]="quota.hard.count!==-1?quota.used.count/quota.hard.count<=quotaDangerCoefficient &"a.used.count/quota.hard.count>=quotaWarningCoefficient:false"
+ >
@@ -48,7 +50,9 @@
0.9:false">
+ [class.danger]="quota.hard.storage!==-1?quota.used.storage/quota.hard.storage>quotaDangerCoefficient:false"
+ [class.warning]="quota.hard.storage!==-1?quota.used.storage/quota.hard.storage>=quotaWarningCoefficient&"a.used.storage/quota.hard.storage<=quotaDangerCoefficient:false"
+ >
diff --git a/src/portal/lib/src/config/project-quotas/project-quotas.component.ts b/src/portal/lib/src/config/project-quotas/project-quotas.component.ts
index df5effd32b..fa457b03ed 100644
--- a/src/portal/lib/src/config/project-quotas/project-quotas.component.ts
+++ b/src/portal/lib/src/config/project-quotas/project-quotas.component.ts
@@ -8,7 +8,7 @@ import {
, getByte, GetIntegerAndUnit
} from '../../utils';
import { ErrorHandler } from '../../error-handler/index';
-import { QuotaUnits, QuotaUnlimited } from '../../shared/shared.const';
+import { QuotaUnits, QuotaUnlimited, QUOTA_DANGER_COEFFICIENT, QUOTA_WARNING_COEFFICIENT } from '../../shared/shared.const';
import { EditProjectQuotasComponent } from './edit-project-quotas/edit-project-quotas.component';
import {
ConfigurationService
@@ -46,6 +46,8 @@ export class ProjectQuotasComponent implements OnChanges {
currentPage = 1;
totalCount = 0;
pageSize = 15;
+ quotaDangerCoefficient: number = QUOTA_DANGER_COEFFICIENT;
+ quotaWarningCoefficient: number = QUOTA_WARNING_COEFFICIENT;
@Input()
get allConfig(): Configuration {
return this.config;
diff --git a/src/portal/lib/src/shared/shared.const.ts b/src/portal/lib/src/shared/shared.const.ts
index 8a310b0867..3bd04909d3 100644
--- a/src/portal/lib/src/shared/shared.const.ts
+++ b/src/portal/lib/src/shared/shared.const.ts
@@ -122,6 +122,8 @@ export const CONFIG_AUTH_MODE = {
OIDC_AUTH: "oidc_auth",
UAA_AUTH: "uaa_auth"
};
+export const QUOTA_DANGER_COEFFICIENT = 0.9;
+export const QUOTA_WARNING_COEFFICIENT = 0.7;
export const PROJECT_ROOTS = [
{
NAME: "admin",
diff --git a/src/portal/src/app/project/summary/summary.component.html b/src/portal/src/app/project/summary/summary.component.html
index d53588b42a..70d640c1a5 100644
--- a/src/portal/src/app/project/summary/summary.component.html
+++ b/src/portal/src/app/project/summary/summary.component.html
@@ -35,7 +35,8 @@
-
0.9:false">
+
quotaDangerCoefficient:false"
+ [class.warning]="summaryInformation?.quota?.hard?.count!==-1?summaryInformation?.quota?.used?.count/summaryInformation?.quota?.hard?.count<=quotaDangerCoefficient&&summaryInformation?.quota?.used?.count/summaryInformation?.quota?.hard?.count>=quotaWarningCoefficient:false">
@@ -58,7 +59,8 @@
0.9:false">
+ [class.danger]="summaryInformation?.quota?.hard?.storage!==-1?summaryInformation?.quota?.used?.storage/summaryInformation?.quota?.hard?.storage>quotaDangerCoefficient:false"
+ [class.warning]="summaryInformation?.quota?.hard?.storage!==-1?summaryInformation?.quota?.used?.storage/summaryInformation?.quota?.hard?.storage<=quotaDangerCoefficient&&summaryInformation?.quota?.used?.storage/summaryInformation?.quota?.hard?.storage>=quotaWarningCoefficient:false">
diff --git a/src/portal/src/app/project/summary/summary.component.ts b/src/portal/src/app/project/summary/summary.component.ts
index 00bdaf1468..457d7fbb2c 100644
--- a/src/portal/src/app/project/summary/summary.component.ts
+++ b/src/portal/src/app/project/summary/summary.component.ts
@@ -1,9 +1,9 @@
-import { Component, OnInit, Input } from '@angular/core';
-import { ProjectService, clone, QuotaUnits, getSuitableUnit, ErrorHandler, GetIntegerAndUnit } from '@harbor/ui';
-import { Router, ActivatedRoute } from '@angular/router';
-import { forkJoin } from 'rxjs';
+import { Component, OnInit } from '@angular/core';
+import { ProjectService, clone, QuotaUnits, getSuitableUnit, ErrorHandler, GetIntegerAndUnit
+ , QUOTA_DANGER_COEFFICIENT, QUOTA_WARNING_COEFFICIENT } from '@harbor/ui';
+import { ActivatedRoute } from '@angular/router';
+
import { AppConfigService } from "../../app-config.service";
-export const riskRatio = 0.9;
@Component({
selector: 'summary',
templateUrl: './summary.component.html',
@@ -12,6 +12,8 @@ export const riskRatio = 0.9;
export class SummaryComponent implements OnInit {
projectId: number;
summaryInformation: any;
+ quotaDangerCoefficient: number = QUOTA_DANGER_COEFFICIENT;
+ quotaWarningCoefficient: number = QUOTA_WARNING_COEFFICIENT;
constructor(
private projectService: ProjectService,
private errorHandler: ErrorHandler,