first commit symfony 6

This commit is contained in:
2022-07-25 17:16:08 +02:00
parent 2bba3d5695
commit 8181ca1c39
53 changed files with 754 additions and 116 deletions

View File

@ -2,81 +2,16 @@
{% block body %}
{% if app.user %}
<button class="btn btn-primary" onClick="send()">Send</button>
<div id="chat"></div>
<div class="row">
<div class="col col-md6">
<h3>Chat #1</h3>
{{ render(path("app_publish_sample",{id:1})) }}
</div>
<div class="col col-md6">
<h3>Chat #2</h3>
{{ render(path("app_publish_sample",{id:2})) }}
</div>
</div>
{% endif %}
{% endblock %}
{% block localscript %}
{% if app.user %}
<script>
function connect() {
channel="chat";
id=1;
const eventSource = new EventSource("{{ mercure('chat-1')|escape('js') }}");
eventSource.onopen = function(e) {
console.log("== ONOPEN");
sendMessage(channel,id,{command: "alive"});
};
eventSource.onclose = function(e) {
console.log("== ONCLOSE");
sendMessage(channel,id,{command: "dead"});
setTimeout(function() { connect(); }, 1000);
};
eventSource.onmessage = event => {
data=JSON.parse(event.data);
ret=data.ret;
console.log("== ONMESSAGE = "+ret.command);
console.log(ret);
switch (ret.command) {
case "alive":
sendMessage(channel,id,{command: "meto"});
break;
case "meto":
break;
case "dead":
break;
case "push":
$("#chat").prepend('<div class="card mt-3"><div class="card-body">'+ret.message+'</div></div>');
break;
}
}
$(window).on("beforeunload", function() {
sendMessage(channel,id,{command: "dead"});
})
}
connect();
function sendMessage(channel,id,msg) {
url="{{path("app_publish",{channel:'xxx',id:'yyy'})}}";
url=url.replace('xxx',channel);
url=url.replace('yyy',id);
$.ajax({
method: "POST",
url: url,
data: {
msg: msg
},
success: function(data, dataType)
{
},
});
}
function send() {
sendMessage('chat',1,{command: "push", message:"pouet"});
}
</script>
{% endif %}
{% endblock %}

View File

@ -1,17 +1,9 @@
{% extends "base.html.twig" %}
{% block localstyle %}
<style>
label {
color: var(--colorftbodylight);
}
</style>
{% endblock %}
{% block body %}
<div style="text-align:center">
<img src="{{ appAlias }}uploads/logo/{{ app.session.get('logolight') }}" style="height:120px;margin-top:10px;margin-bottom:20px;">
<h1 style="border:none">{{appName}}</h1>
<h1 style="border:none">{{app.session.get('appname')}}</h1>
{{ form_start(form, {'action': path('app_loginldapcheck'), 'method': 'POST'}) }}
<div class="card homecard mb-3" style="width:400px; margin:auto; text-align: left;">
<div class="card-body">

View File

@ -1,17 +1,11 @@
{% extends "base.html.twig" %}
{% block localstyle %}
<style>
label {
color: var(--colorftbodylight);
}
</style>
{% endblock %}
{% block body %}
<div style="text-align:center">
<img src="{{ appAlias }}uploads/logo/{{ app.session.get('logolight') }}" style="height:120px;margin-top:10px;margin-bottom:20px;">
<h1 style="border:none">{{appName}}</h1>
<h1 style="border:none">{{app.session.get('appname')}}</h1>
<form action="{{ path('app_login') }}" method="post">
<div class="card homecard mb-3" style="width:400px; margin:auto">
<div class="card-body">

View File

@ -0,0 +1,20 @@
{% extends "base.html.twig" %}
{% block body %}
Vous avez pu vous connecter à {{ app.session.get('appname') }} mais vous n'avez aucun compte sur l'application.<br>
Contacter votre administrateur si vous souhaitez y accéder.<br><br>
Vous allez être déconnectés d'ici quelques secondes.
{% endblock %}
{% block localscript %}
<script>
$(document).ready(function() {
// Redirection vers la mire d'authentification
setTimeout(function(){
window.location.href="{{ path("app_logout") }}";
}, 6000);
});
</script>
{% endblock %}

View File

@ -0,0 +1,95 @@
{% if app.user %}
{% set idwidget=uniqueId() %}
<div id="chat{{idwidget}}">
<textarea class="form-control mb-2" id="pushmessage" rows="3"></textarea>
<button class="btn btn-primary" onClick="send{{idwidget}}()" class="mt-2">Send</button>
<div id="aliveusers" class="mt-3 mb-3"></div>
<div id="chat"></div>
</div>
<script>
function connect{{idwidget}}() {
channel="chat";
id{{idwidget}}={{id}};
const eventSource = new EventSource("{{ mercure('chat-'~id)|escape('js') }}");
eventSource.onopen = function(e) {
console.log("== ONOPEN");
sendMessage{{idwidget}}(channel,id{{idwidget}},{command: "alive"});
};
eventSource.onclose = function(e) {
console.log("== ONCLOSE");
sendMessage{{idwidget}}(channel,id,{command: "dead"});
setTimeout(function() { connect{{idwidget}}(); }, 5000);
};
eventSource.onmessage = event => {
data=JSON.parse(event.data);
ret=data.ret;
console.log("== ONMESSAGE = "+ret.command);
console.log(ret);
switch (ret.command) {
case "alive":
sendMessage{{idwidget}}(channel,id{{idwidget}},{command: "meto"});
break;
case "meto":
if(!$("#chat{{idwidget}} #aliveuser"+ret.from.id).length) {
html='<img id="aliveuser'+ret.from.id+'" src="'+ret.from.avatar+'" title="'+ret.from.displayname+'"class="avatar me-1">';
$("#chat{{idwidget}} #aliveusers").append(html);
}
break;
case "dead":
sendMessage{{idwidget}}(channel,id{{idwidget}},{command: "alive"});
if($("#aliveuser"+ret.from.id).length) {
$("#aliveuser"+ret.from.id).remove();
}
break;
case "push":
html ='<div class="card mt-1"><div class="card-body d-flex">';
html+='<img id="msguser'+ret.from.id+'" src="'+ret.from.avatar+'" title="'+ret.from.displayname+'"class="avatar me-1">';
html+='<div class="ps-2"><small>'+ret.message.replace(/\n/g,"<br>")+'</small></div>';
html+='</div></div>';
$("#chat{{idwidget}} #chat").prepend(html);
break;
}
}
$(window).on("beforeunload", function() {
sendMessage{{idwidget}}(channel,id{{idwidget}},{command: "dead"});
})
}
connect{{idwidget}}();
function sendMessage{{idwidget}}(channel,id,msg) {
url="{{path("app_publish",{channel:'xxx',id:'yyy'})}}";
url=url.replace('xxx',channel);
url=url.replace('yyy',id{{idwidget}});
$.ajax({
method: "POST",
url: url,
data: {
msg: msg
},
success: function(data, dataType)
{
},
});
}
function send{{idwidget}}() {
if($("#chat{{idwidget}} #pushmessage").val()) {
sendMessage{{idwidget}}('chat',1,{command: "push", message:$("#chat{{idwidget}} #pushmessage").val()});
$("#chat{{idwidget}} #pushmessage").val("");
}
}
</script>
{% endif %}

View File

@ -9,6 +9,12 @@
route: 'app_admin_config',
name: 'Général',
},
{
icon: 'fas fa-paint-brush',
route: 'app_admin_theme',
name: 'Thème',
},
]
},
{

View File

@ -0,0 +1,29 @@
{% extends 'base.html.twig' %}
{% block body %}
<h1>Thèmes</h1>
<h2>Thème en cours</h2>
<div class="text-center" style="width:330px">
<img src="{{currentheme.url}}/look.png" style="width:100%; background-color: {{app.session.get('colorbgbodydark') }}"><br>
{{currentheme.name}}
</div>
<h2 class="mt-5">Thèmes disponibles</h2>
<div>
{% for theme in themes %}
<div class="text-center mb-4" style="width:330px; display: inline-block">
<img src="{{theme.url}}/look.png" style="height:170px; background-color: {{app.session.get('colorbgbodydark') }}"><br>
{{theme.name}}<br>
<a href="{{ path("app_admin_theme_select",{"name":theme.dir}) }}" class="btn btn-primary" role="button">Sélectionner</a>
</div>
{% endfor %}
</div>
{% endblock %}

View File

@ -14,7 +14,7 @@
</div>
<div class="card-body">
<table class="table table-striped table-bordered table-hover" id="dataTables" style="width:100%; font-size:11px;">
<table class="table table-striped table-bordered table-hover wrap" id="dataTables" style="width:100%; font-size:11px;">
<thead>
<tr>
{% if access=="admin" or access=="modo"%}
@ -44,7 +44,6 @@
$(document).ready(function() {
$('#dataTables').DataTable({
columnDefs: [ { "targets": 'no-sort', "orderable": false },{ "targets": 'no-visible', "visible": false } ],
responsive: true,
iDisplayLength: 100,
processing: true,
serverSide: true,

View File

@ -12,6 +12,10 @@
<script src="{{ asset('bundles/tetranzselect2entity/js/select2entity.js') }}"></script>
{{ include('Include/style.css.twig') }}
{% if not app.session.get("apptheme") is empty %}
<link href="{{ appAlias }}themes/{{ app.session.get("apptheme") }}/style.css" rel="stylesheet" media="screen" />
{% endif %}
{% block localstyle %}{% endblock %}
</head>