From c3d611adb272c07356c99e0d11675e493aacdb64 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 10 Oct 2017 14:45:13 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Login=20sin=20url=20de=20redirecci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/auth/server/boot/routes.js | 34 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/services/auth/server/boot/routes.js b/services/auth/server/boot/routes.js index 39864da206..00165863dc 100644 --- a/services/auth/server/boot/routes.js +++ b/services/auth/server/boot/routes.js @@ -10,10 +10,11 @@ module.exports = function(app) { }); app.post('/login', function(req, res) { - let user = req.body.user ? req.body.user : ""; - let password = req.body.password; + let body = req.body; + let user = body.user; + let password = body.password; let syncOnFail = true; - let usesEmail = user.indexOf('@') !== -1; + let usesEmail = user && user.indexOf('@') !== -1; login(); @@ -38,26 +39,23 @@ module.exports = function(app) { return; } - let parsedLocation; let loginUrl; - let shouldContinue = false; + let continueUrl; - if (req.body.location) - parsedLocation = url.parse(req.body.location, true); - - if (parsedLocation && parsedLocation.query) { - loginUrl = applications[parsedLocation.query.apiKey]; - shouldContinue = parsedLocation.query.continue; - } - + try { + let query = url.parse(req.body.location, true).query; + loginUrl = applications[query.apiKey]; + continueUrl = query.continue; + } catch (e) {} + if (!loginUrl) loginUrl = applications.default; - res.json({ + res.send(JSON.stringify({ token: token.id, - continue: shouldContinue, + continue: continueUrl, loginUrl: loginUrl - }); + })); } function findCb(err, instance) { if (!instance || instance.password !== md5(password)) { @@ -78,9 +76,9 @@ module.exports = function(app) { } function badLogin() { res.status(401); - res.json({ + res.send(JSON.stringify({ message: 'Login failed' - }); + })); } }); From eeda5b45fd397d51b30aa9b956293b842c2f71b4 Mon Sep 17 00:00:00 2001 From: dherrero Date: Tue, 10 Oct 2017 15:01:10 +0200 Subject: [PATCH 2/5] routes change model and first look --- client/route/src/index/index.html | 4 ++-- client/route/src/index/item-route.html | 15 ++++++++++++++ client/route/src/index/item-route.js | 8 ++++++++ .../models/{route.json => delivery.json} | 20 +++++++++++-------- services/route/server/datasources.json | 10 ---------- services/route/server/datasources.test.json | 5 ----- services/route/server/model-config.json | 6 ++---- 7 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 client/route/src/index/item-route.html rename services/route/common/models/{route.json => delivery.json} (72%) diff --git a/client/route/src/index/index.html b/client/route/src/index/index.html index 6cdc1a1d84..7b30e6549c 100644 --- a/client/route/src/index/index.html +++ b/client/route/src/index/index.html @@ -1,4 +1,4 @@ -< +
@@ -13,7 +13,7 @@ - +
diff --git a/client/route/src/index/item-route.html b/client/route/src/index/item-route.html new file mode 100644 index 0000000000..c2837513d6 --- /dev/null +++ b/client/route/src/index/item-route.html @@ -0,0 +1,15 @@ + + + + + + ID_RUTA: + {{$ctrl.route.id}} + + + + + + + + \ No newline at end of file diff --git a/client/route/src/index/item-route.js b/client/route/src/index/item-route.js index e69de29bb2..0eeb9fcd5f 100644 --- a/client/route/src/index/item-route.js +++ b/client/route/src/index/item-route.js @@ -0,0 +1,8 @@ +import ngModule from '../module'; + +ngModule.component('vnItemRoute', { + template: require('./item-route.html'), + bindings: { + route: '<' + } +}); diff --git a/services/route/common/models/route.json b/services/route/common/models/delivery.json similarity index 72% rename from services/route/common/models/route.json rename to services/route/common/models/delivery.json index 2cf7844836..0317074f31 100644 --- a/services/route/common/models/route.json +++ b/services/route/common/models/delivery.json @@ -1,15 +1,21 @@ { - "name": "Route", + "name": "Delivery", "base": "MyModel", "validateUpsert": true, "properties": { "id": { - "type": "Number", "id": true, - "description": "Identifier" + "type": "Number", + "forceId": false }, "date": { - "type": "date" + "type": "Date" + }, + "m3":{ + "type": "Number" + }, + "warehouseFk":{ + "type": "Number" } }, "acls": [ @@ -25,7 +31,5 @@ "principalId": "root", "permission": "ALLOW" } - ], - "validations": [], - "methods": {} -} \ No newline at end of file + ] +} diff --git a/services/route/server/datasources.json b/services/route/server/datasources.json index 33d77acda1..ba7db7577e 100644 --- a/services/route/server/datasources.json +++ b/services/route/server/datasources.json @@ -27,15 +27,5 @@ "password": "", "connectTimeout": 20000, "acquireTimeout": 20000 - }, - "client": { - "name": "client", - "connector": "remote", - "url": "http://localhost:3002/api" - }, - "route": { - "name": "route", - "connector": "remote", - "url": "http://localhost:3004/api" } } diff --git a/services/route/server/datasources.test.json b/services/route/server/datasources.test.json index 6e81700ce6..9b7ac4e580 100644 --- a/services/route/server/datasources.test.json +++ b/services/route/server/datasources.test.json @@ -27,10 +27,5 @@ "password": "", "connectTimeout": 20000, "acquireTimeout": 20000 - }, - "client": { - "name": "client", - "connector": "remote", - "url": "http://localhost:3002/api" } } diff --git a/services/route/server/model-config.json b/services/route/server/model-config.json index 2391df5b2d..904b02b80b 100644 --- a/services/route/server/model-config.json +++ b/services/route/server/model-config.json @@ -42,9 +42,7 @@ "Account": { "dataSource": "auth" }, - "Route": { - "dataSource": "route", - "public": true + "Delivery": { + "dataSource": "vn" } - } From 911fbb2f8bcc1ea6a0dcf6bbc91e11fa74d660bc Mon Sep 17 00:00:00 2001 From: dherrero Date: Wed, 11 Oct 2017 09:18:26 +0200 Subject: [PATCH 3/5] =?UTF-8?q?filtro=20de=20rutas=20con=20paginaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/route/src/index/index.html | 4 +- client/route/src/index/item-route.html | 34 ++++++++++------- client/route/src/index/style.css | 12 ++++++ services/route/common/methods/filter.js | 48 ++++++++++++++++++++++++ services/route/common/models/delivery.js | 3 ++ 5 files changed, 85 insertions(+), 16 deletions(-) create mode 100644 services/route/common/methods/filter.js create mode 100644 services/route/common/models/delivery.js diff --git a/client/route/src/index/index.html b/client/route/src/index/index.html index 7b30e6549c..337bb2a2ad 100644 --- a/client/route/src/index/index.html +++ b/client/route/src/index/index.html @@ -1,4 +1,4 @@ - +
@@ -13,7 +13,7 @@ - +
diff --git a/client/route/src/index/item-route.html b/client/route/src/index/item-route.html index c2837513d6..6b982b9aac 100644 --- a/client/route/src/index/item-route.html +++ b/client/route/src/index/item-route.html @@ -1,15 +1,21 @@ - - - - - - ID_RUTA: - {{$ctrl.route.id}} - - - - - - - + + + + + ID_RUTA: + {{$ctrl.route.id}} + + + Fecha: + {{$ctrl.route.date | date:'dd/MM/yyyy'}} + + + m3: + {{$ctrl.route.m3}} + + + + + + \ No newline at end of file diff --git a/client/route/src/index/style.css b/client/route/src/index/style.css index e69de29bb2..0a369664ed 100644 --- a/client/route/src/index/style.css +++ b/client/route/src/index/style.css @@ -0,0 +1,12 @@ +vn-item-route { + display: block; +} +vn-item-route a { + display: block; + text-decoration: none; + color: inherit; +} +vn-item-route a:hover { + color: white; + background-color: #424242; +} \ No newline at end of file diff --git a/services/route/common/methods/filter.js b/services/route/common/methods/filter.js new file mode 100644 index 0000000000..a31c200d03 --- /dev/null +++ b/services/route/common/methods/filter.js @@ -0,0 +1,48 @@ +module.exports = function(Delivery) { + Delivery.installMethod('filter', filterRoutes); + + function filterRoutes(params) { + if (params.search) + return searchWhere(params); + return andWhere(params); + } + + function searchWhere(params) { + return { + where: { + or: [ + {id: params.search}, + {name: {regexp: params.search}} + ] + + }, + skip: (params.page - 1) * params.size, + limit: params.size + }; + } + + function andWhere(params) { + let filters = { + where: {}, + skip: (params.page - 1) * params.size, + limit: params.size + }; + + delete params.page; + delete params.size; + + if (params.phone) { + filters.where.or = [ + {phone: params.phone}, + {mobile: params.phone} + ]; + delete params.phone; + } + Object.keys(params).forEach( + key => { + filters.where[key] = (key === 'postcode' || key === 'fi') ? params[key] : {regexp: params[key]}; + } + ); + return filters; + } +}; diff --git a/services/route/common/models/delivery.js b/services/route/common/models/delivery.js new file mode 100644 index 0000000000..8639d24b55 --- /dev/null +++ b/services/route/common/models/delivery.js @@ -0,0 +1,3 @@ +module.exports = function(Delivery) { + require('../methods/filter.js')(Delivery); +}; \ No newline at end of file From cf36d7d6bee942a3e258072cc6d1978f5437cd81 Mon Sep 17 00:00:00 2001 From: dherrero Date: Wed, 11 Oct 2017 12:09:22 +0200 Subject: [PATCH 4/5] module routes: front dev 80% --- client/route/routes.json | 55 ++++++++++++++++++- client/route/src/card/card.html | 27 +++++++++ client/route/src/card/card.js | 12 ++++ client/route/src/create/create.html | 29 ++++++++++ client/route/src/create/create.js | 21 +++++++ client/route/src/index/index.html | 4 +- client/route/src/index/item-route.html | 2 +- client/route/src/route.js | 3 + client/route/src/search-panel/locale/es.json | 10 ++++ .../route/src/search-panel/search-panel.html | 17 ++++++ client/route/src/search-panel/search-panel.js | 27 +++++++++ client/salix/src/components/home/style.scss | 3 +- .../src/components/main-menu/main-menu.html | 1 + .../salix/src/components/main-menu/style.scss | 5 ++ services/route/common/methods/filter.js | 2 +- 15 files changed, 212 insertions(+), 6 deletions(-) create mode 100644 client/route/src/card/card.html create mode 100644 client/route/src/card/card.js create mode 100644 client/route/src/create/create.html create mode 100644 client/route/src/create/create.js create mode 100644 client/route/src/search-panel/locale/es.json create mode 100644 client/route/src/search-panel/search-panel.html create mode 100644 client/route/src/search-panel/search-panel.js diff --git a/client/route/routes.json b/client/route/routes.json index e6da8754f1..b1b9358c98 100644 --- a/client/route/routes.json +++ b/client/route/routes.json @@ -1,13 +1,66 @@ { "module": "route", "name": "Route", - + "icon" : "local_shipping", "validations" : false, "routes": [ { "url": "/routes", "state": "routes", + "abstract": true, + "component": "ui-view" + }, + { + "url": "/list", + "state": "routes.index", "component": "vn-route-index" + }, + { + "url": "/create", + "state": "routes.create", + "component": "vn-route-create" + }, + { + "url": "/:id", + "state": "routes.card", + "abstract": true, + "component": "vn-route-card" + }, + { + "url": "/basicData", + "state": "routes.card.basicData", + "component": "vn-route-basic-data", + "params": { + "route": "$ctrl.route" + }, + "menu": { + "description": "Datos básicos", + "icon": "person" + } + }, + { + "url": "/logisticData", + "state": "routes.card.logisticData", + "component": "vn-route-logistic-data", + "params": { + "route": "$ctrl.route" + }, + "menu": { + "description": "Datos logísticos", + "icon": "local_shipping" + } + }, + { + "url": "/tickets", + "state": "routes.card.tickets", + "component": "vn-route-tickets", + "params": { + "route": "$ctrl.route" + }, + "menu": { + "description": "Tickets asignados", + "icon": "assignment" + } } ] } \ No newline at end of file diff --git a/client/route/src/card/card.html b/client/route/src/card/card.html new file mode 100644 index 0000000000..985c02d90e --- /dev/null +++ b/client/route/src/card/card.html @@ -0,0 +1,27 @@ + + + + + + + + + local_shipping + + +
Ruta {{::$ctrl.route.id}}
+
{{$ctrl.route.date | date:'dd/MM/yyyy'}}
+
+
+
+
+ +
+ + + +
+ \ No newline at end of file diff --git a/client/route/src/card/card.js b/client/route/src/card/card.js new file mode 100644 index 0000000000..e0655c0691 --- /dev/null +++ b/client/route/src/card/card.js @@ -0,0 +1,12 @@ +import ngModule from '../module'; + +class RouteCard { + constructor() { + this.route = null; + } +} + +ngModule.component('vnRouteCard', { + template: require('./card.html'), + controller: RouteCard +}); diff --git a/client/route/src/create/create.html b/client/route/src/create/create.html new file mode 100644 index 0000000000..f976ccdead --- /dev/null +++ b/client/route/src/create/create.html @@ -0,0 +1,29 @@ + + + +
+
+ + + Create Route + + + + + + + + + + + + + + + +
+
diff --git a/client/route/src/create/create.js b/client/route/src/create/create.js new file mode 100644 index 0000000000..e5092c7323 --- /dev/null +++ b/client/route/src/create/create.js @@ -0,0 +1,21 @@ +import ngModule from '../module'; + +class RouteCreate { + constructor($scope, $state) { + this.$ = $scope; + this.$state = $state; + this.route = {}; + console.log('hi world'); + } + onSubmit() { + this.$.watcher.submit().then( + json => this.$state.go('routes.card.basicData', {id: json.data.id}) + ); + } +} +RouteCreate.$inject = ['$scope', '$state']; + +ngModule.component('vnRouteCreate', { + template: require('./create.html'), + controller: RouteCreate +}); diff --git a/client/route/src/index/index.html b/client/route/src/index/index.html index 337bb2a2ad..7cbf0100f9 100644 --- a/client/route/src/index/index.html +++ b/client/route/src/index/index.html @@ -8,7 +8,7 @@ on-search="$ctrl.search(index)" advanced="true" search="$ctrl.model.search" - popover="vn-client-search-panel"> + popover="vn-route-search-panel"> @@ -17,7 +17,7 @@
- +
diff --git a/client/route/src/index/item-route.html b/client/route/src/index/item-route.html index 6b982b9aac..226d75810c 100644 --- a/client/route/src/index/item-route.html +++ b/client/route/src/index/item-route.html @@ -1,4 +1,4 @@ - + diff --git a/client/route/src/route.js b/client/route/src/route.js index 69a09db10e..b490a2039b 100644 --- a/client/route/src/route.js +++ b/client/route/src/route.js @@ -2,3 +2,6 @@ export * from './module'; // import components import './index/index'; +import './search-panel/search-panel'; +import './create/create'; +import './card/card'; diff --git a/client/route/src/search-panel/locale/es.json b/client/route/src/search-panel/locale/es.json new file mode 100644 index 0000000000..1dc7b850f4 --- /dev/null +++ b/client/route/src/search-panel/locale/es.json @@ -0,0 +1,10 @@ +{ + "Client id": "Id cliente", + "Tax number": "NIF/CIF", + "Name": "Nombre", + "Social name": "Razon social", + "Town/City": "Ciudad", + "Postcode": "Código postal", + "Email": "Correo electrónico", + "Phone": "Teléfono" +} \ No newline at end of file diff --git a/client/route/src/search-panel/search-panel.html b/client/route/src/search-panel/search-panel.html new file mode 100644 index 0000000000..7249bbd9c4 --- /dev/null +++ b/client/route/src/search-panel/search-panel.html @@ -0,0 +1,17 @@ +
+
+ + + + + + + + + + + + + +
+
diff --git a/client/route/src/search-panel/search-panel.js b/client/route/src/search-panel/search-panel.js new file mode 100644 index 0000000000..c1b79d5de0 --- /dev/null +++ b/client/route/src/search-panel/search-panel.js @@ -0,0 +1,27 @@ +import ngModule from '../module'; + +export default class Controller { + constructor($window) { + this.$window = $window; + // onSubmit() is defined by @vnSearchbar + this.onSubmit = () => {}; + } + onSearch() { + this.setStorageValue(); + this.onSubmit(this.filter); + } + $onChanges() { + var value = JSON.parse(this.$window.sessionStorage.getItem('filter')); + if (value !== undefined) + this.filter = value; + } + setStorageValue() { + this.$window.sessionStorage.setItem('filter', JSON.stringify(this.filter)); + } +} +Controller.$inject = ['$window']; + +ngModule.component('vnRouteSearchPanel', { + template: require('./search-panel.html'), + controller: Controller +}); diff --git a/client/salix/src/components/home/style.scss b/client/salix/src/components/home/style.scss index 135f5d461e..b35c1a1c75 100644 --- a/client/salix/src/components/home/style.scss +++ b/client/salix/src/components/home/style.scss @@ -45,8 +45,9 @@ vn-home { } i{ - font-size: 50px !important; + font-size: 75px !important; margin: 0 auto; + padding-top: 15px; } &:hover{ opacity: 0.7; diff --git a/client/salix/src/components/main-menu/main-menu.html b/client/salix/src/components/main-menu/main-menu.html index a85bebb7c3..25b375fd39 100644 --- a/client/salix/src/components/main-menu/main-menu.html +++ b/client/salix/src/components/main-menu/main-menu.html @@ -6,6 +6,7 @@
  • +
  • diff --git a/client/salix/src/components/main-menu/style.scss b/client/salix/src/components/main-menu/style.scss index 6b9687d5e2..ea454ebf3e 100644 --- a/client/salix/src/components/main-menu/style.scss +++ b/client/salix/src/components/main-menu/style.scss @@ -8,6 +8,11 @@ vn-main-menu { vertical-align: middle; margin-top: -3px; } + i{ + float: left; + padding-top: 13px; + margin-right: 3px; + } } li.mdl-menu__item:hover{ background-color: #FF9300; diff --git a/services/route/common/methods/filter.js b/services/route/common/methods/filter.js index a31c200d03..22e93afbd0 100644 --- a/services/route/common/methods/filter.js +++ b/services/route/common/methods/filter.js @@ -40,7 +40,7 @@ module.exports = function(Delivery) { } Object.keys(params).forEach( key => { - filters.where[key] = (key === 'postcode' || key === 'fi') ? params[key] : {regexp: params[key]}; + filters.where[key] = {regexp: params[key]}; } ); return filters; From 4dae59aa09ed0399c7fb70141dd7e72c00f2ba58 Mon Sep 17 00:00:00 2001 From: dherrero Date: Wed, 11 Oct 2017 12:47:02 +0200 Subject: [PATCH 5/5] zone model and rest api --- client/core/src/autocomplete/autocomplete.js | 69 +++++++++++-------- client/production/src/locale/en.json | 4 +- client/route/routes.json | 2 +- client/route/src/locale/en.json | 3 + client/route/src/locale/es.json | 2 +- .../route/src/search-panel/search-panel.html | 8 ++- client/salix/src/locale/es.json | 2 + services/route/common/models/zone.json | 33 +++++++++ services/route/server/model-config.json | 3 + 9 files changed, 92 insertions(+), 34 deletions(-) create mode 100644 client/route/src/locale/en.json create mode 100644 services/route/common/models/zone.json diff --git a/client/core/src/autocomplete/autocomplete.js b/client/core/src/autocomplete/autocomplete.js index f0e6eb3043..a4e04a9be4 100644 --- a/client/core/src/autocomplete/autocomplete.js +++ b/client/core/src/autocomplete/autocomplete.js @@ -19,6 +19,7 @@ class Autocomplete extends Component { this.maxRow = 10; this.showField = this.showField || 'name'; this.valueField = this.valueField || 'id'; + this.order = this.order || 'name ASC'; this.items = this.data || []; this.displayValueMultiCheck = []; this._multiField = []; @@ -219,38 +220,45 @@ class Autocomplete extends Component { } getItems() { let filter = {}; + if (!this.finding) { + this.finding = true; - if (this.maxRow) { - if (this.items) { - filter.skip = this.items.length; - } - filter.limit = this.maxRow; - filter.order = 'name ASC'; - } - - let json = JSON.stringify(filter); - - this.removeLoadMore = false; - - this.$http.get(`${this.url}?filter=${json}`).then( - json => { - if (json.data.length) { - json.data.forEach( - el => { - if (this.multiple) { - el.checked = this.field.indexOf(el[this.valueField]) !== -1; - } - this.items.push(el); - } - ); - if (filter.skip === 0 && this.maxRow && json.data.length < this.maxRow) { - this.removeLoadMore = true; - } - } else { - this.maxRow = false; + if (this.maxRow) { + if (this.items) { + filter.skip = this.items.length; } + filter.limit = this.maxRow; + filter.order = this.order; } - ); + + let json = JSON.stringify(filter); + + this.removeLoadMore = false; + + this.$http.get(`${this.url}?filter=${json}`).then( + json => { + if (json.data.length) { + json.data.forEach( + el => { + if (this.multiple) { + el.checked = this.field.indexOf(el[this.valueField]) !== -1; + } + this.items.push(el); + } + ); + if (filter.skip === 0 && this.maxRow && json.data.length < this.maxRow) { + this.removeLoadMore = true; + } + } else { + this.maxRow = false; + } + this.finding = false; + }, + () => { + this.finding = false; + } + ); + } } $onInit() { this.findMore = this.url && this.maxRow; @@ -308,7 +316,8 @@ module.component('vnAutocomplete', { data: ' - + diff --git a/client/salix/src/locale/es.json b/client/salix/src/locale/es.json index f2bc551fc0..fc09328176 100644 --- a/client/salix/src/locale/es.json +++ b/client/salix/src/locale/es.json @@ -9,5 +9,7 @@ "Can't contact with server": "No se pudo contactar con el servidor", "Push on applications menu": "Para abrir un módulo pulsa en el menú de aplicaciones", "Clients": "Clientes", + "Routes" : "Rutas", + "Production" : "Producción", "Modules access" : "Acceso a módulos" } \ No newline at end of file diff --git a/services/route/common/models/zone.json b/services/route/common/models/zone.json new file mode 100644 index 0000000000..a7a45bd273 --- /dev/null +++ b/services/route/common/models/zone.json @@ -0,0 +1,33 @@ +{ + "name": "Zone", + "base": "MyModel", + "validateUpsert": true, + "properties": { + "id": { + "id": true, + "type": "Number", + "forceId": false + }, + "name": { + "type": "String" + }, + "printingOrder":{ + "type": "Number" + } + }, + "acls": [ + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "DENY" + }, + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "root", + "permission": "ALLOW" + } + ] + } + \ No newline at end of file diff --git a/services/route/server/model-config.json b/services/route/server/model-config.json index 904b02b80b..da305afb08 100644 --- a/services/route/server/model-config.json +++ b/services/route/server/model-config.json @@ -44,5 +44,8 @@ }, "Delivery": { "dataSource": "vn" + }, + "Zone": { + "dataSource": "vn" } }