Laravel Livewire multiple components not started asyncronously - laravel

I have 4 livewire components, rendered in dashboard as:
#livewire('profits.stats')
#livewire('costs.stats')
#livewire('leads.stats')
#livewire('sales.stats')
However, when page loads they run one after another instead of asyncronously. I put a sleep(3) to test, and each starts after the previous ones 3 second delay. How to get them to all start same time?
toggleShowData below has the sleep method, and sets showData=true. I saw this in a tutorial for now to have a loading for individual components
I don't think its relevant, but here is my template:
<div wire:init="toggleShowData">
<div wire:loading.delay class="align-items-center">
<div class="flex items-center justify-center ">
<div class="w-40 h-40 border-t-4 border-b-4 border-brand-500 rounded-full animate-spin"></div>
</div>
</div>
<div class="flex-auto p-4 bg-brand-300 rounded" wire:loading.remove>
<div class="flex flex-wrap">
<div class="relative w-full pr-4 max-w-full flex-grow flex-1">
<h5 class="text-gray-100 uppercase font-bold text-xs"> Costs</h5>
<span class="font-semibold text-xl text-gray-300">$34,100</span>
</div>
<div class="relative w-auto pl-4 flex-initial">
<div
class="text-white p-3 text-center inline-flex items-center justify-center w-12 h-12 shadow-lg rounded-full bg-red-500">
<i class="fas fa-chart-bar"></i>
</div>
</div>
</div>
<p class="text-sm text-gray-100 mt-4">
<span class="text-emerald-500 mr-2"><i class="fas fa-arrow-up"></i> 2,99% </span>
<span class="whitespace-nowrap"> Since last month </span></p>
</div>
</div>

The first render of the livewire page happens inside the PHP process in the backend.
Blade sees that you are requesting a livewire component and replaces this with the result of your parse() method from your component.
This indeed happens in sync, once the page is rendered the components can render itself async

Related

Robotframework - appium testing for hybrid android app (Angular)

I have a hard time testing our hybrid app with Robotframework tests using appium library. The application has 2 contexts:
Native (android)
Web (Angular)
The problem that I Have is when I'm in the web context and I'm trying to use XPath locators to locate elements that contain some text using the expression: Click Element //*[contains(#text,some_containing_text)] I would have the result of the root element which contains the element that I'm trying to locate. So in the end my test is clicking all the wrong way then it should be clicking because of that locator returning the root element of the HTML page.
This functionality of locating elements by just saying "Click element that contains something like this" is working with the selenium library on our Web application. But my question is why (or what I'm doing wrong) it doesn't work with appium Robotframework library.
Using appium 1.6.3.
I'm searching for span with the text Ukončit
<app-attendance-detail class="ng-star-inserted">
<div class="py-4">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="mb-4">
<div class="row">
<div class="col-12"><h4 class="fs-14 mb-1 font-weight-bold">úterý, 09:56:00 26.07.2022</h4>
</div>
</div>
<h4 class="fs-14 fs-md-16 mb-4 font-weight-bold text-gray-light ng-star-inserted">
<span>Začátek dnešní směny od</span> dnes v 9:45 </h4>
<div class="e-timer text-gray ng-star-inserted">00:10h</div>
<a href="#" title="#" preventdefault=""
class="btn btn-primary w-100 text-uppercase font-weight-bold px-9 mt-6 ng-star-inserted"><i
class="icon icon-stop position-relative bottom-1 mr-1"></i><span translate=""
ng-reflect-translate="">Ukončit</span></a>
<div class="row row-xs mt-2 ng-star-inserted">
<div class="col-6 px-1"><a href="#" title="#" preventdefault=""
class="btn btn-white border-primary-dark text-primary w-100 text-uppercase font-weight-bold px-9"><i
class="icon icon-pause position-relative bottom-1 mr-1"></i><span>Začátek<br>přestávky</span></a>
</div>
<div class="col-6 px-1"><a href="#" title="#" preventdefault=""
class="btn btn-white border-primary-dark text-primary w-100 text-uppercase font-weight-bold px-9"><span>Odchod<br>jiné</span></a>
</div>
</div>
</div>
<div class="mt-4"><h4 translate="" class="fs-14 fs-md-16 mb-2 font-weight-bold"
ng-reflect-translate="">Docházka</h4><a title="#" target="_blank"
class="d-block bg-white px-3 border-radius-sm box-shadow-sm mb-2 text-gray ng-star-inserted"
href="https://h5tws.cezdata.corp:44320/sap/bc/bsp/sap/zjd_dovol/overview.htm">
<div class="row">
<div class="col py-3 pb-3">
<div translate="" class="fs-16 font-weight-bold text-uppercase" ng-reflect-translate="">
Žádost o dovolenou
</div>
</div>
<div
class="col col-xs py-2 text-center border-left border-gray-light d-flex align-items-center justify-content-center">
<div class="text-gray"><i class="icon icon-forward"></i></div>
</div>
</div>
</a><a title="#" target="_blank"
class="d-block bg-white px-3 border-radius-sm box-shadow-sm mb-2 text-gray ng-star-inserted"
href="https://h5tws.cezdata.corp:44320/sap/bc/bsp/sap/zjd_doli/selection_screen.htm">
<div class="row">
<div class="col py-3 pb-3">
<div translate="" class="fs-16 font-weight-bold text-uppercase" ng-reflect-translate="">
Docházkový list
</div>
</div>
<div
class="col col-xs py-2 text-center border-left border-gray-light d-flex align-items-center justify-content-center">
<div class="text-gray"><i class="icon icon-forward"></i></div>
</div>
</div>
</a></div>
<div class="mt-4"><h4 translate="" class="fs-14 fs-md-16 mb-2 font-weight-bold"
ng-reflect-translate="">Záznamy</h4><a routinglink="attendance/records"
href="#" title="#"
class="d-block bg-white px-3 border-radius-sm box-shadow-sm mb-2 text-gray"
ng-reflect-routing-link="attendance/records">
<div class="row">
<div class="col py-3 pb-3">
<div translate="" class="fs-16 font-weight-bold text-uppercase" ng-reflect-translate="">
Přehled záznamů
</div>
</div>
<div
class="col col-xs py-2 text-center border-left border-gray-light d-flex align-items-center justify-content-center">
<div class="text-gray"><i class="icon icon-forward"></i></div>
</div>
</div>
</a></div>
</div>
</div>
</div>
<app-modal-dialog styleclass="shadow" ng-reflect-style-class="shadow" ng-reflect-show-header="false"
ng-reflect-dismissable-mask="false" ng-reflect-dialog-id="4">
<p-dialog class="p-element ng-tns-c30-7 ng-star-inserted" ng-reflect-style-class="shadow"
ng-reflect-visible="false" ng-reflect-modal="true" ng-reflect-dismissable-mask="false"
ng-reflect-transition-options="0ms" ng-reflect-show-header="false" ng-reflect-draggable="true"
ng-reflect-resizable="true" ng-reflect-close-on-escape="true" ng-reflect-base-z-index="1050">
</p-dialog>
</app-modal-dialog>
<app-modal-dialog styleclass="shadow" ng-reflect-style-class="shadow" ng-reflect-show-header="false"
ng-reflect-dialog-id="5" ng-reflect-dismissable-mask="false">
<p-dialog class="p-element ng-tns-c30-8 ng-star-inserted" ng-reflect-style-class="shadow"
ng-reflect-visible="false" ng-reflect-modal="true" ng-reflect-dismissable-mask="false"
ng-reflect-transition-options="0ms" ng-reflect-show-header="false" ng-reflect-draggable="true"
ng-reflect-resizable="true" ng-reflect-close-on-escape="true" ng-reflect-base-z-index="1050">
</p-dialog>
</app-modal-dialog>
</div>
This is the keyword in Robot testcase
Attendance_action
[Arguments] ${action}
Click element //*[contains(#text, "${action}")]
Sleep 2s
Thanks for updating the question to include the details of how the XPath is called. It seems to me that you will end up with an expression like //*[contains(#text, "Ukončit")]; I would not expect that to return anything because the expression #text is a refererence to an attribute with the name text. It's not a reference to the textual content of an element.
I suspect what you actually meant to enter was an expression like this:
//*[text()[contains(., "Ukončit")]]
Translation: any element which contains a text node which itself contains the string "Ukončit". That should return a single span element:
<span translate="" ng-reflect-translate="">Ukončit</span>

How to pass data between components Laravel

Hello I'm confused on how should I pass collections/data to another component so I can display it in another component (in this case I'm showing discounts so it will be a section with popular discounts and another section showing latest discounts).
So i have this index.blade.php and i'm a bit confused on how to pass the data to x-discount-card component so I can access to $discount->title on the component. Right now I get "undefined variable $discount" so it seems i'm not accessing it right.
<x-layout>
<main>
#include('components.categories-row')
#include('discounts._best')
<section class="w-4/6 mx-auto my-8 font-bold flex flex-col items-center justify-center">
<h1 class="uppercase text-main-gray text-4xl bold self-start text-center mb-4 ">Últimos Descuentos</h1>
#if($discounts->count())
#foreach($discounts as $discount)
<x-discount-card :discount="$discount" />
#endforeach
#else
<p class="my-8 text-center">No hay descuentos disponibles. Por favor vuelva mas tarde. </p>
#endif
</section>
</main>
</x-layout>
discount-component
#props(['discount'])
<div
class="w-[20rem] h-auto bg-gradient-to-b from-card-light-gray to-card-main-gray p-6 rounded-2xl drop-shadow-xl md:w-[35rem] lg:w-[35rem] lg:w-[50rem] lg:h-auto mb-4">
<div class="flex-col items-center text-center justify-center h-full lg:grid lg:grid-cols-4 lg:grid-rows-4">
<a href="" class="flex justify-center lg:row-span-4 lg:-ml-10">
<img class="h-full " src="/images/pngwing.com.png" alt="" width="120" height="120">
</a>
<div
class="flex-col justify-center items-center text-center w-full lg:col-start-2 lg:col-span-full lg:row-start-1 lg:row-span-full lg:-ml-14">
<a href="/discount/1" class="lg:grid lg:row-start-2">
<h2 class="text-white font-bold text-lg md:text-2xl lg:my-2">{{ $discount->title }}</h2>
<div class="flex my-4 items-center text-center justify-center lg:my-2">
<p class="text-price-color font-bold mr-8 text-xl md:text-2xl">139,99€</p>
<p class="line-through text-white text-lg md:text-lg">149,99 (-10€)</p>
</div>
<p class="text-white my-8 text-sm md:text-lg lg:my-4">Bambas nike con 10€ de descuento y envio gratis.
Salen a
139,99€</p>
</a>
<div
class="flex-col items-center justify-center gap-2 lg:flex-row lg:inline-flex lg:col-start-2 lg:col-span-full lg:row-start-4 lg:row-end-5">
<a class="flex items-center justify-center my-2 " href="/user/1">
<img class="rounded-full mr-2" src="https://i.pravatar.cc/35"
alt="">
<p class="mr-4 text-white text-sm font-bold transition-transform hover:translate-x-0.5 md:text-lg">
JohnDoe</p>
</a>
<div class="flex items-center justify-center my-4 gap-4 lg:mx-4">
<div
class="border border-light-gray p-1 rounded-md transition-transform hover:-translate-y-0.5 cursor-pointer">
<img class="h-full" src="/images/heart.png" alt="" width="22" height="22">
</div>
<div
class="border border-light-gray p-1 rounded-md transition-transform hover:-translate-y-0.5 cursor-pointer">
<img class="h-full" src="/images/dislike.png" alt="" width="22" height="22">
</div>
<div
class="flex items-center border border-light-gray p-1 rounded-md transition-transform hover:-translate-y-0.5 cursor-pointer lg:px-4">
<img class="h-full" src="/images/comment.png" alt="" width="22" height="22">
<p class="text-light-gray ml-2">10</p>
</div>
</div>
<div class="flex justify-center lg:w-[250px] lg:-mr-14">
<button
class="flex my-4 items-center justify-center bg-gradient-to-b from-button-light-orange to-button-dark-orange p-2 rounded-md transition-transform hover:-translate-y-0.5 md:p-4 lg:w-full ">
<p class="text-light-gray mr-4 font-bold text-sm md:text-lg ">Ver Chollo</p>
<img src="/images/external-link.png" alt="" width="20" height="20">
</button>
</div>
</div>
</div>
</div>
<div
class="w-auto absolute top-5 left-5 flex-col items-center justify-center rounded-2xl bg-button-light-orange p-2 drop-shadow-lg md:flex-row md:inline-flex">
<p class="text-white text-xs uppercase font-bold mr-2 md:text-sm ">10%</p>
<p class="text-white text-xs uppercase font-bold md:text-sm ">descuento</p>
</div>
</div>
Also on the routes file i'm passing discounts but i'm a bit confused on how should I pass the data because right now i'm getting "undefined variable $discount error"
Route::get('/', function () {
return view('discounts.index', [
'discounts' => Discount::all(),
// ->where('premium','=',false)
'categories' => Category::all()
]);
})->name('home');
On the discounts._best component i'll display the discounts with more likes but this will be done in the future but I share the component too because maybe something there is what is causing the error.
<section class=" w-full text-center h-3/4 bg-light-gray flex flex-col items-center justify-center p-10">
<h1 class="uppercase text-main-gray mb-8 text-4xl font-bold">Descuentos Populares</h1>
<x-discount-card />
</section>
I searched on the Laravel Documentation about Component attributes but I dont know what i'm doing wrong and still confused.

Seeing elements of #guest when logged in

<div class="col-6 col-md-4 col-lg-3 mb-4 mb-sm-5">
<div class="col-12 h-100 c-bg-offwhite p-0">
<div class="row">
<div class="col-12 text-center">
<img class="w-100" src="{{ url('/storage/photo_images/'.$image) }}" alt="">
</div>
<div class="col-12 text-left">
<p class="p color-black d-block px-4 pt-4 pb-3 mt-0 mb-0">{{$photo->title}}</h3>
</div>
#guest
<div class="col-12">
<div class="px-4 pb-4">
<a href="/contact">
<button class="w-100 btn-primary">Get a quote</button>
</a>
</div>
</div>
#endguest
</div>
</div>
#auth
<div class="col-12 p-0 mt-3">
<a href="/photos/{{$photo->slug}}/edit">
<button class="w-100 btn-primary">Edit</button>
</a>
</div>
#endauth
</div>
The code is a photo, with a title and a button for customers to click to contact the company. When an end-user is logged in it turns into an edit button, but sits underneath so not to confuse it with the customer facing button. It should be a case of one button on, one button off.
auth
guest
I'm so sorry for not really understanding your question.
But based on you question and the screenshot you provides it's already do what it shoud do.
#guest will be showing a button with 'Get A Quote' written on it and links to /contact
and #auth will be showing edit button when a user is logged in.

make a Grid system like bootstrap in Tailwind

i am using TailWind with blade template in laravel, how can i make those card like in the bootstrap, i mean every three items in the one column :
#section('content')
<div class="flex justify-center">
<div class="w-8/12 bg-white p-6 rounded-lg mt-10 ">
#forelse($products as $product)
<!-- Box -->
<div class="md:flex md:justify-center md:space-x-8 md:px-14">
<!-- box-1 -->
<div class="mt-16 py-4 px-4 bg-whit w-72 bg-white rounded-xl shadow-lg hover:shadow-xl transform hover:scale-110 transition duration-500 mx-auto md:mx-0">
<div class="w-sm">
<img class="w-64" src="{{asset('storage/images/products/'.$product->image)}}" alt="" />
<div class="mt-4 text-green-600 text-center">
<h1 class="text-xl font-bold">{{$product->name}}</h1>
<div class="mt-4 text-gray-600">{{$product->info}}</div>
<div class="mt-4 px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-300 text-green-800">{{$product->category->name}}</div>
<button class="mt-8 mb-4 py-2 px-14 rounded-full bg-green-600 text-white tracking-widest hover:bg-green-500 transition duration-200">MORE</button>
</div>
</div>
</div>
#empty
<h1 class="text-center">There is no Products</h1>
#endforelse
<div> {{$products->links()}}</div>
</div>
</div>
#endsection
Recreate the Bootstrap grid system in Tailwind CSS
<div class="grid grid-cols-12">Your column goes here</div>
You can follow this link for further details. https://shortbuzz.in/blog/shortbuzz.in/how-to-create-tailwind-css-grid-system-like-the-bootstrap-grid-system
Here's Peppermintology's comment in the form of an answer:
It sounds like you're looking for a 3 column grid. To do that in Tailwind CSS, use the grid classes like this:
<div class="grid grid-cols-3">
<!--- Generated cards go here --->
</div>
<div class="container mx-auto">
  <div class="grid grid-cols-12 gap-1">
    <div class="col-span-12 sm:col-span-12 md:col-span-3 lg:col-span-3 xl:col-span-3 2xl:col-span-3">Column</div>
    <div class="col-span-12 sm:col-span-12 md:col-span-3 lg:col-span-3 xl:col-span-3 2xl:col-span-3">Column</div>
    <div class="col-span-12 sm:col-span-12 md:col-span-3 lg:col-span-3 xl:col-span-3 2xl:col-span-3">Column</div>
  </div>
</div>

How to highlight the class from an object prop in vue.js with laravel

I need help or suggestion in highlighting / toggling a class and displaying data I'm just using blade/server-side in passing props, so from this in blade
<chat-app :respondent="{{ $user[0]->respondent }}" :user="{{ auth()->user() }}"></chat-app>```
then inside the ChatApp.vue file
<message-inbox :contact="respondent" :messages="messages"></message-inbox>
the contact prop there contains the user object that we'll send the chat to... including his id and display name and other basic details..
now I want to fetch all the messages but also highlighting that specific respondent's message.
<li class="bg-blue flex flex-no-wrap items-center text-black cursor-pointer p-3">
<img class="flex justify-center items-center flex-no-shrink w-12 h-12 bg-grey rounded-full font-semibold text-xl text-white mr-3" :src="userAvatar" alt="">
<div class="flex-1 min-w-0">
<div class="flex justify-between mb-1">
<h2 class="font-semibold text-sm">
<i class="fas fa-users fa-fw"></i> {{ conversation.respondent }}
</h2>
<span class="text-sm">
<i class="fas fa-check fa-fw"></i>
10:00
</span>
</div>
<div class="text-sm truncate">
<span>
Some latest messages from this conversation.
</span>
</div>
</div>
</li>
props : {
contact : {
type : Object,
default : null
},
messages : {
type : Array,
default : []
},
}
I think you should do the following to highlight the mentioned respondent.
Change your li tag as below code:
<li class="bg-blue flex flex-no-wrap items-center text-black cursor-pointer p-3" :class="{'highlight': conversation.respondent == respondent}">
<img class="flex justify-center items-center flex-no-shrink w-12 h-12 bg-grey rounded-full font-semibold text-xl text-white mr-3" :src="userAvatar" alt="">
<div class="flex-1 min-w-0">
<div class="flex justify-between mb-1">
<h2 class="font-semibold text-sm">
<i class="fas fa-users fa-fw"></i> {{ conversation.respondent }}
</h2>
<span class="text-sm">
<i class="fas fa-check fa-fw"></i>
10:00
</span>
</div>
<div class="text-sm truncate">
<span>
Some latest messages from this conversation.
</span>
</div>
</div>
</li>
Add highlight class in your CSS part as below:
.highlight {
color: yellow;
}

Resources