Skip to content

Commit

Permalink
Merge pull request #590 from ever-co/develop
Browse files Browse the repository at this point in the history
Latest from develop to master
  • Loading branch information
evereq committed Jun 5, 2019
2 parents f5a8af1 + 5ab565f commit 66bc454
Show file tree
Hide file tree
Showing 21 changed files with 939 additions and 418 deletions.
4 changes: 2 additions & 2 deletions admin/website-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"chart.js": "^2.8.0",
"ckeditor": "^4.11.4",
"classlist.js": "1.1.20150312",
"core-js": "^3.0.1",
"core-js": "^3.1.3",
"cryptiles": "^4.1.3",
"echarts": "^4.2.1",
"eva-icons": "^1.1.1",
Expand Down Expand Up @@ -204,7 +204,7 @@
"ts-node": "^8.1.0",
"tslint": "^5.16.0",
"typescript": "~3.2.4",
"typescript-tslint-plugin": "^0.3.1",
"typescript-tslint-plugin": "^0.4.0",
"webpack-dev-server": "^3.3.1",
"yargs": "^13.2.4"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default class FakeDataUsers {
environment.DEFAULT_LATITUDE
]
}
}
},
isBanned: Math.random() < 0.01
},
password: '123456'
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<div (click)="redirect()" class="{{ redirectPage ? 'redirectBtn' : '' }}">
<h6 class="warehouse-name-smt">
<strong>{{ rowData.name }}</strong>
<strong
>{{ rowData.name
}}<span *ngIf="rowData.isBanned" class="badge badge-danger"
>ban</span
></strong
>
</h6>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h4 class="modal-title" id="modal-title">Profile Ban</h4>
type="button"
ngbAutofocus
class="btn btn-danger"
(click)="modal.close(user.id)"
(click)="modal.close(user)"
>
Ok
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

<button
class="btn btn-danger mr-2 d-inline-block"
[disabled]="!isOnlyOneCustomerSelected"
[disabled]="!isOnlyOneCustomerSelected || showBanLoading"
[nbSpinner]="showBanLoading"
(click)="banSelectedRows()"
>
<i class="ion-md-close-circle button-icon"></i>
Expand All @@ -48,6 +49,14 @@
'CUSTOMERS_VIEW.BAN' | translate
}}</small>
</button>
<input
type="checkbox"
name="bannedOnly"
id="showBannedOnly"
[(ngModel)]="showOnlyBanned"
[ngModelOptions]="{ standalone: true }"
/>
<label for="bannedOnly">Show Banned Only</label>
</nb-card-header>

<nb-card-body [nbSpinner]="loading">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {

static noInfoSign = '';
public loading: boolean;
public showBanLoading = false;

protected customers: User[] = [];
protected orders: Order[] = [];
Expand All @@ -59,6 +60,8 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
private dataCount: number;
private $users;

public _showOnlyBanned: boolean;

constructor(
private readonly _router: Router,
private readonly _ordersService: OrdersService,
Expand Down Expand Up @@ -140,8 +143,14 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
});
modal.componentInstance.user = this._selectedCustomers[0];
modal.result
.then((id) => this._usersService.unbanUser(id))
.catch(console.error);
.then(async (user) => {
this.showBanLoading = true;
await this._usersService.unbanUser(user.id);
this._loadDataSmartTable();
this.showBanLoading = false;
this._notifyService.success(`${user.name} is unbanned!`);
})
.catch((_) => {});
}

private showBanPopup() {
Expand All @@ -153,8 +162,14 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
});
modal.componentInstance.user = this._selectedCustomers[0];
modal.result
.then((id) => this._usersService.banUser(id))
.catch(console.error);
.then(async (user) => {
this.showBanLoading = true;
await this._usersService.banUser(user.id);
this._loadDataSmartTable();
this.showBanLoading = false;
this._notifyService.success(`${user.name} is banned!`);
})
.catch((_) => {});
}

private _loadSettingsSmartTable() {
Expand Down Expand Up @@ -252,7 +267,7 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
users.map((u) => u.id)
);

const usersVM = users.map((user) => {
let usersVM = users.map((user) => {
const userOrders = usersOrders.find(
(res) => res['id'] === user.id
);
Expand Down Expand Up @@ -285,6 +300,10 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {

await this.loadDataCount();

if (this.showOnlyBanned) {
usersVM = usersVM.filter((user) => user.isBanned);
}

const usersData = new Array(this.dataCount);

usersData.splice(perPage * (page - 1), perPage, ...usersVM);
Expand Down Expand Up @@ -346,6 +365,15 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
);
}

public set showOnlyBanned(v: boolean) {
this._showOnlyBanned = v;
this._loadDataSmartTable();
}

public get showOnlyBanned(): boolean {
return this._showOnlyBanned;
}

ngOnDestroy() {
this.ngDestroy$.next();
this.ngDestroy$.complete();
Expand Down
15 changes: 10 additions & 5 deletions admin/website-angular/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4439,7 +4439,7 @@ core-js-pure@3.0.1:
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.0.1.tgz#37358fb0d024e6b86d443d794f4e37e949098cbe"
integrity sha512-mSxeQ6IghKW3MoyF4cz19GJ1cMm7761ON+WObSyLfTu/Jn3x7w4NwNFnrZxgl4MTSvYYepVLNuRtlB4loMwJ5g==

core-js@3.0.1, core-js@^3.0.1:
core-js@3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.0.1.tgz#1343182634298f7f38622f95e73f54e48ddf4738"
integrity sha512-sco40rF+2KlE0ROMvydjkrVMMG1vYilP2ALoRXcYR4obqbYIuV3Bg+51GEDW+HF8n7NRA+iaA4qD0nD9lo9mew==
Expand All @@ -4454,6 +4454,11 @@ core-js@^2.2.0, core-js@^2.4.0, core-js@^2.5.7, core-js@^2.6.5:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.5.tgz#44bc8d249e7fb2ff5d00e0341a7ffb94fbf67895"
integrity sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A==

core-js@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.1.3.tgz#95700bca5f248f5f78c0ec63e784eca663ec4138"
integrity sha512-PWZ+ZfuaKf178BIAg+CRsljwjIMRV8MY00CbZczkR6Zk5LfkSkjGoaab3+bqRQWVITNZxQB7TFYz+CFcyuamvA==

core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
Expand Down Expand Up @@ -13478,10 +13483,10 @@ typeface-exo@^0.0.61:
resolved "https://registry.yarnpkg.com/typeface-exo/-/typeface-exo-0.0.61.tgz#10c6113292da354cb9f26ee9d0b0c996f1a7a3bd"
integrity sha512-AH3bMVYnVpg2G+CJbgtogTuJpWGS0zspHJzzVR8cCgTtkbUI0pj8WBB+RFo14CHbF5MmZgYe7TVoWz+j4Yo6Jg==

typescript-tslint-plugin@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/typescript-tslint-plugin/-/typescript-tslint-plugin-0.3.1.tgz#d86ae0342c9e8f9ecfcbcc47f7a7c2b5ab0e86f9"
integrity sha512-h8HEPBm36UEs901ld1x6m5eY/UFb4mF+A0nvERr4BWMww5wnV5nfcm9ZFt18foYL0GQ5NVMt1Tb3466WUU8dRQ==
typescript-tslint-plugin@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/typescript-tslint-plugin/-/typescript-tslint-plugin-0.4.0.tgz#af1729e72b770489b2b912809694f46c3281bb72"
integrity sha512-83zipyk5bCqu/LHifaWPmJ7Xnl6lLn/3KmWINgr+XND79BrVWmkV8CudKc+a9Jhjs2opvVKq0n0P4O4NhHOixw==
dependencies:
minimatch "^3.0.4"
mock-require "^3.0.2"
Expand Down
17 changes: 9 additions & 8 deletions backend/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@nestjs/typeorm": "^6.1.1",
"@nestjs/websockets": "^6.1.1",
"apollo-server-express": "^2.4.8",
"axios": "^0.18.0",
"axios": "^0.19.0",
"bcrypt": "^3.0.4",
"bluebird": "^3.5.4",
"body-parser": "^1.19.0",
Expand All @@ -84,6 +84,7 @@
"express": "^4.16.4",
"express-handlebars": "^3.0.2",
"faker": "^4.1.0",
"fstream": "^1.0.12",
"graphql": "^14.2.1",
"graphql-playground-middleware-express": "^1.7.12",
"graphql-subscriptions": "^1.1.0",
Expand Down Expand Up @@ -138,14 +139,14 @@
"underscore.string": "^3.3.5",
"upath": "^1.1.2",
"uuid": "^3.3.2",
"validator": "^10.11.0",
"validator": "^11.0.0",
"ws": "^7.0.0"
},
"devDependencies": {
"@commitlint/cli": "^7.5.2",
"@commitlint/config-conventional": "^7.5.0",
"@commitlint/config-lerna-scopes": "^7.5.1",
"@commitlint/travis-cli": "^7.5.2",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"@commitlint/config-lerna-scopes": "^8.0.0",
"@commitlint/travis-cli": "^8.0.0",
"@nestjs/testing": "^6.1.1",
"@types/bcrypt": "^3.0.0",
"@types/bluebird": "^3.5.26",
Expand All @@ -157,7 +158,7 @@
"@types/express": "^4.16.1",
"@types/faker": "^4.1.5",
"@types/form-data": "^2.2.1",
"@types/google-maps": "^3.2.0",
"@types/google-maps": "^3.2.1",
"@types/handlebars": "^4.1.0",
"@types/inversify": "^2.0.33",
"@types/jest": "^24.0.11",
Expand Down Expand Up @@ -185,7 +186,7 @@
"@types/ws": "^6.0.1",
"concurrently": "^4.1.0",
"conventional-changelog": "^3.1.4",
"core-js": "^3.0.1",
"core-js": "^3.1.3",
"coveralls": "^3.0.3",
"cross-env": "^5.2.0",
"cz-conventional-changelog": "^2.1.0",
Expand Down
2 changes: 2 additions & 0 deletions backend/api/src/services/users/UsersService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export class UsersService extends DBService<User>
const firstName = faker.name.firstName();
const lastName = faker.name.lastName();
const email = faker.internet.email(firstName, lastName);
const isBanned = Math.random() < 0.02;

const geoLocation: IGeoLocationCreateObject = {
countryId: faker.random.number(Country.ZW) as Country,
Expand All @@ -475,6 +476,7 @@ export class UsersService extends DBService<User>
geoLocation,
apartment: `${customerCount}`,
email,
isBanned,
image: faker.image.avatar(),
phone: faker.phone.phoneNumber(),
_createdAt: faker.date.between(
Expand Down

0 comments on commit 66bc454

Please sign in to comment.