Thursday, September 28, 2017

populate and refresh html table using socket.io

I am making an application on using Node.js and angular as fronthand. There I am getting one text file which is log information of users and continously growing. The data is as below,

13:24:24:007,Peter,male,3720,yes
13:24:24:007,John,male,1520,yes
13:24:24:023,John,male,9720,yes
13:24:24:023,Mario,male,9820,no
13:24:24:023,Katy,female,4320,no
13:24:24:038,John,male,3620,no
.....
.....

I want to show the aggregate report data in table format to the client html page for dashboard kind of thing as below.

username    firstlogin  lastglogin  minamount   maxamount
Peter   13:24:24:007    13:24:24:007    3720    3720
John    13:24:24:007    13:24:24:038    1520    3620
Mario   13:24:24:023    13:24:24:023    9820    9820

I am using socket.io to fetch data from server to client. Currently I am making aggregate data in two dimentional array and sending that compelete array to client. At client side, formating that array to display on html page. The problem is, i am sending entire array even for a small change in one users. Thie table may be a big table with 100-200 records. I personally believe this is not right approach. There must be some better way to do this as it overloading the network traffic unnecessarily. Please suggest me some better approach where only changed data is sent to client. If there is change in only one cell, (Peter’s last login) , only that cell data to be sent to via socket and refresh on html table.

Thanks

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/09/28/populate-and-refresh-html-table-using-socket-io/
via @lzomedia #developer #freelance #web

No comments:

Post a Comment