Electron js not displaying data from Mysql - javascript

I am new in web development and trying to use electron js to develop an application.
I am trying to connect my electron app to mysql database running on local machine but the issue is that electron is giving insecure resource warning and not displaying the data. I tried to turn off these security features but nothing is working, I can verify that my query is fetching the data from database.
Please see the image below:

I see a response with 3 RowDataPackage items, so it looks like turning of the security setting works.
You might want to convert the array with RowDataPackage items to an actual array by converting it to a JSON string and parse it back again.
Example:
JSON.parse(JSON.stringify(mysqlResults))

Related

Is it possible to write data in JSON file without AJAX or backend?

I´m developing an small test app and I had a doubt about JSON in frontend.
I´m working with React and I´m using a JSON file as a small testing DB, saving only 1 user. The fact is that I want to write more users there and edit the JSON registers.
Is that possible without backend or AJAX?
**EDIT: **
I´m using localStorage for the actual logged in user and it´s moves, at the end need to save it´s data before I close session and localStorage loses.
AJAX is used for HTTP requests between a front-end (ex: ReactJS, VueJS) and a back-end (ex: NodeJS/Express, Python/Flask).
If you're using a JSON variable, the data will be deleted everytime the website refreshes. If you're using a JSON file, you can't access the file system from the browser for security reasons.
What I recommend to use is localStorage, which acts as a local database for front-end ONLY per browser (per user).
The most common usage is:
The setter:
localStorage.setItem('name', 'John')
The getter:
const name = localStorage.getItem('name');
console.log(name) // John
In React, you could set and update data as the following in this example I made:
DEMO https://stackblitz.com/edit/react-fctts3
Short answer, no. you can't write data directly to client's disk.
but there are workarounds.
one way is using common browsers storage options. such as localstorage:
localStorage.setItem(keyname, value)
read more here
another way if you need to move the data is to make the user download your file, and save it. when you need it again they can re-upload it to your front-end page. you can read up on this here.
of course there are other options like cookies and IndexedDB/WebSQL. but I think local storage can do just fine for your needs.
EDIT:
if you don't have problem with having an internet connection, there is also the awesom option of using google sheets as a database! using this tool:
https://sheety.co/

Serverside Dashboard buildup (Node.JS)

I´m sending some sensordata to my azure IoT-Hub and now I want to display them on different Dashboards.
To get started I used the template from a Microsoft Tutorial and it works fine:
https://github.com/Azure-Samples/web-apps-node-iot-hub-data-visualization.git
The only problem is, that the Dashboard only show the new data that comes in for the client.
After every reload of the page (from the client side) the Dashboards are completely blank at first and then build up the data that comes up next.
(I think the client loads the script and builds the Dashboard up itself?)
I load the index.html file and in the html-file are linked some js-files.
My question is now if it´s possible to build up the Dashboards the whole time on the serverside in Node.js?
So if a client connects to my site, it automatically shows all saved data from my Dashboards (even from the past)
TLTR:
Can you generate data on Dashboards on the serverside and then just "mirror" the Dashboard to the Client?
Probably you are looking for a solution with Dashboard that can show previous day data as well.If so you need to push data from IoT hub to some other storage like CosmosDB etc and built your custom dashboard on it.
I had a similar requirement like that and used Azure Time Series Insights for that purpose.The API would return data to UI which has Dashboard build on Angular. Have documented the same here :
http://learniotwithzain.com/2019/03/near-real-time-iot-data-exploration-using-azure-time-series-insights/
Azure Time Series Insights product has some ClientSide SDK as well. Please do check the cost associated and see if this suits your requirement.

SAPUI5 Odata Connection to Server

i have a question.. is there a way to get the odata data without a cloud connector? so basicly like http/https://serverip:port/sap/opu/odata/sap/... ?
If i try it trough the browser it works.. i get my metadata.
my manifest looks like this
i tryed it also with http.. but it wont work cause the origin request is a https (webide). The Console says..
i try it already with proxy/ before the ip but almost the same.. the errormessage go away except of one the [ODataMetadata] initial loading of metadata failed - . I even dont get the login popup like before over the cloud connector.. so is there a way to do it like this? that i can develope in the webide? in someday i want that the appilcation i a standalone app. And dont need the scp
thanks guys.
If you are using SAP Web IDE, the easiest way to do it, would be to add a Destination for your backend system in SAP Cloud Platform, and then add an OData service using that Destination in SAP Web IDE (this will create entries in manifest.json and create wiring to the destination in neo-app.json). As your particular endpoint works through your browser, you wouldn't need to use Cloud Connector.

Getting data out of Mongodb with Angularjs

I come from a LAMP stack background but lately I am been interested in Node.js/Angluarjs combo. Now I am wanting to get Mongodb into the mix but I am having the hardest time getting it set up. Every tutorial I find using a different kind of stack, some are using Express.js, others Mongoose, or something else. How do I go about using angularjs HTTP service to connect to Mongo? Do I need an intermediate library like Mongoose or can I do it directly with Angular. I had set this up a while back as an experiment. I am trying to do what I am doing in this page. In this, I am storing the data in a JSON file. I want to replace that JSON file with a connection to the Mongodb. I have MongoDb installed globally for Node and I have created a data collection through the console. You can see my experiment here - http://monkbunker.com/saas/#/
And the code for the http connection I have for this can be seen here starting on line 14 https://github.com/seanandersonmke/saas/blob/master/js/main.js
Is this similar to how I can work with MongoDB? How to set up an initial connection? I have sat down several times now for hours and ended up stumped every time. Please help.
thanks.
Have a look on the following links:
Querying MongoDB with JSON / HTTP / REST Interface
Does MongoDB have a native REST interface?
There is a full python proxy solution:
http://python-eve.org/
Maybe this is helpful for you.:)

HTML 5 localStorage feature stopped working suddenly in my Phonegap app for IOS

Actually this app has been developed using the Phonegap. It is not a native IOS Application. You can get more information about Phonegap from the official site http://phonegap.com.
As you know we use HTML, CSS, JAVACRIPT in a Phonegap Application, so we are using an HTML 5 feature of local storage in our application in order to save some local data.
Like I did in login page. I sent a request to server with the login details using AJAX and if the login details are valid then the server sends a user id as a JSON response.
I saved that user id using HTML 5 local storage feature like below:
user_id=data['user_id']; // the array data is the array that was generated from JSON response
window.localStorage.setItem("user_id",user_id);​ //saved user id in local storage
The above code saves the Id of the user in the local storage who is currently logged into the app.
But I am unable to retrieve that information from the local storage on the next page when I tried to retrieve it using the following code:
user_id = window.localStorage.getItem("user_id");​ // fetch user id from local storage
it saves "undefined" in variable user_id.
On the inner pages of app I have to send this user_id to the server after fetching it form the local sotrage in order to get the data of the logged in user as a JSON resonponse from the server. But rather than sending actual user id it is sending "undefined" in place of that user_id to the server because of which the server doesn't generate proper JSON response and the AJAX gives an error callback where I am showing this message as an alert:
"Application could not reach doggone server. Please check your internet connection."
The strange thing is that it was working earlier when users purchased the app from app store and it stopped working suddenly when i tried to submit the new build for the next version of the app.
I did some research on google and I found that HTML 5 local storage doesn't work on IOS 5.1 or later. But it was working few days earlier. It stopped working since I am trying to upload the new binary for next version 2.0.
Kindly look at it this problem and provide a solution to us. Our whole app is using the HTML 5 local storage feature almost on every page in order to fetch the current user data from server.
put the
window.localStorage.setItem("user_id",user_id);​
in a try/catch block. You might easily catch a QUOTA_EXCEEDED error (ran out of storage space). Happened to me just the other day...

Categories

Resources