Add routing-resolvers

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
AllForNothing 2020-03-17 15:05:49 +08:00
parent eb2af6095e
commit 887d693fa4
80 changed files with 264 additions and 201 deletions

View File

@ -19,7 +19,7 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { CookieService } from 'ngx-cookie';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { SessionService } from './shared/session.service';
import { AppConfigService } from './app-config.service';
import { AppConfigService } from './services/app-config.service';
import { AppComponent } from './app.component';
import { ClarityModule } from "@clr/angular";
import { APP_BASE_HREF } from "@angular/common";

View File

@ -18,9 +18,9 @@ import { TranslateService } from '@ngx-translate/core';
import { CookieService } from 'ngx-cookie';
import { SessionService } from './shared/session.service';
import { AppConfigService } from './app-config.service';
import { ThemeService } from './theme.service';
import { themeArray, ThemeInterface } from './theme';
import { AppConfigService } from './services/app-config.service';
import { ThemeService } from './services/theme.service';
import { themeArray, ThemeInterface } from './services/theme';
import { clone } from '../lib/utils/utils';
const HAS_STYLE_MODE: string = 'styleModeLocal';

View File

@ -14,7 +14,7 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, APP_INITIALIZER, LOCALE_ID, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { AppComponent } from './app.component';
import { InterceptHttpService } from './intercept-http.service';
import { InterceptHttpService } from './services/intercept-http.service';
import { BaseModule } from './base/base.module';
import { HarborRoutingModule } from './harbor-routing.module';
@ -26,8 +26,8 @@ import { DeveloperCenterModule } from './dev-center/dev-center.module';
import { registerLocaleData } from '@angular/common';
import { TranslateService } from "@ngx-translate/core";
import { AppConfigService } from './app-config.service';
import { SkinableConfig } from "./skinable-config.service";
import { AppConfigService } from './services/app-config.service';
import { SkinableConfig } from "./services/skinable-config.service";
import { ProjectConfigComponent } from './project/project-config/project-config.component';
import zh from '@angular/common/locales/zh-Hans';

View File

@ -3,8 +3,8 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { GlobalSearchComponent } from './global-search.component';
import { SearchTriggerService } from './search-trigger.service';
import { FormsModule } from '@angular/forms';
import { AppConfigService } from '../../app-config.service';
import { SkinableConfig } from "../../skinable-config.service";
import { AppConfigService } from '../../services/app-config.service';
import { SkinableConfig } from "../../services/skinable-config.service";
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';

View File

@ -19,12 +19,12 @@ import { Subject , Subscription } from "rxjs";
import { SearchTriggerService } from './search-trigger.service';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import {TranslateService} from "@ngx-translate/core";
import {SkinableConfig} from "../../skinable-config.service";
import {SkinableConfig} from "../../services/skinable-config.service";
const deBounceTime = 500; // ms

View File

@ -4,13 +4,13 @@ import { SearchResults } from './search-results';
import { SearchTriggerService } from './search-trigger.service';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { AppConfigService } from './../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { ListProjectROComponent } from '../../shared/list-project-ro/list-project-ro.component';
import { MessageHandlerService } from '../../shared/message-handler/message-handler.service';
import { SearchResultComponent } from './search-result.component';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { of } from 'rxjs';
import { AppConfig } from '../../app-config';
import { AppConfig } from '../../services/app-config';
import { ClarityModule } from '@clr/angular';
describe('SearchResultComponent', () => {

View File

@ -18,7 +18,7 @@ import { GlobalSearchService } from './global-search.service';
import { SearchResults } from './search-results';
import { SearchTriggerService } from './search-trigger.service';
import { AppConfigService } from './../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { MessageHandlerService } from '../../shared/message-handler/message-handler.service';
import { filter, switchMap } from "rxjs/operators";

View File

@ -1,5 +1,4 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AppConfigService } from '../..//app-config.service';
import { RouterTestingModule } from '@angular/router/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { SessionService } from '../../shared/session.service';
@ -18,8 +17,9 @@ import { FormsModule } from '@angular/forms';
import { MessageHandlerService } from '../../shared/message-handler/message-handler.service';
import { AccountSettingsModalService } from '../../account/account-settings/account-settings-modal-service.service';
import { PasswordSettingService } from '../../account/password-setting/password-setting.service';
import { SkinableConfig } from '../../skinable-config.service';
import { SkinableConfig } from '../../services/skinable-config.service';
import { InlineAlertComponent } from '../../shared/inline-alert/inline-alert.component';
import { AppConfigService } from "../../services/app-config.service";
describe('HarborShellComponent', () => {
let component: HarborShellComponent;

View File

@ -14,7 +14,7 @@
import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Subscription } from "rxjs";
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { ModalEvent } from '../modal-event';
import { modalEvents } from '../modal-events.const';

View File

@ -6,10 +6,10 @@ import { PlatformLocation } from '@angular/common';
import { NavigatorComponent } from './navigator.component';
import { RouterTestingModule } from '@angular/router/testing';
import { CookieService } from 'ngx-cookie';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { MessageHandlerService } from '../../shared/message-handler/message-handler.service';
import { SearchTriggerService } from '../global-search/search-trigger.service';
import { SkinableConfig } from "../../skinable-config.service";
import { SkinableConfig } from "../../services/skinable-config.service";
describe('NavigatorComponent', () => {
let component: NavigatorComponent;

View File

@ -21,14 +21,14 @@ import { modalEvents } from '../modal-events.const';
import { SessionService } from '../../shared/session.service';
import { CookieService, CookieOptions } from 'ngx-cookie';
import { supportedLangs, enLang, languageNames } from '../../shared/shared.const';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { SearchTriggerService } from '../global-search/search-trigger.service';
import { MessageHandlerService } from '../../shared/message-handler/message-handler.service';
import { SkinableConfig } from "../../skinable-config.service";
import { SkinableConfig } from "../../services/skinable-config.service";
import { CommonRoutes } from "../../../lib/entities/shared.const";
import { ThemeInterface, themeArray } from '../../theme';
import { ThemeInterface, themeArray } from '../../services/theme';
import { clone } from '../../../lib/utils/utils';
import { ThemeService } from '../../theme.service';
import { ThemeService } from '../../services/theme.service';
const HAS_STYLE_MODE: string = 'styleModeLocal';
@Component({

View File

@ -1,7 +1,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MessageHandlerService } from '../../shared/message-handler/message-handler.service';
import { ConfirmMessageHandler } from '../config.msg.utils';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { ConfigurationService } from '../config.service';
import { ConfigurationAuthComponent } from './config-auth.component';
import { TranslateModule, TranslateService } from '@ngx-translate/core';

View File

@ -16,7 +16,7 @@ import { NgForm } from '@angular/forms';
import { Subscription } from "rxjs";
import { MessageHandlerService } from '../../shared/message-handler/message-handler.service';
import { ConfirmMessageHandler } from '../config.msg.utils';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { ConfigurationService } from '../config.service';
import { Configuration } from "../../../lib/components/config/config";
import { ErrorHandler } from "../../../lib/utils/error-handler";

View File

@ -5,7 +5,7 @@ import { MessageHandlerService } from '../shared/message-handler/message-handler
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ClarityModule } from "@clr/angular";
import { AppConfigService } from '../app-config.service';
import { AppConfigService } from '../services/app-config.service';
import { ConfigurationService } from './config.service';
import { ConfigurationComponent } from './config.component';
import { of } from 'rxjs';

View File

@ -17,7 +17,7 @@ import { ConfirmationTargets, ConfirmationState } from '../shared/shared.const';
import { SessionService } from '../shared/session.service';
import { ConfirmationDialogService } from '../shared/confirmation-dialog/confirmation-dialog.service';
import { MessageHandlerService } from '../shared/message-handler/message-handler.service';
import { AppConfigService } from '../app-config.service';
import { AppConfigService } from '../services/app-config.service';
import { ConfigurationAuthComponent } from './auth/config-auth.component';
import { ConfigurationEmailComponent } from './email/config-email.component';
import { ConfigurationService } from './config.service';

View File

@ -7,7 +7,7 @@ import { GroupService } from "../group.service";
import { MessageHandlerService } from "./../../shared/message-handler/message-handler.service";
import { SessionService } from "./../../shared/session.service";
import { UserGroup } from "./../group";
import { AppConfigService } from "../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { AddGroupModalComponent } from './add-group-modal.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

View File

@ -7,7 +7,7 @@ import { GroupService } from "../group.service";
import { MessageHandlerService } from "./../../shared/message-handler/message-handler.service";
import { SessionService } from "./../../shared/session.service";
import { UserGroup } from "./../group";
import { AppConfigService } from "../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { GroupType } from "../../../lib/entities/shared.const";
@Component({

View File

@ -9,7 +9,7 @@ import { GroupService } from "./group.service";
import { of } from "rxjs";
import { ConfirmationDialogService } from "./../shared/confirmation-dialog/confirmation-dialog.service";
import { MessageHandlerService } from '../shared/message-handler/message-handler.service';
import { AppConfigService } from '../app-config.service';
import { AppConfigService } from '../services/app-config.service';
import { OperationService } from "../../lib/components/operation/operation.service";
describe('GroupComponent', () => {

View File

@ -16,7 +16,7 @@ import { UserGroup } from "./group";
import { GroupService } from "./group.service";
import { MessageHandlerService } from "../shared/message-handler/message-handler.service";
import { throwError as observableThrowError } from "rxjs";
import { AppConfigService } from '../app-config.service';
import { AppConfigService } from '../services/app-config.service';
import { OperationService } from "../../lib/components/operation/operation.service";
import { operateChanges, OperateInfo, OperationState } from "../../lib/components/operation/operate";
import { errorHandler } from "../../lib/utils/shared/shared.utils";

View File

@ -29,7 +29,6 @@ import { SignInComponent } from './sign-in/sign-in.component';
import { ResetPasswordComponent } from './account/password-setting/reset-password/reset-password.component';
import { GroupComponent } from './group/group.component';
import { TotalReplicationPageComponent } from './replication/total-replication/total-replication-page.component';
import { ReplicationTasksPageComponent } from './replication/replication-tasks-page/replication-tasks-page.component';
import { DestinationPageComponent } from './replication/destination/destination-page.component';
import { AuditLogComponent } from './log/audit-log.component';
import { LogPageComponent } from './log/log-page.component';
@ -40,7 +39,7 @@ import { RobotAccountComponent } from './project/robot-account/robot-account.com
import { WebhookComponent } from './project/webhook/webhook.component';
import { ProjectLabelComponent } from './project/project-label/project-label.component';
import { ProjectConfigComponent } from './project/project-config/project-config.component';
import { ProjectRoutingResolver } from './project/project-routing-resolver.service';
import { ProjectRoutingResolver } from './services/routing-resolvers/project-routing-resolver.service';
import { ListChartsComponent } from './project/helm-chart/list-charts.component';
import { ListChartVersionsComponent } from './project/helm-chart/list-chart-versions/list-chart-versions.component';
import { HelmChartDetailComponent } from './project/helm-chart/helm-chart-detail/chart-detail.component';
@ -60,6 +59,9 @@ import { USERSTATICPERMISSION } from "../lib/services";
import { RepositoryGridviewComponent } from "./project/repository/repository-gridview.component";
import { ArtifactListPageComponent } from "./project/repository/artifact-list-page/artifact-list-page.component";
import { ArtifactSummaryComponent } from "./project/repository/artifact/artifact-summary.component";
import { ReplicationTasksComponent } from "../lib/components/replication/replication-tasks/replication-tasks.component";
import { ReplicationTasksRoutingResolverService } from "./services/routing-resolvers/replication-tasks-routing-resolver.service";
import { ArtifactDetailRoutingResolverService } from "./services/routing-resolvers/artifact-detail-routing-resolver.service";
const harborRoutes: Routes = [
{ path: '', redirectTo: 'harbor', pathMatch: 'full' },
@ -149,8 +151,11 @@ const harborRoutes: Routes = [
canActivate: [SystemAdminGuard],
},
{
path: 'replications/:id/:tasks',
component: ReplicationTasksPageComponent,
path: 'replications/:id/tasks',
component: ReplicationTasksComponent,
resolve: {
replicationTasksRoutingResolver: ReplicationTasksRoutingResolverService
},
canActivate: [SystemAdminGuard],
canActivateChild: [SystemAdminGuard]
},
@ -334,7 +339,7 @@ const harborRoutes: Routes = [
component: ArtifactSummaryComponent,
canActivate: [MemberGuard],
resolve: {
projectResolver: ProjectRoutingResolver
artifactResolver: ArtifactDetailRoutingResolverService
}
},
{
@ -342,7 +347,7 @@ const harborRoutes: Routes = [
component: ArtifactSummaryComponent,
canActivate: [MemberGuard],
resolve: {
projectResolver: ProjectRoutingResolver
artifactResolver: ArtifactDetailRoutingResolverService
}
},
{

View File

@ -5,7 +5,7 @@ import { CUSTOM_ELEMENTS_SCHEMA, ChangeDetectorRef } from '@angular/core';
import { ClarityModule } from '@clr/angular';
import { FormsModule } from '@angular/forms';
import { SessionService } from "../../shared/session.service";
import { AppConfigService } from "../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { RouterTestingModule } from '@angular/router/testing';
import { SearchTriggerService } from "../../base/global-search/search-trigger.service";
import { MessageHandlerService } from "../../shared/message-handler/message-handler.service";

View File

@ -27,7 +27,7 @@ import { ConfirmationDialogService } from "../../shared/confirmation-dialog/conf
import { MessageHandlerService } from "../../shared/message-handler/message-handler.service";
import { ConfirmationMessage } from "../../shared/confirmation-dialog/confirmation-message";
import { SearchTriggerService } from "../../base/global-search/search-trigger.service";
import { AppConfigService } from "../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { Project } from "../project";
import { map, catchError, finalize } from "rxjs/operators";
import { throwError as observableThrowError } from "rxjs";

View File

@ -1,7 +1,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { of } from "rxjs";
import { MemberService } from '../member.service';
import { AppConfigService } from "../../../app-config.service";
import { AppConfigService } from "../../../services/app-config.service";
import { ClarityModule } from '@clr/angular';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TranslateModule, TranslateService } from '@ngx-translate/core';

View File

@ -26,7 +26,7 @@ import { InlineAlertComponent } from '../../../shared/inline-alert/inline-alert.
import { UserService } from '../../../user/user.service';
import { MemberService } from '../member.service';
import { UserGroup } from "../../../group/group";
import { AppConfigService } from "../../../app-config.service";
import { AppConfigService } from "../../../services/app-config.service";
import { ProjectRootInterface } from "../../../../lib/services";
import { GroupType, PROJECT_ROOTS } from "../../../../lib/entities/shared.const";
import { errorHandler } from "../../../../lib/utils/shared/shared.utils";

View File

@ -12,7 +12,7 @@ import { MessageHandlerService } from "../../shared/message-handler/message-hand
import { ConfirmationDialogService } from "../../shared/confirmation-dialog/confirmation-dialog.service";
import { SessionService } from "../../shared/session.service";
import { MemberService } from "./member.service";
import { AppConfigService } from "../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { of } from 'rxjs';
import { OperationService } from "../../../lib/components/operation/operation.service";
import { UserPermissionService } from "../../../lib/services";

View File

@ -28,7 +28,7 @@ import { AddGroupComponent } from './add-group/add-group.component';
import { AddHttpAuthGroupComponent } from './add-http-auth-group/add-http-auth-group.component';
import { MemberService } from "./member.service";
import { AddMemberComponent } from "./add-member/add-member.component";
import { AppConfigService } from "../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { map, catchError } from "rxjs/operators";
import { throwError as observableThrowError } from "rxjs";
import { OperationService } from "../../../lib/components/operation/operation.service";

View File

@ -10,7 +10,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { of } from 'rxjs';
import { ActivatedRoute } from '@angular/router';
import { SessionService } from '../../shared/session.service';
import { AppConfigService } from "../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { ProjectService, UserPermissionService } from "../../../lib/services";
import { ErrorHandler } from "../../../lib/utils/error-handler";

View File

@ -15,7 +15,7 @@ import { Component, OnInit, HostListener, AfterViewInit, OnDestroy, ChangeDetect
import { ActivatedRoute, Router } from '@angular/router';
import { Project } from '../project';
import { SessionService } from '../../shared/session.service';
import { AppConfigService } from "../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { forkJoin, Subject, Subscription } from "rxjs";
import { UserPermissionService, USERSTATICPERMISSION } from "../../../lib/services";
import { ErrorHandler } from "../../../lib/utils/error-handler";

View File

@ -27,7 +27,7 @@ import { AddMemberComponent } from './member/add-member/add-member.component';
import { AddGroupComponent } from './member/add-group/add-group.component';
import { MemberService } from './member/member.service';
import { RobotService } from './robot-account/robot-account.service';
import { ProjectRoutingResolver } from './project-routing-resolver.service';
import { ProjectRoutingResolver } from '../services/routing-resolvers/project-routing-resolver.service';
import { TargetExistsValidatorDirective } from '../shared/target-exists-directive';
import { HelmChartModule } from './helm-chart/helm-chart.module';
import { RobotAccountComponent } from './robot-account/robot-account.component';
@ -114,7 +114,6 @@ import { LastTriggerComponent } from "./webhook/last-trigger/last-trigger.compon
],
exports: [ProjectComponent, ListProjectComponent],
providers: [
ProjectRoutingResolver,
MemberService,
RobotService,
WebhookService,

View File

@ -11,24 +11,6 @@
// 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.
/*
[
{
"project_id": 1,
"owner_id": 1,
"name": "library",
"creation_time": "2017-02-10T07:57:56Z",
"creation_time_str": "",
"deleted": 0,
"owner_name": "",
"public": 1,
"togglable": true,
"update_time": "2017-02-10T07:57:56Z",
"current_user_role_id": 1,
"repo_count": 0
}
]
*/
export class Project {
project_id: number;
owner_id: number;

View File

@ -9,7 +9,7 @@ import { of } from 'rxjs';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ActivatedRoute, Router } from '@angular/router';
import { SessionService } from "../../../shared/session.service";
import { AppConfigService } from "../../../app-config.service";
import { AppConfigService } from "../../../services/app-config.service";
import { ArtifactService } from "../../../../../ng-swagger-gen/services/artifact.service";
import { ArtifactDefaultService } from "../artifact/artifact.service";
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";

View File

@ -15,7 +15,7 @@ import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ArtifactListComponent } from "./artifact-list/artifact-list.component";
import { ArtifactDefaultService } from "../artifact/artifact.service";
import { AppConfigService } from "../../../app-config.service";
import { AppConfigService } from "../../../services/app-config.service";
import { SessionService } from "../../../shared/session.service";
import { ArtifactClickEvent } from "../../../../lib/services";
import { Project } from "../../project";

View File

@ -9,7 +9,8 @@ import { ArtifactService } from "../../../../../ng-swagger-gen/services/artifact
import { ErrorHandler } from "../../../../lib/utils/error-handler";
import { TranslateFakeLoader, TranslateLoader, TranslateModule } from "@ngx-translate/core";
import { ActivatedRoute, Router } from "@angular/router";
import { AppConfigService } from "../../../app-config.service";
import { AppConfigService } from "../../../services/app-config.service";
import { Project } from "../../project";
describe('ArtifactSummaryComponent', () => {
@ -43,11 +44,7 @@ describe('ArtifactSummaryComponent', () => {
}
},
data: {
projectResolver: {
has_project_admin_role: true,
current_user_role_id: 3,
name: "demo"
}
artifactResolver: [mockedArtifact, new Project()]
}
},
data: of({

View File

@ -5,7 +5,7 @@ import { ErrorHandler } from "../../../../lib/utils/error-handler";
import { Label } from "../../../../../ng-swagger-gen/models/label";
import { ProjectService } from "../../../../lib/services";
import { ActivatedRoute, Router } from "@angular/router";
import { AppConfigService } from "../../../app-config.service";
import { AppConfigService } from "../../../services/app-config.service";
import { Project } from "../../project";
import { finalize } from "rxjs/operators";
@ -77,11 +77,9 @@ export class ArtifactSummaryComponent implements OnInit {
if (this.repositoryName && this.artifactDigest) {
const resolverData = this.route.snapshot.data;
if (resolverData) {
const pro: Project = <Project>resolverData['projectResolver'];
const pro: Project = <Project>(resolverData['artifactResolver'][1]);
this.projectName = pro.name;
if (this.projectName) {
this.getArtifactDetails();
}
this.artifact = <Artifact>(resolverData['artifactResolver'][0]);
}
}
}

View File

@ -7,7 +7,7 @@ import { RobotService } from "../robot-account.service";
import { of } from "rxjs";
import { MessageHandlerService } from "../../../shared/message-handler/message-handler.service";
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { AppConfigService } from "../../../app-config.service";
import { AppConfigService } from "../../../services/app-config.service";
import { ErrorHandler } from "../../../../lib/utils/error-handler";
describe('AddRobotComponent', () => {

View File

@ -17,7 +17,7 @@ import { TranslateService } from "@ngx-translate/core";
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';
import { AppConfigService } from "../../../app-config.service";
import { AppConfigService } from "../../../services/app-config.service";
import { ErrorHandler } from "../../../../lib/utils/error-handler";
const ONE_THOUSAND: number = 1000;
const NEVER_EXPIRED: number = -1;

View File

@ -4,7 +4,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { AppConfigService } from "../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { SummaryComponent } from './summary.component';
import { ProjectService, UserPermissionService } from "../../../lib/services";
import { ErrorHandler } from "../../../lib/utils/error-handler";

View File

@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { AppConfigService } from "../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { QUOTA_DANGER_COEFFICIENT, QUOTA_WARNING_COEFFICIENT, QuotaUnits } from "../../../lib/entities/shared.const";
import { ProjectService, UserPermissionService, USERSTATICPERMISSION } from "../../../lib/services";
import { ErrorHandler } from "../../../lib/utils/error-handler";

View File

@ -1 +0,0 @@
<replication-tasks [executionId]="executionId"></replication-tasks>

View File

@ -1,48 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ReplicationTasksPageComponent } from './replication-tasks-page.component';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { of } from 'rxjs';
describe('ReplicationTasksPageComponent', () => {
let component: ReplicationTasksPageComponent;
let fixture: ComponentFixture<ReplicationTasksPageComponent>;
let mockActivatedRoute = {
snapshot: {
params: 1
}
};
let mockRouter = null;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ReplicationTasksPageComponent],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
imports: [
TranslateModule.forRoot()
],
providers: [
{
provide: ActivatedRoute, useValue: mockActivatedRoute
},
{
provide: Router, useValue: mockRouter
},
TranslateService
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ReplicationTasksPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -1,18 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-replication-tasks-page',
templateUrl: './replication-tasks-page.component.html',
styleUrls: ['./replication-tasks-page.component.scss']
})
export class ReplicationTasksPageComponent implements OnInit {
executionId: string;
constructor(
private route: ActivatedRoute,
) { }
ngOnInit(): void {
this.executionId = this.route.snapshot.params["id"];
}
}

View File

@ -13,13 +13,10 @@
// limitations under the License.
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ReplicationManagementComponent } from './replication-management/replication-management.component';
import { ReplicationPageComponent } from './replication-page.component';
import { TotalReplicationPageComponent } from './total-replication/total-replication-page.component';
import { DestinationPageComponent } from './destination/destination-page.component';
import { ReplicationTasksPageComponent } from './replication-tasks-page/replication-tasks-page.component';
import { SharedModule } from '../shared/shared.module';
import {ReactiveFormsModule} from "@angular/forms";
@ -33,13 +30,11 @@ import {ReactiveFormsModule} from "@angular/forms";
ReplicationPageComponent,
ReplicationManagementComponent,
TotalReplicationPageComponent,
ReplicationTasksPageComponent,
DestinationPageComponent,
],
exports: [
ReplicationPageComponent,
DestinationPageComponent,
ReplicationTasksPageComponent,
TotalReplicationPageComponent,
]
})

View File

@ -9,7 +9,7 @@ import { FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import {SessionService} from "../../shared/session.service";
import {AppConfigService} from "../../app-config.service";
import {AppConfigService} from "../../services/app-config.service";
describe('TotalReplicationPageComponent', () => {
let component: TotalReplicationPageComponent;

View File

@ -14,7 +14,7 @@
import { Component } from '@angular/core';
import {Router, ActivatedRoute} from "@angular/router";
import {SessionService} from "../../shared/session.service";
import {AppConfigService} from "../../app-config.service";
import {AppConfigService} from "../../services/app-config.service";
import { ReplicationRule } from "../../../lib/services";
@Component({

View File

@ -3,8 +3,7 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/
import { CookieService } from 'ngx-cookie';
import { AppConfigService } from './app-config.service';
import { AppConfig } from './app-config';
import { Component } from '@angular/core';
import { CURRENT_BASE_HREF } from "../lib/utils/utils";
import { CURRENT_BASE_HREF } from "../../lib/utils/utils";
describe('AppConfigService', () => {
let injector: TestBed;

View File

@ -15,12 +15,12 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { CookieService } from 'ngx-cookie';
import { AppConfig } from './app-config';
import { CookieKeyOfAdmiral, HarborQueryParamKey } from './shared/shared.const';
import { maintainUrlQueryParmas } from './shared/shared.utils';
import { map, catchError } from "rxjs/operators";
import { Observable, throwError as observableThrowError } from "rxjs";
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS } from "../lib/utils/utils";
import { CONFIG_AUTH_MODE } from "../lib/entities/shared.const";
import { CookieKeyOfAdmiral, HarborQueryParamKey } from '../shared/shared.const';
import { maintainUrlQueryParmas } from '../shared/shared.utils';
import { map } from "rxjs/operators";
import { Observable } from "rxjs";
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS } from "../../lib/utils/utils";
import { CONFIG_AUTH_MODE } from "../../lib/entities/shared.const";
export const systemInfoEndpoint = CURRENT_BASE_HREF + "/systeminfo";
/**
* Declare service to handle the bootstrap options

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { ClairDBStatus } from "../lib/services";
import { ClairDBStatus } from "../../lib/services";
export class AppConfig {
with_notary: boolean;

View File

@ -0,0 +1,23 @@
import { TestBed, inject } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { ProjectService } from "../../../lib/services";
import { ArtifactService } from "../../../../ng-swagger-gen/services/artifact.service";
import { ArtifactDetailRoutingResolverService } from "./artifact-detail-routing-resolver.service";
describe('ArtifactDetailRoutingResolverService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
providers: [
{ provide: ProjectService, useValue: null },
{ provide: ArtifactService, useValue: null },
]
});
});
it('should be created', inject([ArtifactDetailRoutingResolverService], (service: ArtifactDetailRoutingResolverService) => {
expect(service).toBeTruthy();
}));
});

View File

@ -0,0 +1,56 @@
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// 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 { Injectable } from '@angular/core';
import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';
import { forkJoin, Observable, of } from 'rxjs';
import { map, catchError, mergeMap } from "rxjs/operators";
import { Artifact } from "../../../../ng-swagger-gen/models/artifact";
import { ArtifactService } from "../../../../ng-swagger-gen/services/artifact.service";
import { Project } from "../../project/project";
import { ProjectService } from "../../../lib/services";
@Injectable({
providedIn: 'root'
})
export class ArtifactDetailRoutingResolverService implements Resolve<Artifact> {
constructor(
private projectService: ProjectService,
private artifactService: ArtifactService,
private router: Router) { }
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Artifact> | any {
const projectId: string = route.params['id'];
const repositoryName: string = route.params['repo'];
const artifactDigest: string = route.params['digest'];
return this.projectService
.getProject(projectId)
.pipe(
mergeMap((project: Project) => {
return forkJoin([this.artifactService.getArtifact({
repositoryName: repositoryName,
reference: artifactDigest,
projectName: project.name,
withLabel: true,
withScanOverview: true,
withSignature: true,
withImmutableStatus: true
}), of(project)]);
}),
catchError (error => {
this.router.navigate(['/harbor', 'projects']);
return null;
})
);
}
}

View File

@ -1,8 +1,8 @@
import { TestBed, inject } from '@angular/core/testing';
import { SessionService } from '../shared/session.service';
import { SessionService } from '../../shared/session.service';
import { ProjectRoutingResolver } from './project-routing-resolver.service';
import { RouterTestingModule } from '@angular/router/testing';
import { ProjectService } from "../../lib/services";
import { ProjectService } from "../../../lib/services";
describe('ProjectRoutingResolverService', () => {
beforeEach(() => {

View File

@ -13,17 +13,19 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';
import { Project } from './project';
import { SessionService } from '../shared/session.service';
import { Project } from '../../project/project';
import { SessionService } from '../../shared/session.service';
import { Observable } from 'rxjs';
import { map, catchError } from "rxjs/operators";
import { RoleInfo } from '../shared/shared.const';
import { RoleInfo } from '../../shared/shared.const';
import { Roles } from '../shared/shared.const';
import { ProjectService } from "../../lib/services";
import { Roles } from '../../shared/shared.const';
import { ProjectService } from "../../../lib/services";
@Injectable()
@Injectable({
providedIn: 'root'
})
export class ProjectRoutingResolver implements Resolve<Project> {
constructor(

View File

@ -0,0 +1,21 @@
import { TestBed, inject } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { ReplicationService } from "../../../lib/services";
import { ReplicationTasksRoutingResolverService } from "./replication-tasks-routing-resolver.service";
describe('ReplicationTasksRoutingResolverService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
providers: [
{ provide: ReplicationService, useValue: null },
]
});
});
it('should be created', inject([ReplicationTasksRoutingResolverService], (service: ReplicationTasksRoutingResolverService) => {
expect(service).toBeTruthy();
}));
});

View File

@ -0,0 +1,46 @@
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// 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 { Injectable } from '@angular/core';
import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { map, catchError } from "rxjs/operators";
import { ReplicationJob, ReplicationService } from "../../../lib/services";
@Injectable({
providedIn: 'root'
})
export class ReplicationTasksRoutingResolverService implements Resolve<ReplicationJob> {
constructor(
private replicationService: ReplicationService,
private router: Router) { }
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<ReplicationJob> | any {
// Support both parameters and query parameters
let executionId = route.params['id'];
if (!executionId) {
executionId = route.queryParams['project_id'];
}
return this.replicationService.getExecutionById(executionId)
.pipe(map((res: ReplicationJob) => {
if (!res) {
this.router.navigate(['/harbor', 'projects']);
}
return res;
}), catchError (error => {
this.router.navigate(['/harbor', 'projects']);
return null;
}));
}
}

View File

@ -1,7 +1,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule, TranslateService } from "@ngx-translate/core";
import { AppConfigService } from '../../app-config.service';
import { SkinableConfig } from "../../skinable-config.service";
import { AppConfigService } from '../../services/app-config.service';
import { SkinableConfig } from "../../services/skinable-config.service";
import { AboutDialogComponent } from './about-dialog.component';
import { ClarityModule } from "@clr/angular";

View File

@ -14,8 +14,8 @@
import { Component, OnInit } from '@angular/core';
import { TranslateService } from "@ngx-translate/core";
import { AppConfigService } from '../../app-config.service';
import { SkinableConfig } from "../../skinable-config.service";
import { AppConfigService } from '../../services/app-config.service';
import { SkinableConfig } from "../../services/skinable-config.service";
@Component({
selector: 'about-dialog',

View File

@ -1,7 +1,7 @@
import { TestBed, inject } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { SessionService } from '../../shared/session.service';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { MessageHandlerService } from '../message-handler/message-handler.service';
import { SearchTriggerService } from '../../base/global-search/search-trigger.service';
import { AuthCheckGuard } from './auth-user-activate.service';

View File

@ -21,7 +21,7 @@ import {
} from '@angular/router';
import { SessionService } from '../../shared/session.service';
import { AdmiralQueryParamKey } from '../../shared/shared.const';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { maintainUrlQueryParmas } from '../../shared/shared.utils';
import { MessageHandlerService } from '../message-handler/message-handler.service';
import { SearchTriggerService } from '../../base/global-search/search-trigger.service';

View File

@ -1,7 +1,7 @@
import { TestBed, async, inject } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { ModeGuard } from './mode-guard-activate.service';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
describe('ModeGuardActivateServiceGuard', () => {
const fakeAppConfigService = null;

View File

@ -18,7 +18,7 @@ import {
RouterStateSnapshot,
CanActivateChild
} from '@angular/router';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { Observable } from 'rxjs';
import { CommonRoutes } from "../../../lib/entities/shared.const";

View File

@ -1,7 +1,7 @@
import { TestBed, async, inject } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { OidcGuard } from './oidc-guard-active.service';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { of } from 'rxjs';
import { UserPermissionService } from "../../../lib/services";

View File

@ -19,7 +19,7 @@ import {
RouterStateSnapshot,
CanActivateChild
} from '@angular/router';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { Observable } from 'rxjs';
import { CommonRoutes } from "../../../lib/entities/shared.const";
import { UserPermissionService } from "../../../lib/services";

View File

@ -1,7 +1,7 @@
import { TestBed, inject } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { SystemAdminGuard } from './system-admin-activate.service';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { SessionService } from '../../shared/session.service';
describe('SystemAdminGuard', () => {

View File

@ -20,7 +20,7 @@ import {
NavigationExtras
} from '@angular/router';
import { SessionService } from '../../shared/session.service';
import { AppConfigService } from '../../app-config.service';
import { AppConfigService } from '../../services/app-config.service';
import { Observable } from 'rxjs';
import { CommonRoutes } from "../../../lib/entities/shared.const";

View File

@ -13,7 +13,7 @@ import { StatisticsService } from "./statistics.service";
import { SessionService } from "../session.service";
import { MessageHandlerService } from "../message-handler/message-handler.service";
import { StatisticHandler } from "./statistic-handler.service";
import { AppConfigService } from "./../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
import { Statistics } from './statistics';
import { Volumes } from './volumes';
describe('StatisticsPanelComponent', () => {

View File

@ -22,7 +22,7 @@ import { Volumes } from "./volumes";
import { MessageHandlerService } from "../message-handler/message-handler.service";
import { StatisticHandler } from "./statistic-handler.service";
import { AppConfigService } from "./../../app-config.service";
import { AppConfigService } from "../../services/app-config.service";
@Component({

View File

@ -2,10 +2,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SignInComponent } from './sign-in.component';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { RouterTestingModule } from '@angular/router/testing';
import { AppConfigService } from '../app-config.service';
import { AppConfigService } from '../services/app-config.service';
import { SessionService } from '../shared/session.service';
import { CookieService } from 'ngx-cookie';
import { SkinableConfig } from "../skinable-config.service";
import { SkinableConfig } from "../services/skinable-config.service";
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
import { ClarityModule } from "@clr/angular";
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

View File

@ -19,11 +19,11 @@ import { SessionService } from '../shared/session.service';
import { SignInCredential } from '../shared/sign-in-credential';
import { SignUpComponent } from '../account/sign-up/sign-up.component';
import { ForgotPasswordComponent } from '../account/password-setting/forgot-password/forgot-password.component';
import { AppConfigService } from '../app-config.service';
import { AppConfig } from '../app-config';
import { AppConfigService } from '../services/app-config.service';
import { AppConfig } from '../services/app-config';
import { User } from '../user/user';
import { CookieService, CookieOptions } from 'ngx-cookie';
import { SkinableConfig } from "../skinable-config.service";
import { SkinableConfig } from "../services/skinable-config.service";
import {ModalEvent} from "../base/modal-event";
import {modalEvents} from "../base/modal-events.const";
import {AboutDialogComponent} from "../shared/about-dialog/about-dialog.component";

View File

@ -6,7 +6,7 @@ import { UserService } from './user.service';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ConfirmationDialogService } from '../shared/confirmation-dialog/confirmation-dialog.service';
import { MessageHandlerService } from '../shared/message-handler/message-handler.service';
import { AppConfigService } from '../app-config.service';
import { AppConfigService } from '../services/app-config.service';
import { SessionService } from '../shared/session.service';
import { UserComponent } from './user.component';
import { OperationService } from "../../lib/components/operation/operation.service";

View File

@ -19,7 +19,7 @@ import { ConfirmationDialogService } from '../shared/confirmation-dialog/confirm
import { ConfirmationMessage } from '../shared/confirmation-dialog/confirmation-message';
import { MessageHandlerService } from '../shared/message-handler/message-handler.service';
import { SessionService } from '../shared/session.service';
import { AppConfigService } from '../app-config.service';
import { AppConfigService } from '../services/app-config.service';
import { NewUserModalComponent } from './new-user-modal.component';
import { UserService } from './user.service';
import { User } from './user';

View File

@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ClarityModule } from '@clr/angular';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { AppConfigService } from "../app-config.service";
import { AppConfigService } from "../services/app-config.service";
import { VulnerabilityPageComponent } from './vulnerability-page.component';
describe('VulnerabilityPageComponent', () => {

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { AppConfigService } from "../app-config.service";
import { AppConfigService } from "../services/app-config.service";
@Component({
selector: "vulnerability-page",

View File

@ -1,5 +1,5 @@
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ReplicationService } from "../../../services/replication.service";
import { TranslateService } from '@ngx-translate/core';
import { finalize } from "rxjs/operators";
@ -9,6 +9,7 @@ import { ReplicationJob, ReplicationTasks, Comparator, ReplicationJobItem, State
import { CustomComparator, DEFAULT_PAGE_SIZE } from "../../../utils/utils";
import { RequestQueryParams } from "../../../services/RequestQueryParams";
import { REFRESH_TIME_DIFFERENCE } from '../../../entities/shared.const';
const executionStatus = 'InProgress';
@Component({
selector: 'replication-tasks',
@ -30,7 +31,7 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy {
stopOnGoing: boolean;
executions: ReplicationJobItem[];
timerDelay: Subscription;
@Input() executionId: string;
executionId: string;
startTimeComparator: Comparator<ReplicationJob> = new CustomComparator<
ReplicationJob
>("start_time", "date");
@ -43,13 +44,19 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy {
private router: Router,
private replicationService: ReplicationService,
private errorHandler: ErrorHandler,
private route: ActivatedRoute,
) { }
ngOnInit(): void {
this.searchTask = '';
this.getExecutionDetail();
this.executionId = this.route.snapshot.params['id'];
const resolverData = this.route.snapshot.data;
if (resolverData) {
const replicationJob = <ReplicationJob>(resolverData["replicationTasksRoutingResolver"]);
this.executions = replicationJob.data;
this.clrLoadPage();
}
}
getExecutionDetail(): void {
this.inProgress = true;
if (this.executionId) {