Skip to content
This repository has been archived by the owner on Apr 30, 2018. It is now read-only.

Fill userlist from mysql Database #24

Open
ehrenberg opened this issue Jun 24, 2016 · 1 comment
Open

Fill userlist from mysql Database #24

ehrenberg opened this issue Jun 24, 2016 · 1 comment

Comments

@ehrenberg
Copy link

ehrenberg commented Jun 24, 2016

Hi everyone,

I've tried to fill my Userlist with Ajax in my own Adapter. But no users shown. The Array is filled. I'am confused. Maybe some help?
Thanks alot!

this.users = new Array();
        $users = this.users;
        $.ajax({
            url : "/plugins/messages/ajax.php",
            type : "POST",
            dataType: 'json',
            data : {
                type : "get_userlist"
            },
            success : function(data, textStatus, jqXHR) {
                $.each(data, function(index) {
                    var tmpUser                 = new ChatUserInfo();
                    tmpUser.Id                  = data[index].ID;
                    tmpUser.RoomId              = 1;
                    tmpUser.Name                = data[index].FirstName+' '+data[index].LastName;
                    tmpUser.Email               = data[index].Email;
                    tmpUser.ProfilePictureUrl   = "";
                    tmpUser.Status              = data[index].Online;
                    $users.push(tmpUser);
                });
            }
        });

        this.users = $users;
@ehrenberg ehrenberg changed the title Fill userlist Fill userlist from mysql Database Jun 27, 2016
@ehrenberg
Copy link
Author

My solution:

    DemoServerAdapter.prototype.getUserList = function(roomId, conversationId, done) {
        console.log("DemoServerAdapter: getUserList");

        var tmpUsers    = new Array();
        $.ajax({
            url : "/plugins/messages/ajax.php",
            type : "POST",
            dataType: 'json',
            data : {type : "get_userlist"},
            context:this,
            success : function(data) {
                var $t = new Array();
                $.each(data, function(index) {
                    console.log(index);
                    var tmpUser                 = new ChatUserInfo();
                    tmpUser.Id                  = data[index].ID;
                    tmpUser.RoomId              = 1;
                    tmpUser.Name                = data[index].FirstName+' '+data[index].LastName;
                    tmpUser.Email               = data[index].Email;
                    tmpUser.ProfilePictureUrl   = "";
                    tmpUser.Status              = data[index].Online;
                    tmpUsers[index] = tmpUser;
                });
                this.users = tmpUsers;
                if (roomId == DemoAdapterConstants.DEFAULT_ROOM_ID) {
                    done(this.users);
                    return;
                }
                throw "The given room or conversation is not supported by the demo adapter";
            }
        });

    };

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant