Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #613

Merged
merged 16 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions admin/website-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@
"@angular/platform-browser-dynamic": "^8.0.0",
"@angular/router": "^8.0.0",
"@asymmetrik/ngx-leaflet": "^5.0.2",
"@ng-bootstrap/ng-bootstrap": "^4.2.1",
"@fortawesome/fontawesome-free": "^5.9.0",
"@nebular/auth": "^4.0.0",
"@nebular/bootstrap": "^4.0.0",
"@nebular/security": "^4.0.0",
"@nebular/theme": "^4.0.0",
"@ng-bootstrap/ng-bootstrap": "^4.1.1",
"@ng-select/ng-select": "^2.18.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
Expand Down Expand Up @@ -165,7 +165,7 @@
"@storybook/addon-notes": "^5.0.10",
"@storybook/addons": "^5.0.10",
"@storybook/angular": "^5.0.10",
"@types/async": "^2.4.1",
"@types/async": "^3.0.0",
"@types/d3-color": "^1.2.2",
"@types/faker": "^4.1.5",
"@types/googlemaps": "^3.30.19",
Expand All @@ -186,7 +186,7 @@
"cross-env": "^5.2.0",
"dotenv": "^8.0.0",
"envalid": "^5.0.0",
"husky": "^2.3.0",
"husky": "^2.4.0",
"jasmine-core": "^3.4.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^4.1.0",
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
24 changes: 12 additions & 12 deletions admin/website-angular/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1131,10 +1131,10 @@
dependencies:
intersection-observer "0.5.0"

"@ng-bootstrap/ng-bootstrap@^4.1.1":
version "4.1.1"
resolved "https://registry.yarnpkg.com/@ng-bootstrap/ng-bootstrap/-/ng-bootstrap-4.1.1.tgz#5e9c477ed9cc19114b56a0abc87e9c8483fb6bbf"
integrity sha512-OgbmPVhbDdNpIwogEXsycUJG0caNtb2+wCABfLUClgi9YcfNXhZ9Phu2GQq7Pk/LO66okth6s77RBQnbTJuysg==
"@ng-bootstrap/ng-bootstrap@^4.2.1":
version "4.2.1"
resolved "https://registry.yarnpkg.com/@ng-bootstrap/ng-bootstrap/-/ng-bootstrap-4.2.1.tgz#aa87f2ee6c4def0be087d4f456930b1e0761d91a"
integrity sha512-7etP9X9jKIkbuDzU3ngI2jQhHQDZxIu0ErvlkHb7u7YH9akIOLVkXvz2mTMvcFABWZhze64UjFuEgR46b6WGSw==
dependencies:
tslib "^1.9.0"

Expand Down Expand Up @@ -1567,10 +1567,10 @@
d3-shape "^1.2.0"
d3-time-format "^2.1.0"

"@types/async@^2.4.1":
version "2.4.1"
resolved "https://registry.yarnpkg.com/@types/async/-/async-2.4.1.tgz#43c3b2c60eab41c25ca0009c07ca7d619d943119"
integrity sha512-C09BK/wXzbW+/JK9zckhe+FeSbg7NmvVjUWwApnw7ksRpUq3ecGLiq2Aw1LlY4Z/VmtdhSaIs7jO5/MWRYMcOA==
"@types/async@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/async/-/async-3.0.0.tgz#d403560ee2aabccdb7936cb9a3fee5f147d626bd"
integrity sha512-DvEhEeG8ynipwkg7LtNHlO99+vEVbin+E+3YuzeJCM9TREewJ1B5fdZsQzykR7fKuh6rKh8mEir36zKd3uafOA==

"@types/bson@*":
version "4.0.0"
Expand Down Expand Up @@ -7066,10 +7066,10 @@ humanize-ms@^1.2.1:
dependencies:
ms "^2.0.0"

husky@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/husky/-/husky-2.3.0.tgz#8b78ed24d763042df7fd899991985d65a976dd13"
integrity sha512-A/ZQSEILoq+mQM3yC3RIBSaw1bYXdkKnyyKVSUiJl+iBjVZc5LQEXdGY1ZjrDxC4IzfRPiJ0IqzEQGCN5TQa/A==
husky@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/husky/-/husky-2.4.0.tgz#1bac7c44588f6e91f808b72efc82d24a57194f36"
integrity sha512-3k1wuZU20gFkphNWMjh2ISCFaqfbaLY7R9FST2Mj9HeRhUK9ydj9qQR8qfXlog3EctVGsyeilcZkIT7uBZDDVA==
dependencies:
cosmiconfig "^5.2.0"
execa "^1.0.0"
Expand Down
10 changes: 5 additions & 5 deletions backend/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"@nestjs/platform-socket.io": "^6.1.1",
"@nestjs/swagger": "^3.0.2",
"@nestjs/typeorm": "^6.1.1",
"@nestjs/websockets": "^6.1.1",
"apollo-server-express": "^2.4.8",
"@nestjs/websockets": "^6.3.1",
"apollo-server-express": "^2.6.1",
"axios": "^0.19.0",
"bcrypt": "^3.0.4",
"bluebird": "^3.5.4",
Expand Down Expand Up @@ -103,7 +103,7 @@
"moment": "^2.24.0",
"mongodb": "^3.2.3",
"mongodb-memory-server": "^5.1.0",
"mongoose": "^5.5.4",
"mongoose": "^5.5.13",
"morgan": "^1.9.1",
"ms": "^2.1.1",
"node-sass": "^4.11.0",
Expand Down Expand Up @@ -190,7 +190,7 @@
"coveralls": "^3.0.3",
"cross-env": "^5.2.0",
"cz-conventional-changelog": "^2.1.0",
"husky": "^2.3.0",
"husky": "^2.4.0",
"jest": "^24.7.1",
"nodemon": "^1.18.11",
"nyc": "^14.1.1",
Expand All @@ -199,7 +199,7 @@
"pretty-quick": "^1.10.0",
"require-directory": "^2.1.1",
"rxjs-tslint": "0.1.5",
"snyk": "^1.161.1",
"snyk": "^1.173.1",
"supertest": "^4.0.2",
"ts-jest": "^24.0.2",
"ts-loader": "^5.4.3",
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
Loading