Skip to content

Commit

Permalink
Merge pull request #1 from ihorskyi/master
Browse files Browse the repository at this point in the history
Some initial updates
  • Loading branch information
andyforever authored Jan 18, 2017
2 parents c0065c8 + 97e542a commit 8e6565b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
56 changes: 34 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
<script src="./mdl/material.min.js"></script>
</head>
<body>
<div id="progreeBar" class="mdl-progress mdl-js-progress mdl-progress__indeterminate" style="width: 100%; display: none"></div>
<div id="progressBar" class="mdl-progress mdl-js-progress mdl-progress__indeterminate" style="width: 100%; display: none"></div>
<div id="main">
<form onsubmit="handleSubmit(this); return false;">
<div class="mdl-grid">
<div class="mdl-cell mdl-cell--6-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="host" name="host" required>
<input class="mdl-textfield__input" type="text" id="host" name="host" value="localhost" required>
<label class="mdl-textfield__label" for="host">Host</label>
<span class="mdl-textfield__error">Host cannot be number empty!</span>
</div>
</div>
<div class="mdl-cell mdl-cell--6-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="port" pattern="-?[0-9]*(\.[0-9]+)?" name="port" required>
<input class="mdl-textfield__input" type="text" id="port" pattern="-?[0-9]*(\.[0-9]+)?" name="port" value="3306" required>
<label class="mdl-textfield__label" for="port">Port</label>
<span class="mdl-textfield__error">Port must be number type and cannot be empty!</span>
</div>
Expand All @@ -34,24 +34,24 @@
</div>
</div>
<div class="mdl-cell mdl-cell--6-col">
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-1">
<input type="radio" id="option-1" class="mdl-radio__button" name="dialect" value="mysql" checked>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="dialect-mysql">
<input type="radio" id="dialect-mysql" class="mdl-radio__button" onchange='onDialectChange("mysql")' name="dialect" value="mysql" checked>
<span class="mdl-radio__label">Mysql</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-2">
<input type="radio" id="option-2" class="mdl-radio__button" name="dialect" value="mariadb">
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="dialect-mariadb">
<input type="radio" id="dialect-mariadb" class="mdl-radio__button" onchange='onDialectChange("mariadb")' name="dialect" value="mariadb">
<span class="mdl-radio__label">Mariadb</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-3">
<input type="radio" id="option-3" class="mdl-radio__button" name="dialect" value="sqlite">
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="dialect-sqlite">
<input type="radio" id="dialect-sqlite" class="mdl-radio__button" onchange='onDialectChange("sqlite")' name="dialect" value="sqlite">
<span class="mdl-radio__label">Sqlite</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-4">
<input type="radio" id="option-4" class="mdl-radio__button" name="dialect" value="postgres">
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="dialect-postgres">
<input type="radio" id="dialect-postgres" class="mdl-radio__button" onchange='onDialectChange("postgres")' name="dialect" value="postgres">
<span class="mdl-radio__label">Postgres</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-5">
<input type="radio" id="option-5" class="mdl-radio__button" name="dialect" value="mssql">
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="dialect-mssql">
<input type="radio" id="dialect-mssql" class="mdl-radio__button" onchange='onDialectChange("mssql")' name="dialect" value="mssql">
<span class="mdl-radio__label">Mssql</span>
</label>
</div>
Expand Down Expand Up @@ -80,7 +80,7 @@
<div class="mdl-cell mdl-cell--6-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="upload" id="directory" name="directory" onclick="openFileDialog()">
<label class="mdl-textfield__label" for="output">Output</label>
<label class="mdl-textfield__label" for="directory">Output</label>
</div>
</div>
</div>
Expand All @@ -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;
})
}
Expand All @@ -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') {
Expand All @@ -151,6 +159,10 @@
return data;
}

function onDialectChange(dialect) {
$portInput.value = DIALECT_PORTS.find(x => x.dialect === dialect).port
}

</script>

</html>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"dependencies": {
"mysql": "^2.12.0",
"pg": "6.1.2",
"sequelize-auto": "^0.4.18"
}
}

0 comments on commit 8e6565b

Please sign in to comment.