Giter Club home page Giter Club logo

angular-sails-bind's People

Contributors

aklinkert avatar arryon avatar artur-krueger avatar diegopamio avatar fladi avatar idvb avatar nhahn avatar rmarku avatar tomkaltz avatar villegas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-sails-bind's Issues

How do you think ?

Hey, how do you think, the same lib can be done with Laravel? I mean Laravel is very similiar to Sails.

Changing a JSON value in the db, will cause scope item to turn into a JSON string?

Hey,

So I'm having a little trouble with altering JSON objects in a MySQL database via the RESTapi, when I change a value it will update the bound scope object, but it will change it into a JSON string, then if I refresh the page it will actually parse the JSON correctly.

example:

table:
animal

id:int(ai) | name:string | interests:json

1 | Mr. Sniffles | ["mewing","taking over the world","catnip"]

So the in my controller this will get me a object:
$scope.animals

[{
id: 1,
name: "Mr. Sniffles",
interests: [
"mewing",
"taking over the world",
"catnip"
]
}]

Which is great, but now if I HTTP PUT to /animal/1
interests : '["mewing","catnip"]'

It will change the scope object into:

[{
id: 1,
name: "Mr. Sniffles",
interests: '["mewing","catnip"]' // (string)
}]

Then if I refresh the page it will change it into:

[{
id: 1,
name: "Mr. Sniffles",
interests: [
"mewing",
"catnip"
]
}]

Thanks in advance,

Changing subset doesn't update the socket

Hi,

In my controller I have this,

$sailsBind.bind('model, $scope, $scope.pagination);

When I change $scope.pagination in my controller, the change isn't passed on to the socket. Cant redeclare $sailsBind.bind() because it breaks the model in sailsjs and eventually I end up with an empty model.

Cheers,

Ash

$scope.$apply() not called on "created" message

We've just noticed $apply() isn't called when receiving a model created message from Sails. I've only just started using the module, so haven't tested any other events. We're using autoWatch:true.

Angular 1.0.8
Sails 0.10.0

I've fixed this on my local machine. Let me know if you want a pull request.

N-to-N items

I'm testing Angular Sails Bind, and it is really close to being super powerful in my app. I'm wondering if there is a way (or if it should) work off sub-items. That is, imagine I have A's and B's with an N-to-N relationship. I query for one A and get it back, and it has three B's attached to it. If I could watch items in B and manipulate them, it would be super powerful. I imagine others would have a benefit with this also.

Is this a good feature request? Useful? Doable?

Thanks,

Ryan

Add callback function for angular controller

The standard method of loading content using $http in Angular has the option to specify a success callback when the content has loaded, so that in the controller, you can initiate scope bindings dependent on data.
The angular-sails-bind directive has no such thing. I implemented it myself in arryon@0ec4907 but probably there is a better way to do this, like the default .success() and .error() paradigm. Any ideas?

Error: io.socket is undefined

I am trying to integrate this with my angular project but as soon as I make a call inside a controller I get the following error:

 Error: io.socket is undefined
 _get@http://localhost:9000/bower_components/angular-sails-bind/angular-sails-bind.js:179:13

I have confirmed that sails.io.js is being included before angular etc etc, any ideas?

Discussion board?

Is there a discussion board for this lib?

This is really great I gotta say.

Binding doesn't work on some models possibly with HTTP POST

This might be an issue with Sails, or my configuration.

However in my controller I am binding:

$sailsBind.bind("user", $scope)
$sailsBind.bind("task", $scope)

When I am using the register function on the controller updates are not being sent. I can see socket messages being pushed to the task object.

the register function is being called via HTTP POST instead of a socket call.

Task works, user does not.

User model:

var User = {
  // Enforce model schema in the case of schemaless databases
  schema: true,

  attributes: {
    groups: {
        collection: 'groups',
        via: 'members',
    required: true
    },
    username  : { type: 'string', unique: true, required: true },
  email     : { type: 'email',  unique: true, required: true },

  passports : { collection: 'Passport', via: 'user' }
    // Groups

  }
};

module.exports = User;

User controller:

/**
 * UserController
 *
 * @description :: Server-side logic for managing Users
 * @help        :: See http://links.sailsjs.org/docs/controllers
 */


module.exports = {

  session: function(req, res) {

    res.json({
      success: true
    });
  },


  //expose a method for angular to be able to see if we are logged in
  isLoggedIn: function(req,res){

    //TODO: make sure that only the clients with the right session get the broadcast
    //sails.sockets.broadcast("authNotification" , "authorized",{socketId: req.socket.id, user: req.user} );    

    res.json({sessionID: req.session.sessionID, roles: req.session.roles, user: req.user} );
    //res.json(req.isAuthenticated() ? {sessionID: req.sessionID, user: req.user} : 0);
  },
  //expose a method for angular to be able to see if we are logged in
  sayHi: function(req,res){
    sails.sockets.broadcast("authNotification" , "message", {message: "onLogin"} );  
    sails.sockets.broadcast("authNotification" , "message", {message: "hello3"} );    
    res.json({result:"sent"});
  },
  sendHello: function(req,res) {
    //req.sessionID
    sails.io.sockets.in('asdf').emit("eventName", {data:true});
    //sails.sockets.broadcast.to("asdf").emit('loggedOut', {loggedOff: 'true'});

    res.json({
        sessionid: req.sessionID,
        message: "sent"
    })

  },
  register: function(req,res){

    //associate group
    Groups.findOrCreate({
      groupName: 'user'
    }, {
      groupName: 'user',
      description: 'Generic user'
    }).exec(function createFindCB(err, userGroup) {
      //Check password for equality
      var password = req.param('password');
      var confirmation = req.param('confirmation');
      //TODO: enfore better passsword enforcement
      if(!password){
        res.json({err: { message: "You must enter a password" }});
      } else if (password == confirmation){
        var userObj = {
          username: req.param('username'),
          email: req.param('email'),
          groups: [userGroup.id]
        };

        //Create user
        User.create(userObj, function userCreated(err, user) {
          if (err) {
            res.json({
              err: err
            });
          } else {
            //Associate passport ( password )
            //TODO: include other authentication mechanisms
            Passport.create({
              protocol: 'local',
              password: password,
              user: user.id
            }, function (err, passport) {
              if (err){
                User.destroy(user.id, function deleteCB(deleteErr){
                  sails.log(deleteErr);
                });
                res.json({err:err});
                console.log(err);              
              } else {
                res.json({success: true});
              }
            });

          }
        });
      } else {
        res.json({err: { message: "Passwords do not match" }});
      }

    });

  }

};

Server errors aren't manageable

I have policies that reject unauthorized requests to certain resources. It is quite easy to catch and handle if I'm using the REST API.
I can't find a good way of doing this with this module yet.

Set headers?

Is it possible to set headers for the socket requests?
As i would like to be able to set a Auth header on each request?

Use proper sails blueprint rest routes rather than shortcut routes

Currently, the routes used are the blueprint routes generated by the config option for shortcuts, rather than the routes generated from the config option for REST. The REST routes are a little bit more standard / secure, and the behavior is more consistent when using them.

So for the create/update/and delete actions done, these routes and verbs should be updated appropriately.

JSON objects

Using a Sails model "item" that specifies "runtimeData" as a JSON object, I have not been able to get this to work when runtimeData is already set to a value. For instance, given this data existent in the MongoDB data store:

$scope.items[0].runtimeData = { "currentVal": 1 };

The following does not trigger an update:
$scope.items[0].runtimeData.currentVal = 2;

And this rarely / unreliably triggers an update:
$scope.items[0].runtimeData = { "currentVal" : 2 };

But this always triggers:
$scope.items[0].runtimeData = { "lastUpdate" : new Date().getTime(), "currentVal" : 2 };

It seems that a combination of changing the entire runtimeData object AND including a value is what is causing the update to be performed properly. All bindings at the root level ($scope.items[0].customVal = "5") work great at mirroring back to the database.

Any ideas? I haven't dived into the code enough to know how to fix, and I am new to Angular.

Thanks!

Ryan

'undefined is not a function' on Update?

The model collection seems to be initing just fine. However, when I use another browser window to PUT changes to the model, the moment I submit those changes I get this error on the front end of the app...
undefinederror

I'm logging out the section of angular-sails-bind.js that is erring out.
console

Seems like I'm almost there, but updates is breaking the front end.

Connect on a different url?

I have an angularjs app running on port 3131. This is what I get in the console.

GET XHR http://127.0.0.1:3131/socket.io/ [HTTP/1.1 404 Not Found 2ms]
"
        Socket is trying to reconnect to Sails...
_-|>_-  (attempt #4)

"

So I've tried to change the url but the output stayed the same

io.sails.url = 'http://localhost:1337'; 

Is there a way to achieve this?

Thank you

$scope.$watchCollection not implemented in Angular 1.0.8

I've hacked a fix using the deep watch syntax in my controller:

$scope.$watchCollection = function(variable, cb) {
    return $scope.$watch(variable, cb, true);
};

Could we replace $watchCollection with $watch(resourceName + "s", callback, true)?

firefox errors

Getting various errors in Firefox using the firebug console:

Error: model.forEach is not a function 

addCollectionWatchersToSubitemsOf@https://10.0.2.204/js/bower_components/angular-

sails-bind/dist/angular-sails-bind.js:120:7 bind/<@https://10.0.2.204

/js/bower_components/angular-sails-bind/dist/angular-sails-bind.js:45:9 

Re/e/l.promise.then/J@https://10.0.2.204/js/angular.min.js:101:1

Along with others. Not really sure what could be causing it as I am mostly a newb but just thought I would throw it on here in case anyone else was having the same problem or had some input. Working fine in Chrome. If theres any useful info you want from me I can try to provide it, but we aren't doing anything particularly special.

Weird pagination

hello there

i used

$sailsBind.bind("resource", $scope);

in my project to listen to realtime updates via socket of resource model, but it only display the first 30 records, like it was paginating the results. This a default behavior or some king of pagination that sails do??

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.