| # | +Nome | +Hash | +Criado em | +Atualizado em | +Status | +
|---|
diff --git a/db/api.js b/db/api.js new file mode 100644 index 0000000..e0c9e09 --- /dev/null +++ b/db/api.js @@ -0,0 +1,27 @@ +function read_all(Sign, callback) { + Sign.find(function(err, signs) { + if (err) callback(null); + + callback(signs); + }); +}; + +function create(object, callback) { + object.save(function(err, sign) { + if (err) callback(null); + + callback(sign); + }); +}; + +function remove(Sign, hash, callback) { + Sign.remove({ uuid: hash }, function(err, sign) { + if (err) callback(null); + + callback(sign); + }); +}; + +module.exports.read_all = read_all; +module.exports.create = create; +module.exports.remove = remove; \ No newline at end of file diff --git a/db/config.js b/db/config.js new file mode 100644 index 0000000..7227b8d --- /dev/null +++ b/db/config.js @@ -0,0 +1,12 @@ +function connectMongo(mongoose) { + var db = mongoose.connection; + + db.on('error', console.error); + db.once('open', function() { + console.log('Conectado ao MongoDB.') + }); + + mongoose.connect('mongodb://localhost/wikilibras-api'); +}; + +module.exports.connect = connectMongo; \ No newline at end of file diff --git a/db/schemas/sinal.js b/db/schemas/sinal.js new file mode 100644 index 0000000..5d87095 --- /dev/null +++ b/db/schemas/sinal.js @@ -0,0 +1,15 @@ +function init_schema(mongoose) { + var signSchema = new mongoose.Schema({ + name: String, + uuid: String, + status: String, + created_at: { type: Date }, + updated_at: { type: Date } + }); + + var Sign = mongoose.model('Sign', signSchema); + + return Sign; +}; + +module.exports.init = init_schema; \ No newline at end of file diff --git a/endpoints/sinal.js b/endpoints/sinal.js index 05728fc..5a3a274 100644 --- a/endpoints/sinal.js +++ b/endpoints/sinal.js @@ -1,5 +1,31 @@ -function initEndpoint(req, res) { - res.send(200, { 'status': 'Estrutura Montada :)'}); +var uuid = require('node-uuid'); +var API = require('../db/api'); + +function init_endpoint(req, res, Sign) { + /* Verifica se o paramêtro [name] existe ou possui algum valor */ + if ((req.body.name === '') || (req.body.name === undefined)) { + res.send(500, { 'error': 'Especifique o nome do sinal' }); + return; + } + + var array = ['Sucesso', 'Falhou', 'Processando'] + + var sign_object = new Sign({ + name: req.body.name, + uuid: uuid.v4(), + created_at: new Date(), + updated_at: new Date(), + status: array[Math.floor(Math.random() * array.length)] + }); + + API.create(sign_object, function(result) { + if (result !== null) { + res.send(200, { 'status': 'Sinal ' + result.name + ' criado com sucesso'}); + } else { + res.send(500, { 'error': 'Erro na criação.'}); + } + }); }; -module.exports.init = initEndpoint; \ No newline at end of file +module.exports.init = init_endpoint; + diff --git a/package.json b/package.json index cd44047..de41871 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "dependencies": { "express": "~3.5.1", "mkdirp": "^0.5.0", + "mongoose": "^3.8.16", "node-uuid": "^1.4.1" } } diff --git a/public/assets/css/.sass-cache/b8ff95717abe9141bb02c85d4daf286641f59094/main.scssc b/public/assets/css/.sass-cache/b8ff95717abe9141bb02c85d4daf286641f59094/main.scssc new file mode 100644 index 0000000..8839851 Binary files /dev/null and b/public/assets/css/.sass-cache/b8ff95717abe9141bb02c85d4daf286641f59094/main.scssc differ diff --git a/public/assets/css/main.css b/public/assets/css/main.css new file mode 100644 index 0000000..a7db885 --- /dev/null +++ b/public/assets/css/main.css @@ -0,0 +1,38 @@ +body { + margin: 0; + padding: 0; } + +header { + width: 100%; + height: 60px; + box-shadow: 1px 1px 2px #c2c2c2; } + header > p { + -webkit-font-smoothing: antialiased; + text-align: center; + position: relative; + top: 13px; + font-family: 'Open Sans Light',X-LocaleSpecific-Light,'Open Sans',X-LocaleSpecific,sans-serif; + font-weight: normal; + line-height: 100%; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75); + color: #484848; + font-size: 30px; } + +.main-container { + width: 100%; + display: table; } + .main-container .table-wl { + width: 70%; + margin: 0 auto; + margin-top: 40px; } + .main-container .table-wl tbody tr ._success { + color: #85D42A; + font-weight: bold; } + .main-container .table-wl tbody tr ._error { + color: red; + font-weight: bold; } + .main-container .table-wl tbody tr ._processing { + color: #c2c2c2; + font-weight: bold; } + +/*# sourceMappingURL=main.css.map */ diff --git a/public/assets/css/main.css.map b/public/assets/css/main.css.map new file mode 100644 index 0000000..803ba26 --- /dev/null +++ b/public/assets/css/main.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAAA,IAAK;EACJ,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;;AAGX,MAAO;EACN,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,UAAU,EAAE,mBAAmB;EAE/B,UAAI;IACH,sBAAsB,EAAE,WAAW;IACnC,UAAU,EAAE,MAAM;IAClB,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,IAAI;IACT,WAAW,EAAE,gFAAgF;IAC7F,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,iCAA8B;IAC3C,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,IAAI;;AAIjB,eAAgB;EACf,KAAK,EAAE,IAAI;EACX,OAAO,EAAE,KAAK;EAEd,yBAAU;IACT,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,IAAI;IAId,4CAAU;MACT,KAAK,EAAE,OAAO;MACd,WAAW,EAAE,IAAI;IAGlB,0CAAQ;MACP,KAAK,EAAE,GAAG;MACV,WAAW,EAAE,IAAI;IAGlB,+CAAa;MACZ,KAAK,EAAE,OAAO;MACd,WAAW,EAAE,IAAI", +"sources": ["main.scss"], +"names": [], +"file": "main.css" +} \ No newline at end of file diff --git a/public/assets/css/main.scss b/public/assets/css/main.scss new file mode 100644 index 0000000..5934ccd --- /dev/null +++ b/public/assets/css/main.scss @@ -0,0 +1,53 @@ +body { + margin: 0; + padding: 0; +} + +header { + width: 100%; + height: 60px; + box-shadow: 1px 1px 2px #c2c2c2; + + > p { + -webkit-font-smoothing: antialiased; + text-align: center; + position: relative; + top: 13px; + font-family: 'Open Sans Light',X-LocaleSpecific-Light,'Open Sans',X-LocaleSpecific,sans-serif; + font-weight: normal; + line-height: 100%; + text-shadow: 0 1px 0 rgba(255,255,255,0.75); + color: #484848; + font-size: 30px; + } +} + +.main-container { + width: 100%; + display: table; + + .table-wl { + width: 70%; + margin: 0 auto; + margin-top: 40px; + + tbody { + tr { + ._success { + color: #85D42A; + font-weight: bold; + } + + ._error { + color: red; + font-weight: bold; + } + + ._processing { + color: #c2c2c2; + font-weight: bold; + } + } + } + } +} \ No newline at end of file diff --git a/public/assets/js/main.js b/public/assets/js/main.js new file mode 100644 index 0000000..a22a454 --- /dev/null +++ b/public/assets/js/main.js @@ -0,0 +1,81 @@ +var Main = function() { + + function _init() { + + } + + function _getSigns() { + $.ajax({ + type:'GET', + url: '/api/signs', + dataType: 'json' + }).done(function(data) { + _setTable(data); + }).fail(function(err) { + var table = $('.table-wl > tbody'); + + var row = + '
Wikilibras API Interface
+| # | +Nome | +Hash | +Criado em | +Atualizado em | +Status | +
|---|