Skip to content

Commit 66bc454

Browse files
authored
Merge pull request #590 from ever-co/develop
Latest from develop to master
2 parents f5a8af1 + 5ab565f commit 66bc454

File tree

21 files changed

+939
-418
lines changed

21 files changed

+939
-418
lines changed

admin/website-angular/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"chart.js": "^2.8.0",
100100
"ckeditor": "^4.11.4",
101101
"classlist.js": "1.1.20150312",
102-
"core-js": "^3.0.1",
102+
"core-js": "^3.1.3",
103103
"cryptiles": "^4.1.3",
104104
"echarts": "^4.2.1",
105105
"eva-icons": "^1.1.1",
@@ -204,7 +204,7 @@
204204
"ts-node": "^8.1.0",
205205
"tslint": "^5.16.0",
206206
"typescript": "~3.2.4",
207-
"typescript-tslint-plugin": "^0.3.1",
207+
"typescript-tslint-plugin": "^0.4.0",
208208
"webpack-dev-server": "^3.3.1",
209209
"yargs": "^13.2.4"
210210
},

admin/website-angular/src/app/@core/data/fakeDataServices/users.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export default class FakeDataUsers {
3030
environment.DEFAULT_LATITUDE
3131
]
3232
}
33-
}
33+
},
34+
isBanned: Math.random() < 0.01
3435
},
3536
password: '123456'
3637
};
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<div (click)="redirect()" class="{{ redirectPage ? 'redirectBtn' : '' }}">
22
<h6 class="warehouse-name-smt">
3-
<strong>{{ rowData.name }}</strong>
3+
<strong
4+
>{{ rowData.name
5+
}}<span *ngIf="rowData.isBanned" class="badge badge-danger"
6+
>ban</span
7+
></strong
8+
>
49
</h6>
510
</div>

admin/website-angular/src/app/@shared/user/ban-confirm/ban-confirm.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h4 class="modal-title" id="modal-title">Profile Ban</h4>
3030
type="button"
3131
ngbAutofocus
3232
class="btn btn-danger"
33-
(click)="modal.close(user.id)"
33+
(click)="modal.close(user)"
3434
>
3535
Ok
3636
</button>

admin/website-angular/src/app/pages/+customers/customers.component.html

+10-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535

3636
<button
3737
class="btn btn-danger mr-2 d-inline-block"
38-
[disabled]="!isOnlyOneCustomerSelected"
38+
[disabled]="!isOnlyOneCustomerSelected || showBanLoading"
39+
[nbSpinner]="showBanLoading"
3940
(click)="banSelectedRows()"
4041
>
4142
<i class="ion-md-close-circle button-icon"></i>
@@ -48,6 +49,14 @@
4849
'CUSTOMERS_VIEW.BAN' | translate
4950
}}</small>
5051
</button>
52+
<input
53+
type="checkbox"
54+
name="bannedOnly"
55+
id="showBannedOnly"
56+
[(ngModel)]="showOnlyBanned"
57+
[ngModelOptions]="{ standalone: true }"
58+
/>
59+
<label for="bannedOnly">Show Banned Only</label>
5160
</nb-card-header>
5261

5362
<nb-card-body [nbSpinner]="loading">

admin/website-angular/src/app/pages/+customers/customers.component.ts

+33-5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
4848

4949
static noInfoSign = '';
5050
public loading: boolean;
51+
public showBanLoading = false;
5152

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

63+
public _showOnlyBanned: boolean;
64+
6265
constructor(
6366
private readonly _router: Router,
6467
private readonly _ordersService: OrdersService,
@@ -140,8 +143,14 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
140143
});
141144
modal.componentInstance.user = this._selectedCustomers[0];
142145
modal.result
143-
.then((id) => this._usersService.unbanUser(id))
144-
.catch(console.error);
146+
.then(async (user) => {
147+
this.showBanLoading = true;
148+
await this._usersService.unbanUser(user.id);
149+
this._loadDataSmartTable();
150+
this.showBanLoading = false;
151+
this._notifyService.success(`${user.name} is unbanned!`);
152+
})
153+
.catch((_) => {});
145154
}
146155

147156
private showBanPopup() {
@@ -153,8 +162,14 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
153162
});
154163
modal.componentInstance.user = this._selectedCustomers[0];
155164
modal.result
156-
.then((id) => this._usersService.banUser(id))
157-
.catch(console.error);
165+
.then(async (user) => {
166+
this.showBanLoading = true;
167+
await this._usersService.banUser(user.id);
168+
this._loadDataSmartTable();
169+
this.showBanLoading = false;
170+
this._notifyService.success(`${user.name} is banned!`);
171+
})
172+
.catch((_) => {});
158173
}
159174

160175
private _loadSettingsSmartTable() {
@@ -252,7 +267,7 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
252267
users.map((u) => u.id)
253268
);
254269

255-
const usersVM = users.map((user) => {
270+
let usersVM = users.map((user) => {
256271
const userOrders = usersOrders.find(
257272
(res) => res['id'] === user.id
258273
);
@@ -285,6 +300,10 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
285300

286301
await this.loadDataCount();
287302

303+
if (this.showOnlyBanned) {
304+
usersVM = usersVM.filter((user) => user.isBanned);
305+
}
306+
288307
const usersData = new Array(this.dataCount);
289308

290309
usersData.splice(perPage * (page - 1), perPage, ...usersVM);
@@ -346,6 +365,15 @@ export class CustomersComponent implements AfterViewInit, OnDestroy {
346365
);
347366
}
348367

368+
public set showOnlyBanned(v: boolean) {
369+
this._showOnlyBanned = v;
370+
this._loadDataSmartTable();
371+
}
372+
373+
public get showOnlyBanned(): boolean {
374+
return this._showOnlyBanned;
375+
}
376+
349377
ngOnDestroy() {
350378
this.ngDestroy$.next();
351379
this.ngDestroy$.complete();

admin/website-angular/yarn.lock

+10-5
Original file line numberDiff line numberDiff line change
@@ -4439,7 +4439,7 @@ [email protected]:
44394439
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.0.1.tgz#37358fb0d024e6b86d443d794f4e37e949098cbe"
44404440
integrity sha512-mSxeQ6IghKW3MoyF4cz19GJ1cMm7761ON+WObSyLfTu/Jn3x7w4NwNFnrZxgl4MTSvYYepVLNuRtlB4loMwJ5g==
44414441

4442-
[email protected], core-js@^3.0.1:
4442+
44434443
version "3.0.1"
44444444
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.0.1.tgz#1343182634298f7f38622f95e73f54e48ddf4738"
44454445
integrity sha512-sco40rF+2KlE0ROMvydjkrVMMG1vYilP2ALoRXcYR4obqbYIuV3Bg+51GEDW+HF8n7NRA+iaA4qD0nD9lo9mew==
@@ -4454,6 +4454,11 @@ core-js@^2.2.0, core-js@^2.4.0, core-js@^2.5.7, core-js@^2.6.5:
44544454
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.5.tgz#44bc8d249e7fb2ff5d00e0341a7ffb94fbf67895"
44554455
integrity sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A==
44564456

4457+
core-js@^3.1.3:
4458+
version "3.1.3"
4459+
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.1.3.tgz#95700bca5f248f5f78c0ec63e784eca663ec4138"
4460+
integrity sha512-PWZ+ZfuaKf178BIAg+CRsljwjIMRV8MY00CbZczkR6Zk5LfkSkjGoaab3+bqRQWVITNZxQB7TFYz+CFcyuamvA==
4461+
44574462
[email protected], core-util-is@~1.0.0:
44584463
version "1.0.2"
44594464
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -13478,10 +13483,10 @@ typeface-exo@^0.0.61:
1347813483
resolved "https://registry.yarnpkg.com/typeface-exo/-/typeface-exo-0.0.61.tgz#10c6113292da354cb9f26ee9d0b0c996f1a7a3bd"
1347913484
integrity sha512-AH3bMVYnVpg2G+CJbgtogTuJpWGS0zspHJzzVR8cCgTtkbUI0pj8WBB+RFo14CHbF5MmZgYe7TVoWz+j4Yo6Jg==
1348013485

13481-
typescript-tslint-plugin@^0.3.1:
13482-
version "0.3.1"
13483-
resolved "https://registry.yarnpkg.com/typescript-tslint-plugin/-/typescript-tslint-plugin-0.3.1.tgz#d86ae0342c9e8f9ecfcbcc47f7a7c2b5ab0e86f9"
13484-
integrity sha512-h8HEPBm36UEs901ld1x6m5eY/UFb4mF+A0nvERr4BWMww5wnV5nfcm9ZFt18foYL0GQ5NVMt1Tb3466WUU8dRQ==
13486+
typescript-tslint-plugin@^0.4.0:
13487+
version "0.4.0"
13488+
resolved "https://registry.yarnpkg.com/typescript-tslint-plugin/-/typescript-tslint-plugin-0.4.0.tgz#af1729e72b770489b2b912809694f46c3281bb72"
13489+
integrity sha512-83zipyk5bCqu/LHifaWPmJ7Xnl6lLn/3KmWINgr+XND79BrVWmkV8CudKc+a9Jhjs2opvVKq0n0P4O4NhHOixw==
1348513490
dependencies:
1348613491
minimatch "^3.0.4"
1348713492
mock-require "^3.0.2"

backend/api/package.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@nestjs/typeorm": "^6.1.1",
6262
"@nestjs/websockets": "^6.1.1",
6363
"apollo-server-express": "^2.4.8",
64-
"axios": "^0.18.0",
64+
"axios": "^0.19.0",
6565
"bcrypt": "^3.0.4",
6666
"bluebird": "^3.5.4",
6767
"body-parser": "^1.19.0",
@@ -84,6 +84,7 @@
8484
"express": "^4.16.4",
8585
"express-handlebars": "^3.0.2",
8686
"faker": "^4.1.0",
87+
"fstream": "^1.0.12",
8788
"graphql": "^14.2.1",
8889
"graphql-playground-middleware-express": "^1.7.12",
8990
"graphql-subscriptions": "^1.1.0",
@@ -138,14 +139,14 @@
138139
"underscore.string": "^3.3.5",
139140
"upath": "^1.1.2",
140141
"uuid": "^3.3.2",
141-
"validator": "^10.11.0",
142+
"validator": "^11.0.0",
142143
"ws": "^7.0.0"
143144
},
144145
"devDependencies": {
145-
"@commitlint/cli": "^7.5.2",
146-
"@commitlint/config-conventional": "^7.5.0",
147-
"@commitlint/config-lerna-scopes": "^7.5.1",
148-
"@commitlint/travis-cli": "^7.5.2",
146+
"@commitlint/cli": "^8.0.0",
147+
"@commitlint/config-conventional": "^8.0.0",
148+
"@commitlint/config-lerna-scopes": "^8.0.0",
149+
"@commitlint/travis-cli": "^8.0.0",
149150
"@nestjs/testing": "^6.1.1",
150151
"@types/bcrypt": "^3.0.0",
151152
"@types/bluebird": "^3.5.26",
@@ -157,7 +158,7 @@
157158
"@types/express": "^4.16.1",
158159
"@types/faker": "^4.1.5",
159160
"@types/form-data": "^2.2.1",
160-
"@types/google-maps": "^3.2.0",
161+
"@types/google-maps": "^3.2.1",
161162
"@types/handlebars": "^4.1.0",
162163
"@types/inversify": "^2.0.33",
163164
"@types/jest": "^24.0.11",
@@ -185,7 +186,7 @@
185186
"@types/ws": "^6.0.1",
186187
"concurrently": "^4.1.0",
187188
"conventional-changelog": "^3.1.4",
188-
"core-js": "^3.0.1",
189+
"core-js": "^3.1.3",
189190
"coveralls": "^3.0.3",
190191
"cross-env": "^5.2.0",
191192
"cz-conventional-changelog": "^2.1.0",

backend/api/src/services/users/UsersService.ts

+2
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ export class UsersService extends DBService<User>
454454
const firstName = faker.name.firstName();
455455
const lastName = faker.name.lastName();
456456
const email = faker.internet.email(firstName, lastName);
457+
const isBanned = Math.random() < 0.02;
457458

458459
const geoLocation: IGeoLocationCreateObject = {
459460
countryId: faker.random.number(Country.ZW) as Country,
@@ -475,6 +476,7 @@ export class UsersService extends DBService<User>
475476
geoLocation,
476477
apartment: `${customerCount}`,
477478
email,
479+
isBanned,
478480
image: faker.image.avatar(),
479481
phone: faker.phone.phoneNumber(),
480482
_createdAt: faker.date.between(

0 commit comments

Comments
 (0)