From 8a2fbaaa1ca2ec32d9e06683f8c68aad4a29a42d Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sun, 19 Jul 2020 13:27:03 +0200 Subject: [PATCH] Adding login service for new webapp --- .../main/archiva-web/src/app/app.module.ts | 2 + .../modules/general/login/login.component.ts | 7 +++- .../services/archiva-request.service.spec.ts | 34 ++++++++++++++++ .../app/services/archiva-request.service.ts | 40 +++++++++++++++++++ .../src/app/services/login.service.spec.ts | 34 ++++++++++++++++ .../src/app/services/login.service.ts | 34 ++++++++++++++++ .../src/environments/environment.ts | 7 ++++ .../src/main/webapp/WEB-INF/web.xml | 12 ++++++ 8 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.spec.ts create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.ts create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/login.service.spec.ts create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/login.service.ts 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 e991091b0..270aa431b 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,6 +18,7 @@ */ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; +import { HttpClientModule } from '@angular/common/http'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; @@ -43,6 +44,7 @@ import {FormsModule} from "@angular/forms"; BrowserModule, AppRoutingModule, FormsModule, + HttpClientModule, ], providers: [], bootstrap: [AppComponent] diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/login/login.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/login/login.component.ts index bb018b6a6..97c0020b8 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/login/login.component.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/general/login/login.component.ts @@ -20,6 +20,7 @@ import { Component, OnInit } from '@angular/core'; // noinspection ES6UnusedImports import { FormsModule } from "@angular/forms"; import { Logindata } from "../../../logindata"; +import { LoginService } from "../../../services/login.service"; @Component({ selector: 'app-login', @@ -36,7 +37,11 @@ export class LoginComponent implements OnInit { get diagnostic() { return JSON.stringify(this.submitted); } - constructor() { } + login(): void { + this.loginService.login(username, password); + } + + constructor(private loginService: LoginService) { } ngOnInit(): void { } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.spec.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.spec.ts new file mode 100644 index 000000000..159b1ee32 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.spec.ts @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { TestBed } from '@angular/core/testing'; + +import { ArchivaRequestService } from './archiva-request.service'; + +describe('ArchivaRequestService', () => { + let service: ArchivaRequestService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ArchivaRequestService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.ts new file mode 100644 index 000000000..8bbfc04ec --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/archiva-request.service.ts @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { HttpClient } from "@angular/common/http"; +import { environment } from "../../environments/environment"; + +@Injectable({ + providedIn: 'root' +}) +export class ArchivaRequestService { + + + executeRestCall(type: string, module: string, service: string, input: object, callback: (result: object) => void ) : void { + let modulePath = environment.application.servicePaths[module]; + let url = environment.application.baseUrl + environment.application.restPath + "/"+modulePath+"/" + service + "Service"; + if (type == "get") { + this.http.get(url,) + } else if ( type == "post") { + this.http.post(url); + } + } + + constructor(private http : HttpClient) { } +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/login.service.spec.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/login.service.spec.ts new file mode 100644 index 000000000..c75cae26b --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/login.service.spec.ts @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { TestBed } from '@angular/core/testing'; + +import { LoginService } from './login.service'; + +describe('LoginService', () => { + let service: LoginService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(LoginService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/login.service.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/login.service.ts new file mode 100644 index 000000000..99937d5c2 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/login.service.ts @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { ArchivaRequestService } from "./archiva-request.service"; + + +@Injectable({ + providedIn: 'root' +}) +export class LoginService { + + login(username: string, password: string) { + + throw new Error("Method not implemented."); + } + + constructor(private archiva : ArchivaRequestService) { } +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/environments/environment.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/environments/environment.ts index 50fea5358..605dc26cc 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/environments/environment.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/environments/environment.ts @@ -25,6 +25,13 @@ export const environment = { production: false, application: { + baseUrl: 'http://localhost:8080', + restPath: '/restServices', + servicePaths: { + archiva:"archivaServices", + redback:"redbackServices", + ui:"archivaUiServices" + }, name: 'archiva-starter', angular: 'Angular 10.0.2', bootstrap: 'Bootstrap 4.5.0', diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml index e7152779f..fa04fc605 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml @@ -145,10 +145,22 @@ 1 + + CXFServletV2 + org.apache.cxf.transport.servlet.CXFServlet + 1 + + + CXFServlet /restServices/* + + + CXFServletV2 + /api/* + index.html -- 2.39.5