mirror of https://github.com/hrfee/jfa-go
login, lang, and theme work. Currently only makes a request to a hello-world type endpoint to verify auth works. Accessible at /my/account.user-page
parent
54fde33a20
commit
726acb9c29
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func (app *appContext) HelloWorld(gc *gin.Context) {
|
||||
gc.JSON(200, stringResponse{"It worked!", "none"})
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<html lang="en" class="light">
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="{{ .urlBase }}/css/{{ .cssVersion }}bundle.css">
|
||||
<script>
|
||||
window.URLBase = "{{ .urlBase }}";
|
||||
window.notificationsEnabled = {{ .notifications }};
|
||||
window.emailEnabled = {{ .emailEnabled }};
|
||||
window.telegramEnabled = {{ .telegramEnabled }};
|
||||
window.discordEnabled = {{ .discordEnabled }};
|
||||
window.matrixEnabled = {{ .matrixEnabled }};
|
||||
window.ombiEnabled = {{ .ombiEnabled }};
|
||||
window.langFile = JSON.parse({{ .language }});
|
||||
window.linkResetEnabled = {{ .linkResetEnabled }};
|
||||
window.language = "{{ .langName }}";
|
||||
</script>
|
||||
{{ template "header.html" . }}
|
||||
<title>{{ .lang.Strings.pageTitle }}</title>
|
||||
</head>
|
||||
<body class="max-w-full overflow-x-hidden section">
|
||||
<div id="notification-box"></div>
|
||||
<div class="top-4 left-4 absolute">
|
||||
<span class="dropdown" tabindex="0" id="lang-dropdown">
|
||||
<span class="button ~urge dropdown-button">
|
||||
<i class="ri-global-line"></i>
|
||||
<span class="ml-2 chev"></span>
|
||||
</span>
|
||||
<div class="dropdown-display">
|
||||
<div class="card ~neutral @low">
|
||||
<label class="switch pb-4">
|
||||
<input type="radio" name="lang-time" id="lang-12h">
|
||||
<span>{{ .strings.time12h }}</span>
|
||||
</label>
|
||||
<label class="switch pb-4">
|
||||
<input type="radio" name="lang-time" id="lang-24h">
|
||||
<span>{{ .strings.time24h }}</span>
|
||||
</label>
|
||||
<div id="lang-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
<span class="button ~warning" alt="{{ .strings.theme }}" id="button-theme"><i class="ri-sun-line"></i></span>
|
||||
<span class="button ~critical @low mb-4 unfocused" id="logout-button">{{ .strings.logout }}</span>
|
||||
</div>
|
||||
{{ template "login-modal.html" . }}
|
||||
<div class="page-container">
|
||||
<div class="card @low dark:~d_neutral mb-4" id="card-user">
|
||||
Not logged in.
|
||||
</div>
|
||||
</div>
|
||||
<script src="{{ .urlBase }}/js/user.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -0,0 +1,37 @@
|
||||
import { ThemeManager } from "./modules/theme.js";
|
||||
import { lang, LangFile, loadLangSelector } from "./modules/lang.js";
|
||||
import { Modal } from "./modules/modal.js";
|
||||
import { _get, _post, notificationBox, whichAnimationEvent } from "./modules/common.js";
|
||||
import { Login } from "./modules/login.js";
|
||||
|
||||
const theme = new ThemeManager(document.getElementById("button-theme"));
|
||||
|
||||
window.lang = new lang(window.langFile as LangFile);
|
||||
|
||||
loadLangSelector("user");
|
||||
|
||||
window.animationEvent = whichAnimationEvent();
|
||||
|
||||
window.token = "";
|
||||
|
||||
window.modals = {} as Modals;
|
||||
|
||||
(() => {
|
||||
window.modals.login = new Modal(document.getElementById("modal-login"), true);
|
||||
})();
|
||||
|
||||
window.notifications = new notificationBox(document.getElementById('notification-box') as HTMLDivElement, 5);
|
||||
|
||||
const login = new Login(window.modals.login as Modal, "/my/");
|
||||
login.onLogin = () => {
|
||||
console.log("Logged in.");
|
||||
document.getElementById("card-user").textContent = "Logged In!";
|
||||
_get("/my/hello", null, (req: XMLHttpRequest) => {
|
||||
if (req.readyState == 4) {
|
||||
const card = document.getElementById("card-user");
|
||||
card.textContent = card.textContent + " got response " + req.response["response"];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
login.login("", "");
|
Loading…
Reference in new issue