This is an automated email from the ASF dual-hosted git repository. martin_s pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/archiva.git
commit 0e9352150a8f326d51c8317c5e8eefe8408bd408 Author: Martin Stockhammer <[email protected]> AuthorDate: Tue Jan 12 23:36:37 2021 +0100 Adding cache configuration --- .../services/v2/SecurityConfigurationService.java | 2 +- .../v2/DefaultSecurityConfigurationService.java | 4 +- .../cache-configuration.spec.ts} | 38 ++-------- .../cache-configuration.ts} | 37 ++-------- .../security-configuration-routing.module.ts | 2 + .../security/security-configuration.module.ts | 4 +- .../cache-setting/cache-setting.component.html | 45 ++++++++++++ .../cache-setting/cache-setting.component.scss} | 31 -------- .../cache-setting/cache-setting.component.spec.ts} | 52 ++++++-------- .../cache-setting/cache-setting.component.ts | 82 ++++++++++++++++++++++ .../ldap-security/ldap-security.component.html | 8 +-- .../ldap-security/ldap-security.component.ts | 3 + .../security-configuration.component.html | 3 + .../app/modules/shared/toast/toast.component.scss | 13 +++- .../app/modules/shared/toast/toast.component.ts | 13 ++-- .../src/app/services/security.service.ts | 17 +++++ .../archiva-web/src/app/services/toast.service.ts | 2 +- .../src/main/archiva-web/src/assets/i18n/en.json | 18 +++++ 18 files changed, 238 insertions(+), 136 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/v2/SecurityConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/v2/SecurityConfigurationService.java index 341b6b7..36dd462 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/v2/SecurityConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/v2/SecurityConfigurationService.java @@ -304,7 +304,7 @@ public interface SecurityConfigurationService content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) ) } ) - Response updateCacheConfiguration( CacheConfiguration cacheConfiguration ) throws ArchivaRestServiceException; + CacheConfiguration updateCacheConfiguration( CacheConfiguration cacheConfiguration ) throws ArchivaRestServiceException; @Path("user_managers") diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java index f059613..d5a435b 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java @@ -596,7 +596,7 @@ public class DefaultSecurityConfigurationService implements SecurityConfiguratio } @Override - public Response updateCacheConfiguration( CacheConfiguration cacheConfiguration ) throws ArchivaRestServiceException + public CacheConfiguration updateCacheConfiguration( CacheConfiguration cacheConfiguration ) throws ArchivaRestServiceException { if ( cacheConfiguration == null ) { @@ -610,7 +610,7 @@ public class DefaultSecurityConfigurationService implements SecurityConfiguratio log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration ); updateConfig( cacheConfiguration, redbackRuntimeConfiguration ); redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration ); - return Response.ok( ).build( ); + return getCacheConfiguration( ); } catch ( RepositoryAdminException e ) { diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/cache-configuration.spec.ts similarity index 52% copy from archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss copy to archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/cache-configuration.spec.ts index 878354a..42cf7c5 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/cache-configuration.spec.ts @@ -1,4 +1,4 @@ -/*! +/* * 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 @@ -15,35 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -@import '~bootstrap/scss/functions'; -@import '~bootstrap/scss/variables'; -@import '~bootstrap/scss/mixins'; -@import '~bootstrap/scss/alert'; -:host { - margin:.5em; - padding:1em; - position:fixed; - right:10px; - top:40px; - z-index:1200; -} +import { CacheConfiguration } from './cache-configuration'; -.toast { - max-width: 350px; - font-size: 0.875rem; - background-clip: padding-box; - border: 1px solid rgba(0, 0, 0, 0.1); - box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1); - border-radius: 0.5rem; -} - -ngb-toast.alert { - @extend .alert; -} - -@each $color, $value in $theme-colors { - ngb-toast.alert-#{$color} { - @include alert-variant(theme-color-level($color, $alert-bg-level), theme-color-level($color, $alert-border-level), theme-color-level($color, $alert-color-level)); - } -} +describe('CacheConfiguration', () => { + it('should create an instance', () => { + expect(new CacheConfiguration()).toBeTruthy(); + }); +}); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/cache-configuration.ts similarity index 52% copy from archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss copy to archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/cache-configuration.ts index 878354a..56cd73b 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/cache-configuration.ts @@ -1,4 +1,4 @@ -/*! +/* * 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 @@ -15,35 +15,10 @@ * specific language governing permissions and limitations * under the License. */ -@import '~bootstrap/scss/functions'; -@import '~bootstrap/scss/variables'; -@import '~bootstrap/scss/mixins'; -@import '~bootstrap/scss/alert'; -:host { - margin:.5em; - padding:1em; - position:fixed; - right:10px; - top:40px; - z-index:1200; -} - -.toast { - max-width: 350px; - font-size: 0.875rem; - background-clip: padding-box; - border: 1px solid rgba(0, 0, 0, 0.1); - box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1); - border-radius: 0.5rem; -} - -ngb-toast.alert { - @extend .alert; -} - -@each $color, $value in $theme-colors { - ngb-toast.alert-#{$color} { - @include alert-variant(theme-color-level($color, $alert-bg-level), theme-color-level($color, $alert-border-level), theme-color-level($color, $alert-color-level)); - } +export class CacheConfiguration { + time_to_idle_seconds:number=-1; + time_to_live_seconds:number=-1; + max_entries_in_memory:number = -1; + max_entries_on_disk:number=-1; } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration-routing.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration-routing.module.ts index edb681d..34a6e69 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration-routing.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration-routing.module.ts @@ -22,6 +22,7 @@ import {SecurityConfigurationComponent} from "./security-configuration/security- import {BaseSecurityComponent} from "./security-configuration/base-security/base-security.component"; import {LdapSecurityComponent} from "./security-configuration/ldap-security/ldap-security.component"; import {SecurityPropertiesComponent} from "@app/modules/security/security-configuration/security-properties/security-properties.component"; +import {CacheSettingComponent} from "@app/modules/security/security-configuration/cache-setting/cache-setting.component"; /** @@ -37,6 +38,7 @@ const routes: Routes = [ {path: 'base', component: BaseSecurityComponent}, {path: 'properties', component: SecurityPropertiesComponent}, {path: 'ldap', component: LdapSecurityComponent}, + {path: 'cache', component: CacheSettingComponent}, {path: '', redirectTo: 'base', pathMatch: 'full'} ] } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration.module.ts index a36d796..19001ca 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration.module.ts @@ -25,6 +25,7 @@ import {SecurityConfigurationRoutingModule} from "@app/modules/security/security import { BaseSecurityComponent } from './security-configuration/base-security/base-security.component'; import { LdapSecurityComponent } from './security-configuration/ldap-security/ldap-security.component'; import { SecurityPropertiesComponent } from './security-configuration/security-properties/security-properties.component'; +import { CacheSettingComponent } from './security-configuration/cache-setting/cache-setting.component'; @NgModule({ @@ -32,7 +33,8 @@ import { SecurityPropertiesComponent } from './security-configuration/security-p SecurityConfigurationComponent, BaseSecurityComponent, LdapSecurityComponent, - SecurityPropertiesComponent + SecurityPropertiesComponent, + CacheSettingComponent ], exports: [ SecurityConfigurationComponent diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.html new file mode 100644 index 0000000..45de5eb --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.html @@ -0,0 +1,45 @@ +<!-- + ~ 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. + --> + +<form class="mt-3 mb-3" [formGroup]="userForm" (ngSubmit)="onSubmit()"> + <p class="row col-md-10">{{'security.config.cache.explain'|translate}}</p> + <div class="form-group row col-md-10" + *ngFor="let attName of formFields"> + <label class="col-md-3 col-form-label" + for="{{attName}}" + [openDelay]="500" + [ngbTooltip]="'security.config.cache.attdesc.'+attName|translate" placement="top" + >{{'security.config.cache.attributes.' + attName |translate}}</label> + <div class="col-md-2"> + <input type="text" formControlName="{{attName}}" + id="{{attName}}" + class="form-control text-right" + > + </div> + </div> + + <div class="row col-md-10 mt-5"> + <button class="btn btn-primary col-md-2" type="submit" + [disabled]="userForm.invalid || !userForm.dirty">{{'form.button.save'|translate}}</button> + </div> + <div class="row col-md-10 mt-2"> + <div class="alert col-md-6 ml-1 alert-success" role="alert" + *ngIf="submitError">{{'security.config.cache.submit_error'|translate:{error:submitError.toString()} }}</div> + </div> + +</form> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.scss similarity index 52% copy from archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss copy to archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.scss index 878354a..343c3b1 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.scss @@ -15,35 +15,4 @@ * specific language governing permissions and limitations * under the License. */ -@import '~bootstrap/scss/functions'; -@import '~bootstrap/scss/variables'; -@import '~bootstrap/scss/mixins'; -@import '~bootstrap/scss/alert'; -:host { - margin:.5em; - padding:1em; - position:fixed; - right:10px; - top:40px; - z-index:1200; -} - -.toast { - max-width: 350px; - font-size: 0.875rem; - background-clip: padding-box; - border: 1px solid rgba(0, 0, 0, 0.1); - box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1); - border-radius: 0.5rem; -} - -ngb-toast.alert { - @extend .alert; -} - -@each $color, $value in $theme-colors { - ngb-toast.alert-#{$color} { - @include alert-variant(theme-color-level($color, $alert-bg-level), theme-color-level($color, $alert-border-level), theme-color-level($color, $alert-color-level)); - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.spec.ts similarity index 52% copy from archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss copy to archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.spec.ts index 878354a..6c6edb2 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.spec.ts @@ -1,4 +1,4 @@ -/*! +/* * 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 @@ -15,35 +15,29 @@ * specific language governing permissions and limitations * under the License. */ -@import '~bootstrap/scss/functions'; -@import '~bootstrap/scss/variables'; -@import '~bootstrap/scss/mixins'; -@import '~bootstrap/scss/alert'; -:host { - margin:.5em; - padding:1em; - position:fixed; - right:10px; - top:40px; - z-index:1200; -} +import { ComponentFixture, TestBed } from '@angular/core/testing'; -.toast { - max-width: 350px; - font-size: 0.875rem; - background-clip: padding-box; - border: 1px solid rgba(0, 0, 0, 0.1); - box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1); - border-radius: 0.5rem; -} +import { CacheSettingComponent } from './cache-setting.component'; -ngb-toast.alert { - @extend .alert; -} +describe('CacheSettingComponent', () => { + let component: CacheSettingComponent; + let fixture: ComponentFixture<CacheSettingComponent>; -@each $color, $value in $theme-colors { - ngb-toast.alert-#{$color} { - @include alert-variant(theme-color-level($color, $alert-bg-level), theme-color-level($color, $alert-border-level), theme-color-level($color, $alert-color-level)); - } -} + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ CacheSettingComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(CacheSettingComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.ts new file mode 100644 index 0000000..35578ca --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/cache-setting/cache-setting.component.ts @@ -0,0 +1,82 @@ +/* + * 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 {Component, OnInit} from '@angular/core'; +import {EditBaseComponent} from "@app/modules/shared/edit-base.component"; +import {CacheConfiguration} from "@app/model/cache-configuration"; +import {ActivatedRoute} from "@angular/router"; +import {FormBuilder} from "@angular/forms"; +import {SecurityService} from "@app/services/security.service"; +import {ToastService} from "@app/services/toast.service"; +import {HttpResponse} from "@angular/common/http"; +import {ErrorResult} from "@app/model/error-result"; + +@Component({ + selector: 'app-cache-setting', + templateUrl: './cache-setting.component.html', + styleUrls: ['./cache-setting.component.scss'] +}) +export class CacheSettingComponent extends EditBaseComponent<CacheConfiguration> implements OnInit { + formFields = ['time_to_idle_seconds', 'time_to_live_seconds', 'max_entries_in_memory', 'max_entries_on_disk']; + submitError: ErrorResult = null; + + constructor(private route: ActivatedRoute, + public fb: FormBuilder, private securityService: SecurityService, private toastService: ToastService) { + super(fb); + super.init(fb.group({ + time_to_idle_seconds: [''], + time_to_live_seconds: [''], + max_entries_in_memory: [''], + max_entries_on_disk: [''], + }, {})); + } + + ngOnInit(): void { + this.securityService.getCacheConfiguration().subscribe( + (cacheConfig: CacheConfiguration) => { + this.copyToForm(this.formFields, cacheConfig); + } + ) + } + + createEntity(): CacheConfiguration { + return new CacheConfiguration(); + } + + onSubmit() { + if (this.userForm.valid && this.userForm.dirty) { + let cacheConfig = this.copyFromForm(this.formFields) + this.securityService.updateCacheConfiguration(cacheConfig).subscribe( + (httpCacheConfig: HttpResponse<CacheConfiguration>) => { + this.userForm.reset(); + if (httpCacheConfig.body!=null) { + this.copyToForm(this.formFields, httpCacheConfig.body); + } + this.toastService.showSuccessByKey('cache-settings','security.config.cache.submit_success'); + }, + (error: ErrorResult) => { + this.submitError=error; + this.toastService.showErrorByKey('cache-settings','security.config.cache.submit_error',{error:error.toString()}); + } + ); + } else { + console.log("No changes to update"); + } + } + +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.html index aa2d706..9c23ac0 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.html +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.html @@ -25,7 +25,7 @@ [openDelay]="500" [ngbTooltip]="'security.config.ldap.attdesc.'+attName|translate" placement="top" >{{'security.config.ldap.attributes.' + attName |translate}}</label> - <div [attr.class]="attName=='port'?'col-md-3':'col-md-7'"> + <div [attr.class]="attName=='port'?'col-md-2':'col-md-7'"> <input [attr.type]="attName=='bind_password'?'password':'text'" formControlName="{{attName}}" id="{{attName}}" [ngClass]="getInputClasses(attName)" @@ -94,10 +94,10 @@ </div> - <div class="row col-md-10 mt-4"> - <button class="btn btn-primary col-md-2" type="submit" + <div class="row col-md-10 mt-5"> + <button class="btn btn-primary col-md-3" type="submit" [disabled]="checkProgress|| userForm.invalid || !userForm.dirty">{{'form.button.save'|translate}}</button> - <button class="btn btn-primary col-md-2 offset-1" type="button" (click)="checkLdapConnection()" + <button class="btn btn-primary col-md-3 offset-1" type="button" (click)="checkLdapConnection()" [disabled]="checkProgress||userForm.invalid"> <span *ngIf="checkProgress" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span *ngIf="checkProgress"> {{'form.button.checking'|translate}}</span> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.ts index 03bc343..008efbc 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.ts @@ -140,6 +140,9 @@ export class LdapSecurityComponent extends EditBaseComponent<LdapConfiguration> csClasses = []; } csClasses.push('form-control'); + if (field=='port') { + csClasses.push('text-right') + } return csClasses; } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/security-configuration.component.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/security-configuration.component.html index bcbe2c9..d294351 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/security-configuration.component.html +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/security-configuration.component.html @@ -26,6 +26,9 @@ <li class="nav-item"> <a class="nav-link" routerLink="/security/config/ldap" routerLinkActive="active" href="#">{{'security.config.ldap.head' |translate }}</a> </li> + <li class="nav-item"> + <a class="nav-link" routerLink="/security/config/cache" routerLinkActive="active" href="#">{{'security.config.cache.head' |translate }}</a> + </li> </ul> <router-outlet></router-outlet> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss index 878354a..4d0ee56 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.scss @@ -20,7 +20,7 @@ @import '~bootstrap/scss/mixins'; @import '~bootstrap/scss/alert'; -:host { +app-toasts { margin:.5em; padding:1em; position:fixed; @@ -45,5 +45,16 @@ ngb-toast.alert { @each $color, $value in $theme-colors { ngb-toast.alert-#{$color} { @include alert-variant(theme-color-level($color, $alert-bg-level), theme-color-level($color, $alert-border-level), theme-color-level($color, $alert-color-level)); + .toast-header { + display: flex; + align-items: center; + padding: $toast-padding-y $toast-padding-x; + color: theme-color-level($color, $alert-color-level) !important; + background-color: theme-color-level($color, $alert-bg-level) !important; + background-clip: padding-box; + border-bottom: $toast-border-width solid $toast-header-border-color; + @include border-top-radius(subtract($toast-border-radius, $toast-border-width)); + } } + } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.ts index 995e5d1..def16b0 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/toast/toast.component.ts @@ -16,9 +16,8 @@ * under the License. */ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit, TemplateRef, ViewEncapsulation} from '@angular/core'; import {ToastService} from "@app/services/toast.service"; -import {TemplateRef} from "@angular/core"; import {AppNotification} from "@app/model/app-notification"; @Component({ @@ -33,7 +32,11 @@ import {AppNotification} from "@app/model/app-notification"; (mouseenter)="autohide = false" (mouseleave)="autohide = true" > - <i *ngIf="toast.type=='error'" class="fas fa-exclamation-triangle"></i> + <ng-template ngbToastHeader > + <i class="fas fa-exclamation-triangle" *ngIf="toast.type=='error'" ></i> + <i class="fas fa-thumbs-up" *ngIf="toast.type=='success'" ></i> + <i class="fas fa-info" *ngIf="toast.type!='success'&&toast.type!='error'" ></i> + </ng-template> <ng-template [ngIf]="isTemplate(toast)" [ngIfElse]="text"> <ng-template [ngTemplateOutlet]="toast.body" [ngTemplateOutletContext]="toast.contextData" ></ng-template> </ng-template> @@ -41,7 +44,9 @@ import {AppNotification} from "@app/model/app-notification"; <ng-template #text>{{ toast.body }}</ng-template> </ngb-toast> `, - styleUrls:['./toast.component.scss'] + styleUrls:['./toast.component.scss'], + // Needed for styling the components + encapsulation: ViewEncapsulation.None }) export class ToastComponent implements OnInit { diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/security.service.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/security.service.ts index aef5127..2ad75f1 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/security.service.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/security.service.ts @@ -27,6 +27,7 @@ import {LdapConfiguration} from "@app/model/ldap-configuration"; import {PagedResult} from "@app/model/paged-result"; import {Role} from "@app/model/role"; import {PropertyEntry} from "@app/model/property-entry"; +import {CacheConfiguration} from "@app/model/cache-configuration"; @Injectable({ providedIn: 'root' @@ -123,4 +124,20 @@ export class SecurityService { })) } + getCacheConfiguration() : Observable<CacheConfiguration> { + return this.rest.executeRestCall<CacheConfiguration>("get", "archiva", "security/config/cache", null).pipe( + catchError((error: HttpErrorResponse) => { + return throwError(this.rest.getTranslatedErrorResult(error)); + }) + ); + } + + updateCacheConfiguration(cacheConfig:CacheConfiguration) : Observable<HttpResponse<CacheConfiguration>> { + return this.rest.executeResponseCall<CacheConfiguration>("put", "archiva", "security/config/cache", cacheConfig).pipe( + catchError((error: HttpErrorResponse) => { + return throwError(this.rest.getTranslatedErrorResult(error)); + }) + ); + } + } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/toast.service.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/toast.service.ts index f4955ef..2d515f8 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/toast.service.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/services/toast.service.ts @@ -87,7 +87,7 @@ export class ToastService { options.classname=['alert','alert-info'] options.type='success' if (!options.delay) { - options.delay=8000 + options.delay=80000 } this.show(origin,textOrTpl,options) } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/assets/i18n/en.json b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/assets/i18n/en.json index 3e415b2..744f015 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/assets/i18n/en.json +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/assets/i18n/en.json @@ -252,6 +252,24 @@ }, "edit_success": "Property has been updated", "edit_error": "Could not save the property value: {error}" + }, + "cache": { + "head": "Cache Settings", + "explain": "Lifetime and storage settings for the User Cache", + "submit_success": "The cache settings have been updated successfully", + "submit_error": "Could not update the cache setting: {error}", + "attributes" : { + "time_to_idle_seconds": "Max. idle time (s)", + "time_to_live_seconds": "Time to Live (s)", + "max_entries_in_memory": "Maximum entries in memory", + "max_entries_on_disk": "Maximum entries stored on disk" + }, + "attdesc": { + "time_to_idle_seconds": "Entries will be discarded, if they are not used for this time.", + "time_to_live_seconds": "Entries will be discarded after this time.", + "max_entries_in_memory": "Maximum number of entries that are kept in memory", + "max_entries_on_disk": "Maximum number of entries that will be persistently stored on disk" + } } } },
