rasmusbergpalm / jslate

Write your dashboards in pure html/js
jslate.com
244 stars 54 forks source link

Enhancement: Ability to share a dashboard #30

Closed brianhks closed 11 years ago

brianhks commented 11 years ago

One option for doing this is to make a dashboard public. When a dashboard is public authentication is skipped for that url. Would also have to make changes so the dashboard is read only. Any other suggestions?

rasmusbergpalm commented 11 years ago

Add uuid token to the dashboards table, auto-generate it when creating a dashboard. Provide a public url to the dashboard at dashboards/public/ Use $Auth->allow('public') to allow access if you've got the token (sec. model assumes uuid's are impossible to guess and don't leak) Provide a method to generate a new token for owning user.

brianhks commented 11 years ago

So if I follow you correctly then I add a new view to dashboards called 'public' That will give me my read only view of the dashboard doing the lookup by the UUID. Sounds good.

rasmusbergpalm commented 11 years ago

Yea

function beforeFilter(){
$this->allow('public')
}

function public($uuid){
$dashboard = $this->Dashboard->find('first', array(...));
if(empty($dashboard)) throw new UnauthorizedException();

//set view vars, render view template
rasmusbergpalm commented 11 years ago

fixed in d27b3b2a7ca624b4b55dd858de9603f967528b00

brianhks commented 11 years ago

I see a problem with what you have done. You changed wid so that it has a dash '-' in it. The dash prevents me from using the wid in a js function name. It needs to be underscores '_'.

rasmusbergpalm commented 11 years ago

Ok. Feel free to change it. You can use uniqid() instead of String::uuid(), which doesn't have any dashes

rasmusbergpalm commented 11 years ago

Btw. Why do you need it in a js function name?

brianhks commented 11 years ago

We are creating some complicated control widgets and in doing so it is best served to put some of the functionality into functions that are called from multiple places. Without wid in the function name we cannot have multiple control widgets on the page.

Brian

On Jul 12, 2013, at 1:45 AM, Rasmus Berg Palm notifications@github.com wrote:

Btw. Why do you need it in a js function name?

— Reply to this email directly or view it on GitHub.

rasmusbergpalm commented 11 years ago

You cant just use the wid as a parameter in the function? Anyways, feel free to change it :)

brianhks commented 11 years ago

The idea is this

function myFunction_${wid}(someParam) {}

//Call function myFunction_${wid}('hello');

The wid is used as part of the function name, to make sure there are no clashes with other functions defined in other widgets. I'll create a patch.

Brian

On Fri, Jul 12, 2013 at 10:45 AM, Rasmus Berg Palm <notifications@github.com

wrote:

You cant just use the wid as a parameter in the function? Anyways, feel free to change it :)

— Reply to this email directly or view it on GitHubhttps://github.com/rasmusbergpalm/jslate/issues/30#issuecomment-20888695 .