paging clients

This commit is contained in:
Vicente Falco 2017-02-07 13:24:04 +01:00
parent ec08e271f0
commit 5a6682c773
9 changed files with 101 additions and 14 deletions

View File

@ -1,5 +1,6 @@
// Coloque su configuración en este archivo para sobrescribir la configuración predeterminada y de usuario. // Coloque su configuración en este archivo para sobrescribir la configuración predeterminada y de usuario.
{ {
// Carácter predeterminado de final de línea. // Carácter predeterminado de final de línea.
"files.eol": "\n" "files.eol": "\n",
"vsicons.presets.angular": true
} }

View File

@ -28,5 +28,7 @@ export {NAME as CLIENT_CONFIRM_INDEX,
COMPONENT as CLIENT_CONFIRM_INDEX_COMPONENT} from './confirm/index'; COMPONENT as CLIENT_CONFIRM_INDEX_COMPONENT} from './confirm/index';
export {NAME as NEW_NOTE_INDEX, export {NAME as NEW_NOTE_INDEX,
COMPONENT as NEW_NOTE_INDEX_COMPONENT} from './new-note/index'; COMPONENT as NEW_NOTE_INDEX_COMPONENT} from './new-note/index';
export {NAME as CLIENT_PAGING,
COMPONENT as CLIENT_PAGING_COMPONENT} from './index/index-paging';
import './web-access/index'; import './web-access/index';

View File

@ -0,0 +1,13 @@
<div vn-horizontal>
<vn-one style="text-align:center;">
<paging page="pagingClient.currentPage"
page-size="pagingClient.numPerPage"
total="pagingClient.numPages"
show-prev-next="true"
show-first-last="true"
ul-class="pagination"
active-class="active"
ng-click="pagingClient.figureOutToDisplay()">
</paging>
</vn-one>
</div>

View File

@ -0,0 +1,64 @@
import template from './index-paging.html';
import {module} from '../module';
export const NAME = 'vnPagingClient';
export const COMPONENT = {
template: template,
bindings: {
filter: '<',
clients: '='
},
controllerAs: 'pagingClient',
controller: function($http) {
var self = this;
let queryStr = '/client/api/Clients';
let where = this.filter;
let numPerPage = 3;
this.$onChanges = function(changes) {
if (Object.keys(self.filter).length > 0){
where = self.filter;
this.getClients();
this.getNumPages();
}
else {
where = "";
this.currentPage = 1;
this.getAllClients();
}
this.figureOutToDisplay();
};
this.getNumPages = () => {
var nPages = self.clients.length / numPerPage;
this.numPages = Math.ceil(nPages);
};
this.figureOutToDisplay = () => {
var begin = ((this.currentPage - 1) * numPerPage);
this.getClients(begin);
};
this.getAllClients = () => {
$http.get(queryStr).then(
json => {
self.clients = json.data;
this.getNumPages();
}
);
};
this.getClients = function(end) {
var json = JSON.stringify({where: where, limit: numPerPage, skip: end});
self.queryStr = `${queryStr}?filter=${json}`;
$http.get(self.queryStr).then(
json => {
self.clients = json.data;
}
);
};
}
};
COMPONENT.controller.$inject = ['$http'];
module.component(NAME, COMPONENT);

View File

@ -13,6 +13,7 @@
<vn-card margin-medium-top> <vn-card margin-medium-top>
<vn-item-client ng-repeat="client in search.clients" title="View client" client="client"></vn-item-client> <vn-item-client ng-repeat="client in search.clients" title="View client" client="client"></vn-item-client>
</vn-card> </vn-card>
<vn-paging-client clients="search.clients" filter="search.filter"></vn-paging-client>
</div> </div>
<a ui-sref="create" fixed-bottom-right> <a ui-sref="create" fixed-bottom-right>
<vn-float-button icon="person_add"></vn-float-button> <vn-float-button icon="person_add"></vn-float-button>

View File

@ -7,11 +7,10 @@ export const COMPONENT = {
template: template, template: template,
controllerAs: 'search', controllerAs: 'search',
controller: function($http) { controller: function($http) {
this.clients = []; var self = this;
this.find = function() { this.find = function() {
var where = null; var where = {};
var filter = this.filter; var filter = this.filter;
var queryStr = '/client/api/Clients';
var search = filter.search; var search = filter.search;
if (search) if (search)
where = {name: {ilike: search}}; where = {name: {ilike: search}};
@ -37,13 +36,8 @@ export const COMPONENT = {
} }
if (where) { if (where) {
let json = JSON.stringify({where: where}); self.filter = where;
queryStr = `${queryStr}?filter=${json}`;
} }
$http.get(queryStr).then(
json => this.clients = json.data
);
}; };
this.filter = {}; this.filter = {};
this.find(); this.find();

View File

@ -2,7 +2,7 @@
"ids": { "ids": {
"User": 2, "User": 2,
"AccessToken": 2, "AccessToken": 2,
"Client": 20, "Client": 21,
"PaymentMethod": 4, "PaymentMethod": 4,
"SalesPerson": 11, "SalesPerson": 11,
"Address": 83, "Address": 83,
@ -24,7 +24,8 @@
"14": "{\"name\":\"Cliente 1\",\"id\":14,\"street\":\"Aaaaaaaaaa\",\"fi\":\"1234567890A\",\"socialName\":\"Cliente 1\",\"fax\":\"963242100\",\"dischargeDate\":\"01/01/2017\",\"telefono\":\"963242100\",\"salesPerson\":\"2\",\"email\":\"informatica@verdnatura.es\",\"city\":\"asdf\",\"postcode\":\"asdf\",\"phone\":\"asdf\",\"mobile\":\"asdf\",\"credit\":2345,\"cyc\":56,\"iban\":\"asdf\",\"dueDay\":345,\"gestdoc\":2435,\"surcharge\":true,\"navigate\":true}", "14": "{\"name\":\"Cliente 1\",\"id\":14,\"street\":\"Aaaaaaaaaa\",\"fi\":\"1234567890A\",\"socialName\":\"Cliente 1\",\"fax\":\"963242100\",\"dischargeDate\":\"01/01/2017\",\"telefono\":\"963242100\",\"salesPerson\":\"2\",\"email\":\"informatica@verdnatura.es\",\"city\":\"asdf\",\"postcode\":\"asdf\",\"phone\":\"asdf\",\"mobile\":\"asdf\",\"credit\":2345,\"cyc\":56,\"iban\":\"asdf\",\"dueDay\":345,\"gestdoc\":2435,\"surcharge\":true,\"navigate\":true}",
"15": "{\"name\":\"Florsiteria Pepa\",\"fi\":\"12341234rasf\",\"socialName\":\"asdfasd\",\"dueDay\":5,\"id\":15,\"payMethod\":\"2\",\"salesPerson\":\"1\",\"modify\":\"BasicData\",\"iban\":\"sdfgsdfgsdfg\",\"email\":\"pepa@flores.es\"}", "15": "{\"name\":\"Florsiteria Pepa\",\"fi\":\"12341234rasf\",\"socialName\":\"asdfasd\",\"dueDay\":5,\"id\":15,\"payMethod\":\"2\",\"salesPerson\":\"1\",\"modify\":\"BasicData\",\"iban\":\"sdfgsdfgsdfg\",\"email\":\"pepa@flores.es\"}",
"16": "{\"name\":\"Floristeria Antonieta\",\"fi\":\"2345234523d\",\"socialName\":\"23452345assdfgsdfgt\",\"active\":true,\"dueDay\":5,\"id\":16,\"modify\":\"FiscalData\",\"email\":\"antonieta@gmail.com\",\"phone\":\"654654654\",\"mobile\":\"654456456\",\"fax\":\"456456456\",\"street\":\"asdfasdf\",\"salesPerson\":8}", "16": "{\"name\":\"Floristeria Antonieta\",\"fi\":\"2345234523d\",\"socialName\":\"23452345assdfgsdfgt\",\"active\":true,\"dueDay\":5,\"id\":16,\"modify\":\"FiscalData\",\"email\":\"antonieta@gmail.com\",\"phone\":\"654654654\",\"mobile\":\"654456456\",\"fax\":\"456456456\",\"street\":\"asdfasdf\",\"salesPerson\":8}",
"19": "{\"name\":\"Planticas Eustaquio\",\"fi\":\"789456123B\",\"socialName\":\"Eustaquio Martinez\",\"active\":true,\"dueDay\":5,\"id\":19,\"email\":\"peustaquio@hotmail.es\"}" "19": "{\"name\":\"Planticas Eustaquio\",\"fi\":\"789456123B\",\"socialName\":\"Eustaquio Martinez\",\"active\":true,\"dueDay\":5,\"id\":19,\"email\":\"peustaquio@hotmail.es\"}",
"20": "{\"name\":\"Vicente Falco\",\"fi\":\"73773536R\",\"socialName\":\"vicente falco\",\"active\":true,\"dueDay\":5,\"id\":20,\"phone\":\"963258073\",\"mobile\":\"636898196\",\"fax\":\"636898196\",\"email\":\"vicente.falco@gmail.com\"}"
}, },
"PaymentMethod": { "PaymentMethod": {
"1": "{\"name\":\"Tarjeta\",\"id\":1}", "1": "{\"name\":\"Tarjeta\",\"id\":1}",

View File

@ -53,3 +53,14 @@
2017/01/16 08:26:22 [notice] 1256#3772: signal process started 2017/01/16 08:26:22 [notice] 1256#3772: signal process started
2017/01/17 13:27:35 [notice] 7104#204: signal process started 2017/01/17 13:27:35 [notice] 7104#204: signal process started
2017/01/17 13:38:00 [notice] 1592#8484: signal process started 2017/01/17 13:38:00 [notice] 1592#8484: signal process started
2017/02/03 11:15:49 [notice] 4528#1708: signal process started
2017/02/03 11:26:13 [notice] 11816#3532: signal process started
2017/02/03 11:29:20 [notice] 10596#10772: signal process started
2017/02/03 11:48:22 [notice] 11236#6496: signal process started
2017/02/06 12:27:21 [notice] 8676#5728: signal process started
2017/02/06 12:27:21 [error] 8676#5728: OpenEvent("Global\ngx_stop_6316") failed (2: FormatMessage() error:(15100))
2017/02/06 12:28:24 [notice] 9840#6896: signal process started
2017/02/06 14:34:18 [notice] 6568#9564: signal process started
2017/02/07 07:05:55 [notice] 3804#4508: signal process started
2017/02/07 07:05:55 [error] 3804#4508: OpenEvent("Global\ngx_stop_6996") failed (2: FormatMessage() error:(15100))
2017/02/07 12:56:15 [notice] 9668#8064: signal process started