Giter VIP home page Giter VIP logo

Comments (12)

sihorton avatar sihorton commented on June 26, 2024

Hi Ivbeck,

We have not yet offically implemented custom functions for the various platforms. However don't let that put you off. Take a look at Edge.js for example:

This claims to allow you to use .net code from node.js. There are a number of different projects to do similar things and it would even be possible to create a windows exe and pass in a parameter of what you want it to do. Some of the functions we want to have accessible:-

  • Native file picker dialog
  • system tray icon & menu

Take a quick surf and see if edge.js can be used and then send us a little demo if you are successful and we can include the function for others to use in deskshell.

I am an old visual basic hacker so eventually I can create an exe that can be called from node to do these functions, but maybe .net is better?

/Simon

from appjs-deskshell.

sihorton avatar sihorton commented on June 26, 2024

I have just had a play around with edge.js and nothing really worked. I think it is a bit of a dead end solution. I tried also using powershell / vbs / windows scripting host as a quick hack solution, however these were quite limited (I was able to get up a dialog ok but was unable to set the starting directory or fully control the solution). Therefore I think a C / VB or similar solution is required.

from appjs-deskshell.

sihorton avatar sihorton commented on June 26, 2024

I have now put together a native file picker demo: https://github.com/sihorton/deskshell-showcase/tree/master/win-native-func

This uses nsis to provide a native file picker and wraps the functionality in a node module. The implementation is a little weak at the moment and I have not had time to add all of the options one might like yet, but it does show a native file picker being used.

from appjs-deskshell.

sihorton avatar sihorton commented on June 26, 2024

I have now implemented native folder and file picker dialogs and added parameters like the initial directory to start from and so on. Updated the demo app to show correct syntax and added html controls to be able to experiment passing in different parameters.

Closing the issue now since the functionality is now implemented. Currently it is in the deskshell-showcase repository but we can move it into deskshell main release after some more testing and development.

from appjs-deskshell.

lvbeck avatar lvbeck commented on June 26, 2024

@sihorton, thanks it works like a charm! Sorry yesterday I was not able look at the edge.js but you already implemented it in another approach, that's awesome! And I test the filePicker in my app by following your showcasedemo, then I want to read the file content like this

window.deskShell.sendMessage('filePicker',{
filter:"*.json"
,folder:""
,opensave:"open"
},function(result) {
if (result.file) {
alert('You picked:'+result.file);
window.fs.readFile(result.file, function (err, data) {
if (err) throw err;
});
}
});

however I got a error says "Uncaught TypeError: Cannot call method 'readFile' of undefined", so I realize that I can't just call nodejs function on the browser side by using window.fs = require("fs") like what I did with appjs:-(
After google around I found someone has created a proxy for calling nodejs functions: #18
I will test this approach in my app now, but I really hope that the proxy functionality can be merged into offical clientApi.

from appjs-deskshell.

sihorton avatar sihorton commented on June 26, 2024

All you need to do is to is to add a new "readFile" message that you send from the browser with the file the user selected, and then a new socket.on("readFile" ....) function that implements reading the file from disk and returning its contents. I implemented this functionality for you in the showcase demo so you can see source code of how to do it. There is a new button and this will alert the contents of the file that you choose (so only pick small files :-) )

The proxy example is really cool, I want to include it in deskshell in the future for people that want to code everything in the browser but would like access to nodejs modules from there. We need to play around with the functionality a bit more and then come up with the best api and setup to use for it.

from appjs-deskshell.

lvbeck avatar lvbeck commented on June 26, 2024

Hi @sihorton , the showcase demo works but unluckily my apps does not, somehow the window.deskShell.sendMessage function fails silently. How can I turn the debug mode on to check the server console log?

from appjs-deskshell.

sihorton avatar sihorton commented on June 26, 2024

The easiest way is to rename your app.desk file to be app.desk-debug it will then pop up the console and hopefully that will show you what is wrong.

from appjs-deskshell.

lvbeck avatar lvbeck commented on June 26, 2024

@sihorton thanks, I found the problem, simply because my socket port is in use, change it to another port number solve the issue!

from appjs-deskshell.

sihorton avatar sihorton commented on June 26, 2024

Ah yes ok, if you don't specify a port then it will pick a random free port and use that instead, localStorage and web database is tied to the application port however so they will appear not to save if you use a random free port.

from appjs-deskshell.

lvbeck avatar lvbeck commented on June 26, 2024

@sihorton, yes I decided to use a fixed port for local data persistence, but it was already used by another application I am running, my fault:)

from appjs-deskshell.

sihorton avatar sihorton commented on June 26, 2024

Good it is working for you now :-)

from appjs-deskshell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.