From 50b07ac06e91a6b4899374309e0392fd80a3f63c Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sun, 29 Nov 2020 21:00:58 +0100 Subject: [PATCH] Fixing routing for new user module in web app --- .../archiva-web/src/app/app-routing.module.ts | 78 +++++++++---------- .../main/archiva-web/src/app/app.module.ts | 22 ++++-- .../src/app/modules/shared/shared.module.ts | 3 +- .../app/modules/user/user-routing.module.ts | 7 +- .../src/app/modules/user/user.module.ts | 6 +- 5 files changed, 63 insertions(+), 53 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts index 6e13f819d..877e4ac2a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts @@ -16,21 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from '@angular/router'; -import { AboutComponent } from './modules/shared/about/about.component'; -import { ContactComponent } from './modules/shared/contact/contact.component'; -import { HomeComponent } from './modules/shared/home/home.component'; -import { NotFoundComponent } from './modules/shared/not-found/not-found.component'; -import { LoginComponent } from "./modules/shared/login/login.component"; -import { SearchComponent } from './modules/repo/search/search.component'; +import {AboutComponent} from './modules/shared/about/about.component'; +import {ContactComponent} from './modules/shared/contact/contact.component'; +import {HomeComponent} from './modules/shared/home/home.component'; +import {NotFoundComponent} from './modules/shared/not-found/not-found.component'; +import {LoginComponent} from "./modules/shared/login/login.component"; +import {SearchComponent} from './modules/repo/search/search.component'; import {BrowseComponent} from "./modules/repo/browse/browse.component"; import {UploadComponent} from "./modules/repo/upload/upload.component"; import {ManageRolesComponent} from "./modules/user/manage-roles/manage-roles.component"; -import {SecurityConfigurationComponent} from "./modules/user/security-configuration/security-configuration.component"; import {RoutingGuardService as Guard} from "./services/routing-guard.service"; -import {UserModule} from "./modules/user/user.module"; +import {SecurityConfigurationComponent} from "./modules/user/security-configuration/security-configuration.component"; /** * You can use Guard (RoutingGuardService) for permission checking. The service needs data with one parameter 'perm', @@ -38,38 +37,37 @@ import {UserModule} from "./modules/user/user.module"; */ const routes: Routes = [ - { path: '', component: HomeComponent, - children: [ - {path:'repo/search', component: SearchComponent}, - {path:'repo/browse', component: BrowseComponent}, - {path:'repo/upload', component: UploadComponent}, - {path:'', redirectTo:'repo/search', pathMatch:'full'}, - ]}, - { path: 'users', loadChildren: () => import('./modules/user/user.module').then(m => m.UserModule) - }, - { path: 'user', component: HomeComponent,canActivate:[Guard],data:{perm: 'menu.user.section'}, - children: [ - { path: 'roles', component: ManageRolesComponent }, - { path: 'config', component: SecurityConfigurationComponent}, - ] - }, - { path: 'contact', component: ContactComponent }, - { path: 'about', component: AboutComponent }, - { path: 'login', component: LoginComponent }, - { path: 'logout', component: HomeComponent }, - { path: '**', component: NotFoundComponent } - , - { - path: '', - redirectTo: '', - pathMatch: 'full' - } + { + path: '', component: HomeComponent, + children: [ + {path: 'repo/search', component: SearchComponent}, + {path: 'repo/browse', component: BrowseComponent}, + {path: 'repo/upload', component: UploadComponent}, + {path: '', redirectTo: 'repo/search', pathMatch: 'full'}, + ] + }, + + { + path: 'user', component: HomeComponent,canActivate:[Guard],data:{perm: 'menu.user.section'}, + children: [ + {path: 'users', loadChildren: () => import('./modules/user/user.module').then(m => m.UserModule)}, + {path: 'roles', component: ManageRolesComponent}, + {path: 'config', component: SecurityConfigurationComponent}, + ] + }, + {path: 'contact', component: ContactComponent}, + {path: 'about', component: AboutComponent}, + {path: 'login', component: LoginComponent}, + {path: 'logout', component: HomeComponent}, + {path: '**', component: NotFoundComponent} + ]; @NgModule({ - imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' }), UserModule], - exports: [RouterModule], - declarations: [] + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule], + declarations: [] }) -export class AppRoutingModule { } +export class AppRoutingModule { +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts index 73bfc21c2..91332a446 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts @@ -18,8 +18,8 @@ */ import {BrowserModule} from '@angular/platform-browser'; import {NgModule} from '@angular/core'; -import {HttpClientModule} from '@angular/common/http'; -import {MESSAGE_FORMAT_CONFIG} from 'ngx-translate-messageformat-compiler'; +import {HttpClient, HttpClientModule} from '@angular/common/http'; +import {MESSAGE_FORMAT_CONFIG, TranslateMessageFormatCompiler} from 'ngx-translate-messageformat-compiler'; import {AppRoutingModule} from './app-routing.module'; import {AppComponent} from './app.component'; @@ -37,8 +37,8 @@ import {BrowseComponent} from './modules/repo/browse/browse.component'; import {UploadComponent} from './modules/repo/upload/upload.component'; import {SecurityConfigurationComponent} from './modules/user/security-configuration/security-configuration.component'; import {CoreModule} from "./modules/core/core.module"; -import {SharedModule} from "./modules/shared/shared.module"; -import {UserModule} from "./modules/user/user.module"; +import {httpTranslateLoader, SharedModule} from "./modules/shared/shared.module"; +import {TranslateCompiler, TranslateLoader, TranslateModule} from "@ngx-translate/core"; @NgModule({ @@ -58,6 +58,17 @@ import {UserModule} from "./modules/user/user.module"; SecurityConfigurationComponent, ], imports: [ + TranslateModule.forRoot({ + compiler: { + provide: TranslateCompiler, + useClass: TranslateMessageFormatCompiler + }, + loader: { + provide: TranslateLoader, + useFactory: httpTranslateLoader, + deps: [HttpClient] + } + }), BrowserModule, AppRoutingModule, FormsModule, @@ -65,8 +76,7 @@ import {UserModule} from "./modules/user/user.module"; HttpClientModule, CoreModule, - SharedModule, - UserModule + SharedModule ], providers: [ { provide: MESSAGE_FORMAT_CONFIG, useValue: { locales: ['en', 'de'] }} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/shared.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/shared.module.ts index 93ae0df31..cf7ef71f7 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/shared.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/shared.module.ts @@ -27,7 +27,6 @@ import {TranslateMessageFormatCompiler} from "ngx-translate-messageformat-compil import {HttpClient} from "@angular/common/http"; import {TranslateHttpLoader} from "@ngx-translate/http-loader"; import {RouterModule} from "@angular/router"; -import {FormsModule} from "@angular/forms"; @@ -52,7 +51,7 @@ import {FormsModule} from "@angular/forms"; RouterModule, NgbPaginationModule, NgbTooltipModule, - TranslateModule.forRoot({ + TranslateModule.forChild({ compiler: { provide: TranslateCompiler, useClass: TranslateMessageFormatCompiler diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/user-routing.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/user-routing.module.ts index eaada2d68..bd88f139d 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/user-routing.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/user-routing.module.ts @@ -23,6 +23,8 @@ import { ManageUsersListComponent } from './users/manage-users-list/manage-users import { ManageUsersAddComponent } from './users/manage-users-add/manage-users-add.component'; import { ManageUsersEditComponent } from './users/manage-users-edit/manage-users-edit.component'; import { ManageUsersDeleteComponent } from './users/manage-users-delete/manage-users-delete.component'; +import {SharedModule} from "../shared/shared.module"; +import {TranslateModule} from "@ngx-translate/core"; /** @@ -31,8 +33,7 @@ import { ManageUsersDeleteComponent } from './users/manage-users-delete/manage-u */ const routes: Routes = [ - { path: 'users', component: ManageUsersComponent, - data: { perm: 'menu.user.manage' }, + { path: '', component: ManageUsersComponent, children: [ {path: 'list', component: ManageUsersListComponent}, {path: 'add', component: ManageUsersAddComponent}, @@ -45,7 +46,7 @@ const routes: Routes = [ @NgModule({ imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + exports: [], declarations: [] }) export class UserRoutingModule { } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/user.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/user.module.ts index 5757b3d9e..a5cc6edfd 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/user.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/user/user.module.ts @@ -26,6 +26,8 @@ import {SharedModule} from "../shared/shared.module"; import {FormsModule, ReactiveFormsModule} from "@angular/forms"; import {ManageUsersDeleteComponent} from './users/manage-users-delete/manage-users-delete.component'; import {UserRoutingModule} from "./user-routing.module"; +import {TranslateLoader, TranslateModule } from '@ngx-translate/core'; +import { HttpClient } from '@angular/common/http'; @NgModule({ @@ -44,10 +46,10 @@ import {UserRoutingModule} from "./user-routing.module"; ], imports: [ CommonModule, - UserRoutingModule, SharedModule, FormsModule, - ReactiveFormsModule + ReactiveFormsModule, + UserRoutingModule ] }) export class UserModule { -- 2.39.5