B4J Tutorial SithasoDaisy TailwindCSS UI Toolkit: Q & A

Hi there

NB: Where possible, please include a simple project that demonstrates your use case.

Do you have any questions about SithasoDaisy UI Toolkit?

You can shoot it here and we will oblige.

Thanks in advance?


Join on Telegram


Check $5 WebApps

 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Thanks! It worked, but:
1 - I don't see the logs in the IDE : Log(params.Get("parameter1")).
Even in the SithasoDaisy demo - like the sub btncode_click - I can't see the logs.

2 - I have a code to save a text file (based in second option of this post) that uses a #if javascript.
It works before, but now if I put the javascript code I get a blank page.

2.1 - I can't see the SDUIButton1 that I put in the home layout (pgHome).

What could be happens?
The project is in attached.
I have updated the project. These are the changes made.



  • Use hamburger to show & close the drawer.
  • Click a button and generate a text file & download it.
 

Attachments

  • WriteTextFileAndDownload.zip
    44.7 KB · Views: 74

Mashiane

Expert
Licensed User
Longtime User
I have this link:
that me returns a JSON:
B4X:
{"resultado":"1","resultado_txt":"sucesso - cep completo","uf":"MG","cidade":"Belo Horizonte","bairro":"Centro","tipo_logradouro":"Avenida","logradouro":"Afonso Pena"}
I try to use the code of the module demoADClients of the SithasoDaisyDemo to get the contents, but don't works. The postal.Success return False.
Here is my code. What I can do wrong?
B4X:
Sub btnPostalCode_click (e As BANanoEvent)
    Dim postal As SDUIFetch
    postal.Initialize("http://cep.republicavirtual.com.br/web_cep.php?cep=30130003&formato=json")
    postal.SetContentTypeApplicationJSON
    banano.Await(postal.GetWait)
    If postal.Success Then
        'on success, get the results
        Dim response As Map = postal.response
        'as per fields we have defined.
        Dim results As List = response.get("results")  '??
        'as per fields we have defined.
        For Each postalcode As Map In results
            Dim c As Map = CreateMap()
            c.Put("uf", postalcode.Get("uf"))
            c.Put("cidade", postalcode.Get("cidade"))
            c.Put("bairro", postalcode.Get("bairro"))
            c.Put("logradouro", postalcode.Get("logradouro"))
        Next
    Else
        Log(postal.ErrorMessage)
    End If
End Sub
You call a http, this needs to be called not from https, in your case it gives a 404.

This is the output with.

B4X:
Dim postal As SDUIAxios
    postal.Initialize("http://cep.republicavirtual.com.br/web_cep.php")
    'add a parameters
    postal.AddParameter("cep", "30130003")
    postal.AddParameter("formato", "json")
    'execute the post
    banano.Await(postal.GetWait)
    Log(postal.Status)
    Log(postal.Data)

1677053140348.png


SDUIFetch is based on BANanoFetch, Im not sure why it gives a blank.
 

Attachments

  • 1677052586016.png
    1677052586016.png
    24 KB · Views: 57
  • postalCode.gif
    postalCode.gif
    114.5 KB · Views: 56
  • axios api call.zip
    45.3 KB · Views: 68
Last edited:

alwaysbusy

Expert
Licensed User
Longtime User
Native BANano works just fine, so something must be wrong in your SDUIFetch wrapper.

B4X:
Dim fetch As BANanoFetch
Dim fetchOptions As BANanoFetchOptions
Dim fetchResponse As BANanoFetchResponse        
Dim Error As String
        
fetchOptions.Initialize
fetchOptions.Method = "GET"
fetch.Initialize("http://cep.republicavirtual.com.br/web_cep.php?cep=30130003&formato=json", fetchOptions)
Try
        ' wait for the response
        fetchResponse = BANano.Await(fetch)
        ' wait for the json part of the response
        Log(BANano.Await(fetchResponse.Json))        
Catch(Error)
        Log(Error)
End Try

Result:
1677053803625.png


Alwaysbusy
 

Mashiane

Expert
Licensed User
Longtime User
SDUIFetch - Fixed

issue was: banano.Await(postal.GetWait) internals

B4X:
Dim postal As SDUIFetch
    postal.Initialize("http://cep.republicavirtual.com.br/web_cep.php")
    'add a parameters
    postal.AddParameter("cep", "30130003")
    postal.AddParameter("formato", "json")
    'execute the get
    banano.Await(postal.GetWait)
    Log(postal.Status)
    Log(postal.StatusText)
    Log(postal.Success)
    Log(postal.Response)

1677061811560.png



NB: Patch now available for download.
 
Last edited:

asales

Expert
Licensed User
Longtime User
1 - I don't see the logs in the IDE : Log(params.Get("parameter1")).
Even in the SithasoDaisy demo - like the sub btncode_click - I can't see the logs.
The answer to my question: the logs are not show in the Logs tab of the B4J IDE, but in the console of the browser.
In the Microsoft Edge I open the console with Ctrl+Shift+J.
 

asales

Expert
Licensed User
Longtime User
SDUIFetch - Fixed

issue was: banano.Await(postal.GetWait) internals

B4X:
Dim postal As SDUIFetch
    postal.Initialize("http://cep.republicavirtual.com.br/web_cep.php")
    'add a parameters
    postal.AddParameter("cep", "30130003")
    postal.AddParameter("formato", "json")
    'execute the get
    banano.Await(postal.GetWait)
    Log(postal.Status)
    Log(postal.StatusText)
    Log(postal.Success)
    Log(postal.Response)

NB: Patch now available for download.
Now as I can see the logs, I get this message when I try the code.:
B4X:
Mixed Content: The page at 'https://localhost/sithasodrawer/index.html' was loaded over HTTPS, but requested an insecure resource 'http://cep.republicavirtual.com.br/web_cep.php?cep=30130003&formato=json'. 
This request has been blocked; the content must be served over HTTPS.
How can I access the insecure HTTP://?
Thanks for all help in this thread!
 

alwaysbusy

Expert
Licensed User
Longtime User
How can I access the insecure HTTP://?
As far as I know this is not possible any more for obvious security reasons. A https site can no longer access insecure http resources. Their https certificate seems to be only valid if coming from a *.uni5.net, uni5.net domain.
 

asales

Expert
Licensed User
Longtime User
The SDUIFullCalendar component is great, but:

1- I can translate the month, week, days and buttons use the locale property:
1677157456999.png

but I could not translate this button ("today"):
1677157428624.png


2 - If I resize the browser or access the calendar using a mobile, it don't show correctly:
mobile
1677157714506.png


desktop
1677157780260.png
 

asales

Expert
Licensed User
Longtime User
I'm trying to load a text file and read his lines (one by one) as a list.
This is my code to read the file and get the lines, but "myText.Get(i)" get char by char instead line by line.
B4X:
Dim myText As List = banano.Await(banano.GetFileAsText(fp, Null, "UTF-8"))
For i = 0 To myText.Size -1
    Log(myText.Get(i))   'show char by char instead line by line
Next
How I can read the text file line by line?
Thanks in advance for any tips.
 

angel_

Well-Known Member
Licensed User
Longtime User
I'm trying to load a text file and read his lines (one by one) as a list.
This is my code to read the file and get the lines, but "myText.Get(i)" get char by char instead line by line.
B4X:
Dim myText As List = banano.Await(banano.GetFileAsText(fp, Null, "UTF-8"))
For i = 0 To myText.Size -1
    Log(myText.Get(i))   'show char by char instead line by line
Next
How I can read the text file line by line?
Thanks in advance for any tips.
Try this:

B4X:
Dim myStrText As String = banano.Await(banano.GetFileAsText(fp, Null, "UTF-8"))
Dim myText As List = BANano.Split(CRLF, myStrText)
For i = 0 To myText.Size -1
    Log(myText.Get(i))
Next
 

asales

Expert
Licensed User
Longtime User
Try this:

B4X:
Dim myStrText As String = banano.Await(banano.GetFileAsText(fp, Null, "UTF-8"))
Dim myText As List = BANano.Split(CRLF, myStrText)
For i = 0 To myText.Size -1
    Log(myText.Get(i))
Next
It worked. Thanks!
 

asales

Expert
Licensed User
Longtime User
I'm trying to hide this component (SDUIRadioGroup) in runtime, with the code below, but the caption is not hide:
B4X:
radGender.Hide
1677426183447.png

How can I hide the caption too?
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
I'm trying to hide this component (SDUIRadioGroup) in runtime, with the code below, but the caption is not hide:
B4X:
radGender.Hide
View attachment 139755
How can I hide the caption too?
B4X:
Sub ShowRadio(RadioID As String)
    BANano.GetElement($"#${RadioID}_formcontrol"$).RemoveClass("hidden")
End Sub

Sub HideRadio(RadioID As String)
    BANano.GetElement($"#${RadioID}_formcontrol"$).AddClass("hidden")
End Sub

Please use this for now, will be fixed in the next release. Thank you.
 

sdleidel

Active Member
Licensed User
Longtime User
I have a Question:
i have this PHP-code to "download" a file from the Server"


php:
function getmyfile($path, $filename) {
 
$file = $path."/".$filename;

header('Content-type: application/octet-stream');
header("Content-Type: ".mime_content_type($file));
header("Content-Disposition: attachment; filename=".$filename);
while (ob_get_level()) {
    ob_end_clean();
}
readfile($file);

}

This code is OK

Now, how i can get this working in my "Sithaso APP" ?
I have test with:
test:
Dim s As String = banano.CallInlinePHPWait("getmyfile", CreateMap("mypath":"C:/laragon/www/PDFBestellung", "myfile":"Bestellung"&myLieferscheinnr&".pdf"))

But i would like that the browser download the file ...
 

Mashiane

Expert
Licensed User
Longtime User
I have a Question:
i have this PHP-code to "download" a file from the Server"


php:
function getmyfile($path, $filename) {
 
$file = $path."/".$filename;

header('Content-type: application/octet-stream');
header("Content-Type: ".mime_content_type($file));
header("Content-Disposition: attachment; filename=".$filename);
while (ob_get_level()) {
    ob_end_clean();
}
readfile($file);

}

This code is OK

Now, how i can get this working in my "Sithaso APP" ?
I have test with:
test:
Dim s As String = banano.CallInlinePHPWait("getmyfile", CreateMap("mypath":"C:/laragon/www/PDFBestellung", "myfile":"Bestellung"&myLieferscheinnr&".pdf"))

But i would like that the browser download the file ...
If you can get the "blob" of the file, you can execute..

B4X:
SDUIShared.DownloadBlob(blobOfFile, "Bestellung"&myLieferscheinnr&".pdf")
 

asales

Expert
Licensed User
Longtime User
B4X:
Sub ShowRadio(RadioID As String)
    BANano.GetElement($"#${RadioID}_formcontrol"$).RemoveClass("hidden")
End Sub

Sub HideRadio(RadioID As String)
    BANano.GetElement($"#${RadioID}_formcontrol"$).AddClass("hidden")
End Sub

Please use this for now, will be fixed in the next release. Thank you.
I tried this way, but don't worked:
B4X:
HideRadio("radGender")
 

asales

Expert
Licensed User
Longtime User
Can I set a max lenght to the text of the SDUITextArea?
I don't want the user put more the 500 characters in the textfield, for example.
 

asales

Expert
Licensed User
Longtime User
One more to my question list:
- Everytime that I deploy a project, it create this files in the assets subfolder of www:
600by600.jpg, SithasoDaisyLogo.jpg, daisyui.jpg, .woff2 and .ttf extension files.

I don't use this files and it is don't in the assets folder of my project.
How can I remove this files automatically when I compile the project?

Thanks in advance.
 
Top