automatic redirect to /admin/dashboard

This commit is contained in:
Roman Hergenreder 2020-06-21 15:43:26 +02:00
parent 9fc9a2a43f
commit bf20318a8d
3 changed files with 19 additions and 35 deletions

@ -1,8 +1,8 @@
$(document).ready(function() {
// Login
$("#username").keypress(function(e) { if(e.which == 13) $("#password").focus(); });
$("#password").keypress(function(e) { if(e.which == 13) $("#btnLogin").click(); });
$("#username").keypress(function(e) { if(e.which === 13) $("#password").focus(); });
$("#password").keypress(function(e) { if(e.which === 13) $("#btnLogin").click(); });
$("#btnLogin").click(function() {
const username = $("#username").val();
const password = $("#password").val();
@ -26,34 +26,11 @@ $(document).ready(function() {
});
});
$("#userTableRefresh").click(function() {
let tbody = $("#userTable > tbody");
let page = parseInt($("#userPageNavigation li.active > a").text().trim());
tbody.find("tr").remove();
tbody.append("<tr><td colspan=\"4\" class=\"text-center\">Loading… " + createLoadingIcon() + "</td></tr>");
jsCore.apiCall("/user/fetch", { page: page}, function (data) {
let pageCount = data["pages"];
let users = data["users"];
let userRows = [];
// TODO: .. maybe use ts instead of plain js?
for(let userId in users) {
let user = users[userId];
userRows.push("<tr><td>" + user.name + "</td><td>" + user.email + "</td><td></td><td></td></tr>");
}
tbody.html(userRows.join(""));
}, function (err) {
$("#btnLogout").click(function() {
jsCore.apiCall("/user/logout", function(data) {
document.location = "/admin/dashboard";
}, function(err) {
alert(err);
});
});
$("#btnLogout").click(function() {
jsCore.apiCall("/user/logout", function(data) {
document.location = "/admin";
}, function(err) {
alert("err");
});
});
});

2
js/admin.min.js vendored

File diff suppressed because one or more lines are too long

@ -1,10 +1,17 @@
import * as React from "react";
import {Link} from "react-router-dom";
import {Link, useLocation, useHistory} from "react-router-dom";
import Icon from "./elements/icon";
export default class View404 extends React.Component {
render() {
return <div className={"error-page"}>
export default function View404(props) {
const location = useLocation();
const history = useHistory();
if (location.pathname === "/admin" || location.pathname === "/admin/") {
history.push("/admin/dashboard");
}
return (
<div className={"error-page"}>
<h2 className={"headline text-warning"}>404</h2>
<div className={"error-content"}>
<h3>
@ -26,5 +33,5 @@ export default class View404 extends React.Component {
</form>
</div>
</div>
}
)
}