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="navbar-nav ml-auto">
<span *ngIf="auth.authenticated" class="navbar-text border-right pr-2 mr-2">
{{user.userInfo.fullName}}
{{user.userInfo.full_name}}
</span>
<ul class="navbar-nav">
<li class="nav-item active">

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@
BASE_URL="http://localhost:8080/archiva"
USER_NAME="admin"
PASSWD="admin456"
USERS=25
USERS=50
#Authenticate
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" \
-H "Authorization: Bearer ${TOKEN}" \
-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))
echo " "
sleep 0.2 # Sleeping to get different creation timestamps
done