Browse Source

OpenAPI & Dashboard 2

master
eduveks 5 years ago
parent
commit
90700b7b31
13 changed files with 269 additions and 9 deletions
  1. +11
    -0
      config/_development.json
  2. BIN
      dbs/social_ests.mv.db
  3. +126
    -0
      public/scripts/main.js
  4. +1
    -1
      public/scripts/main.js.map
  5. +15
    -0
      server/services/_openapi.json
  6. +12
    -0
      server/services/_schema/cities.js
  7. +33
    -0
      server/services/register.post.in.json
  8. +1
    -8
      server/services/register.post.js
  9. +11
    -0
      server/services/register.post.out.200.json
  10. +15
    -0
      server/services/register.post.out.409.json
  11. +20
    -0
      ui/src/containers/Dashboard2Container/index.jsx
  12. +8
    -0
      ui/src/containers/Dashboard2Container/index.less
  13. +16
    -0
      ui/src/index.jsx

+ 11
- 0
config/_development.json View File

@ -49,5 +49,16 @@
"access_expires": 60,
"refresh_expires": 1440,
"algorithm": "HS512"
},
"openapi": {
"host": "http://eduardo-velasques.dev.netuno.org:10030",
"basePath": "/services",
"schemes": [ "http" ],
"servers": [
{
"url": "http://eduardo-velasques.dev.netuno.org:10030/services",
"description": "Plataforma Social - Desenvolvimento Local"
}
]
}
}

BIN
dbs/social_ests.mv.db View File


+ 126
- 0
public/scripts/main.js View File

@ -172873,6 +172873,24 @@ function copy(text, options) {
module.exports = copy;
/***/ }),
/***/ "./node_modules/css-loader/dist/cjs.js?!./node_modules/less-loader/dist/cjs.js?!./src/containers/Dashboard2Container/index.less":
/*!********************************************************************************************************************************************************!*\
!*** ./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/less-loader/dist/cjs.js??ref--6-2!./src/containers/Dashboard2Container/index.less ***!
\********************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// Imports
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(/*! ../../../node_modules/css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
exports = ___CSS_LOADER_API_IMPORT___(true);
// Module
exports.push([module.i, ".my-dashboard {\n width: 100%;\n}\n.my-dashboard__button {\n padding: 80px;\n text-align: center;\n}\n", "",{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA;EACE,WAAW;AACb;AACA;EACE,aAAa;EACb,kBAAkB;AACpB","file":"index.less","sourcesContent":[".my-dashboard {\n width: 100%;\n}\n.my-dashboard__button {\n padding: 80px;\n text-align: center;\n}\n"]}]);
// Exports
module.exports = exports;
/***/ }),
/***/ "./node_modules/css-loader/dist/cjs.js?!./node_modules/less-loader/dist/cjs.js?!./src/containers/DashboardContainer/index.less":
@ -238871,6 +238889,106 @@ var TabelaPessoas = function TabelaPessoas() {
/***/ }),
/***/ "./src/containers/Dashboard2Container/index.jsx":
/*!******************************************************!*\
!*** ./src/containers/Dashboard2Container/index.jsx ***!
\******************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Dashboard2Container; });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _index_less__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index.less */ "./src/containers/Dashboard2Container/index.less");
/* harmony import */ var _index_less__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_index_less__WEBPACK_IMPORTED_MODULE_1__);
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var Dashboard2Container = /*#__PURE__*/function (_Component) {
_inherits(Dashboard2Container, _Component);
var _super = _createSuper(Dashboard2Container);
function Dashboard2Container(props) {
var _this;
_classCallCheck(this, Dashboard2Container);
_this = _super.call(this, props);
_this.state = {};
return _this;
}
_createClass(Dashboard2Container, [{
key: "render",
value: function render() {
var counter = this.state.counter;
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
className: "my-dashboard"
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h1", null, "Outro Dashboard REACT"));
}
}]);
return Dashboard2Container;
}(react__WEBPACK_IMPORTED_MODULE_0__["Component"]);
/***/ }),
/***/ "./src/containers/Dashboard2Container/index.less":
/*!*******************************************************!*\
!*** ./src/containers/Dashboard2Container/index.less ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var api = __webpack_require__(/*! ../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
var content = __webpack_require__(/*! !../../../node_modules/css-loader/dist/cjs.js??ref--6-1!../../../node_modules/less-loader/dist/cjs.js??ref--6-2!./index.less */ "./node_modules/css-loader/dist/cjs.js?!./node_modules/less-loader/dist/cjs.js?!./src/containers/Dashboard2Container/index.less");
content = content.__esModule ? content.default : content;
if (typeof content === 'string') {
content = [[module.i, content, '']];
}
var options = {};
options.insert = "head";
options.singleton = false;
var update = api(content, options);
module.exports = content.locals || {};
/***/ }),
/***/ "./src/containers/DashboardContainer/index.jsx":
/*!*****************************************************!*\
!*** ./src/containers/DashboardContainer/index.jsx ***!
@ -239061,11 +239179,19 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js");
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _containers_DashboardContainer_index_jsx__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./containers/DashboardContainer/index.jsx */ "./src/containers/DashboardContainer/index.jsx");
/* harmony import */ var _containers_Dashboard2Container_index_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./containers/Dashboard2Container/index.jsx */ "./src/containers/Dashboard2Container/index.jsx");
var dashboardDiv = document.getElementById("app-dashboard");
var dashboardContainer = dashboardDiv ? react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_containers_DashboardContainer_index_jsx__WEBPACK_IMPORTED_MODULE_2__["default"], null), dashboardDiv) : false;
netuno.addNavigationLoad(function () {
$('[netuno-navigation]').children().first().after("\n <li>\n <a netuno-navigation-dashboardx=\"\" href=\"#netuno_dashboard2\">\n <i class=\"fa fa-fw fa-home\"></i> DashboardX\n </a>\n </li>\n ");
$('[netuno-containers]').children().first().after("\n <div netuno-container-dashboard2 id=\"netuno_dashboard2\" style=\"display: none;\">Outro Dashboard</div>\n ");
var dashboard2Div = document.getElementById("netuno_dashboard2");
var dashboard2Container = dashboard2Div ? react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_containers_Dashboard2Container_index_jsx__WEBPACK_IMPORTED_MODULE_3__["default"], null), dashboard2Div) : false;
});
netuno.addNavigationLoad(function () {
$('[netuno-navigation]').find('a').on('netuno:click', function (e) {
var link = $(e.target);


+ 1
- 1
public/scripts/main.js.map
File diff suppressed because it is too large
View File


+ 15
- 0
server/services/_openapi.json View File

@ -0,0 +1,15 @@
{
"info": {
"title": "Plataforma Social",
"description": "REST API da Plataforma Social.",
"version": "1.0"
},
"components": {
"securitySchemes": {
"BearerAuth": {
"type": "http",
"scheme": "bearer"
}
}
}
}

+ 12
- 0
server/services/_schema/cities.js View File

@ -0,0 +1,12 @@
const dbCidades = _db.query(`
select * from cidade
`)
const cities = _val.list()
for (let dbCidade of dbCidades) {
cities.add(dbCidade.getString("uid"))
}
_dataSchema.set("enum", cities)

+ 33
- 0
server/services/register.post.in.json View File

@ -0,0 +1,33 @@
{
"summary": "Registo",
"description": "Registo das contas dos utilizadores.",
"type": "object",
"properties": {
"name": {
"type": "string-not-empty"
},
"surname": {
"type": "string-not-empty"
},
"city_uid": {
"_schema": "cities"
},
"email": {
"type": "string-not-empty"
},
"username": {
"type": "string-not-empty"
},
"password": {
"type": "string-not-empty"
}
},
"required": [
"name",
"surname",
"city_uid",
"email",
"username",
"password"
]
}

+ 1
- 8
server/services/register.post.js View File

@ -11,14 +11,7 @@ const dbCidade = _db.get("cidade", cityUid)
const emailExists = _user.firstByMail(email)
const usernameExists = _user.firstByUser(username)
if (dbCidade == null) {
_header.status(409)
_out.json(
_val.map()
.set("error", true)
.set("message", "city-not-found")
)
} else if (emailExists != null) {
if (emailExists != null) {
_header.status(409)
_out.json(
_val.map()


+ 11
- 0
server/services/register.post.out.200.json View File

@ -0,0 +1,11 @@
{
"type": "object",
"properties": {
"result": {
"type": "boolean"
}
},
"required": [
"result"
]
}

+ 15
- 0
server/services/register.post.out.409.json View File

@ -0,0 +1,15 @@
{
"type": "object",
"properties": {
"error": {
"type": "boolean"
},
"message": {
"type": "string-not-empty"
}
},
"required": [
"error",
"message"
]
}

+ 20
- 0
ui/src/containers/Dashboard2Container/index.jsx View File

@ -0,0 +1,20 @@
import React, { Component } from "react";
import "./index.less";
export default class Dashboard2Container extends Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
const { counter } = this.state;
return (
<div className="my-dashboard">
<h1>Outro Dashboard REACT</h1>
</div>
);
}
}

+ 8
- 0
ui/src/containers/Dashboard2Container/index.less View File

@ -0,0 +1,8 @@
.my-dashboard {
width: 100%;
&__button {
padding: 80px;
text-align: center;
}
}

+ 16
- 0
ui/src/index.jsx View File

@ -1,11 +1,27 @@
import React from "react";
import ReactDOM from "react-dom";
import DashboardContainer from "./containers/DashboardContainer/index.jsx";
import Dashboard2Container from "./containers/Dashboard2Container/index.jsx";
const dashboardDiv = document.getElementById("app-dashboard");
const dashboardContainer = dashboardDiv ? ReactDOM.render(<DashboardContainer />, dashboardDiv) : false;
netuno.addNavigationLoad(() => {
$('[netuno-navigation]').children().first().after(`
<li>
<a netuno-navigation-dashboardx="" href="#netuno_dashboard2">
<i class="fa fa-fw fa-home"></i> DashboardX
</a>
</li>
`);
$('[netuno-containers]').children().first().after(`
<div netuno-container-dashboard2 id="netuno_dashboard2" style="display: none;">Outro Dashboard</div>
`);
const dashboard2Div = document.getElementById("netuno_dashboard2");
const dashboard2Container = dashboard2Div ? ReactDOM.render(<Dashboard2Container />, dashboard2Div) : false;
});
netuno.addNavigationLoad(() => {
$('[netuno-navigation]').find('a').on('netuno:click', (e)=> {
const link = $(e.target);


Loading…
Cancel
Save