I have an Angular App which is wrapped by an electron. Plus, I used node.js to get MySQL data and give it to the angularJs through electron. In my project, there is no steady database, so I have to change the database credentials from client side and it should persist for a particular client.
Like I have these default credentials :
{
"host":"localhost",
"username":"root",
"password":"123",
"database":"mydata"
}
Now when I move this application to a client, first the application try to connect to db with default credentials and if fails it should ask user for new credetials and it should be saved(maybe as json file!).
I tried prompt from npm, it works fine just with command-line, I want a prompt dialog in electron build app! How can I achieve?
you can use this in your node file.
command :
npm install electron-prompt
code :
const prompt = require('electron-prompt');
prompt({
title: 'Prompt example',
label: 'URL:',
value: 'http://example.org',
inputAttrs: { // attrs to be set if using 'input'
type: 'url'
},
type: 'select', // 'select' or 'input, defaults to 'input'
selectOptions: { // select options if using 'select' type
'value 1': 'Display Option 1',
'value 2': 'Display Option 2',
'value 3': 'Display Option 3'
}
})
.then((r) => {
console.log('result', r); // null if window was closed, or user clicked Cancel
})
.catch(console.error);