$token = $request->token;
$userId = backpack_user()->id;
+ if($request->clear) {
+ cache()->forget('connexion'.$fluidbookId);
+ }
+
$connexionExist = cache()->get('connexion'.$fluidbookId);
- //cache()->forget('connexion');
if($connexionExist && $fluidbookId === $connexionExist['f_id']) {
if($userId != $connexionExist['id'] || $token !== $connexionExist['token']) {
return "unavailable";
}, 5000)*/
- setInterval(function() {
+ let interval = null;
+ function intervalConnection() {
+ interval = setInterval(function () {
+ $.ajax({
+ method: "POST",
+ url: '/fluidbook-publication/' + FLUIDBOOK_DATA.id + '/edit/links',
+ data: {id: FLUIDBOOK_DATA.id, token: $("[data-token]").data("token")}
+ }).done(function (msg) {
+ if (msg === "unavailable") {
+ if ($("#popup-overlay").find('.popup').length === 0) {
+ $("#popup-overlay").addClass("show")
+ window.linkeditor.popup.open('unavailable');
+ }
+ } else {
+ $("#popup-overlay").removeClass("show")
+ window.linkeditor.popup.close();
+ }
+ });
+ }, 2000)
+ }
+ intervalConnection()
+
+ //
+ $("body").on("click", "#connectTo", function(e) {
+ e.preventDefault()
+ clearInterval(interval)
$.ajax({
method: "POST",
url: '/fluidbook-publication/' + FLUIDBOOK_DATA.id + '/edit/links',
- data: {id: FLUIDBOOK_DATA.id, token: $("[data-token]").data("token") }
+ data: {id: FLUIDBOOK_DATA.id, token: $("[data-token]").data("token"), clear: true }
}).done(function (msg) {
- if(msg === "unavailable") {
- if($("#popup-overlay").find('.popup').length === 0) {
- $("#popup-overlay").addClass("show")
- window.linkeditor.popup.open('unavailable');
- }
- } else {
- $("#popup-overlay").removeClass("show")
- window.linkeditor.popup.close();
- }
+ intervalConnection();
});
- }, 5000)
+
+ })
});
<h2>{{__('Fluidbook en cours d\'utilisation')}}</h2>
<p>{{__('Utilisateur : ')}} {{ $user->firstname }} {{ $user->lastname }}</p>
<p>Identifiant: {{ $user->id }}</p>
- <!--<p class="button">
- <button type="submit">{{__('Ejecter l\'utilisateur')}}</button>
- </p>-->
+ <p class="button">
+ <button id="connectTo" type="submit">{{__('Ejecter l\'utilisateur')}}</button>
+ </p>
</div>
</div>