GithubHelp home page GithubHelp logo

Comments (21)

felixhageloh avatar felixhageloh commented on August 14, 2024

Good questions! To give you some answers:

  • Yes only one screen for now. Check Issue #9 for more details
  • indeed, widgets are serialized to plain objects right now, so there is no scope. However, using properties works (even though I am not a big fan of this myself). So you can change your example to
note:  "bob"
command: "date"
refreshFrequency: 10000
render: (output) -> """
  <h3>#{output} #{@note}</h3>
  • It is not possible at the moment. You are correct that the backend is in nodejs but widgets are executed in the client (except for the command of course). So to make this work I'd have to use browserify or something, which might be an idea for the future. What you can do though is write a node app that spits out some output and then execute it using command
  • see above, but I agree that there might be some cases where you don't need to execute a command, so I might make it non mandatory in future versions
  • see Issue #10 for some details on that

from uebersicht.

edasque avatar edasque commented on August 14, 2024

Ah, interesting. So everything actually runs on the browser side (except for the command evaluation I imagine) and all 'variables' are actually the (client-side) widget object properties.

So the widget developer has no access to anything that's happening in node.js. Is node.js just used to exec the command, compile the coffeescript to JS, listen to modified files in the widget directory and pass that code to the browser side?

from uebersicht.

felixhageloh avatar felixhageloh commented on August 14, 2024

yes that is indeed pretty much how it works :)

from uebersicht.

edasque avatar edasque commented on August 14, 2024

Would there be a way for the node.js side to communicate with the client side of the widget (maybe through socket.io) so a widget would have client side & server side components.

from uebersicht.

felixhageloh avatar felixhageloh commented on August 14, 2024

that is in away how it is at the moment, albeit the communication only happens using polling (refreshFrequency) and with simple http requests. It would be cool to at some point use web sockets to allow for streaming and pushing of info from the backend, I agree!

from uebersicht.

edasque avatar edasque commented on August 14, 2024

But there is no way for the developer to create code that runs on the server side (node.js).

from uebersicht.

felixhageloh avatar felixhageloh commented on August 14, 2024

There is! You can just ship any execetuable (so this can be a node app) with your widget, by adding it to the widget folder.

from uebersicht.

jalvarado91 avatar jalvarado91 commented on August 14, 2024

When you say I can ship any executable, does that include shipping a bash script with my widget that I can call from command?

from uebersicht.

felixhageloh avatar felixhageloh commented on August 14, 2024

Exactly, at the moment widget commands are exectuted relative to the widgets directory, so if you put your shell script inside your widget folder you can call it from command like so:

command: "./my-widget.widget/the-script.sh some args"

from uebersicht.

JaredVogt avatar JaredVogt commented on August 14, 2024

Another way to use uebersicht is simply as a mechanism to display output - and define location on desktop.

command: "source $HOME/.bash_profile &> /dev/null && $HOME/projects/ubersicht/uberTest.coffee"

That gets me my normal shell environment (all libs available - nvm, etc) and then runs a script that does everything - including create all HTML, etc - just returns a string.

style: """
  top: 300px
  left: 40px
"""

all this does is set positioning...

render: (data) -> "#{data}"

data is just a string with all HTML/Data/CSS already included. So all the magic happens in uberTest.coffee. Also easy to debug since you can just run your script from shell or in a browser - once you have it working, the last step is to create the "display script" in the ubersicht directory (as shown above).

from uebersicht.

felixhageloh avatar felixhageloh commented on August 14, 2024

good one!

from uebersicht.

felixhageloh avatar felixhageloh commented on August 14, 2024

It would, however, make sharing them more difficult since you are relying on tools and npm modules being installed on your system. Great for your personal widgets and for developing though!

from uebersicht.

edasque avatar edasque commented on August 14, 2024

@felixhageloh , that's true. Ultimately though I think widget really should have a server side & client side components, including a package.json describing required node.js package which could be auto installed via the npm API by uerbersicht.

from uebersicht.

felixhageloh avatar felixhageloh commented on August 14, 2024

could be an option, indeed. I guess a prerequisite would be to have a 'proper' way to install widgets

from uebersicht.

edasque avatar edasque commented on August 14, 2024

I feel the current system works really well. Just a folder for active widgets. If they're not in that folder, they're not installed. If they're in that folder and haven't been installed yet (or the package.json or other files are new) run the npm install (or use npm programmatically in node).

from uebersicht.

danyalaytekin avatar danyalaytekin commented on August 14, 2024

Thanks for the hint @JaredVogt, it helped me get Ruby working with Übersicht . I still have to put the full path to my preferred Ruby executable as rbenv selection isn't respected. Not sure why, but no problem for now.

from uebersicht.

jhvanophem avatar jhvanophem commented on August 14, 2024

So how many things were implemented from this discussion, and what still needs to be done?

from uebersicht.

felixhageloh avatar felixhageloh commented on August 14, 2024

@jhvanophem sorry for the late response. From the top of my head:

  • multiple screens are supported now
  • you can require npm modules
  • command is not mandatory anymore (if refreshFrequency is set to false)
  • I would need to double check but I think global vars also work now

from uebersicht.

motleydev avatar motleydev commented on August 14, 2024

Is there an example of how to to "require" a node module in the script? Just like normal with a var x = require(...) ? Do I understand the docs correct that this is only available if using coffeescript? Thanks!

from uebersicht.

motleydev avatar motleydev commented on August 14, 2024

Also, if this is running with node in the background, does it mean that it uses the default version of node? IE if I set a default with NVM it will use that and if so does it mean that I can use es6 syntax as long as my node version supports it?

from uebersicht.

felixhageloh avatar felixhageloh commented on August 14, 2024

Did you figure out how to use require - I think there were some answers in another thread?

Regarding node, there are a few things to keep in mind:

  • all js code in widgets runs in a 'browser' so the node version doesn't really matter. The browser is a WebView which is in sync with the current version of Safari you have on your system, so it supports anything that your version of Safari does. Regardless of that, all widgets, except plain JS ones are compiled using babel, so you can use ES6 in JSX widgets.
  • You can make a node script which you can call as your command, in which case you can use whatever version of node you have installed on your system. Keep in mind that by default Übersicht doesn't load your .bash_profile so you might have to do that manually in your command (or use full paths to your node binary)
  • Übersicht does come with its own version of node but it is not easily possible to access it (it is called localnode and is inside the Übersicht app bundle)

Hop this helps!

from uebersicht.

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.