automatic redirect to /admin/dashboard
This commit is contained in:
parent
9fc9a2a43f
commit
bf20318a8d
35
js/admin.js
35
js/admin.js
@ -1,8 +1,8 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
$("#username").keypress(function(e) { if(e.which == 13) $("#password").focus(); });
|
$("#username").keypress(function(e) { if(e.which === 13) $("#password").focus(); });
|
||||||
$("#password").keypress(function(e) { if(e.which == 13) $("#btnLogin").click(); });
|
$("#password").keypress(function(e) { if(e.which === 13) $("#btnLogin").click(); });
|
||||||
$("#btnLogin").click(function() {
|
$("#btnLogin").click(function() {
|
||||||
const username = $("#username").val();
|
const username = $("#username").val();
|
||||||
const password = $("#password").val();
|
const password = $("#password").val();
|
||||||
@ -26,34 +26,11 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#userTableRefresh").click(function() {
|
$("#btnLogout").click(function() {
|
||||||
let tbody = $("#userTable > tbody");
|
jsCore.apiCall("/user/logout", function(data) {
|
||||||
let page = parseInt($("#userPageNavigation li.active > a").text().trim());
|
document.location = "/admin/dashboard";
|
||||||
tbody.find("tr").remove();
|
}, function(err) {
|
||||||
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) {
|
|
||||||
alert(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
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 * as React from "react";
|
||||||
import {Link} from "react-router-dom";
|
import {Link, useLocation, useHistory} from "react-router-dom";
|
||||||
import Icon from "./elements/icon";
|
import Icon from "./elements/icon";
|
||||||
|
|
||||||
export default class View404 extends React.Component {
|
export default function View404(props) {
|
||||||
render() {
|
|
||||||
return <div className={"error-page"}>
|
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>
|
<h2 className={"headline text-warning"}>404</h2>
|
||||||
<div className={"error-content"}>
|
<div className={"error-content"}>
|
||||||
<h3>
|
<h3>
|
||||||
@ -26,5 +33,5 @@ export default class View404 extends React.Component {
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user