Minor improvements
This commit is contained in:
parent
8ce74edc38
commit
8fc0b4bb05
@ -51,7 +51,7 @@ class Fetch extends Request {
|
||||
}
|
||||
|
||||
$sql = $this->user->getSQL();
|
||||
$res = $sql->select("User.uid as userId", "User.name", "User.email", "User.created_at",
|
||||
$res = $sql->select("User.uid as userId", "User.name", "User.email", "User.registered_at",
|
||||
"Group.uid as groupId", "Group.name as groupName")
|
||||
->from("User")
|
||||
->leftJoin("UserGroup", "User.uid", "UserGroup.user_id")
|
||||
@ -76,7 +76,7 @@ class Fetch extends Request {
|
||||
"uid" => $userId,
|
||||
"name" => $row["name"],
|
||||
"email" => $row["email"],
|
||||
"created_at" => $row["created_at"],
|
||||
"registered_at" => $row["registered_at"],
|
||||
"groups" => array(),
|
||||
);
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ namespace Documents\Install {
|
||||
if(is_string($sql)) {
|
||||
$msg = "Error connecting to database: $sql";
|
||||
} else if(!$sql->isConnected()) {
|
||||
if (!$sql->checkRequirements()["success"]) {
|
||||
if (!$sql->checkRequirements()) {
|
||||
$driverName = $sql->getDriverName();
|
||||
$installLink = "https://www.php.net/manual/en/$driverName.setup.php";
|
||||
$link = $this->createExternalLink($installLink);
|
||||
|
@ -31,16 +31,6 @@ class AdminDashboardBody extends Body {
|
||||
}
|
||||
}
|
||||
|
||||
private function getUsers() : array {
|
||||
$req = new \Api\User\Fetch($this->getDocument()->getUser());
|
||||
if(!$req->execute()) {
|
||||
$this->errorMessages[] = $req->getLastError();
|
||||
return array();
|
||||
} else {
|
||||
return $req->getResult()['users'];
|
||||
}
|
||||
}
|
||||
|
||||
private function getHeader() {
|
||||
|
||||
// Locale
|
||||
@ -135,6 +125,9 @@ class AdminDashboardBody extends Body {
|
||||
|
||||
private function getSidebar() {
|
||||
|
||||
$logout = L("Logout");
|
||||
$iconLogout = $this->createIcon("arrow-left", "fas", "nav-icon");
|
||||
|
||||
$menuEntries = array(
|
||||
"dashboard" => array(
|
||||
"name" => "Dashboard",
|
||||
@ -196,8 +189,12 @@ class AdminDashboardBody extends Body {
|
||||
</li>";
|
||||
}
|
||||
|
||||
$html .=
|
||||
"</ul>
|
||||
$html .= "<li class=\"nav-item\">
|
||||
<a href=\"#\" id=\"btnLogout\" class=\"nav-link\">
|
||||
$iconLogout<p>$logout</p>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</aside>";
|
||||
@ -241,8 +238,6 @@ class AdminDashboardBody extends Body {
|
||||
|
||||
private function getContent() {
|
||||
|
||||
$this->getUsers();
|
||||
|
||||
$view = $this->getView();
|
||||
$html = "<div class=\"content-wrapper p-2\">";
|
||||
|
||||
|
@ -85,13 +85,12 @@ class UserOverview extends AdminView {
|
||||
|
||||
private function getUserRows() {
|
||||
|
||||
$dateFormat = L("Y/m/d");
|
||||
$userRows = array();
|
||||
|
||||
foreach($this->users as $uid => $user) {
|
||||
$name = $user["name"];
|
||||
$email = $user["email"] ?? "";
|
||||
$registeredAt = (new DateTime($user["created_at"]))->format($dateFormat);
|
||||
$registeredAt = formatDate($user["registered_at"]);
|
||||
$groups = $this->getGroups($user["groups"]);
|
||||
|
||||
$userRows[] =
|
||||
|
@ -140,7 +140,13 @@ function dateFunction($str, $d = NULL) {
|
||||
}
|
||||
|
||||
function getPeriodString($d) {
|
||||
if(!is_a($d, "DateTime")) $d = new DateTime($d);
|
||||
|
||||
try {
|
||||
$d = new DateTime($d);
|
||||
} catch(Exception $e) {
|
||||
return L("Unknown");
|
||||
}
|
||||
|
||||
$diff = datetimeDiff(new DateTime(), $d);
|
||||
$diff = abs($diff);
|
||||
|
||||
@ -161,3 +167,27 @@ function getPeriodString($d) {
|
||||
|
||||
return L(sprintf($str, $diff));
|
||||
}
|
||||
|
||||
function formatDateTime($d) {
|
||||
$format = L("Y/m/d H:i:s");
|
||||
return apply_format($d, $format);
|
||||
}
|
||||
|
||||
function formatTime($d) {
|
||||
$format = L("H:i:s");
|
||||
return apply_format($d, $format);
|
||||
}
|
||||
|
||||
function formatDate($d) {
|
||||
$format = L("Y/m/d");
|
||||
return apply_format($d, $format);
|
||||
}
|
||||
|
||||
function apply_format($d, $fmt) {
|
||||
try {
|
||||
$dt = new DateTime($d);
|
||||
return $dt->format($fmt);
|
||||
} catch(Exception $e) {
|
||||
return L("Unknown");
|
||||
}
|
||||
}
|
||||
|
@ -48,4 +48,12 @@ $(document).ready(function() {
|
||||
alert(err);
|
||||
});
|
||||
});
|
||||
|
||||
$("#btnLogout").click(function() {
|
||||
jsCore.apiCall("/user/logout", function(data) {
|
||||
document.location = "/admin";
|
||||
}, function(err) {
|
||||
alert("err");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user