From 97e542aa7cccddb22fee8391a2099ae2156f6fdf Mon Sep 17 00:00:00 2001 From: Ihor Halchevskyi Date: Tue, 17 Jan 2017 13:30:53 -0500 Subject: [PATCH] 'port' will change according to dialect that user select --- README.md | 5 +++++ index.html | 56 +++++++++++++++++++++++++++++++--------------------- package.json | 1 + 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 5aa1d66..e50290f 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,11 @@ npm install npm start ``` +Or do the same by executing one line +```bash +git clone https://github.com/andyforever/sequelizer.git && cd sequelizer && npm install && npm start +``` + ![screenshot](https://gw.alicdn.com/tps/TB1ZWLGPXXXXXcoXFXXXXXXXXXX-1720-1160.png) Specially Thanks the great projects. diff --git a/index.html b/index.html index 849a164..8a20c1c 100644 --- a/index.html +++ b/index.html @@ -7,20 +7,20 @@ - +
- + Host cannot be number empty!
- + Port must be number type and cannot be empty!
@@ -34,24 +34,24 @@
-
@@ -80,7 +80,7 @@
- +
@@ -106,22 +106,30 @@ const generate = require('./generate') const {dialog} = require('electron').remote; - const $progreeBar = document.getElementById('progreeBar'); + const $progressBar = document.getElementById('progressBar'); const $exportBtn = document.getElementById('exportBtn'); const $directoryInput = document.getElementById('directory'); + const $portInput = document.getElementById('port'); + const DIALECT_PORTS = [ + { dialect:'mssql', port:1433 }, + { dialect:'mysql', port:3306 }, + { dialect:'mariadb', port:3306 }, + { dialect:'postgres', port:5432 }, + { dialect:'sqlite', port:null } + ] function handleSubmit(form) { - let data = getFormData(form); + const data = getFormData(form); data.tables = data.tables.split(','); data.directory = data.directory || __dirname + '/models' - data.camelCase = data.camelCase == 'on' ? true : false + data.camelCase = data.camelCase === 'on' - $progreeBar.style.display="block"; + $progressBar.style.display="block"; $exportBtn.disabled = true; generate(data.database, data.username, data.password, data, function() { - $progreeBar.style.display="none"; + $progressBar.style.display="none"; $exportBtn.disabled = false; }) } @@ -135,10 +143,10 @@ } function getFormData(form) { - let data = {}; - let inputs = form.getElementsByTagName('input') + const data = {}; + const inputs = form.getElementsByTagName('input') - for (var i = 0; i < inputs.length; i++) { + for (let i = 0; i < inputs.length; i++) { if(inputs[i].type == 'text' || inputs[i].type == 'password') { data[inputs[i].name] = inputs[i].value } else if (inputs[i].type == 'radio' || inputs[i].type == 'checkbox') { @@ -151,6 +159,10 @@ return data; } + function onDialectChange(dialect) { + $portInput.value = DIALECT_PORTS.find(x => x.dialect === dialect).port + } + diff --git a/package.json b/package.json index 30ce601..941e019 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "dependencies": { "mysql": "^2.12.0", + "pg": "6.1.2", "sequelize-auto": "^0.4.18" } }