Refactor code structures.

This commit is contained in:
kunw 2017-02-13 18:01:48 +08:00
parent 9a97af1783
commit 4a48bbb418
36 changed files with 210 additions and 191 deletions

View File

@ -5,7 +5,9 @@ import { HttpModule } from '@angular/http';
import { ClarityModule } from 'clarity-angular'; import { ClarityModule } from 'clarity-angular';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { AccountModule } from './account/account.module'; import { AccountModule } from './account/account.module';
import { HarborShellModule } from './harbor-shell/harbor.shell.module';
import { BaseModule } from './base/base.module';
import { HarborRoutingModule } from './harbor-routing.module'; import { HarborRoutingModule } from './harbor-routing.module';
import { SharedModule } from './shared.module'; import { SharedModule } from './shared.module';
@ -16,7 +18,7 @@ import { SharedModule } from './shared.module';
imports: [ imports: [
SharedModule, SharedModule,
AccountModule, AccountModule,
HarborShellModule, BaseModule,
HarborRoutingModule HarborRoutingModule
], ],
providers: [], providers: [],

View File

@ -1,35 +1,31 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { BaseComponent } from './base.component';
import { HarborShellComponent } from './harbor-shell.component';
import { DashboardComponent } from '../dashboard/dashboard.component'; import { DashboardComponent } from '../dashboard/dashboard.component';
import { ProjectComponent } from '../project/project.component'; import { ProjectComponent } from '../project/project.component';
import { ProjectListComponent } from '../project/project-list.component';
import { ProjectDetailComponent } from '../project-detail/project-detail.component'; import { ProjectDetailComponent } from '../project/project-detail/project-detail.component';
import { RepositoryComponent } from '../repository/repository.component'; import { RepositoryComponent } from '../repository/repository.component';
import { ReplicationComponent } from '../replication/replication.component'; import { ReplicationComponent } from '../replication/replication.component';
import { MemberComponent } from '../member/member.component'; import { MemberComponent } from '../member/member.component';
import { LogComponent } from '../log/log.component'; import { LogComponent } from '../log/log.component';
const harborShellRoutes: Routes = [ const baseRoutes: Routes = [
{ {
path: 'harbor', path: 'harbor', component: BaseComponent,
component: HarborShellComponent,
children: [ children: [
{ path: 'dashboard', component: DashboardComponent }, { path: 'dashboard', component: DashboardComponent },
{ path: 'project', component: ProjectComponent } { path: 'projects', component: ProjectComponent }
] ]
} }];
];
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild(harborShellRoutes) RouterModule.forChild(baseRoutes)
], ],
exports: [ RouterModule ] exports: [ RouterModule ]
}) })
export class HarborShellRoutingModule { export class BaseRoutingModule {
} }

View File

@ -0,0 +1 @@
<harbor-shell></harbor-shell>

View File

@ -0,0 +1,9 @@
import { Component } from '@angular/core';
@Component({
selector: 'base',
templateUrl: 'base.component.html'
})
export class BaseComponent {
}

View File

@ -0,0 +1,35 @@
import { NgModule } from '@angular/core';
import { SharedModule } from '../shared.module';
import { DashboardModule } from '../dashboard/dashboard.module';
import { ProjectModule } from '../project/project.module';
import { ProjectDetailModule } from '../project/project-detail/project-detail.module';
import { NavigatorComponent } from './navigator/navigator.component';
import { GlobalSearchComponent } from './global-search/global-search.component';
import { FooterComponent } from './footer/footer.component';
import { HarborShellComponent } from './harbor-shell/harbor-shell.component';
import { BaseComponent } from './base.component';
import { BaseRoutingModule } from './base-routing.module';
@NgModule({
imports: [
SharedModule,
DashboardModule,
ProjectModule,
ProjectDetailModule,
BaseRoutingModule
],
declarations: [
BaseComponent,
NavigatorComponent,
GlobalSearchComponent,
FooterComponent,
HarborShellComponent
],
exports: [ BaseComponent ]
})
export class BaseModule {
}

View File

@ -10,7 +10,7 @@
<a class="nav-link" id="dashboard-link" [routerLink]="['/harbor', 'dashboard']" routerLinkActive="active"> <a class="nav-link" id="dashboard-link" [routerLink]="['/harbor', 'dashboard']" routerLinkActive="active">
<span class="nav-text">Dashboard</span> <span class="nav-text">Dashboard</span>
</a> </a>
<a class="nav-link" id="dashboard-link" [routerLink]="['/harbor', 'project']" routerLinkActive="active"> <a class="nav-link" id="dashboard-link" [routerLink]="['/harbor', 'projects']" routerLinkActive="active">
<span class="nav-text">Project</span> <span class="nav-text">Project</span>
</a> </a>
</div> </div>

View File

@ -5,9 +5,6 @@ import { HttpModule } from '@angular/http';
import { ClarityModule } from 'clarity-angular'; import { ClarityModule } from 'clarity-angular';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { AccountModule } from './account/account.module'; import { AccountModule } from './account/account.module';
import { HarborShellModule } from './harbor-shell/harbor.shell.module';
import { HarborRoutingModule } from './harbor-routing.module';
@NgModule({ @NgModule({
imports: [ imports: [

View File

@ -1,8 +0,0 @@
import { NgModule } from '@angular/core';
import { FooterComponent } from './footer.component';
@NgModule({
declarations: [ FooterComponent ],
exports: [ FooterComponent ]
})
export class FooterModule {}

View File

@ -1,10 +0,0 @@
import { NgModule } from '@angular/core';
import { GlobalSearchComponent } from './global-search.component';
import { SharedModule } from '../shared.module';
@NgModule({
imports: [ SharedModule ],
declarations: [ GlobalSearchComponent ],
exports: [ GlobalSearchComponent ]
})
export class GlobalSearchModule {}

View File

@ -1,30 +0,0 @@
import { NgModule } from '@angular/core';
import { NavigatorModule } from '../navigator/navigator.module';
import { GlobalSearchModule } from '../global-search/global-search.module';
import { FooterModule } from '../footer/footer.module';
import { DashboardModule } from '../dashboard/dashboard.module';
import { ProjectModule } from '../project/project.module';
import { ProjectDetailModule } from '../project-detail/project-detail.module';
import { HarborShellRoutingModule } from './harbor-shell-routing.module';
import { HarborShellComponent } from './harbor-shell.component';
import { SharedModule } from '../shared.module';
@NgModule({
imports: [
SharedModule,
GlobalSearchModule,
NavigatorModule,
FooterModule,
DashboardModule,
ProjectModule,
ProjectDetailModule,
HarborShellRoutingModule
],
declarations: [ HarborShellComponent ],
exports: [ HarborShellComponent ]
})
export class HarborShellModule {}

View File

@ -1,19 +0,0 @@
import { NgModule } from '@angular/core';
import { NavigatorComponent } from './navigator.component';
import { SharedModule } from '../shared.module';
import { GlobalSearchComponent } from '../global-search/global-search.component';
import { GlobalSearchModule } from '../global-search/global-search.module';
import { RouterModule } from '@angular/router';
@NgModule({
imports: [
SharedModule,
GlobalSearchModule,
RouterModule
],
declarations: [ NavigatorComponent ],
exports: [ NavigatorComponent ]
})
export class NavigatorModule {}

View File

@ -1,30 +0,0 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { ProjectDetailComponent } from './project-detail.component';
import { RepositoryComponent } from '../repository/repository.component';
import { ReplicationComponent } from '../replication/replication.component';
import { MemberComponent } from '../member/member.component';
import { LogComponent } from '../log/log.component';
const projectDetailRoutes: Routes = [
{
path: 'projects/:id',
component: ProjectDetailComponent,
children: [
{ path: 'repository', component: RepositoryComponent },
{ path: 'replication', component: ReplicationComponent },
{ path: 'member', component: MemberComponent },
{ path: 'log', component: LogComponent }
]
}
];
@NgModule({
imports: [
RouterModule.forChild(projectDetailRoutes)
],
exports: [ RouterModule ]
})
export class ProjectDetailRoutingModule {}

View File

@ -1,34 +0,0 @@
import { NgModule } from '@angular/core';
import { NavigatorModule } from '../navigator/navigator.module';
import { GlobalSearchModule } from '../global-search/global-search.module';
import { FooterModule } from '../footer/footer.module';
import { RepositoryModule } from '../repository/repository.module';
import { ReplicationModule } from '../replication/replication.module';
import { MemberModule } from '../member/member.module';
import { LogModule } from '../log/log.module';
import { ProjectDetailComponent } from './project-detail.component';
import { SharedModule } from '../shared.module';
import { ProjectDetailRoutingModule } from './project-detail-routing.module';
@NgModule({
imports: [
SharedModule,
GlobalSearchModule,
NavigatorModule,
FooterModule,
RepositoryModule,
ReplicationModule,
MemberModule,
LogModule,
ProjectDetailRoutingModule
],
declarations: [ ProjectDetailComponent ],
exports: [ ProjectDetailComponent ]
})
export class ProjectDetailModule {}

View File

@ -0,0 +1,25 @@
<clr-modal [(clrModalOpen)]="create_project_opened">
<h3 class="modal-title">New Project</h3>
<div class="modal-body">
<form>
<section class="form-block">
<div class="form-group">
<label for="create_project_username" class="col-md-4">Project Name</label>
<input type="text" class="col-md-8" id="create_project_username" size="20">
</div>
<div class="form-group">
<label class="col-md-4">Public</label>
<div class="checkbox-inline">
<input type="checkbox" id="create_project_public">
<label for="create_project_public"></label>
</div>
</div>
</section>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline" (click)="create_project_opened = false">Cancel</button>
<button type="button" class="btn btn-primary" (click)="create_project_opened = false">Ok</button>
</div>
</clr-modal>
<button class="btn btn-sm" (click)="create_project_opened = true">New Project</button>

View File

@ -0,0 +1,9 @@
import { Component } from '@angular/core';
@Component({
selector: 'create-project',
templateUrl: 'create-project.component.html'
})
export class CreateProjectComponent {
}

View File

@ -0,0 +1,10 @@
<clr-dropdown [clrMenuPosition]="'bottom-left'">
<button class="btn btn-sm btn-outline-primary" clrDropdownToggle>
My Projects
<clr-icon shape="caret down"></clr-icon>
</button>
<div class="dropdown-menu">
<a href="javascript:void(0)" clrDropdownItem>My Projects</a>
<a href="javascript:void(0)" clrDropdownItem>Public Projects</a>
</div>
</clr-dropdown>

View File

@ -0,0 +1,7 @@
import { Component } from '@angular/core';
@Component({
selector: 'filter-project',
templateUrl: 'filter-project.component.html'
})
export class FilterProjectComponent {}

View File

@ -7,7 +7,7 @@
<clr-dg-column>Owner</clr-dg-column> <clr-dg-column>Owner</clr-dg-column>
<clr-dg-column>Description</clr-dg-column> <clr-dg-column>Description</clr-dg-column>
<clr-dg-row *ngFor="let p of projects"> <clr-dg-row *ngFor="let p of projects">
<clr-dg-cell><a [routerLink]="['/projects', p.id, 'repository']" >{{p.name}}</a></clr-dg-cell> <clr-dg-cell><a [routerLink]="['/harbor', 'projects', p.id, 'repository']" >{{p.name}}</a></clr-dg-cell>
<clr-dg-cell>{{p.isPublic ? 'Public': 'Private'}}</clr-dg-cell> <clr-dg-cell>{{p.isPublic ? 'Public': 'Private'}}</clr-dg-cell>
<clr-dg-cell>{{p.repoCount}}</clr-dg-cell> <clr-dg-cell>{{p.repoCount}}</clr-dg-cell>
<clr-dg-cell>{{p.creationTime}}</clr-dg-cell> <clr-dg-cell>{{p.creationTime}}</clr-dg-cell>

View File

@ -1,12 +1,12 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Project } from './project'; import { Project } from '../project';
@Component({ @Component({
selector: 'project-list', selector: 'list-project',
templateUrl: 'project-list.component.html' templateUrl: 'list-project.component.html'
}) })
export class ProjectListComponent implements OnInit { export class ListProjectComponent implements OnInit {
projects: Project[]; projects: Project[];
ngOnInit(): void { ngOnInit(): void {

View File

@ -1,4 +1,3 @@
<navigator></navigator>
<h1 class="display-in-line">Project 01</h1><h6 class="display-in-line project-title">PROJECT</h6> <h1 class="display-in-line">Project 01</h1><h6 class="display-in-line project-title">PROJECT</h6>
<nav class="subnav"> <nav class="subnav">
<ul class="nav"> <ul class="nav">

View File

@ -0,0 +1,27 @@
import { NgModule } from '@angular/core';
import { SharedModule } from '../../shared.module';
import { ProjectDetailComponent } from './project-detail.component';
import { RepositoryComponent } from '../../repository/repository.component';
import { ReplicationComponent } from '../../replication/replication.component';
import { MemberComponent } from '../../member/member.component';
import { LogComponent } from '../../log/log.component';
import { RouterModule } from '@angular/router';
@NgModule({
imports: [
SharedModule,
RouterModule
],
declarations: [
ProjectDetailComponent,
RepositoryComponent,
ReplicationComponent,
MemberComponent,
LogComponent
],
exports: [ ProjectDetailComponent ]
})
export class ProjectDetailModule {}

View File

@ -0,0 +1,38 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { BaseComponent } from '../base/base.component';
import { ProjectComponent } from './project.component';
import { ProjectDetailComponent } from './project-detail/project-detail.component';
import { RepositoryComponent } from '../repository/repository.component';
import { ReplicationComponent } from '../replication/replication.component';
import { MemberComponent } from '../member/member.component';
import { LogComponent } from '../log/log.component';
const projectRoutes: Routes = [
{ path: 'harbor',
component: BaseComponent,
children: [
{ path: 'projects', component: ProjectComponent },
{
path: 'projects/:id',
component: ProjectDetailComponent,
children: [
{ path: 'repository', component: RepositoryComponent },
{ path: 'replication', component: ReplicationComponent },
{ path: 'member', component: MemberComponent },
{ path: 'log', component: LogComponent }
]
}
]
}
];
@NgModule({
imports: [
RouterModule.forChild(projectRoutes)
],
exports: [ RouterModule ]
})
export class ProjectRoutingModule {}

View File

@ -1,31 +1,7 @@
<h3>Projects</h3> <h3>Projects</h3>
<clr-modal [(clrModalOpen)]="create_project_opened">
<h3 class="modal-title">New Project</h3>
<div class="modal-body">
<form>
<section class="form-block">
<div class="form-group">
<label for="create_project_username" class="col-md-4">Project Name</label>
<input type="text" class="col-md-8" id="create_project_username" size="20">
</div>
<div class="form-group">
<label class="col-md-4">Public</label>
<div class="checkbox-inline">
<input type="checkbox" id="create_project_public">
<label for="create_project_public"></label>
</div>
</div>
</section>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline" (click)="create_project_opened = false">Cancel</button>
<button type="button" class="btn btn-primary" (click)="create_project_opened = false">Ok</button>
</div>
</clr-modal>
<div class="row flex-items-xs-between"> <div class="row flex-items-xs-between">
<div class="col-xs-4"> <div class="col-xs-4">
<button class="btn btn-sm" (click)="create_project_opened = true">New Project</button> <create-project></create-project>
</div> </div>
<div class="col-xs-4"> <div class="col-xs-4">
<clr-dropdown [clrMenuPosition]="'bottom-left'"> <clr-dropdown [clrMenuPosition]="'bottom-left'">
@ -38,9 +14,9 @@
<a href="javascript:void(0)" clrDropdownItem>Public Projects</a> <a href="javascript:void(0)" clrDropdownItem>Public Projects</a>
</div> </div>
</clr-dropdown> </clr-dropdown>
<input type="text" placeholder="Search for projects"> <search-project></search-project>
</div> </div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<project-list></project-list> <list-project></list-project>
</div> </div>
</div> </div>

View File

@ -8,9 +8,6 @@ import { Router } from '@angular/router';
styleUrls: [ 'project.css' ] styleUrls: [ 'project.css' ]
}) })
export class ProjectComponent implements OnInit { export class ProjectComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
} }

View File

@ -1,18 +1,30 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { ProjectComponent } from './project.component';
import { ProjectListComponent } from './project-list.component';
import { SharedModule } from '../shared.module'; import { SharedModule } from '../shared.module';
import { RouterModule } from '@angular/router'; import { ProjectDetailModule } from './project-detail/project-detail.module';
import { ProjectComponent } from './project.component';
import { CreateProjectComponent } from './create-project/create-project.component';
import { SearchProjectComponent } from './search-project/search-project.component';
import { FilterProjectComponent } from './filter-project/filter-project.component';
import { ListProjectComponent } from './list-project/list-project.component';
import { ProjectDetailComponent } from './project-detail/project-detail.component';
import { ProjectRoutingModule } from './project-routing.module';
@NgModule({ @NgModule({
imports: [ imports: [
SharedModule, SharedModule,
RouterModule ProjectDetailModule,
ProjectRoutingModule
], ],
declarations: [ declarations: [
ProjectComponent, ProjectComponent,
ProjectListComponent CreateProjectComponent,
SearchProjectComponent,
FilterProjectComponent,
ListProjectComponent
], ],
exports: [ ProjectComponent ] exports: [ ListProjectComponent ]
}) })
export class ProjectModule {} export class ProjectModule {}

View File

@ -0,0 +1 @@
<input type="text" placeholder="Search for projects">

View File

@ -0,0 +1,9 @@
import { Component } from '@angular/core';
@Component({
selector: 'search-project',
templateUrl: 'search-project.component.html'
})
export class SearchProjectComponent {
}