简体   繁体   English

如何从Mysql Server将数据加载到仪表板视图?

[英]How to load data to dashboard view from Mysql Server?

I have a lot of data coming from different places and getting stored in MySQL database. 我有很多数据来自不同的地方,并存储在MySQL数据库中。 I want to create a dashboard view of that. 我想为此创建一个仪表板视图。 There are two problems, 有两个问题

  1. I want the data to show up on the dashboard page as soon as it gets inserted into the database. 我希望数据一插入数据库就立即显示在仪表板页面上。 (avoid using lookup). (避免使用查找)。
  2. A solution in Java/JavaScript language is expected. 期望使用Java / JavaScript语言的解决方案。
  3. Can I use firebase or something similar that loads data automatically? 我可以使用Firebase或类似的自动加载数据的工具吗?

I have seen some live dashboards and I keep on wondering how they do it. 我看到了一些实时仪表板,我一直想知道它们是如何做到的。 It will be great if community can provide link to some good tutorials. 如果社区可以提供一些良好教程的链接,那将是很好的。

I can see some different approaches to solve your problem. 我可以看到一些解决您问题的方法。 First of all, you have to decide from where your data will be provided to the dashboard. 首先,您必须确定将从何处将数据提供给仪表板。

For example: if you create a web app to show some data provided directly by your MySql database, you will have to create a backend app that handles authentication and provide data. 例如:如果您创建一个Web应用程序以显示MySql数据库直接提供的一些数据,则必须创建一个处理身份验证并提供数据的后端应用程序。 As you quoted in your question, you want realtime updates. 正如您在问题中所引用的,您需要实时更新。 To do this, you will have to create an architecture using WebSocket which will provide data from MySql as soon as they available. 为此,您必须使用WebSocket创建一个体系结构,该体系结构将在MySql可用时立即提供数据。 In this case, you would have full control of the system and wouldn't use Firebase, but it demands extra work. 在这种情况下,您将完全控制系统并且不会使用Firebase,但是这需要额外的工作。

I've faced this problem and, in my case, my team decided to use Firebase as a tool to speed up the process. 我已经遇到了这个问题,就我而言,我的团队决定使用Firebase作为加快该过程的工具。 In my project I have a huge relational database and had to provide some specific information in a dashboard for managers and executives. 在我的项目中,我有一个庞大的关系数据库,并且必须在仪表板中为经理和主管提供一些特定的信息。 I decided to write a Java application that reads these data from my production database and push them to a Firebase Realtime Database every five minutes. 我决定编写一个Java应用程序,每隔五分钟从生产数据库中读取这些数据并将其推送到Firebase实时数据库。 Then, we created a web app that shows these data stored at Firebase. 然后,我们创建了一个Web应用程序,显示存储在Firebase中的这些数据。 In this case, I haven't had to handle authentication (because Firebase provide it) and WebSocket. 在这种情况下,我不必处理身份验证(因为Firebase提供了身份验证)和WebSocket。 As soon my backend Java App send data to Firebase, it is showed in the dashboard, without needing reload the page. 一旦我的后端Java App将数据发送到Firebase,它就会显示在仪表板中,而无需重新加载页面。

In Firebase's GitHub account you can see many examples about manipulating data that will be updated in real time. 在Firebase的GitHub帐户中,您可以看到许多有关处理将实时更新的数据的示例。

https://github.com/firebase/quickstart-js https://github.com/firebase/quickstart-js

English isn't my native language, so sorry for possible mistakes. 英语不是我的母语,对于可能出现的错误,我们深表歉意。

Assuming that you have your service running on: http://localhost:4848/ and it has the 2 methods. 假设您的服务在以下位置运行: http:// localhost:4848 /,并且它具有2种方法。 The first insert on Mysql the and the other get the information of the table that you inserting. 第一个在Mysql上插入,另一个在您获取所插入表的信息。

 var apiURL = 'localhost:4848/'; // Web service URL displayUsers(); // When the documents load function insertUser(input) { var apiMethod = 'insert/user'; var data = $("#username").val(); $.ajax({ type: "POST", url: (apiURL + apiMethod), data: data, success: function (response) { displayUsers(); }, dataType: 'text' }); } function displayUsers() { var apiMethod = 'getAll'; $.ajax({ type: "POST", url: (apiURL + apiMethod), success: function (response) { $('#user-list').text(response); }, dataType: 'text' }); } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="form"> <input type="text" id="username"> <input type="submit" value="Add" onclick="insertUser()"> </div> <div class="list" id="user-list"> </div> 

Also watch this Post . 也请看这篇文章 About firebase I don't know what could help you. 关于Firebase,我不知道有什么可以帮助您的。 But I think this may help you. 但是我认为这可能对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM