Switching to snake case for v2 REST service

This commit is contained in:
Martin Stockhammer 2020-11-09 21:10:16 +01:00
parent 069e7af871
commit 544db79262
11 changed files with 60 additions and 56 deletions

View File

@ -30,7 +30,7 @@
<div class="collapse navbar-collapse" id="navbarsDefault"> <div class="collapse navbar-collapse" id="navbarsDefault">
<div class="navbar-nav ml-auto"> <div class="navbar-nav ml-auto">
<span *ngIf="auth.authenticated" class="navbar-text border-right pr-2 mr-2"> <span *ngIf="auth.authenticated" class="navbar-text border-right pr-2 mr-2">
{{user.userInfo.fullName}} {{user.userInfo.full_name}}
</span> </span>
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="nav-item active"> <li class="nav-item active">

View File

@ -17,7 +17,7 @@
*/ */
export class ErrorMessage { export class ErrorMessage {
errorKey: string; error_key: string;
args: string[]; args: string[];
message: string; message: string;
} }

View File

@ -19,9 +19,9 @@
import {ErrorMessage} from "./error-message"; import {ErrorMessage} from "./error-message";
export class ErrorResult { export class ErrorResult {
errorMessages: Array<ErrorMessage> error_messages: Array<ErrorMessage>
constructor(errorMessages: Array<ErrorMessage>) { constructor(errorMessages: Array<ErrorMessage>) {
this.errorMessages = errorMessages; this.error_messages = errorMessages;
} }
} }

View File

@ -19,6 +19,6 @@
export class Operation { export class Operation {
name: string; name: string;
description: string; description: string;
descriptionKey: string; description_key: string;
permanent: boolean; permanent: boolean;
} }

View File

@ -17,7 +17,7 @@
*/ */
export class PaginationInfo { export class PaginationInfo {
totalCount : number; total_count : number;
offset: number; offset: number;
limit: number; limit: number;
} }

View File

@ -23,7 +23,7 @@ export class Permission {
name: string; name: string;
description: string; description: string;
permanent: boolean; permanent: boolean;
descriptionKey: string; description_key: string;
operation: Operation; operation: Operation;
resource: Resource; resource: Resource;
} }

View File

@ -19,17 +19,17 @@
export class UserInfo { export class UserInfo {
user_id:string; user_id:string;
id:string; id:string;
fullName:string; full_name:string;
email:string; email:string;
validated:boolean; validated:boolean;
locked:boolean; locked:boolean;
passwordChangeRequired:boolean; password_change_required:boolean;
permanent:boolean; permanent:boolean;
timestampAccountCreation:Date; timestamp_account_creation:Date;
timestampLastLogin:Date; timestamp_last_login:Date;
timestampLastPasswordChange:Date; timestamp_last_password_change:Date;
readOnly:boolean; read_only:boolean;
userManagerId:string; user_manager_id:string;
validationToken:string; validation_token:string;
language:string; language:string;
} }

View File

@ -132,7 +132,7 @@ export class PaginatedEntitiesComponent<T> implements OnInit, FieldToggle, After
mergeMap((params: { search: string, page: number }) => { mergeMap((params: { search: string, page: number }) => {
return this.service(params.search, (params.page - 1) * this.pageSize, this.pageSize, this.sortField, this.sortOrder); return this.service(params.search, (params.page - 1) * this.pageSize, this.pageSize, this.sortField, this.sortOrder);
}), share()); }), share());
this.total$ = source.pipe(pluck('pagination', 'totalCount')); this.total$ = source.pipe(pluck('pagination', 'total_count'));
this.items$ = source.pipe(pluck('data')); this.items$ = source.pipe(pluck('data'));
} }
@ -189,6 +189,7 @@ export class PaginatedEntitiesComponent<T> implements OnInit, FieldToggle, After
this.sortFieldChange.emit(this.sortField); this.sortFieldChange.emit(this.sortField);
} }
if (sortFieldChanged || sortOrderChanged) { if (sortFieldChanged || sortOrderChanged) {
this.page = 1;
this.changePage(1); this.changePage(1);
} }
} }

View File

@ -18,43 +18,45 @@
--> -->
<app-paginated-entities [service]="service" pageSize="5" [(sortField)]="sortField" [(sortOrder)]="sortOrder" <app-paginated-entities [service]="service" pageSize="5" [(sortField)]="sortField" [(sortOrder)]="sortOrder"
#parent> #parent>
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
<thead class="thead-light"> <thead class="thead-light">
<tr sorted [sortFieldEmitter]="parent.sortFieldChange" [sortOrderEmitter]="parent.sortOrderChange" <tr sorted [sortFieldEmitter]="parent.sortFieldChange" [sortOrderEmitter]="parent.sortOrderChange"
[toggleObserver]="parent" > [toggleObserver]="parent">
<app-th-sorted [fieldArray]="['user_id']" contentText="users.list.table.head.user_id"></app-th-sorted> <app-th-sorted [fieldArray]="['user_id']" contentText="users.list.table.head.user_id"></app-th-sorted>
<app-th-sorted contentText="users.list.table.head.fullName" [fieldArray]="['fullName']" ></app-th-sorted> <app-th-sorted [fieldArray]="['full_name']" contentText="users.list.table.head.full_name" ></app-th-sorted>
<app-th-sorted contentText="users.list.table.head.email" [fieldArray]="['email']"></app-th-sorted> <app-th-sorted [fieldArray]="['email']" contentText="users.list.table.head.email" ></app-th-sorted>
<app-th-sorted [fieldArray]="['validated','user_id']"> <app-th-sorted [fieldArray]="['validated','user_id']">
<span class="fas fa-check" placement="top" <span class="fas fa-check" placement="top"
[ngbTooltip]="heads.validated" [attr.aria-label]="heads.validated"> [ngbTooltip]="heads.validated" [attr.aria-label]="heads.validated"></span>
</span> </app-th-sorted>
</app-th-sorted> <app-th-sorted [fieldArray]="['locked','user_id']"><span class="fas fa-lock" placement="top"
<th scope="col"><span class="fas fa-lock" placement="top" [ngbTooltip]="heads.locked" [attr.aria-label]="heads.locked"></span></app-th-sorted>
[ngbTooltip]="heads.locked" [attr.aria-label]="heads.locked"></span></th> <app-th-sorted [fieldArray]="['password_change_required','user_id']"><span class="fa fa-chevron-circle-right" placement="top"
<th scope="col"><span class="fa fa-chevron-circle-right" placement="top" [ngbTooltip]="heads.pwchange" [attr.aria-label]="heads.pwchange"></span>
[ngbTooltip]="heads.pwchange" [attr.aria-label]="heads.pwchange"></span> </app-th-sorted>
</th> <app-th-sorted [fieldArray]="['last_login']" contentText="users.list.table.head.last_login"></app-th-sorted>
<th scope="col">{{'users.list.table.head.lastLogin' | translate}}</th> <app-th-sorted [fieldArray]="['created']" contentText="users.list.table.head.created" ></app-th-sorted>
<app-th-sorted contentText="users.list.table.head.created" [fieldArray]="['created']" ></app-th-sorted> <app-th-sorted [fieldArray]="['last_password_change']" contentText="users.list.table.head.last_password_change"></app-th-sorted>
<th scope="col">{{'users.list.table.head.lastPwChange' | translate}}</th> </tr>
</tr> </thead>
</thead> <tbody>
<tbody> <tr *ngFor="let user of parent.items$ | async" [ngClass]="(user.permanent||user.readOnly)?'table-secondary':''">
<tr *ngFor="let user of parent.items$ | async" [ngClass]="(user.permanent||user.readOnly)?'table-secondary':''" > <td><span data-toggle="tooltip" placement="left" ngbTooltip="{{user.id}}">{{user.user_id}}</span></td>
<td><span data-toggle="tooltip" placement="left" ngbTooltip="{{user.id}}">{{user.user_id}}</span></td> <td>{{user.full_name}}</td>
<td>{{user.fullName}}</td> <td>{{user.email}}</td>
<td>{{user.email}}</td> <td><span class="far" [attr.aria-valuetext]="user.validated"
<td><span class="far" [attr.aria-valuetext]="user.validated" [ngClass]="user.validated?'fa-check-circle':'fa-circle'"></span></td> [ngClass]="user.validated?'fa-check-circle':'fa-circle'"></span></td>
<td><span class="far" [attr.aria-valuetext]="user.locked" [ngClass]="user.locked?'fa-check-circle':'fa-circle'"></span></td> <td><span class="far" [attr.aria-valuetext]="user.locked"
<td><span class="far" [attr.aria-valuetext]="user.passwordChangeRequired" [ngClass]="user.passwordChangeRequired?'fa-check-circle':'fa-circle'"></span></td> [ngClass]="user.locked?'fa-check-circle':'fa-circle'"></span></td>
<td>{{user.timestampLastLogin | date:'yyyy-MM-ddTHH:mm:ss'}}</td> <td><span class="far" [attr.aria-valuetext]="user.passwordChangeRequired"
<td>{{user.timestampAccountCreation | date : 'yyyy-MM-ddTHH:mm:ss'}}</td> [ngClass]="user.password_change_required?'fa-check-circle':'fa-circle'"></span></td>
<td>{{user.timestampLastPasswordChange| date : 'yyyy-MM-ddTHH:mm:ss'}}</td> <td>{{user.timestamp_last_login | date:'yyyy-MM-ddTHH:mm:ss'}}</td>
</tr> <td>{{user.timestamp_account_creation | date : 'yyyy-MM-ddTHH:mm:ss'}}</td>
</tbody> <td>{{user.timestamp_last_password_change| date : 'yyyy-MM-ddTHH:mm:ss'}}</td>
</table> </tr>
</tbody>
</table>
</app-paginated-entities> </app-paginated-entities>

View File

@ -57,13 +57,13 @@
"id": "ID", "id": "ID",
"user_id": "Login Name", "user_id": "Login Name",
"email": "Email", "email": "Email",
"fullName": "Name", "full_name": "Name",
"validated": "User Validated", "validated": "User Validated",
"locked": "User Locked", "locked": "User Locked",
"pwchange": "Password Change Required", "pwchange": "Password Change Required",
"lastLogin": "Last Login", "lastLogin": "Last Login",
"created": "Created", "created": "Created",
"lastPwChange": "Last Password Change" "last_password_change": "Last Password Change"
} }
} }
}, },

View File

@ -21,7 +21,7 @@
BASE_URL="http://localhost:8080/archiva" BASE_URL="http://localhost:8080/archiva"
USER_NAME="admin" USER_NAME="admin"
PASSWD="admin456" PASSWD="admin456"
USERS=25 USERS=50
#Authenticate #Authenticate
TOKEN=$(curl -s -X POST "${BASE_URL}/api/v2/redback/auth/authenticate" -H "accept: application/json" -H "Content-Type: application/json" \ TOKEN=$(curl -s -X POST "${BASE_URL}/api/v2/redback/auth/authenticate" -H "accept: application/json" -H "Content-Type: application/json" \
@ -40,7 +40,8 @@ while [ $NUM -ge 0 ]; do
curl -s -w ' - %{http_code}' -X POST "${BASE_URL}/api/v2/redback/users" -H "accept: application/json" \ curl -s -w ' - %{http_code}' -X POST "${BASE_URL}/api/v2/redback/users" -H "accept: application/json" \
-H "Authorization: Bearer ${TOKEN}" \ -H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"user_id\":\"test${SUFFIX}\",\"fullName\":\"Test User ${SUFFIX}\",\"email\":\"test${SUFFIX}@test.org\",\"validated\":true,\"locked\":false,\"passwordChangeRequired\":false,\"password\":\"test123\"}" -d "{\"user_id\":\"test${SUFFIX}\",\"full_name\":\"Test User ${SUFFIX}\",\"email\":\"test${SUFFIX}@test.org\",\"validated\":true,\"locked\":false,\"password_change_required\":false,\"password\":\"test123\"}"
NUM=$((NUM-1)) NUM=$((NUM-1))
echo " " echo " "
sleep 0.2 # Sleeping to get different creation timestamps
done done