jeroennoten / Laravel-AdminLTE

Easy AdminLTE integration with Laravel
MIT License
3.84k stars 1.08k forks source link

[Question] IframeMode first display view #1253

Closed SMEWebify closed 8 months ago

SMEWebify commented 8 months ago

Hi All

When using iframe mode we get a message " No tab selected!" it is possible to set a default tab in the configuration:

        'default_tab' => [
            'url' => 'opportunities',
            'title' => 'null',
        ],

image But this tab is not loading?

My original need is to display a dashboard for example when loading

visibly the blade view where the @extends('adminlte::page', ['iFrameEnabled' => true]) is located is never displayed?

Regards

kévin

dfsmania commented 8 months ago

@SMEWebify See the Wiki: https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Usage#tabbed-iframe-mode

It stands that the main view of the app, i.e, the view you hit after the login procedure, should be defined as just:

@extends('adminlte::page', ['iFrameEnabled' => true])

I believe other content defined on that main view will be totally ignored.

On the other hand, I have tested default tab locally and it's working here, can you share all your I-Frame configuration and also check on the developers console for errors?

SMEWebify commented 8 months ago

It stands that the main view of the app, i.e, the view you hit after the login procedure, should be defined as just:

@extends('adminlte::page', ['iFrameEnabled' => true])

I believe other content defined on that main view will be totally ignored.

So far we agree

On the other hand, I have tested default tab locally and it's working here, can you share all your I-Frame configuration and also check on the developers console for errors?

adminlte.php menu link to display on defaut tab

[
            'text'        => 'opportunities_trans_key',
            'url'         => 'opportunities',
            'icon'        => 'fa fa-tags',
            'can'         => ['opportunities-menu'],
        ],

adminlte.php iframe config

 'iframe' => [
        'default_tab' => [
            'url' => 'opportunities',
            'title' => 'OPP',
        ],
        'buttons' => [
            'close' => true,
            'close_all' => true,
            'close_all_other' => true,
            'scroll_left' => true,
            'scroll_right' => true,
            'fullscreen' => true,
        ],
        'options' => [
            'loading_screen' => 1000,
            'auto_show_new_tab' => true,
            'use_navbar_items' => false,
        ],
    ],

after connection image after click on OPP image

no specific error in browser console

It's not really a problem in the end, but it raises questions about the architecture, maybe I should make a page dedicated to the iFrame like on the demo site

image so the user will always arrive on a dashboard, but to go to an iframe navigation on another page if he wishes.

dfsmania commented 8 months ago

Have you tried with others links on the default tab or with the full URL path?

Also, locate the package's views for I-Frame mode:

Then make the next change on that file to wrap the configured url with the url() helper method:

--- a/resources/views/vendor/adminlte/partials/cwrapper/cwrapper-iframe.blade.php
+++ b/resources/views/vendor/adminlte/partials/cwrapper/cwrapper-iframe.blade.php
@@ -101,7 +101,7 @@
         {{-- Default Tab Content --}}
         @if(! empty(config('adminlte.iframe.default_tab.url')))
             <div id="panel-default" class="tab-pane fade" role="tabpanel" aria-labelledby="tab-default">
-                <iframe src="{{ config('adminlte.iframe.default_tab.url') }}"></iframe>
+                <iframe src="{{ url(config('adminlte.iframe.default_tab.url')) }}"></iframe>
             </div>
         @endif

If this works, I will create a fix for it soon.

Other than that, I have no other clues about this, on my testing environment it's working fine. Also, the I-Frame feature is totally implemented by the underlying AdminLTE v3 package, there's not much we can do on this package, we just setup the template markup when the I-Frame is enabled, but the event listeners and the Javascript code to manage tabs opening/loading is exclusive of the underlying package...

SMEWebify commented 8 months ago

Hi @dfsmania

Yes I tested these two possibilities (simplest page possible) or the full URL

I'll create a dedicated page for Iframe

thanks anyway

Kévin

dfsmania commented 8 months ago

@SMEWebify Ok, please read the updated comment!

SMEWebify commented 8 months ago

@dfsmania

FYI, I am not publishing the view.

I added url() but that didn't solve it, by trying something else, I changed just the front line

<div id="panel-default" class="tab-pane fade" role="tabpanel" aria-labelledby="tab-default">

by

<div id="panel-default" class="tab-pane active" role="tabpanel" aria-labelledby="tab-default">

image I have the view displayed, but with a display bug

dfsmania commented 8 months ago

Ok, there's something weird happening, the initial set of classes won't matter because they are managed dinamically by the AdminLTE package. On my testing environment, after loading I ended up with the next markup:

<div id="panel-default" class="tab-pane fade active show" role="tabpanel" aria-labelledby="tab-default">
    <iframe src="..." style="height: 740px;"></iframe>
</div>

The height of the iframe is also calculated by the AdminLTE package.

Could you use the inspector tool to check what markup do yo end with?

SMEWebify commented 8 months ago

what do you get on the first load?

For me

<div id="panel-default" class="tab-pane fade" role="tabpanel" aria-labelledby="tab-default">
                <iframe src="opportunities"></iframe>
            </div>

I get this after the click on 'OPP'

            <div id="panel-default" class="tab-pane fade active show" role="tabpanel" aria-labelledby="tab-default">
                <iframe src="opportunities" style="height: 1105.02px;"></iframe>
            </div>
dfsmania commented 8 months ago

@SMEWebify On the first load, after the login procedure, I get what I posted before. Somehow, the AdminLTE package is not managing the default tab in your environment...

Here is the documentation we used when adding the support to this feature, in case you want to investigate further: https://adminlte.io/docs/3.2/javascript/iframe.html

SMEWebify commented 8 months ago

@dfsmania thx, i close this topic