mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
Closes #269: translate audit log
This commit is contained in:
parent
3b281a8c3f
commit
b2dc460b4b
@ -52,7 +52,7 @@ public class AuditLogActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
// Configure the swipe refresh layout
|
||||
SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
|
||||
SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||
swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
|
||||
android.R.color.holo_green_light,
|
||||
android.R.color.holo_orange_light,
|
||||
@ -65,7 +65,7 @@ public class AuditLogActivity extends AppCompatActivity {
|
||||
});
|
||||
|
||||
// Navigate to user profile on click
|
||||
final ListView auditLogListView = (ListView) findViewById(R.id.auditLogListView);
|
||||
final ListView auditLogListView = findViewById(R.id.auditLogListView);
|
||||
auditLogListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
@ -88,15 +88,15 @@ public class AuditLogActivity extends AppCompatActivity {
|
||||
* Refresh the view.
|
||||
*/
|
||||
private void refreshView(String documentId) {
|
||||
final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
|
||||
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
|
||||
final ListView auditLogListView = (ListView) findViewById(R.id.auditLogListView);
|
||||
final SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||
final ProgressBar progressBar = findViewById(R.id.progressBar);
|
||||
final ListView auditLogListView = findViewById(R.id.auditLogListView);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
auditLogListView.setVisibility(View.GONE);
|
||||
AuditLogResource.list(this, documentId, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(JSONObject response) {
|
||||
auditLogListView.setAdapter(new AuditLogListAdapter(response.optJSONArray("logs")));
|
||||
auditLogListView.setAdapter(new AuditLogListAdapter(AuditLogActivity.this, response.optJSONArray("logs")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.sismics.docs.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -30,12 +28,19 @@ public class AuditLogListAdapter extends BaseAdapter {
|
||||
*/
|
||||
private List<JSONObject> logList;
|
||||
|
||||
/**
|
||||
* Context.
|
||||
*/
|
||||
private Context context;
|
||||
|
||||
/**
|
||||
* Audit log list adapter.
|
||||
*
|
||||
* @param context Context
|
||||
* @param logs Logs
|
||||
*/
|
||||
public AuditLogListAdapter(JSONArray logs) {
|
||||
public AuditLogListAdapter(Context context, JSONArray logs) {
|
||||
this.context = context;
|
||||
this.logList = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < logs.length(); i++) {
|
||||
@ -67,11 +72,21 @@ public class AuditLogListAdapter extends BaseAdapter {
|
||||
|
||||
// Build message
|
||||
final JSONObject log = getItem(position);
|
||||
StringBuilder message = new StringBuilder(log.optString("class"));
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
// Translate entity name
|
||||
int stringId = context.getResources().getIdentifier("auditlog_" + log.optString("class"), "string", context.getPackageName());
|
||||
if (stringId == 0) {
|
||||
message.append(log.optString("class"));
|
||||
} else {
|
||||
message.append(context.getResources().getString(stringId));
|
||||
}
|
||||
message.append(" ");
|
||||
|
||||
switch (log.optString("type")) {
|
||||
case "CREATE": message.append(" created"); break;
|
||||
case "UPDATE": message.append(" updated"); break;
|
||||
case "DELETE": message.append(" deleted"); break;
|
||||
case "CREATE": message.append(context.getResources().getString(R.string.auditlog_created)); break;
|
||||
case "UPDATE": message.append(context.getResources().getString(R.string.auditlog_updated)); break;
|
||||
case "DELETE": message.append(context.getResources().getString(R.string.auditlog_deleted)); break;
|
||||
}
|
||||
switch (log.optString("class")) {
|
||||
case "Document":
|
||||
@ -85,9 +100,9 @@ public class AuditLogListAdapter extends BaseAdapter {
|
||||
}
|
||||
|
||||
// Fill the view
|
||||
TextView usernameTextView = (TextView) view.findViewById(R.id.usernameTextView);
|
||||
TextView messageTextView = (TextView) view.findViewById(R.id.messageTextView);
|
||||
TextView dateTextView = (TextView) view.findViewById(R.id.dateTextView);
|
||||
TextView usernameTextView = view.findViewById(R.id.usernameTextView);
|
||||
TextView messageTextView = view.findViewById(R.id.messageTextView);
|
||||
TextView dateTextView = view.findViewById(R.id.dateTextView);
|
||||
usernameTextView.setText(log.optString("username"));
|
||||
messageTextView.setText(message);
|
||||
String date = DateFormat.getDateFormat(parent.getContext()).format(new Date(log.optLong("create_date")));
|
||||
|
@ -9,7 +9,6 @@
|
||||
<string name="validate_error_alphanumeric">Nur Buchstaben und Zahlen</string>
|
||||
|
||||
<!-- App -->
|
||||
<string name="app_name" translatable="false">Sismics Docs</string>
|
||||
<string name="drawer_open">Navigationsleiste öffnen</string>
|
||||
<string name="drawer_close">Navigationsleiste schließen</string>
|
||||
<string name="login_explain"><![CDATA[Um zu beginnen, müssen Sie Sismics Docs Server herunterladen und installieren <a href="https://github.com/sismics/docs">github.com/sismics/docs</a>, sowie die Login-Daten unten eingeben]]></string>
|
||||
@ -69,9 +68,6 @@
|
||||
<string name="pref_clear_history_summary">Leert die aktuellen Suchvorschläge</string>
|
||||
<string name="pref_clear_history_success">Suchvorschläge wurden gelöscht</string>
|
||||
<string name="pref_cache_size">Cache Größe</string>
|
||||
<string name="language_french" translatable="false">Français</string>
|
||||
<string name="language_english" translatable="false">English</string>
|
||||
<string name="language_german" translatable="false">Deutsch</string>
|
||||
<string name="save">Speichern</string>
|
||||
<string name="edit_document">Bearbeiten</string>
|
||||
<string name="error_editing_document">Netzwerkfehler, bitte versuchen Sie es erneut</string>
|
||||
@ -145,4 +141,19 @@
|
||||
<string name="contributors">Mitwirkende</string>
|
||||
<string name="relations">Beziehungen</string>
|
||||
|
||||
<!-- Audit log -->
|
||||
<string name="auditlog_Acl">ACL</string>
|
||||
<string name="auditlog_Comment">Kommentar</string>
|
||||
<string name="auditlog_Document">Dokument</string>
|
||||
<string name="auditlog_File">Datei</string>
|
||||
<string name="auditlog_Group">Gruppe</string>
|
||||
<string name="auditlog_Route">Workflow</string>
|
||||
<string name="auditlog_RouteModel">Workflow-Muster</string>
|
||||
<string name="auditlog_Tag">Tag</string>
|
||||
<string name="auditlog_User">Benutzer</string>
|
||||
<string name="auditlog_Webhook">Webhook</string>
|
||||
<string name="auditlog_created">erstellt</string>
|
||||
<string name="auditlog_updated">aktualisiert</string>
|
||||
<string name="auditlog_deleted">gelöscht</string>
|
||||
|
||||
</resources>
|
||||
|
@ -141,4 +141,19 @@
|
||||
<string name="contributors">Contributeurs</string>
|
||||
<string name="relations">Relations</string>
|
||||
|
||||
<!-- Audit log -->
|
||||
<string name="auditlog_Acl">ACL</string>
|
||||
<string name="auditlog_Comment">Commentaire</string>
|
||||
<string name="auditlog_Document">Document</string>
|
||||
<string name="auditlog_File">Fichier</string>
|
||||
<string name="auditlog_Group">Groupe</string>
|
||||
<string name="auditlog_Route">Workflow</string>
|
||||
<string name="auditlog_RouteModel">Modèle de workflow</string>
|
||||
<string name="auditlog_Tag">Tag</string>
|
||||
<string name="auditlog_User">Utilisateur</string>
|
||||
<string name="auditlog_Webhook">Webhook</string>
|
||||
<string name="auditlog_created">créé</string>
|
||||
<string name="auditlog_updated">mis à jour</string>
|
||||
<string name="auditlog_deleted">supprimé</string>
|
||||
|
||||
</resources>
|
||||
|
@ -145,4 +145,19 @@
|
||||
<string name="contributors">Contributors</string>
|
||||
<string name="relations">Relations</string>
|
||||
|
||||
<!-- Audit log -->
|
||||
<string name="auditlog_Acl">ACL</string>
|
||||
<string name="auditlog_Comment">Comment</string>
|
||||
<string name="auditlog_Document">Document</string>
|
||||
<string name="auditlog_File">File</string>
|
||||
<string name="auditlog_Group">Group</string>
|
||||
<string name="auditlog_Route">Workflow</string>
|
||||
<string name="auditlog_RouteModel">Workflow model</string>
|
||||
<string name="auditlog_Tag">Tag</string>
|
||||
<string name="auditlog_User">User</string>
|
||||
<string name="auditlog_Webhook">Webhook</string>
|
||||
<string name="auditlog_created">created</string>
|
||||
<string name="auditlog_updated">updated</string>
|
||||
<string name="auditlog_deleted">deleted</string>
|
||||
|
||||
</resources>
|
||||
|
@ -489,10 +489,11 @@
|
||||
"Document": "Document",
|
||||
"File": "File",
|
||||
"Group": "Group",
|
||||
"Route": "Workflow",
|
||||
"RouteModel": "Workflow model",
|
||||
"Tag": "Tag",
|
||||
"User": "User",
|
||||
"RouteModel": "Workflow model",
|
||||
"Route": "Workflow"
|
||||
"Webhook": "Webhook"
|
||||
},
|
||||
"selectrelation": {
|
||||
"typeahead": "Type a document title"
|
||||
|
Loading…
Reference in New Issue
Block a user