Minor improvements
This commit is contained in:
parent
8ce74edc38
commit
8fc0b4bb05
@ -51,7 +51,7 @@ class Fetch extends Request {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = $this->user->getSQL();
|
$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")
|
"Group.uid as groupId", "Group.name as groupName")
|
||||||
->from("User")
|
->from("User")
|
||||||
->leftJoin("UserGroup", "User.uid", "UserGroup.user_id")
|
->leftJoin("UserGroup", "User.uid", "UserGroup.user_id")
|
||||||
@ -76,7 +76,7 @@ class Fetch extends Request {
|
|||||||
"uid" => $userId,
|
"uid" => $userId,
|
||||||
"name" => $row["name"],
|
"name" => $row["name"],
|
||||||
"email" => $row["email"],
|
"email" => $row["email"],
|
||||||
"created_at" => $row["created_at"],
|
"registered_at" => $row["registered_at"],
|
||||||
"groups" => array(),
|
"groups" => array(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ namespace Documents\Install {
|
|||||||
if(is_string($sql)) {
|
if(is_string($sql)) {
|
||||||
$msg = "Error connecting to database: $sql";
|
$msg = "Error connecting to database: $sql";
|
||||||
} else if(!$sql->isConnected()) {
|
} else if(!$sql->isConnected()) {
|
||||||
if (!$sql->checkRequirements()["success"]) {
|
if (!$sql->checkRequirements()) {
|
||||||
$driverName = $sql->getDriverName();
|
$driverName = $sql->getDriverName();
|
||||||
$installLink = "https://www.php.net/manual/en/$driverName.setup.php";
|
$installLink = "https://www.php.net/manual/en/$driverName.setup.php";
|
||||||
$link = $this->createExternalLink($installLink);
|
$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() {
|
private function getHeader() {
|
||||||
|
|
||||||
// Locale
|
// Locale
|
||||||
@ -135,6 +125,9 @@ class AdminDashboardBody extends Body {
|
|||||||
|
|
||||||
private function getSidebar() {
|
private function getSidebar() {
|
||||||
|
|
||||||
|
$logout = L("Logout");
|
||||||
|
$iconLogout = $this->createIcon("arrow-left", "fas", "nav-icon");
|
||||||
|
|
||||||
$menuEntries = array(
|
$menuEntries = array(
|
||||||
"dashboard" => array(
|
"dashboard" => array(
|
||||||
"name" => "Dashboard",
|
"name" => "Dashboard",
|
||||||
@ -189,15 +182,19 @@ class AdminDashboardBody extends Body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$html .=
|
$html .=
|
||||||
"<li class=\"nav-item\">
|
"<li class=\"nav-item\">
|
||||||
<a href=\"?view=$view\" class=\"nav-link$active\">
|
<a href=\"?view=$view\" class=\"nav-link$active\">
|
||||||
$icon<p>$name$badge</p>
|
$icon<p>$name$badge</p>
|
||||||
</a>
|
</a>
|
||||||
</li>";
|
</li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .=
|
$html .= "<li class=\"nav-item\">
|
||||||
"</ul>
|
<a href=\"#\" id=\"btnLogout\" class=\"nav-link\">
|
||||||
|
$iconLogout<p>$logout</p>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</aside>";
|
</aside>";
|
||||||
@ -241,8 +238,6 @@ class AdminDashboardBody extends Body {
|
|||||||
|
|
||||||
private function getContent() {
|
private function getContent() {
|
||||||
|
|
||||||
$this->getUsers();
|
|
||||||
|
|
||||||
$view = $this->getView();
|
$view = $this->getView();
|
||||||
$html = "<div class=\"content-wrapper p-2\">";
|
$html = "<div class=\"content-wrapper p-2\">";
|
||||||
|
|
||||||
|
@ -85,13 +85,12 @@ class UserOverview extends AdminView {
|
|||||||
|
|
||||||
private function getUserRows() {
|
private function getUserRows() {
|
||||||
|
|
||||||
$dateFormat = L("Y/m/d");
|
|
||||||
$userRows = array();
|
$userRows = array();
|
||||||
|
|
||||||
foreach($this->users as $uid => $user) {
|
foreach($this->users as $uid => $user) {
|
||||||
$name = $user["name"];
|
$name = $user["name"];
|
||||||
$email = $user["email"] ?? "";
|
$email = $user["email"] ?? "";
|
||||||
$registeredAt = (new DateTime($user["created_at"]))->format($dateFormat);
|
$registeredAt = formatDate($user["registered_at"]);
|
||||||
$groups = $this->getGroups($user["groups"]);
|
$groups = $this->getGroups($user["groups"]);
|
||||||
|
|
||||||
$userRows[] =
|
$userRows[] =
|
||||||
|
@ -140,7 +140,13 @@ function dateFunction($str, $d = NULL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPeriodString($d) {
|
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 = datetimeDiff(new DateTime(), $d);
|
||||||
$diff = abs($diff);
|
$diff = abs($diff);
|
||||||
|
|
||||||
@ -161,3 +167,27 @@ function getPeriodString($d) {
|
|||||||
|
|
||||||
return L(sprintf($str, $diff));
|
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);
|
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