Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
react translations and some other stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodor Truffer committed Feb 11, 2021
1 parent 8f93af2 commit 9c5963a
Show file tree
Hide file tree
Showing 14 changed files with 239 additions and 44 deletions.
2 changes: 1 addition & 1 deletion classes/class.ilOneDriveInitGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function beforeSetContent()
$DIC->ui()->mainTemplate()->addJavaScript("./Customizing/global/plugins/Modules/Cloud/CloudHook/OneDrive/js/OneDriveList.js");
srChunkedDirectFileUploadInputGUI::loadJavaScript($DIC->ui()->mainTemplate());
$rename_url = $DIC->ctrl()->getLinkTargetByClass([ilObjCloudGUI::class, ilCloudPluginActionListGUI::class], ilOneDriveActionListGUI::CMD_INIT_RENAME, "", false, false);
$after_upload_url = $DIC->ctrl()->getLinkTargetByClass([ilObjCloudGUI::class, ilOneDriveUploadGUI::class], ilOneDriveUploadGUI::CMD_AFTER_UPLOAD, "", false, false);
$after_upload_url = $DIC->ctrl()->getLinkTargetByClass([ilObjCloudGUI::class, ilCloudPluginUploadGUI::class], ilOneDriveUploadGUI::CMD_AFTER_UPLOAD, "", false, false);
$this->tpl_file_tree->setVariable(
'PLUGIN_AFTER_CONTENT',
'<script type="text/javascript">' .
Expand Down
6 changes: 5 additions & 1 deletion classes/class.ilOneDriveSettingsGUI.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use srag\Plugins\OneDrive\EventLog\UI\EventLogTableUI;

require_once('./Customizing/global/plugins/Modules/Cloud/CloudHook/OneDrive/classes/Client/class.exodPath.php');

/**
Expand Down Expand Up @@ -101,7 +103,9 @@ protected function showLogs()
global $DIC;
$DIC->tabs()->activateTab('settings');
$this->initSubtabs(self::SUBTAB_LOGS);

$DIC->ui()->mainTemplate()->setContent(
(new EventLogTableUI($DIC))->render()
);
}

protected function initSubtabs(string $active)
Expand Down
1 change: 1 addition & 0 deletions src/EventLog/EventLogEntryAR.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use ActiveRecord;
use ilCloudException;
use stdClass;

/**
* Class EventLogEntry
Expand Down
9 changes: 4 additions & 5 deletions src/EventLog/EventLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class EventLogger
{
public static function logUploadStarted(
int $user_id,
string $file_path,
string $file_path
) {
self::log(
$user_id,
Expand All @@ -35,8 +35,7 @@ public static function logUploadComplete(

public static function logUploadAborted(
int $user_id,
string $file_path,
string $parent
string $file_path
) {
self::log(
$user_id,
Expand All @@ -54,7 +53,7 @@ public static function logObjectDeleted(
) {
self::log(
$user_id,
EventType::uploadAborted(),
EventType::objectDeleted(),
$object_path,
$object_type,
[]
Expand All @@ -69,7 +68,7 @@ public static function logObjectRenamed(
) {
self::log(
$user_id,
EventType::uploadAborted(),
EventType::objectRenamed(),
$object_path_old,
$object_type,
['new_name' => $object_name_new]
Expand Down
32 changes: 32 additions & 0 deletions src/EventLog/UI/EventLogTableUI.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
<?php
namespace srag\Plugins\OneDrive\EventLog\UI;

use srag\Plugins\OneDrive\EventLog\EventLogEntryAR;
use ilTemplate;
use ILIAS\DI\Container;

/**
* Class EventLogTableUI
* @author Theodor Truffer <[email protected]>
*/
class EventLogTableUI
{
/**
* @var Container
*/
protected $dic;

/**
* EventLogTableUI constructor.
* @param Container $dic
*/
public function __construct(Container $dic)
{
$this->dic = $dic;
}

public function render() : string
{
$tpl = new ilTemplate(__DIR__ . '/table/build/index.html', false, false);
$data = array_map(function($entry) {
return array_map(function($value) {
return $value[1];
}, $entry->getArrayForConnector());
}, EventLogEntryAR::get());
return '<script type="application/javascript">' .
'window.exod_log_data = ' . json_encode(array_values($data)) . ';' .
'window.lng = "' . $this->dic->language()->getLangKey() . '";' .
'</script>'
. $tpl->get();
}
}
69 changes: 69 additions & 0 deletions src/EventLog/UI/table/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/EventLog/UI/table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"@types/react": "^17.0.1",
"@types/react-dom": "^17.0.0",
"antd-data-table": "^1.0.1",
"i18next": "^19.8.7",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-i18next": "^11.8.6",
"react-scripts": "4.0.2",
"typescript": "^4.1.4",
"web-vitals": "^1.1.0"
Expand Down
30 changes: 30 additions & 0 deletions src/EventLog/UI/table/src/Columns.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const columns: {
dataIndex: string,
key: string
}[] = [
{
dataIndex: "id",
key: "id"
},
{
dataIndex: "timestamp",
key: "timestamp"
},
{
dataIndex: "event_type",
key: "event_type"
},
{
dataIndex: "path",
key: "path"
},
{
dataIndex: "object_type",
key: "object_type"
},
{
dataIndex: "additional_data",
key: "additional_data"
}
];
export default columns;
55 changes: 18 additions & 37 deletions src/EventLog/UI/table/src/DataTable.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,33 @@
import React from "react";
import { Table } from "antd";
import {Table} from "antd";
import "antd/dist/antd.css";
import columns from "./Columns";
import { withTranslation } from "react-i18next";

export default class DataTable extends React.Component<any, any> {
columns: any = [
{
title: 'Id',
dataIndex: 'id',
key: 'id'
},
{
title: 'Timestamp',
dataIndex: 'timestamp',
key: 'timestamp',
},
{
title: 'Name',
dataIndex: 'event_type',
key: 'event_type',
},
{
title: 'Path',
dataIndex: 'path',
key: 'path',
},
{
title: 'Object Type',
dataIndex: 'object_type',
key: 'object_type',
},
{
title: 'Additional Data',
dataIndex: 'additional_data',
key: 'additional_data',
}
];
class DataTable extends React.Component<any, any> {

constructor(props: any) {
super(props);
// @ts-ignore
let data: any = window.exod_log_data;
this.state = {
data: data
data: data.map((set: any) => {
set.event_type = this.props.t("event_type." + set.event_type);
set.object_type = this.props.t("object_type." + set.object_type);
return set;
})
}
}

render() {
console.log(this.state.data);
return (<Table dataSource={this.state.data} columns={this.columns} />);
return (<Table dataSource={this.state.data} columns={columns.map((val) => {
return {
dataIndex: val.dataIndex,
key: val.key,
title: this.props.t("column." + val.key)
}
})}/>);
}
}

export default withTranslation()(DataTable);
Loading

0 comments on commit 9c5963a

Please sign in to comment.