static
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
import {setContext} from "svelte";
|
import {setContext} from "svelte";
|
||||||
import Navbar from "./Navbar.svelte";
|
import Navbar from "./Navbar.svelte";
|
||||||
import HomeIndex from "./home/Index.svelte";
|
import HomeIndex from "./home/Index.svelte";
|
||||||
|
import BuildReport from "./build/Report.svelte";
|
||||||
|
|
||||||
const components = {
|
const components = {
|
||||||
members: Members,
|
members: Members,
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
recordNotFound: RecordNotFound,
|
recordNotFound: RecordNotFound,
|
||||||
contentIndex: ContentIndex,
|
contentIndex: ContentIndex,
|
||||||
homeIndex: HomeIndex,
|
homeIndex: HomeIndex,
|
||||||
|
buildReport: BuildReport,
|
||||||
};
|
};
|
||||||
|
|
||||||
export let title;
|
export let title;
|
||||||
|
|||||||
@@ -7,60 +7,85 @@
|
|||||||
const channel = getContext("channel");
|
const channel = getContext("channel");
|
||||||
const user = getContext("user");
|
const user = getContext("user");
|
||||||
|
|
||||||
|
function buildWebsite(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
axios.post(channel.lucentUrl + "/build").then(response => {
|
||||||
|
window.location.href = channel.lucentUrl + "/build-report"
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav class="lx-nav">
|
<nav class="lx-nav">
|
||||||
<a class="nav-item" href="{channel.lucentUrl}">{channel.name}</a>
|
|
||||||
<a class="nav-item" href="{channel.lucentUrl}/members">Members</a>
|
<div>
|
||||||
<a class="nav-item" href="{channel.lucentUrl}/profile">
|
|
||||||
<Avatar side="28" name={user.name}/>
|
</div>
|
||||||
</a
|
<div>
|
||||||
>
|
<a class="nav-item" href="{channel.lucentUrl}">{channel.name}</a>
|
||||||
|
<a class="nav-item" href="{channel.lucentUrl}/members">Members</a>
|
||||||
|
|
||||||
|
{#if channel.generateCommand}
|
||||||
|
<button on:click={buildWebsite} class="btn btn-outline-primary btn-sm">Build website</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a class="nav-item" href="{channel.lucentUrl}/profile">
|
||||||
|
<Avatar side="28" name={user.name}/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="offcanvas offcanvas-start show border-0 bg-light-subtle" style="margin-top:36px " data-bs-scroll="true"
|
</nav>
|
||||||
data-bs-backdrop="false"
|
|
||||||
tabindex="-1" aria-labelledby="offcanvasScrollingLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasScrollingLabel">Content</h5>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
|
|
||||||
<div class="accordion" id="accordionPanelsStayOpenExample">
|
<div class="offcanvas offcanvas-start show border-0 bg-light-subtle" style="padding-top:36px " data-bs-scroll="true"
|
||||||
<div class="accordion-item">
|
data-bs-backdrop="false"
|
||||||
<h2 class="accordion-header" id="panelsStayOpen-headingOne">
|
tabindex="-1" aria-labelledby="offcanvasScrollingLabel">
|
||||||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
|
<!-- <div class="offcanvas-header">-->
|
||||||
Main
|
<!-- <h5 class="offcanvas-title" id="offcanvasScrollingLabel">Content</h5>-->
|
||||||
</button>
|
<!-- </div>-->
|
||||||
</h2>
|
<div class="offcanvas-body">
|
||||||
<div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-headingOne">
|
|
||||||
<div class="accordion-body">
|
<div class="accordion" id="accordionPanelsStayOpenExample">
|
||||||
<NavbarMenu
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header" id="panelsStayOpen-headingOne">
|
||||||
|
<button class="accordion-button" type="button" data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true"
|
||||||
|
aria-controls="panelsStayOpen-collapseOne">
|
||||||
|
Main
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show"
|
||||||
|
aria-labelledby="panelsStayOpen-headingOne">
|
||||||
|
<div class="accordion-body">
|
||||||
|
<NavbarMenu
|
||||||
schemas={ channel.schemas.filter((sc) => sc.isEntry)}
|
schemas={ channel.schemas.filter((sc) => sc.isEntry)}
|
||||||
schema={schema}
|
schema={schema}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="accordion-item">
|
</div>
|
||||||
<h2 class="accordion-header" id="panelsStayOpen-headingTwo">
|
<div class="accordion-item">
|
||||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseTwo" aria-expanded="false" aria-controls="panelsStayOpen-collapseTwo">
|
<h2 class="accordion-header" id="panelsStayOpen-headingTwo">
|
||||||
Other
|
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
|
||||||
</button>
|
data-bs-target="#panelsStayOpen-collapseTwo" aria-expanded="false"
|
||||||
</h2>
|
aria-controls="panelsStayOpen-collapseTwo">
|
||||||
<div id="panelsStayOpen-collapseTwo" class="accordion-collapse collapse" aria-labelledby="panelsStayOpen-headingTwo">
|
Other
|
||||||
<div class="accordion-body">
|
</button>
|
||||||
<NavbarMenu
|
</h2>
|
||||||
|
<div id="panelsStayOpen-collapseTwo" class="accordion-collapse collapse"
|
||||||
|
aria-labelledby="panelsStayOpen-headingTwo">
|
||||||
|
<div class="accordion-body">
|
||||||
|
<NavbarMenu
|
||||||
schemas={ channel.schemas.filter((sc) => !sc.isEntry)}
|
schemas={ channel.schemas.filter((sc) => !sc.isEntry)}
|
||||||
schema={schema}
|
schema={schema}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</nav>
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<script>
|
|
||||||
import Icon from "./common/Icon.svelte";
|
|
||||||
|
|
||||||
export let label;
|
|
||||||
let isExpanded = true;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<span class="sidebar-header d-flex align-items-center">
|
|
||||||
{#if !isExpanded}
|
|
||||||
<span class="d-flex" on:click={(e) => (isExpanded = true)}>
|
|
||||||
<Icon icon="circle-chevron-down" viewBox="0 0 512 512" />
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if isExpanded}
|
|
||||||
<span class="d-flex" on:click={(e) => (isExpanded = false)}>
|
|
||||||
<Icon icon="circle-chevron-up" viewBox="0 0 512 512" />
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
<span class="ms-1">{label}</span>
|
|
||||||
<div class="actions">
|
|
||||||
<slot name="actions" />
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
{#if isExpanded}
|
|
||||||
<div class="mb-2">
|
|
||||||
<slot />
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<script>
|
|
||||||
export let active = false;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="sidebar-item" class:active>
|
|
||||||
<slot />
|
|
||||||
<div class="actions">
|
|
||||||
<slot name="actions" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<script>
|
|
||||||
export let active = "";
|
|
||||||
import { getContext } from "svelte";
|
|
||||||
const user = getContext("user");
|
|
||||||
let logged = user?.id ? true : false;
|
|
||||||
let menuItems = [
|
|
||||||
{
|
|
||||||
name: "Account",
|
|
||||||
link: "/profile",
|
|
||||||
auth: true,
|
|
||||||
guest: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Login",
|
|
||||||
link: "/login",
|
|
||||||
auth: false,
|
|
||||||
guest: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Register",
|
|
||||||
link: "/register",
|
|
||||||
auth: false,
|
|
||||||
guest: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ul class="nav justify-content-center mt-4 mb-5">
|
|
||||||
{#each menuItems as item}
|
|
||||||
{#if item.auth == logged || item.guest == !logged}
|
|
||||||
<li class="nav-item">
|
|
||||||
<a
|
|
||||||
class="nav-link"
|
|
||||||
class:active={active == item.name}
|
|
||||||
href={item.link}>{item.name}</a
|
|
||||||
>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
<style>
|
|
||||||
.nav-item a.active{
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<script>
|
<script>
|
||||||
import ErrorAlert from "../common/ErrorAlert.svelte";
|
import ErrorAlert from "../common/ErrorAlert.svelte";
|
||||||
import SpinnerButton from "../common/SpinnerButton.svelte";
|
import SpinnerButton from "../common/SpinnerButton.svelte";
|
||||||
import Nav from "./Nav.svelte";
|
|
||||||
import Avatar from "./Avatar.svelte";
|
import Avatar from "./Avatar.svelte";
|
||||||
import {getContext} from "svelte";
|
import {getContext} from "svelte";
|
||||||
|
|
||||||
const user = getContext("user");
|
const user = getContext("user");
|
||||||
|
const channel = getContext("channel");
|
||||||
let name = user.name;
|
let name = user.name;
|
||||||
let email = user.email;
|
let email = user.email;
|
||||||
let errorMessage = "";
|
let errorMessage = "";
|
||||||
@@ -45,7 +45,6 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Nav active="Account"/>
|
|
||||||
|
|
||||||
<div class="wrapper-tiny">
|
<div class="wrapper-tiny">
|
||||||
<ErrorAlert message={errorMessage}/>
|
<ErrorAlert message={errorMessage}/>
|
||||||
@@ -64,18 +63,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<!-- <form on:submit={saveEmail}>-->
|
|
||||||
<!-- <div class="input-group mb-3">-->
|
|
||||||
<!-- <input-->
|
|
||||||
<!-- type="text"-->
|
|
||||||
<!-- bind:value={email}-->
|
|
||||||
<!-- class="form-control"-->
|
|
||||||
<!-- placeholder="Email"-->
|
|
||||||
<!-- />-->
|
|
||||||
<!-- <SpinnerButton label="Update" />-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </form>-->
|
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<a class="list-group-item list-group-item-action" href="/logout">Logout from this device</a>
|
<a class="list-group-item list-group-item-action" href="{ channel.lucentUrl }/logout">Logout from this device</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<script>
|
||||||
|
import {getContext} from "svelte";
|
||||||
|
import SpinnerButton from "../common/SpinnerButton.svelte";
|
||||||
|
import ErrorAlert from "../common/ErrorAlert.svelte";
|
||||||
|
import MemberSettingsCard from "../members/MemberSettingsCard.svelte";
|
||||||
|
import SuccessAlert from "../common/SuccessAlert.svelte";
|
||||||
|
import Radio from "../forms/Radio.svelte";
|
||||||
|
|
||||||
|
const channel = getContext("channel");
|
||||||
|
export let title;
|
||||||
|
$: output = "";
|
||||||
|
const eventSource = new EventSource(channel.lucentUrl + "/build-report-source");
|
||||||
|
|
||||||
|
console.log("heklko")
|
||||||
|
eventSource.onmessage = function(event) {
|
||||||
|
const data = JSON.parse(event.data);
|
||||||
|
console.log(data)
|
||||||
|
output = output + "message: " + data.time;
|
||||||
|
}
|
||||||
|
eventSource.onerror = (e)=>{
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="wrapper-tiny transparent mb-5">
|
||||||
|
<div class="lx-card mt-5">
|
||||||
|
<h3 class="header-small mb-5">{title}</h3>
|
||||||
|
|
||||||
|
{output}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -158,13 +158,13 @@
|
|||||||
<EditHeader {schema} {record} {isCreateMode} {graph} bind:activeContentTab/>
|
<EditHeader {schema} {record} {isCreateMode} {graph} bind:activeContentTab/>
|
||||||
|
|
||||||
{#if !["_graph", "_info"].includes(activeContentTab)}
|
{#if !["_graph", "_info"].includes(activeContentTab)}
|
||||||
<div
|
<div class="shadow-lg "
|
||||||
style="position:fixed;bottom:0;left:0px;width:100%;background:rgba(255,255,255,.7);z-index:10"
|
style="position:fixed;bottom:0;left:0px;width:100%;background:rgba(255,255,255,1);z-index:1050"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="d-flex mt-4 mb-3 align-items-center justify-content-center"
|
class="d-flex mt-4 mb-3 align-items-center justify-content-center"
|
||||||
>
|
>
|
||||||
<StatusSelect bind:status={record.status} {schema}/>
|
<StatusSelect bind:status={record.status} {record} {schema}/>
|
||||||
{#if isCreateMode}
|
{#if isCreateMode}
|
||||||
<button
|
<button
|
||||||
class="ms-2 btn btn-primary btn-spinner"
|
class="ms-2 btn btn-primary btn-spinner"
|
||||||
|
|||||||
@@ -45,19 +45,7 @@
|
|||||||
<Icon icon="ellipsis"/>
|
<Icon icon="ellipsis"/>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<!--{#if channel.previewTargets.length > 0}-->
|
|
||||||
<!-- <h6 class="dropdown-header">Preview targets</h6>-->
|
|
||||||
<!-- {#each channel.previewTargets as previewTarget}-->
|
|
||||||
<!-- <a-->
|
|
||||||
<!-- class="dropdown-item"-->
|
|
||||||
<!-- target="_blank"-->
|
|
||||||
<!-- rel="noreferrer"-->
|
|
||||||
<!-- href="{previewTarget.url}?id={record.data-->
|
|
||||||
<!-- .id}&schema={record._sys.schema}"-->
|
|
||||||
<!-- >{previewTarget.label}</a-->
|
|
||||||
<!-- >-->
|
|
||||||
<!-- {/each}-->
|
|
||||||
<!--{/if}-->
|
|
||||||
<h6 class="dropdown-header">Record Actions</h6>
|
<h6 class="dropdown-header">Record Actions</h6>
|
||||||
<a
|
<a
|
||||||
class="dropdown-item"
|
class="dropdown-item"
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import {getContext} from "svelte";
|
||||||
import Status from "./Status.svelte";
|
import Status from "./Status.svelte";
|
||||||
import {getStatus, getStatusList} from "./StatusText";
|
import {getStatus, getStatusList} from "./StatusText";
|
||||||
|
|
||||||
|
const channel = getContext("channel");
|
||||||
export let status = "draft";
|
export let status = "draft";
|
||||||
|
export let record;
|
||||||
export let schema;
|
export let schema;
|
||||||
let dropdown;
|
let dropdown;
|
||||||
$: currentStatus = getStatus(status);
|
$: currentStatus = getStatus(status);
|
||||||
@@ -16,31 +19,40 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Example split danger button -->
|
<!-- Example split danger button -->
|
||||||
<div class="btn-group dropup">
|
<div class="d-flex justify-content-between">
|
||||||
<button type="button" class="btn btn-{currentStatus.bg}"
|
<div class="btn-group dropup">
|
||||||
>{currentStatus.text}</button
|
<button type="button" class="btn btn-{currentStatus.bg}"
|
||||||
>
|
>{currentStatus.text}</button
|
||||||
<button
|
>
|
||||||
bind:this={dropdown}
|
<button
|
||||||
type="button"
|
bind:this={dropdown}
|
||||||
class="btn btn-{currentStatus.bg} dropdown-toggle dropdown-toggle-split"
|
type="button"
|
||||||
data-bs-toggle="dropdown"
|
class="btn btn-{currentStatus.bg} dropdown-toggle dropdown-toggle-split"
|
||||||
aria-expanded="false"
|
data-bs-toggle="dropdown"
|
||||||
>
|
aria-expanded="false"
|
||||||
<span class="visually-hidden">Toggle Dropdown</span>
|
>
|
||||||
</button>
|
<span class="visually-hidden">Toggle Dropdown</span>
|
||||||
<div class="dropdown-menu">
|
</button>
|
||||||
<div class="dropdown-header">Change status to</div>
|
<div class="dropdown-menu">
|
||||||
{#each statusList as astatus}
|
<div class="dropdown-header">Change status to</div>
|
||||||
{#if astatus.value !== status}
|
{#each statusList as astatus}
|
||||||
<button
|
{#if astatus.value !== status}
|
||||||
type="button"
|
<button
|
||||||
class="dropdown-item my-2 rounded w-100 bg-{astatus.bg} text-{astatus.color}"
|
type="button"
|
||||||
on:click={(e) => updateStatus(e, astatus.value)}
|
class="dropdown-item my-2 rounded w-100 bg-{astatus.bg} text-{astatus.color}"
|
||||||
>
|
on:click={(e) => updateStatus(e, astatus.value)}
|
||||||
{astatus.text}
|
>
|
||||||
</button>
|
{astatus.text}
|
||||||
{/if}
|
</button>
|
||||||
{/each}
|
{/if}
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
{#if channel.previewTarget}
|
||||||
|
<a href="{channel.previewTarget}?schema={schema.name}&id={record.id}" target="_blank" class="btn btn-outline-info ms-3">
|
||||||
|
Preview
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
.lx-nav{
|
.lx-nav{
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: space-between;
|
||||||
|
padding: 12px 20px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: rgba(255,255,255,.7);
|
background-color: rgba(255,255,255,1);
|
||||||
margin-bottom:0px ;
|
margin-bottom:0px ;
|
||||||
.nav-item{
|
.nav-item{
|
||||||
padding:4px 0;
|
padding:16px 0;
|
||||||
margin: 0 16px;
|
margin: 0 16px;
|
||||||
color: $primary;
|
color: $primary;
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ body {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.cursor-pointer {
|
.cursor-pointer {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,10 +132,10 @@ readonly class AuthService
|
|||||||
/**
|
/**
|
||||||
* @throws LucentException
|
* @throws LucentException
|
||||||
*/
|
*/
|
||||||
public function updateName(string $userId, string $name): void
|
public function updateName( string $name): void
|
||||||
{
|
{
|
||||||
$name = (new Name($name));
|
$name = (new Name($name));
|
||||||
$this->userRepo->updateName($userId, $name);
|
$this->userRepo->updateName($this->currentUserId(), $name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ final class Channel
|
|||||||
function __construct(
|
function __construct(
|
||||||
public string $name,
|
public string $name,
|
||||||
public string $url,
|
public string $url,
|
||||||
|
public string $previewTarget,
|
||||||
|
public string $generateCommand,
|
||||||
public Collection $schemas,
|
public Collection $schemas,
|
||||||
public array $imageFilters,
|
public array $imageFilters,
|
||||||
// public Collection $previewTargets,
|
// public Collection $previewTargets,
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ final class ChannelService
|
|||||||
$channel = new Channel(
|
$channel = new Channel(
|
||||||
name: $configArray["name"] ?? "",
|
name: $configArray["name"] ?? "",
|
||||||
url: rtrim($configArray["url"] ?? "", "/"),
|
url: rtrim($configArray["url"] ?? "", "/"),
|
||||||
|
previewTarget: rtrim($configArray["previewTarget"] ?? "", "/"),
|
||||||
|
generateCommand: $configArray["generateCommand"] ?? "",
|
||||||
schemas: $schemasCollection,
|
schemas: $schemasCollection,
|
||||||
imageFilters: $configArray["imageFilters"] ?? [],
|
imageFilters: $configArray["imageFilters"] ?? [],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,23 +4,29 @@ namespace Lucent\Http\Controller;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Lucent\Account\Auth;
|
use Lucent\Account\AuthService;
|
||||||
|
use Lucent\Svelte\Svelte;
|
||||||
|
use Throwable;
|
||||||
use function Lucent\Response\fail;
|
use function Lucent\Response\fail;
|
||||||
use function Lucent\Response\ok;
|
use function Lucent\Response\ok;
|
||||||
use function Lucent\Svelte\svelte;
|
|
||||||
|
|
||||||
|
|
||||||
class AccountController extends Controller
|
class AccountController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public Svelte $svelte,
|
||||||
|
public AuthService $authService,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function profile()
|
public function profile()
|
||||||
{
|
{
|
||||||
return svelte(
|
return $this->svelte->render(
|
||||||
layout: "account",
|
layout: "account",
|
||||||
view: "profile",
|
view: "profile",
|
||||||
title: "Profile",
|
title: "Profile",
|
||||||
data: []
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,23 +34,12 @@ class AccountController extends Controller
|
|||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(new Auth)->updateName(session("user.id"), $request->input("name"));
|
$this->authService->updateName($request->input("name"));
|
||||||
} catch (\Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
return fail($th);
|
return fail($th);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateEmail(Request $request)
|
|
||||||
{
|
|
||||||
|
|
||||||
try {
|
|
||||||
(new Auth)->updateEmail(session("user.id"), $request->input("email"));
|
|
||||||
} catch (\Throwable $th) {
|
|
||||||
return fail($th);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Lucent\Http\Controller\Api;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Contracts\View\View;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Http\Response;
|
|
||||||
use Lucent\Account\AuthService;
|
|
||||||
use Lucent\LucentException;
|
|
||||||
use function Lucent\Response\fail;
|
|
||||||
use function Lucent\Response\ok;
|
|
||||||
use function Lucent\Svelte\svelte;
|
|
||||||
|
|
||||||
|
|
||||||
class AccountController extends Controller
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
private readonly AuthService $authService,
|
|
||||||
)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function profile(): View
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
return svelte(
|
|
||||||
layout: "account",
|
|
||||||
view: "profile",
|
|
||||||
title: "Profile",
|
|
||||||
data: []
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateName(Request $request): Response
|
|
||||||
{
|
|
||||||
|
|
||||||
try {
|
|
||||||
$this->authService->updateName(session("user.id"), $request->input("name"));
|
|
||||||
} catch (LucentException $th) {
|
|
||||||
return fail($th);
|
|
||||||
}
|
|
||||||
$request->session()->put("user.name", $request->input("name"));
|
|
||||||
|
|
||||||
return ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lucent\Http\Controller;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
use Lucent\Channel\ChannelService;
|
||||||
|
use Lucent\Svelte\Svelte;
|
||||||
|
use function Lucent\Response\ok;
|
||||||
|
|
||||||
|
class BuildController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public readonly Svelte $svelte,
|
||||||
|
public readonly ChannelService $channelService,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function build()
|
||||||
|
{
|
||||||
|
exec("cd ".base_path(). " && php8.2 artisan {$this->channelService->channel->generateCommand} > /dev/null 2>&1 & echo $!",$op);
|
||||||
|
$pid = (int)$op[0];
|
||||||
|
return redirect($this->channelService->channel->lucentUrl . "/build-report");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function report(): View
|
||||||
|
{
|
||||||
|
|
||||||
|
return $this->svelte->render(
|
||||||
|
layout: "channel",
|
||||||
|
view: "buildReport",
|
||||||
|
title: "Build Report",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reportSource()
|
||||||
|
{
|
||||||
|
return response()->stream(function () {
|
||||||
|
while (true) {
|
||||||
|
$curDate = time();
|
||||||
|
echo 'data: {"time": "' . $curDate . '"}';
|
||||||
|
echo "\n\n";
|
||||||
|
logger( $curDate);
|
||||||
|
|
||||||
|
ob_flush();
|
||||||
|
flush();
|
||||||
|
|
||||||
|
// Break the loop if the client aborted the connection (closed the page)
|
||||||
|
if (connection_aborted()) {break;}
|
||||||
|
sleep(2); // 50ms
|
||||||
|
}
|
||||||
|
}, 200, [
|
||||||
|
'Cache-Control' => 'no-cache',
|
||||||
|
'X-Accel-Buffering' => 'no',
|
||||||
|
'Content-Type' => 'text/event-stream',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
|||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
use Lucent\Account\AccountService;
|
||||||
use Lucent\Account\UserRepo;
|
use Lucent\Account\UserRepo;
|
||||||
use Lucent\Channel\ChannelService;
|
use Lucent\Channel\ChannelService;
|
||||||
use Lucent\Query\Query;
|
use Lucent\Query\Query;
|
||||||
@@ -16,7 +17,7 @@ class HomeController extends Controller
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly Svelte $svelte,
|
private readonly Svelte $svelte,
|
||||||
private readonly UserRepo $userRepo,
|
private readonly AccountService $accountService,
|
||||||
private readonly Query $query,
|
private readonly Query $query,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -39,7 +40,7 @@ class HomeController extends Controller
|
|||||||
$sort = data_get($urlParams, "sort") ?? "-_sys.updatedAt";
|
$sort = data_get($urlParams, "sort") ?? "-_sys.updatedAt";
|
||||||
$filter = data_get($urlParams, "filter") ?? [];
|
$filter = data_get($urlParams, "filter") ?? [];
|
||||||
$arguments = array_merge([
|
$arguments = array_merge([
|
||||||
"_sys.status_in" => ["draft", "published"]
|
"status_in" => ["draft", "published"]
|
||||||
], $filter);
|
], $filter);
|
||||||
|
|
||||||
$limit = 30;
|
$limit = 30;
|
||||||
@@ -52,7 +53,7 @@ class HomeController extends Controller
|
|||||||
->sort($sort)
|
->sort($sort)
|
||||||
->run();
|
->run();
|
||||||
|
|
||||||
$users = $this->userRepo->all();
|
$users = $this->accountService->all();
|
||||||
|
|
||||||
return ok([
|
return ok([
|
||||||
"users" => $users,
|
"users" => $users,
|
||||||
|
|||||||
+5
-2
@@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Lucent\Http\Controller\Api\AccountController;
|
use Lucent\Http\Controller\AccountController;
|
||||||
use Lucent\Http\Controller\AuthController;
|
use Lucent\Http\Controller\AuthController;
|
||||||
|
use Lucent\Http\Controller\BuildController;
|
||||||
use Lucent\Http\Controller\FileController;
|
use Lucent\Http\Controller\FileController;
|
||||||
use Lucent\Http\Controller\HomeController;
|
use Lucent\Http\Controller\HomeController;
|
||||||
use Lucent\Http\Controller\MemberController;
|
use Lucent\Http\Controller\MemberController;
|
||||||
use Lucent\Http\Controller\RecordController;
|
use Lucent\Http\Controller\RecordController;
|
||||||
use Lucent\Http\Controller\SchemaController;
|
|
||||||
use Lucent\Revision\RevisionController;
|
use Lucent\Revision\RevisionController;
|
||||||
|
|
||||||
|
|
||||||
@@ -31,6 +31,9 @@ Route::group([
|
|||||||
Route::get('/logout', [AuthController::class, 'logout']);
|
Route::get('/logout', [AuthController::class, 'logout']);
|
||||||
Route::get('/profile', [AccountController::class, 'profile']);
|
Route::get('/profile', [AccountController::class, 'profile']);
|
||||||
Route::post('/account/update-name', [AccountController::class, 'updateName']);
|
Route::post('/account/update-name', [AccountController::class, 'updateName']);
|
||||||
|
Route::get('/build-report', [BuildController::class, 'report']);
|
||||||
|
Route::get('/build-report-source', [BuildController::class, 'reportSource']);
|
||||||
|
Route::post('/build', [BuildController::class, 'build']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
<?php namespace Lucent\StaticGenerator;
|
<?php namespace Lucent\StaticGenerator;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
|
||||||
class StaticGenerator
|
class StaticGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
public function construct()
|
public function __construct(
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,5 +39,13 @@ class StaticGenerator
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createRedirect(string $from, string $to, string $title = "Redirecting", string $message = "Redirecting Soon..."): void
|
||||||
|
{
|
||||||
|
$html = view("lucent::redirect", [
|
||||||
|
"to" => $to,
|
||||||
|
"title" => $title,
|
||||||
|
"message" => $message,
|
||||||
|
])->render();
|
||||||
|
$this->save($from, $html);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>{{$title}}</title>
|
||||||
|
<meta http-equiv="refresh" content="0; url='{{$to}}'"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user