Adding loading and 404 page close #31
This commit is contained in:
parent
e957906da7
commit
d8b6db9229
@ -38,6 +38,7 @@ public class MainBot {
|
||||
public static boolean roleFlag = false;
|
||||
public static HashMap<User, UserSpamUtils> spamUtils = new HashMap<>();
|
||||
public static JDA jda;
|
||||
public static boolean ready = false;
|
||||
|
||||
|
||||
|
||||
@ -87,6 +88,7 @@ public class MainBot {
|
||||
}
|
||||
|
||||
Init.polish(jda);
|
||||
ready = true;
|
||||
|
||||
|
||||
|
||||
@ -102,8 +104,14 @@ public class MainBot {
|
||||
*/
|
||||
public static void handleCommand(CommandParser.CommandContainer cmd)
|
||||
{
|
||||
//On verifie que la commande existe
|
||||
|
||||
if(!ready)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//On verifie que la commande existe
|
||||
if (commandes.containsKey(cmd.commande))
|
||||
{
|
||||
Commande cmdObj = commandes.get(cmd.commande);
|
||||
|
23
src/main/java/net/Broken/RestApi/GeneralApiController.java
Normal file
23
src/main/java/net/Broken/RestApi/GeneralApiController.java
Normal file
@ -0,0 +1,23 @@
|
||||
package net.Broken.RestApi;
|
||||
|
||||
import net.Broken.MainBot;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/")
|
||||
public class GeneralApiController {
|
||||
@RequestMapping(value = "/isReady", method = RequestMethod.GET)
|
||||
public ResponseEntity<String> isReady(){
|
||||
if(MainBot.ready){
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
12
src/main/java/net/Broken/webView/CheckPage.java
Normal file
12
src/main/java/net/Broken/webView/CheckPage.java
Normal file
@ -0,0 +1,12 @@
|
||||
package net.Broken.webView;
|
||||
|
||||
import net.Broken.MainBot;
|
||||
|
||||
public class CheckPage {
|
||||
public static String getPageIfReady(String page){
|
||||
if(MainBot.ready)
|
||||
return page;
|
||||
else
|
||||
return "loading";
|
||||
}
|
||||
}
|
@ -11,6 +11,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
public class GeneralWebView {
|
||||
@RequestMapping("/")
|
||||
public String music(Model model){
|
||||
return "index";
|
||||
|
||||
return CheckPage.getPageIfReady("index");
|
||||
}
|
||||
@RequestMapping("/loading")
|
||||
public String loading(Model model){
|
||||
return "loading";
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
public class MusicWebView {
|
||||
@RequestMapping("/music")
|
||||
public String music(Model model){
|
||||
return "music";
|
||||
return CheckPage.getPageIfReady("music");
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ public class RegisterWebView {
|
||||
@RequestMapping("/register")
|
||||
public String music(@RequestParam(value="id", required = true, defaultValue = "") String id, Model model){
|
||||
model.addAttribute("id", id);
|
||||
return "register";
|
||||
return CheckPage.getPageIfReady("register");
|
||||
}
|
||||
}
|
||||
|
153
src/main/resources/static/error/404.html
Normal file
153
src/main/resources/static/error/404.html
Normal file
@ -0,0 +1,153 @@
|
||||
<!DOCTYPE html>
|
||||
<html >
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
|
||||
<title>Music Control - Discord Bot</title>
|
||||
<link rel="icon"
|
||||
type="image/x-icon"
|
||||
href="favicon.png"/>
|
||||
|
||||
<!-- CSS -->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
|
||||
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||
</head>
|
||||
|
||||
<body class="blue-grey lighten-5" >
|
||||
|
||||
<!--__________________________________________________________-->
|
||||
<!-- NAV BAR -->
|
||||
<!-- AND -->
|
||||
<!-- LOGIN -->
|
||||
<!--__________________________________________________________-->
|
||||
<nav class="blue-grey darken-4 z-depth-3" role="navigation">
|
||||
<div class="nav-wrapper container">
|
||||
<a id="logo-container" href="/" class="brand-logo">Discord Bot</a>
|
||||
<ul class="right hide-on-med-and-down">
|
||||
|
||||
<li >
|
||||
<a class="waves-effect waves-light sidenav-trigger" href="/" data-target="slide-out">Home</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="waves-effect waves-light" href="/music" >Music Control</a>
|
||||
</li>
|
||||
<li id="nav-bar-account">
|
||||
<a class="dropdown-account" data-activates="dropdown1"><i class="material-icons">account_box</i></a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="nav-mobile" class="side-nav">
|
||||
<li class="active">
|
||||
<a class="waves-effect waves-light sidenav-trigger" href="/" data-target="slide-out">Home</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="waves-effect waves-light sidenav-trigger" href="/music" data-target="slide-out" >Music Control</a>
|
||||
</li>
|
||||
|
||||
<!--TODO Connection mobile-->
|
||||
</ul>
|
||||
<a href="#" data-activates="nav-mobile" class="button-navbar-mobile button-collapse"><i class="material-icons">menu</i></a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Dropdown connected -->
|
||||
<ul id="dropdown_connected" class="dropdown-content ">
|
||||
<li>
|
||||
<a class="center blue-grey-text text-darken-4" id="nav-name" style="text-decoration: underline; font-weight: bold"></a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a class="center tooltipped" data-position="left" data-delay="50" data-tooltip="Under Development!">My Account</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="center tooltipped" data-position="left" data-delay="50" data-tooltip="Under Development!">My Playlists</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li><a class="center red-text" id="nav-disconnect" style="font-weight: bold">Disconnect</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<!--________________________________________-->
|
||||
<!-- Connection modal -->
|
||||
<!--________________________________________-->
|
||||
<div id="modal_connection" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="row center">
|
||||
<div class="col s12">
|
||||
<h3 class="" style="font-weight: bold">Sign in</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row center" style="margin-bottom: 0px">
|
||||
<form name="login_form" id="login_form" action="javascript:void(0);" onsubmit="tryConnection()">
|
||||
<div class="row" style="margin-bottom: 0px">
|
||||
<div class="input-field col s6 offset-s3">
|
||||
<i class="material-icons prefix">account_box</i>
|
||||
<input name="username" id="user_input" type="text" class="validate"/>
|
||||
<label for="user_input" data-error="User not registered!">User Name</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="input-field col s6 offset-s3">
|
||||
<i class="material-icons prefix">security</i>
|
||||
<input name="password" id="password_input" type="password" class="validate"/>
|
||||
<label for="password_input" data-error="Wrong password!">Password</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="margin-bottom: 10px">
|
||||
<button id="btn-submit-connect" class="btn waves-effect waves-light light-green darken-1 scale-transition scale-out" type="submit" name="action" >
|
||||
Submit<i class="material-icons right">send</i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<a class="btn waves-effect waves-light brown" href="/register">
|
||||
Create account<i class="material-icons right">person_add</i>
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!--__________________________________________________________-->
|
||||
<!-- -->
|
||||
<!-- END -->
|
||||
<!-- -->
|
||||
<!--__________________________________________________________-->
|
||||
|
||||
<div class="section no-pad-bot main" id="index-banner">
|
||||
|
||||
<div class="center row">
|
||||
<div class="row center valign-wrapper">
|
||||
<div class="col s6">
|
||||
<h1 class="red-text text-darken-2 "><b>Oops!</b></h1>
|
||||
<h2 class=" blue-grey-text "><b>Page not found!</b></h2>
|
||||
<a class="btn btn-large light-green darken-3 waves-effect" href="/">
|
||||
<i class="large material-icons">home</i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col s6">
|
||||
<img class="" src="/img/404.gif" style="border:none;outline: none">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts-->
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.js"
|
||||
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
<script src="/js/materialize.js"></script>
|
||||
<script src="/js/navabar.js"></script>
|
||||
<script src="/js/js.cookie.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
BIN
src/main/resources/static/img/404.gif
Normal file
BIN
src/main/resources/static/img/404.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 MiB |
18
src/main/resources/static/js/loading.js
Normal file
18
src/main/resources/static/js/loading.js
Normal file
@ -0,0 +1,18 @@
|
||||
$(document).ready(function () {
|
||||
setInterval("loop()",1000);
|
||||
});
|
||||
|
||||
function loop() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/api/isReady",
|
||||
success: function (data) {
|
||||
console.log("Ready");
|
||||
debugger;
|
||||
location.reload();
|
||||
}
|
||||
|
||||
}).fail(function (data) {
|
||||
console.log("Not ready");
|
||||
});
|
||||
}
|
@ -124,8 +124,9 @@
|
||||
</div>
|
||||
|
||||
<!-- Scripts-->
|
||||
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.js"
|
||||
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
|
||||
crossorigin="anonymous"></script>
|
||||
<script th:src="@{/js/materialize.js}"></script>
|
||||
<script th:src="@{/js/navabar.js}"></script>
|
||||
<script th:src="@{/js/js.cookie.js}"></script>
|
||||
|
79
src/main/resources/templates/loading.html
Normal file
79
src/main/resources/templates/loading.html
Normal file
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
|
||||
<title>Music Control - Discord Bot</title>
|
||||
<link rel="icon"
|
||||
type="image/x-icon"
|
||||
href="/favicon.png"/>
|
||||
|
||||
<!-- CSS -->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
|
||||
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||
</head>
|
||||
|
||||
<body class="blue-grey lighten-5" >
|
||||
|
||||
<!--__________________________________________________________-->
|
||||
<!-- NAV BAR -->
|
||||
<!-- AND -->
|
||||
<!-- LOGIN -->
|
||||
<!--__________________________________________________________-->
|
||||
<nav class="blue-grey darken-4 z-depth-3" role="navigation">
|
||||
<div class="nav-wrapper container">
|
||||
<a id="logo-container" href="/" class="brand-logo">Discord Bot</a>
|
||||
<ul class="right hide-on-med-and-down">
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="nav-mobile" class="side-nav">
|
||||
|
||||
</ul>
|
||||
<a href="#" data-activates="nav-mobile" class="button-navbar-mobile button-collapse"><i class="material-icons">menu</i></a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!--__________________________________________________________-->
|
||||
<!-- -->
|
||||
<!-- END -->
|
||||
<!-- -->
|
||||
<!--__________________________________________________________-->
|
||||
|
||||
<div class="section no-pad-bot main" id="index-banner">
|
||||
<div class="row center center-align">
|
||||
<h3 class="">Bot is starting</h3>
|
||||
</div>
|
||||
<div class="row center" >
|
||||
<div class="preloader-wrapper big active">
|
||||
<div class="spinner-layer spinner-blue-only">
|
||||
<div class="circle-clipper left">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="gap-patch">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="circle-clipper right">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row center center-align">
|
||||
<h3>Please wait</h3>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Scripts-->
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.js"
|
||||
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
<script th:src="@{/js/materialize.js}"></script>
|
||||
<script th:src="@{/js/loading.js}"></script>
|
||||
<script th:src="@{/js/js.cookie.js}"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -360,7 +360,9 @@
|
||||
</p>
|
||||
|
||||
<!-- Scripts-->
|
||||
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.js"
|
||||
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
<script>
|
||||
var needLogin = true;
|
||||
|
@ -191,7 +191,9 @@
|
||||
|
||||
|
||||
|
||||
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.js"
|
||||
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
|
||||
crossorigin="anonymous"></script>
|
||||
<script th:src="@{/js/materialize.js}"></script>
|
||||
<script th:src="@{/js/register.js}"></script>
|
||||
<script th:src="@{/js/navabar.js}"></script>
|
||||
|
@ -129,7 +129,9 @@
|
||||
</div>
|
||||
|
||||
<!-- Scripts-->
|
||||
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.js"
|
||||
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
<script th:src="@{/js/materialize.js}"></script>
|
||||
<script th:src="@{/js/navabar.js}"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user