Browse Source

use camelCase keys for get_users_property

pull/6491/head
Kyattsukuro 1 month ago
parent
commit
42a7b66670
  1. 14
      src/api/admin.rs
  2. 16
      src/static/templates/admin/users.hbs

14
src/api/admin.rs

@ -351,17 +351,17 @@ async fn get_users_property(users: Vec<(User, Option<SsoUser>)>, conn: &DbConn)
let mut users_json = Vec::with_capacity(users.len()); let mut users_json = Vec::with_capacity(users.len());
for (u, sso_u) in users { for (u, sso_u) in users {
let mut usr = u.to_json(conn).await; let mut usr = u.to_json(conn).await;
usr["cipher_count"] = json!(Cipher::count_owned_by_user(&u.uuid, conn).await); usr["cipherCount"] = json!(Cipher::count_owned_by_user(&u.uuid, conn).await);
usr["attachment_count"] = json!(Attachment::count_by_user(&u.uuid, conn).await); usr["attachmentCount"] = json!(Attachment::count_by_user(&u.uuid, conn).await);
usr["attachment_size"] = json!(get_display_size(Attachment::size_by_user(&u.uuid, conn).await)); usr["attachmentSize"] = json!(get_display_size(Attachment::size_by_user(&u.uuid, conn).await));
usr["user_enabled"] = json!(u.enabled); usr["userEnabled"] = json!(u.enabled);
usr["created_at"] = json!(format_naive_datetime_local(&u.created_at, DT_FMT)); usr["createdAt"] = json!(format_naive_datetime_local(&u.created_at, DT_FMT));
usr["last_active"] = match u.last_active(conn).await { usr["lastActive"] = match u.last_active(conn).await {
Some(dt) => json!(format_naive_datetime_local(&dt, DT_FMT)), Some(dt) => json!(format_naive_datetime_local(&dt, DT_FMT)),
None => json!("Never"), None => json!("Never"),
}; };
usr["sso_identifier"] = json!(sso_u.map(|u| u.identifier.to_string()).unwrap_or(String::new())); usr["ssoIdentifier"] = json!(sso_u.map(|u| u.identifier.to_string()).unwrap_or(String::new()));
users_json.push(usr); users_json.push(usr);
} }

16
src/static/templates/admin/users.hbs

@ -26,7 +26,7 @@
<strong>{{name}}</strong> <strong>{{name}}</strong>
<span class="d-block">{{email}}</span> <span class="d-block">{{email}}</span>
<span class="d-block"> <span class="d-block">
{{#unless user_enabled}} {{#unless userEnabled}}
<span class="badge bg-danger me-2" title="User is disabled">Disabled</span> <span class="badge bg-danger me-2" title="User is disabled">Disabled</span>
{{/unless}} {{/unless}}
{{#if twoFactorEnabled}} {{#if twoFactorEnabled}}
@ -43,22 +43,22 @@
</td> </td>
{{#if ../sso_enabled}} {{#if ../sso_enabled}}
<td> <td>
<span class="d-block">{{sso_identifier}}</span> <span class="d-block">{{ssoIdentifier}}</span>
</td> </td>
{{/if}} {{/if}}
<td> <td>
<span class="d-block">{{created_at}}</span> <span class="d-block">{{createdAt}}</span>
</td> </td>
<td> <td>
<span class="d-block">{{last_active}}</span> <span class="d-block">{{lastActive}}</span>
</td> </td>
<td> <td>
<span class="d-block">{{cipher_count}}</span> <span class="d-block">{{cipherCount}}</span>
</td> </td>
<td> <td>
<span class="d-block"><strong>Amount:</strong> {{attachment_count}}</span> <span class="d-block"><strong>Amount:</strong> {{attachmentCount}}</span>
{{#if attachment_count}} {{#if attachment_count}}
<span class="d-block"><strong>Size:</strong> {{attachment_size}}</span> <span class="d-block"><strong>Size:</strong> {{attachmentSize}}</span>
{{/if}} {{/if}}
</td> </td>
<td> <td>
@ -78,7 +78,7 @@
{{#if ../sso_enabled}} {{#if ../sso_enabled}}
<button type="button" class="btn btn-sm btn-link p-0 border-0 float-right" vw-delete-sso-user>Delete SSO Association</button><br> <button type="button" class="btn btn-sm btn-link p-0 border-0 float-right" vw-delete-sso-user>Delete SSO Association</button><br>
{{/if}} {{/if}}
{{#if user_enabled}} {{#if userEnabled}}
<button type="button" class="btn btn-sm btn-link p-0 border-0 float-right" vw-disable-user>Disable User</button><br> <button type="button" class="btn btn-sm btn-link p-0 border-0 float-right" vw-disable-user>Disable User</button><br>
{{else}} {{else}}
<button type="button" class="btn btn-sm btn-link p-0 border-0 float-right" vw-enable-user>Enable User</button><br> <button type="button" class="btn btn-sm btn-link p-0 border-0 float-right" vw-enable-user>Enable User</button><br>

Loading…
Cancel
Save