Jump to content

Tim Koscielski

  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Tim Koscielski

  1. Tim Koscielski

    TW3StringGrid is available

    I have just done a light review of this StringGrid demo and was wondering if TW3Button is an option. What the real question is how to get the unique ID of selected row and then take the user to either a new form or view based on the selected item. At this time, I have used the TW3Grid, but was interested in perhaps switching over to this one.
  2. Tim Koscielski

    Mixing Javascript and SMS

    Thank you for the quick overview. I had seen notes about the handle, but was hoping someone could summarize it here for me. This helps to clarify and gives me a start. I will always try to figure out how to keep things organized in SMS, but for the short term, ASM may be the crutch I need to get things going.
  3. Tim Koscielski

    Mixing Javascript and SMS

    I have been using ASM blocks in my project and find that I want to mix javascript and SMS. Below are two use cases. In an ASM block I would like to set a SMS attribute on a SMS object like a button doing something like TW3Button.Visible := True In an ASM blick I would like to call a SMS procedure or function to complete some common actions Below is my psuedo code which I am hoping someone can correct and give some guidance on. I'm just looking for enough to be dangerous..... EXAMPLE 1: Set attribute on button. asm // Unsure how to do this here to call back to a button in SMS @W3Button1.Visible = True end; Example 2: Call SMS function from a javascript block procedure TForm.DoSomething; begin ShowMessage('Doing something'); end; procedure TForm.OnButtonClick(Sender: TObject); begin asm @DoSomething; end; end; For me this is the simplest I can make it which will help better understand the javascript-SMS links. I am hopeful that you understand, for these examples, it is not exactly how I'm using them, but for understanding I thouhgt this was the easiest examples I could do. Thanks. tim
  4. Tim Koscielski

    Uploading a file that has been selected using INPUT box type=itFile

    Ok, this first follow up is what I did to get it working based on some of the links for handling forms in javascript. Fortunately because I could mix and match SMS Pascal and Javascript, I get the best of both worlds. On my Smart Form, I have a TW3Button and a TW3EditBox with a type of ltFile. Then with the following javascript, I can get the form posted correctly to a backend which is able to capture the file and other variables of the form. Note that the other elements are created dynamically based on an example I was using. The ShowMessage and Alert items were just feedback mechanisms for me to see this part working. Both my DMVC server and a PHP script were able to process this. I am sure that there is a more friendly SMS way of writing this, but for now it got my form working and I was able to continue to plow forward with this upload piece being reasonably well contained. My key take way was getting the file upload field and the code below did the trick. This may not be the best way, but at least it was a starting point. myFile = document.getElementById('id', 'fupload1'); The InitializeObject was important to label the TW3EditBox element correctly. Below that is the code that I stuck in the OnClick event for the button. I saw many other ways to deal with this, but I just wanted to keep it straight forward for the UI. procedure TForm_ImportFile.InitializeObject; begin inherited; {$I 'Form_ImportFile:impl'} W3ButtonBack.InnerHTML := '<i class="fa fa-arrow-left fa-2x"></i>'; // this is a good place to initialize components W3EditBox1.handle.setAttribute('name','fupload'); W3EditBox1.handle.setAttribute('id', 'fupload1'); // Initialize EditBox id to find it with getElementById below W3EditBox1.InputType := itFile; end; // BUTTON CLICK EVENT CODE ShowMessage('Starting'); asm var formData = new FormData(); alert('Trying to get file box'); myFile = document.getElementById("fupload1").files[0]; alert('Got file: ' + myFile.name); formData.append("username", "Groucho"); formData.append("accountnum", 123456); // number 123456 is immediately converted to a string "123456" // HTML file input, chosen by user //formData.append("fupload", fileInputElement.files[0]); //var myFile = new Blob([content], {type: "text/plain"}); formData.append("userfile", myFile, myFile.name); // JavaScript file-like object var content = '<a id="a"><b id="b">hey!</b></a>'; // the body of the new file... var blob = new Blob([content], { type: "text/xml"}); formData.append("webmasterfile", blob); var request = new XMLHttpRequest(); request.open("POST", ""); request.send(formData); end; ShowMessage('Done');
  5. I am using DMVC and SMS and the user is going to be uploading a file to the server. I can create a simple HTML form which will complete the upload to the DMVC server, but I can't quite figure out how to approach it using SMS. I am hoping to get pointed in the right direction or have some suggested options for uploading the file. This is just something that is going to be simple and I'll save the cool features for later. Ideally I was hoping to upload the file in the background and then provide the user feedback once it was done. Nothing fancy like a progress indicator is needed as these files are small, Are there any samples or places I can look. I am using version Thanks. tim
  6. Tim Koscielski

    Uploading a file that has been selected using INPUT box type=itFile

    Thank you for the help. It has gotten me closer, but the SMS approach does not seem to be capturing the data. Also, remember, I am using DMVC to receive the POST, but for the SMS side, I could just as easily be using a server running PHP, NODE.JS or some other mechanism to receive and process the file. My question is more general about how SMS can emulate a form POST to upload the file. Now to the example. I can see the SMS example posting to the correct page, but not the actual data of the file upload component. Using the inspector in Chrome or FireFox and watching the Network activity, for the SMS example in the data section I only see the following which seems to just the the object name and not the data. [object FormData] Now when I compare and use a standard HTML5 form almost exactly like the sample you posted above, the network watcher in the Inspector of the browser shows the following in the Params section for the post which is a sample text file I am posting. It is the same file used via the SMS form and the HTML form. -----------------------------244962545219104 Content-Disposition: form-data; name="fupload"; filename="Hello.txt" Content-Type: text/plain I am a plain text document. -----------------------------244962545219104-- Any thoughts on what might be happening here. I will dig a little deeper into the Javascript processing of FormData, but I'm hoping this feed back can help. I find SMS to be a great tool, but I feel like a beginner still learning this tool. Thanks. Tim
  7. Tim Koscielski

    My forum password...Issues logging in...

    That was it.... Thank you... I am not less confused... <grin>
  8. Tim Koscielski

    My forum password...Issues logging in...

    For some reason, I can't reset my forum password or figure out the login. I have done this routine about 5 times with no luck. The only way I can get logged into the forum is to follow the "I forgot my password" link. The email gives me a link to set a new password which also logs me in, but if I go to a second browser or if I log off, I can't log back into the forum. Any ideas here to fix this. I have tried everything I could and just can't figure it out.
  9. Tim Koscielski

    What happened to VarIsValidRef?

    In the REST code example I have, it looks like the demo has not been updated to work with version var dt := TDateAndTime(JSON.Parse(http.ResponseText)); // dt.date will be 'undefined' if a bad response is returned // this may cause problems in a more complex code but works fine here Log('Date: ' + dt.date); // better way is to test explicitely Log('Time: ' + if VarIsValidRef(dt.time) then dt.time else 'unknown'); Has this function been removed? If so, what is a method to replace this. I saw some commented examples in SmartCL.Graphics.pas, but I was not sure how to handle this. Thanks for any feedback.
  10. Everyone, In my web app, I needed to get the URL that delivered the app to the browser. I initially thought there might be an object in SMS that would give me this info, but after looking, nothing looked like the obvious solution. So I knew these could be gotten in Javascript so that is what I did. My question is this, is there a better way to do this in SMS? Thanks for the feedback. Below is what I came up with in the InitializeForm procedure. procedure TForm1.InitializeForm; var URL: String; HOST: String; begin inherited; // this is a good place to initialize components // Inline Javascript to get data back to SMS asm @URL = window.location.href; @HOST = window.location.host; console.log('******************'); // Checking in browser to make sure it was correct console.log(window.location.href); end; FURL := URL; // Private object variable for use later FHOST := HOST; // Private object variable for use later end;
  11. Everyone, DEMO APP HERE: https://www.harmonicmix.com/200/ BUILT WITH: SMS Professiional BETA I am relatively new to SMS development, but not new to Delphi development. I have been slowly getting my hands wrapped around the power of SMS and I believe that it is a great tool and I see a lot of promise for rapid development. I have run into a number of hurdles and as a beginner, I have been slowly working through them with the hardest challenge to date being CORS as a new developer. Trying to get a server configured just so has been a challenge and something that can trip me up. However, this latest glitch has me baffled and I'm unsure if it is related to SMS, CORS, web server etc. This one has me baffled and I'm hoping I'm missing something easy and others can look at this and provide me with an AH AH moment. My target platform for now has been a browser running a SMS app which uses a REST API interface and a simple layout. I have created a demo app just to demonstrate this issue and I am using Apache as a hosting platform. But, I have already tried the app on both Apache and IIS and have duplicated issues with images loading ONLY in Chrome. So to the app.... A two form app with a simple layout. Buttons to navigate back and forth between forms. A TW3Image object placed on each form and the image is being loaded in the initialize event like I have seen in many examples The problem is this.... (I think) When I view the app in Firefox, Edge and IE it works as expected, the image loads and I see no broken links. (See good screen shot) In Chrome on MAC or Windows 10, Chrome only shows the image on both forms as a broken link. No image loads. When looking in the network debugger on Chrome, the image won't load with an error of "(failed) net::ERR_FAILED" [see screen shots for Chrome] Below is the simple code for each form. I have attached GOOD screen shots where everything looks OK and and BAD screen shots in Chrome where it fails. Thank you for your help and feedback in looking at this..... I assume it is easy and I'll be happy to share more information if needed. //=============================================================== // FORM1 CODE //=============================================================== unit Form1; interface uses System.Types, System.Types.Convert, System.Objects, System.Time, SmartCL.System, SmartCL.Time, SmartCL.Graphics, SmartCL.Components, SmartCL.FileUtils, SmartCL.Forms, SmartCL.Fonts, SmartCL.Theme, SmartCL.Borders, SmartCL.Layout, SmartCL.Application, SmartCL.Controls.Panel, SmartCL.Controls.Button, SmartCL.Controls.Image; type TForm1 = class(TW3Form) procedure W3Button1Click(Sender: TObject); private {$I 'Form1:intf'} FLayout: TLayout; protected procedure InitializeForm; override; procedure InitializeObject; override; procedure Resize; override; end; implementation { TForm1 } procedure TForm1.W3Button1Click(Sender: TObject); begin Application.GotoForm('Form2', feFromRight); end; procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components FLayout := Layout.Center(W3Panel1); W3Image1.LoadFromURL('https://www.harmonicmix.com/sites/all/images/HM_logo.png'); end; procedure TForm1.InitializeObject; begin inherited; {$I 'Form1:impl'} end; procedure TForm1.Resize; begin inherited; end; initialization Forms.RegisterForm({$I %FILE%}, TForm1); end. //=============================================================== // FORM2 CODE //=============================================================== unit Form2; interface uses System.Types, System.Types.Convert, System.Objects, System.Time, System.IOUtils, System.Device.Storage, SmartCL.System, SmartCL.Time, SmartCL.Graphics, SmartCL.Components, SmartCL.FileUtils, SmartCL.Device.Storage, SmartCL.Forms, SmartCL.Fonts, SmartCL.Theme, SmartCL.Borders, SmartCL.Layout, SmartCL.Application, SmartCL.Controls.Panel, SmartCL.Controls.Button, SmartCL.Controls.Image; type TForm2 = class(TW3Form) procedure W3Button1Click(Sender: TObject); private {$I 'Form2:intf'} FLayout: TLayout; protected procedure InitializeForm; override; procedure InitializeObject; override; procedure Resize; override; end; implementation { TForm2 } procedure TForm2.W3Button1Click(Sender: TObject); begin Application.GotoForm('Form1', feToLeft); end; procedure TForm2.InitializeForm; begin inherited; // this is a good place to initialize components FLayout := Layout.Center(W3Panel1); W3Image1.LoadFromURL('https://www.harmonicmix.com/sites/all/images/HM_logo.png'); end; procedure TForm2.InitializeObject; begin inherited; {$I 'Form2:impl'} end; procedure TForm2.Resize; begin inherited; end; initialization Forms.RegisterForm({$I %FILE%}, TForm2); end.
  12. @IElite Your demo app now works for me too. I did have to use CTRL+F5 on the Windows platforms and few reloads on the Android platforms and then I could see both apps working correctly. Thanks for hanging in there with me and trying out a few things. It really helped me to focus on the app instead of my computer settings. ? I knew this SMS stuff was robust, I just needed the right details. Hoping to still get some thoughts by others on the app.manifest file and how it is a good thing? tim
  13. So I did find where in SMS in Project Options where it can be setup so that the app.manifest and webapp.json are not generated as part of the project. This then compiles to create the correct output. (See screen shot below) I did delete the compiled project from the www folder before building the project again and noted that neither file was generated. I still have a ways to go with understanding all the possible options, but being able to now create and push a web app successfully created with SMS and understand how to make it work is a huge win for me. However, it would be great to have someone on the SMS team perhaps provide a small explanation on different Manifest options that you can generate in SMS and some of the potential side effects that selections can have on each other. Thanks. tim
  14. @IElite Can you remove the app.manifest from your app and I can then give your sample a try? Alright, a complete day of learning and I am getting somewhere. If I remove the app.manifest from the web server either by renaming it or by changing the index.html file and removing it from the top, the image now loads properly every time in Chrome once I did a CTRL-F5 to clear the cache on the browser. Below is the HTML file change I made... //CHANGED FROM <html manifest="app.manifest"> // TO in index.html <html> Ok so now the next part of this adventure... What happen here please? It would be great to close this out with some type of explantion? Is the app.manifest used different on various browsers? Can anyone explain the app.manifest when used with a web app like this which is downloaded from a web server can stop things like this from working? In this regard, I also had this caching issue affect REST requests which were being made with a GET. When I changed the REST request to a POST, they then worked as expected. Thank you for your feedback in helping me to try to understand the differences between standalone SMS apps and apps that are delivered by a web server.
  15. Ok, the last, last comment. Chrome on Android does not load the page. It seems like on first load when items are getting downloaded to the cache, the app loads correctly, but then if you go back to the app later (unsure how much later) and then the image will not load. I duplicated this scenario on two Android devices. One a Samsung Tab and the other a Samsung Galaxy S7.
  16. OK, so my last comment on this and I hope someone else will be able to look at this and tell me what I'm doing wrong. I decided I wanted to test a CEF3 client and downloaded BriskBard which uses a version of Chromium. Unfortunately this CEF3 browser had the exact same issue with my app. Thank you for reading. tim
  17. @IElite Thank you for your help. I was hoping you'd tell me you had changed something on your side, because at first your app worked just fine, but now doesn't in the various Chrome browsers that I have been testing. Attached is a copy of the network inspection going on in Chrome and is what I see on multiple platforms. Just to cover all possible tests, Chrome on Android does not have any of the issues that I see with the desktop browser.
  18. TAKE 1-Starting typing and then went to investigate... Thank you for providing some thoughts, but I can't draw any conclusions. Your app works just fine in my Chrome browser, but my app still shows the broken link. Chrome does work fine if I use the default environment in SMS. It is only when it then is suppose to download the SMS app from a website and run it, that I run into this strange problem. One interesting thing is that we are using the same version of Chrome as my version number matches yours. At this point, I decided to test on a couple different desktops. TAKE 2-Now your app is failing too The buttons moved from the bottom to the top of the test app and now your app is failing like mine with broken image links. When I tested with Firefox Quantum (60.0.1) I also got the app to fail too with loading image links. I could fix it in Firefox by click "Disable cache" on the Network Inspector and then the image started loading properly. This Firefox trick worked with both your app and mine. When I tried the same "Disable Cache" in Chrome, it still will not load the images for either your app or mine. Is there a meta tag that is missing to help the browser deal with the cache properly. I don't think this is an issue with a firewall, virus protection or malware protection as I have tried a number of systems where these variables were different. tim
  19. Just to note with Firefox is that sometimes I can get this to fail in Firefox too like Chrome. However, when it fails in Firefox, if I open the "Inspect Network" debugger, suddenly the page then works just fine. Thank you for your help.