First commit
This commit is contained in:
6
resources/images/svg/twitch.svg
Normal file
6
resources/images/svg/twitch.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="256px" height="268px" viewBox="0 0 256 268" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||
<g>
|
||||
<path d="M17.4579119,0 L0,46.5559188 L0,232.757287 L63.9826001,232.757287 L63.9826001,267.690956 L98.9144853,267.690956 L133.811571,232.757287 L186.171922,232.757287 L256,162.954193 L256,0 L17.4579119,0 Z M40.7166868,23.2632364 L232.73141,23.2632364 L232.73141,151.29179 L191.992415,192.033461 L128,192.033461 L93.11273,226.918947 L93.11273,192.033461 L40.7166868,192.033461 L40.7166868,23.2632364 Z M104.724985,139.668381 L127.999822,139.668381 L127.999822,69.843872 L104.724985,69.843872 L104.724985,139.668381 Z M168.721862,139.668381 L191.992237,139.668381 L191.992237,69.843872 L168.721862,69.843872 L168.721862,139.668381 Z" fill="#5A3E85"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 921 B |
8
resources/js/app.js
vendored
Normal file
8
resources/js/app.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
require('./bootstrap');
|
||||
|
||||
import UIkit from "uikit";
|
||||
import Icons from "uikit/dist/js/uikit-icons";
|
||||
|
||||
window.UIkit = UIkit;
|
||||
|
||||
UIkit.use(Icons);
|
31
resources/js/bootstrap.js
vendored
Normal file
31
resources/js/bootstrap.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import lodash from "lodash";
|
||||
import axios from "axios";
|
||||
|
||||
window._ = lodash;
|
||||
|
||||
/**
|
||||
* We'll load the axios HTTP library which allows us to easily issue requests
|
||||
* to our Laravel back-end. This library automatically handles sending the
|
||||
* CSRF token as a header based on the value of the "XSRF" token cookie.
|
||||
*/
|
||||
|
||||
window.axios = axios;
|
||||
|
||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||
|
||||
/**
|
||||
* Echo exposes an expressive API for subscribing to channels and listening
|
||||
* for events that are broadcast by Laravel. Echo and event broadcasting
|
||||
* allows your team to easily build robust real-time web applications.
|
||||
*/
|
||||
|
||||
// import Echo from 'laravel-echo';
|
||||
|
||||
// window.Pusher = require('pusher-js');
|
||||
|
||||
// window.Echo = new Echo({
|
||||
// broadcaster: 'pusher',
|
||||
// key: process.env.MIX_PUSHER_APP_KEY,
|
||||
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
|
||||
// forceTLS: true
|
||||
// });
|
19
resources/lang/en/auth.php
Normal file
19
resources/lang/en/auth.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used during authentication for various
|
||||
| messages that we need to display to the user. You are free to modify
|
||||
| these language lines according to your application's requirements.
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => 'These credentials do not match our records.',
|
||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||
|
||||
];
|
19
resources/lang/en/pagination.php
Normal file
19
resources/lang/en/pagination.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Pagination Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used by the paginator library to build
|
||||
| the simple pagination links. You are free to change them to anything
|
||||
| you want to customize your views to better match your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'previous' => '« Previous',
|
||||
'next' => 'Next »',
|
||||
|
||||
];
|
22
resources/lang/en/passwords.php
Normal file
22
resources/lang/en/passwords.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are the default lines which match reasons
|
||||
| that are given by the password broker for a password update attempt
|
||||
| has failed, such as for an invalid token or invalid new password.
|
||||
|
|
||||
*/
|
||||
|
||||
'reset' => 'Your password has been reset!',
|
||||
'sent' => 'We have emailed your password reset link!',
|
||||
'throttled' => 'Please wait before retrying.',
|
||||
'token' => 'This password reset token is invalid.',
|
||||
'user' => "We can't find a user with that email address.",
|
||||
|
||||
];
|
151
resources/lang/en/validation.php
Normal file
151
resources/lang/en/validation.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines contain the default error messages used by
|
||||
| the validator class. Some of these rules have multiple versions such
|
||||
| as the size rules. Feel free to tweak each of these messages here.
|
||||
|
|
||||
*/
|
||||
|
||||
'accepted' => 'The :attribute must be accepted.',
|
||||
'active_url' => 'The :attribute is not a valid URL.',
|
||||
'after' => 'The :attribute must be a date after :date.',
|
||||
'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
|
||||
'alpha' => 'The :attribute may only contain letters.',
|
||||
'alpha_dash' => 'The :attribute may only contain letters, numbers, dashes and underscores.',
|
||||
'alpha_num' => 'The :attribute may only contain letters and numbers.',
|
||||
'array' => 'The :attribute must be an array.',
|
||||
'before' => 'The :attribute must be a date before :date.',
|
||||
'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
|
||||
'between' => [
|
||||
'numeric' => 'The :attribute must be between :min and :max.',
|
||||
'file' => 'The :attribute must be between :min and :max kilobytes.',
|
||||
'string' => 'The :attribute must be between :min and :max characters.',
|
||||
'array' => 'The :attribute must have between :min and :max items.',
|
||||
],
|
||||
'boolean' => 'The :attribute field must be true or false.',
|
||||
'confirmed' => 'The :attribute confirmation does not match.',
|
||||
'date' => 'The :attribute is not a valid date.',
|
||||
'date_equals' => 'The :attribute must be a date equal to :date.',
|
||||
'date_format' => 'The :attribute does not match the format :format.',
|
||||
'different' => 'The :attribute and :other must be different.',
|
||||
'digits' => 'The :attribute must be :digits digits.',
|
||||
'digits_between' => 'The :attribute must be between :min and :max digits.',
|
||||
'dimensions' => 'The :attribute has invalid image dimensions.',
|
||||
'distinct' => 'The :attribute field has a duplicate value.',
|
||||
'email' => 'The :attribute must be a valid email address.',
|
||||
'ends_with' => 'The :attribute must end with one of the following: :values.',
|
||||
'exists' => 'The selected :attribute is invalid.',
|
||||
'file' => 'The :attribute must be a file.',
|
||||
'filled' => 'The :attribute field must have a value.',
|
||||
'gt' => [
|
||||
'numeric' => 'The :attribute must be greater than :value.',
|
||||
'file' => 'The :attribute must be greater than :value kilobytes.',
|
||||
'string' => 'The :attribute must be greater than :value characters.',
|
||||
'array' => 'The :attribute must have more than :value items.',
|
||||
],
|
||||
'gte' => [
|
||||
'numeric' => 'The :attribute must be greater than or equal :value.',
|
||||
'file' => 'The :attribute must be greater than or equal :value kilobytes.',
|
||||
'string' => 'The :attribute must be greater than or equal :value characters.',
|
||||
'array' => 'The :attribute must have :value items or more.',
|
||||
],
|
||||
'image' => 'The :attribute must be an image.',
|
||||
'in' => 'The selected :attribute is invalid.',
|
||||
'in_array' => 'The :attribute field does not exist in :other.',
|
||||
'integer' => 'The :attribute must be an integer.',
|
||||
'ip' => 'The :attribute must be a valid IP address.',
|
||||
'ipv4' => 'The :attribute must be a valid IPv4 address.',
|
||||
'ipv6' => 'The :attribute must be a valid IPv6 address.',
|
||||
'json' => 'The :attribute must be a valid JSON string.',
|
||||
'lt' => [
|
||||
'numeric' => 'The :attribute must be less than :value.',
|
||||
'file' => 'The :attribute must be less than :value kilobytes.',
|
||||
'string' => 'The :attribute must be less than :value characters.',
|
||||
'array' => 'The :attribute must have less than :value items.',
|
||||
],
|
||||
'lte' => [
|
||||
'numeric' => 'The :attribute must be less than or equal :value.',
|
||||
'file' => 'The :attribute must be less than or equal :value kilobytes.',
|
||||
'string' => 'The :attribute must be less than or equal :value characters.',
|
||||
'array' => 'The :attribute must not have more than :value items.',
|
||||
],
|
||||
'max' => [
|
||||
'numeric' => 'The :attribute may not be greater than :max.',
|
||||
'file' => 'The :attribute may not be greater than :max kilobytes.',
|
||||
'string' => 'The :attribute may not be greater than :max characters.',
|
||||
'array' => 'The :attribute may not have more than :max items.',
|
||||
],
|
||||
'mimes' => 'The :attribute must be a file of type: :values.',
|
||||
'mimetypes' => 'The :attribute must be a file of type: :values.',
|
||||
'min' => [
|
||||
'numeric' => 'The :attribute must be at least :min.',
|
||||
'file' => 'The :attribute must be at least :min kilobytes.',
|
||||
'string' => 'The :attribute must be at least :min characters.',
|
||||
'array' => 'The :attribute must have at least :min items.',
|
||||
],
|
||||
'not_in' => 'The selected :attribute is invalid.',
|
||||
'not_regex' => 'The :attribute format is invalid.',
|
||||
'numeric' => 'The :attribute must be a number.',
|
||||
'password' => 'The password is incorrect.',
|
||||
'present' => 'The :attribute field must be present.',
|
||||
'regex' => 'The :attribute format is invalid.',
|
||||
'required' => 'The :attribute field is required.',
|
||||
'required_if' => 'The :attribute field is required when :other is :value.',
|
||||
'required_unless' => 'The :attribute field is required unless :other is in :values.',
|
||||
'required_with' => 'The :attribute field is required when :values is present.',
|
||||
'required_with_all' => 'The :attribute field is required when :values are present.',
|
||||
'required_without' => 'The :attribute field is required when :values is not present.',
|
||||
'required_without_all' => 'The :attribute field is required when none of :values are present.',
|
||||
'same' => 'The :attribute and :other must match.',
|
||||
'size' => [
|
||||
'numeric' => 'The :attribute must be :size.',
|
||||
'file' => 'The :attribute must be :size kilobytes.',
|
||||
'string' => 'The :attribute must be :size characters.',
|
||||
'array' => 'The :attribute must contain :size items.',
|
||||
],
|
||||
'starts_with' => 'The :attribute must start with one of the following: :values.',
|
||||
'string' => 'The :attribute must be a string.',
|
||||
'timezone' => 'The :attribute must be a valid zone.',
|
||||
'unique' => 'The :attribute has already been taken.',
|
||||
'uploaded' => 'The :attribute failed to upload.',
|
||||
'url' => 'The :attribute format is invalid.',
|
||||
'uuid' => 'The :attribute must be a valid UUID.',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify custom validation messages for attributes using the
|
||||
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||
| specify a specific custom language line for a given attribute rule.
|
||||
|
|
||||
*/
|
||||
|
||||
'custom' => [
|
||||
'attribute-name' => [
|
||||
'rule-name' => 'custom-message',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Attributes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap our attribute placeholder
|
||||
| with something more reader friendly such as "E-Mail Address" instead
|
||||
| of "email". This simply helps us make our message more expressive.
|
||||
|
|
||||
*/
|
||||
|
||||
'attributes' => [],
|
||||
|
||||
];
|
3
resources/sass/_uikitOverrides.scss
vendored
Normal file
3
resources/sass/_uikitOverrides.scss
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.uk-light .uk-close {
|
||||
color: $close-color !important;
|
||||
}
|
27
resources/sass/app.scss
vendored
Normal file
27
resources/sass/app.scss
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// 1. Your custom variables and variable overwrites.
|
||||
// $global-link-color: #DA7D02;
|
||||
|
||||
// 2. Import default variables and available mixins.
|
||||
@import "~uikit/src/scss/variables-theme.scss";
|
||||
@import "~uikit/src/scss/mixins-theme.scss";
|
||||
|
||||
// 3. Your custom mixin overwrites.
|
||||
// @mixin hook-card() { color: #000; }
|
||||
|
||||
// 4. Import UIkit.
|
||||
@import "~uikit/src/scss/uikit-theme.scss";
|
||||
|
||||
// uikit overrides, mainly fixes of colors due to dark theme
|
||||
@import "uikitOverrides";
|
||||
|
||||
@import "./components/toggle";
|
||||
|
||||
$footer-height: 80px;
|
||||
|
||||
#content {
|
||||
min-height: calc(100vh - #{$navbar-nav-item-height + $footer-height});
|
||||
}
|
||||
|
||||
footer {
|
||||
line-height: $footer-height;
|
||||
}
|
63
resources/sass/components/toggle.scss
vendored
Normal file
63
resources/sass/components/toggle.scss
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Source: w3schools https://www.w3schools.com/howto/howto_css_switch.asp
|
||||
*/
|
||||
|
||||
/* The switch - the box around the slider */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 2em;
|
||||
height: 1em;
|
||||
}
|
||||
|
||||
/* Hide default HTML checkbox */
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* The slider */
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
transition: translate .4s;
|
||||
}
|
||||
|
||||
.slider::before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: .8em;
|
||||
width: .8em;
|
||||
left: .1em;
|
||||
bottom: .1em;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: $text-primary-color;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
box-shadow: 0 0 1px #2196F3;
|
||||
}
|
||||
|
||||
input:checked + .slider::before {
|
||||
transform: translateX(1em);
|
||||
}
|
||||
|
||||
/* Rounded sliders */
|
||||
.slider.round {
|
||||
border-radius: 1em;
|
||||
}
|
||||
|
||||
.slider.round::before {
|
||||
border-radius: 50%;
|
||||
}
|
5
resources/views/common/footer.blade.php
Normal file
5
resources/views/common/footer.blade.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<footer>
|
||||
<p class="uk-margin-remove uk-text-center">
|
||||
© {{ date("Y") }} ─ Alexander BC
|
||||
</p>
|
||||
</footer>
|
47
resources/views/common/header.blade.php
Normal file
47
resources/views/common/header.blade.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<header>
|
||||
|
||||
<nav class="uk-navbar-container uk-navbar-transparent uk-light" uk-navbar>
|
||||
<div class="uk-navbar-left">
|
||||
|
||||
<a class="uk-navbar-item uk-logo" href="/">{{ config("app.name") }}</a>
|
||||
|
||||
<ul class="uk-navbar-nav">
|
||||
@auth
|
||||
<li class="{{ Request::route()->getName() == "me.dashboard" ? "uk-active" : "" }}"><a href="{{ route("me.dashboard") }}">Dashboard</a></li>
|
||||
@endauth
|
||||
{{--
|
||||
<li>
|
||||
<a href="#">Parent</a>
|
||||
<div class="uk-navbar-dropdown">
|
||||
<ul class="uk-nav uk-navbar-dropdown-nav">
|
||||
<li class="uk-active"><a href="#">Active</a></li>
|
||||
<li><a href="#">Item</a></li>
|
||||
<li><a href="#">Item</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li><a href="#">Item</a></li>
|
||||
--}}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="uk-navbar-right">
|
||||
<div class="uk-navbar-nav">
|
||||
@guest
|
||||
<li><a href="{{ route("oauth.twitch.login") }}" uk-icon="sign-in">Sign In</a></li>
|
||||
@endguest
|
||||
|
||||
@auth
|
||||
<li>
|
||||
<a href="#"><img src="{{ Auth::user()->profile_image }}" alt="User profile image" class="uk-border-circle uk-margin-small-right" width="40px">{{ Auth::user()->username }}</a>
|
||||
<div class="uk-navbar-dropdown">
|
||||
<ul class="uk-nav uk-navbar-dropdown-nav">
|
||||
<li><a href="{{ route("oauth.twitch.logout") }}" uk-icon="sign-out">Sign Out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
@endauth
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
</header>
|
17
resources/views/home.blade.php
Normal file
17
resources/views/home.blade.php
Normal file
@@ -0,0 +1,17 @@
|
||||
@extends("layouts.app")
|
||||
|
||||
@section("title", "Homepage")
|
||||
|
||||
@section("content")
|
||||
|
||||
@if(session("error"))
|
||||
<div class="uk-alert-danger uk-container" uk-alert>
|
||||
<a class="uk-alert-close" uk-close></a>
|
||||
<h3 class="uk-text-danger">{{ session("error")["title"] }}</h3>
|
||||
<p>{{ session("error")["description"] }}</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<h3 class="uk-text-center">Site under construction</h3>
|
||||
|
||||
@endsection
|
20
resources/views/layouts/app.blade.php
Normal file
20
resources/views/layouts/app.blade.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ app()->getLocale() }}" class="uk-background-secondary">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>@yield("title") ─ {{ config("app.name") }}</title>
|
||||
<link rel="stylesheet" href="{{ mix('/css/app.css') }}">
|
||||
<script src="{{ mix('/js/app.js') }}" charset="utf-8"></script>
|
||||
</head>
|
||||
<body>
|
||||
@include("common.header")
|
||||
|
||||
<div id="content" class="uk-light">
|
||||
@yield("content")
|
||||
</div>
|
||||
|
||||
@include("common.footer")
|
||||
</body>
|
||||
</html>
|
206
resources/views/me/dashboard.blade.php
Normal file
206
resources/views/me/dashboard.blade.php
Normal file
@@ -0,0 +1,206 @@
|
||||
@extends("layouts.app")
|
||||
|
||||
@section("title", "Dashboard")
|
||||
|
||||
@section("content")
|
||||
|
||||
<div class="uk-container">
|
||||
<h3 class="uk-text-center">Dashboard</h3>
|
||||
|
||||
<h2>Available events</h2>
|
||||
|
||||
<section>
|
||||
<h3>
|
||||
<label class="uk-flex uk-flex-between">
|
||||
<span>
|
||||
Stream (stream start, update and finish)
|
||||
</span>
|
||||
<span class="switch">
|
||||
<input type="checkbox" id="stream-hook" {{ ($streamHook && !($streamHook->disabled || $streamHook->disabled_at)) ? "checked" : "" }}>
|
||||
<span class="slider round"></span>
|
||||
</span>
|
||||
</label>
|
||||
</h3>
|
||||
<div>
|
||||
<p>
|
||||
<span uk-icon="info"></span> A message will be sent to the channel when a stream is started.
|
||||
</p>
|
||||
<div role="form" class="uk-flex" id="discord-webhook">
|
||||
<input type="url" class="uk-input" name="discord_hook_url" placeholder="Discord webhook URL" value="{{ ($streamHook && $streamHook->webhookActions()->first()) ? $streamHook->webhookActions()->first()->discord_hook_url : "" }}" {{ (!$streamHook || ($streamHook->disabled || $streamHook->disabled_at)) ? "disabled" : "" }} />
|
||||
<button name="save" class="uk-button uk-button-primary uk-hidden" uk-icon="check" style="flex-shrink: 0;"></button>
|
||||
<button name="test" class="uk-button uk-button-default" style="flex-shrink: 0;">Send test message</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
/* mask the hook url unless editing or empty */
|
||||
#discord-webhook input[type="url"]:not(:focus):not(:placeholder-shown) {
|
||||
filter: blur(4px);
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
let streamHook = document.getElementById("stream-hook");
|
||||
|
||||
let hookActionForm = document.getElementById("discord-webhook");
|
||||
let discordWebhookUrl = hookActionForm.querySelector("[name=discord_hook_url]");
|
||||
let discordWebhookSaveBtn = hookActionForm.querySelector("[name=save]");
|
||||
let discordWebhookTestBtn = hookActionForm.querySelector("[name=test]");
|
||||
|
||||
let INIT_DISCORD_HOOK_URL = discordWebhookUrl.value;
|
||||
|
||||
// subscribe unsubscribe from stream hook events
|
||||
streamHook.addEventListener("change", async function() {
|
||||
let type = "stream";
|
||||
let mode = `${this.checked ? "" : "un"}subscribe`;
|
||||
|
||||
discordWebhookUrl.disabled = !discordWebhookUrl.disabled;
|
||||
|
||||
try {
|
||||
|
||||
let req = await axios.post("{{ route("hooks.twitch.subscribe") }}", {
|
||||
type: type,
|
||||
mode: mode
|
||||
});
|
||||
|
||||
UIkit.notification({
|
||||
message: `Saved!`,
|
||||
status: "success"
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
|
||||
this.checked = !this.checked;
|
||||
discordWebhookUrl.disabled = !discordWebhookUrl.disabled;
|
||||
|
||||
let errorMsg = `Error toggling the ${type} hook, retry after some seconds.`;
|
||||
|
||||
// validation error
|
||||
switch(e.request.status) {
|
||||
case 422:
|
||||
errorMsg = e.response.data.message;
|
||||
break;
|
||||
case 503:
|
||||
errorMsg = "Site is in maintenance, retry in some minutes...";
|
||||
break;
|
||||
default:
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
UIkit.notification({
|
||||
message: errorMsg,
|
||||
status: "danger"
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// toggle the visibility of the save button
|
||||
discordWebhookUrl.addEventListener("keyup", function () {
|
||||
let show = false;
|
||||
|
||||
if (this.value.trim().length >= "https://discordapp.com/api/webhooks/".length) {
|
||||
|
||||
if (this.value !== INIT_DISCORD_HOOK_URL) {
|
||||
show = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(show && discordWebhookSaveBtn.classList.contains("uk-hidden"))
|
||||
||
|
||||
(!show && !discordWebhookSaveBtn.classList.contains("uk-hidden"))
|
||||
) {
|
||||
discordWebhookSaveBtn.classList.toggle("uk-hidden");
|
||||
}
|
||||
});
|
||||
|
||||
// save discord webhook url
|
||||
discordWebhookSaveBtn.addEventListener("click", async function () {
|
||||
// disable editing the url and hide save button
|
||||
discordWebhookUrl.toggleAttribute("disabled");
|
||||
this.classList.toggle("uk-hidden");
|
||||
|
||||
try {
|
||||
|
||||
let req = await axios.post("{{ route("hooks.twitch.action.add") }}", {
|
||||
type: "stream",
|
||||
discord_hook_url: discordWebhookUrl.value
|
||||
});
|
||||
|
||||
UIkit.notification({
|
||||
message: `Updated!`,
|
||||
status: "success"
|
||||
});
|
||||
|
||||
INIT_DISCORD_HOOK_URL = discordWebhookUrl.value;
|
||||
|
||||
} catch (e) {
|
||||
let errorMsg = "The new url could not be saved, try again after some seconds.";
|
||||
|
||||
// validation error
|
||||
switch(e.request.status) {
|
||||
case 422:
|
||||
errorMsg = e.response.data.errors[discordWebhookUrl.name];
|
||||
break;
|
||||
case 503:
|
||||
errorMsg = "Site is in maintenance, retry in some minutes...";
|
||||
break;
|
||||
default:
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
UIkit.notification({
|
||||
message: errorMsg,
|
||||
status: "danger"
|
||||
});
|
||||
|
||||
this.classList.toggle("uk-hidden");
|
||||
|
||||
}
|
||||
|
||||
// make editable the webhook url
|
||||
discordWebhookUrl.toggleAttribute("disabled");
|
||||
});
|
||||
|
||||
// send test message
|
||||
discordWebhookTestBtn.addEventListener("click", async function () {
|
||||
try {
|
||||
let req = await axios.post("{{ route("hooks.twitch.action.test.discord") }}", {
|
||||
discord_hook_url: discordWebhookUrl.value
|
||||
});
|
||||
|
||||
UIkit.notification({
|
||||
message: `Test message sent`,
|
||||
status: "success"
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
|
||||
let errorMsg = "There was an error sending the test message.";
|
||||
|
||||
// validation error
|
||||
switch(e.request.status) {
|
||||
case 422:
|
||||
errorMsg = e.response.data.errors[discordWebhookUrl.name];
|
||||
break;
|
||||
case 503:
|
||||
errorMsg = "Site is in maintenance, retry in some minutes...";
|
||||
break;
|
||||
default:
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
UIkit.notification({
|
||||
message: errorMsg,
|
||||
status: "danger"
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
@endsection
|
Reference in New Issue
Block a user