Skip to content

Commit

Permalink
Merge pull request #690 from adshares/develop
Browse files Browse the repository at this point in the history
v1.2.1
  • Loading branch information
m-pilarczyk authored Sep 20, 2019
2 parents df38ae1 + 015d33b commit 94ae269
Show file tree
Hide file tree
Showing 44 changed files with 889 additions and 397 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.1] - 2019-09-20
### Added
- Billing history filtering
- Nwsletter subscribe option
### Changed
- Internal classifier rejects banners only

## [0.11.0] - 2019-06-12
### Fixed
- Minor display issues
Expand Down Expand Up @@ -115,7 +122,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Advertiser features (Campaigns & Ads)
- Publisher features (Sites & AdUnits)

[Unreleased]: https://github.com/adshares/adpanel/compare/v0.11.0...develop
[Unreleased]: https://github.com/adshares/adpanel/compare/v1.2.1...develop
[1.2.1]: https://github.com/adshares/adpanel/compare/v0.11.0...v1.2.1
[0.11.0]: https://github.com/adshares/adpanel/compare/v0.10.0...v0.11.0
[0.10.0]: https://github.com/adshares/adpanel/compare/v0.9.0...v0.10.0
[0.9.0]: https://github.com/adshares/adpanel/compare/v0.8.0...v0.9.0
Expand Down
20 changes: 13 additions & 7 deletions src/app/admin/admin-guard.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/take';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs';

import { SessionService } from "app/session.service";
import { SessionService } from 'app/session.service';

@Injectable()
export class AdminGuard implements CanActivate {
Expand All @@ -15,8 +14,15 @@ export class AdminGuard implements CanActivate {
}

canActivate(
route: ActivatedRouteSnapshot
): boolean {
return this.session.isAdmin();
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<boolean> | Promise<boolean> | boolean {
if (this.session.isAdmin()) {
return true;
}

this.router.navigate(['/auth', 'login'], {queryParams: {redirectUrl: state.url}});

return false;
}
}
5 changes: 0 additions & 5 deletions src/app/admin/user-reports/user-reports.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export class UserReportsComponent extends HandleSubscription implements OnInit {
this.to.setValue(moment().endOf('day').format());
}

load(timespan) {
}



getReportAdvertisers() {
const from = moment(this.from.value).format();
const to = moment(this.to.value).format();
Expand Down
20 changes: 13 additions & 7 deletions src/app/advertiser/advertiser-guard.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/take';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs';

import { SessionService } from "app/session.service";
import { SessionService } from 'app/session.service';

@Injectable()
export class AdvertiserGuard implements CanActivate {
Expand All @@ -15,8 +14,15 @@ export class AdvertiserGuard implements CanActivate {
}

canActivate(
route: ActivatedRouteSnapshot
): boolean {
return this.session.isAdvertiser();
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<boolean> | Promise<boolean> | boolean {
if (this.session.isAdvertiser()) {
return true;
}

this.router.navigate(['/auth', 'login'], {queryParams: {redirectUrl: state.url}});

return false;
}
}
84 changes: 43 additions & 41 deletions src/app/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { MatDialog } from '@angular/material/dialog';
import 'rxjs/add/operator/map';

import { ApiService } from 'app/api/api.service';
import { SessionService } from "app/session.service";
import { SessionService } from 'app/session.service';

import { LocalStorageUser, User } from 'models/user.model';
import { AccountChooseDialogComponent } from 'common/dialog/account-choose-dialog/account-choose-dialog.component';
import { HandleSubscription } from 'common/handle-subscription';

import { appSettings } from 'app-settings';
import { isUnixTimePastNow } from 'common/utilities/helpers';
import { Store } from "@ngrx/store";
import { AppState } from "models/app-state.model";
import { Store } from '@ngrx/store';
import { AppState } from 'models/app-state.model';
import * as authActions from 'store/auth/auth.actions';

@Component({
Expand Down Expand Up @@ -102,26 +102,56 @@ export class LoginComponent extends HandleSubscription implements OnInit {
(user: User) => {
this.processLogin(user);
if (user.isAdmin) {
this.session.setAccountTypeChoice('admin');
this.router.navigate(['/admin/dashboard']);
this.session.setAccountTypeChoice(SessionService.ACCOUNT_TYPE_ADMIN);
this.navigateByUrl(this.route.snapshot.queryParams['redirectUrl'] || '/admin/dashboard');
return;
} else {
const accountType = this.session.getAccountTypeChoice();
if (user.isPublisher && accountType === 'publisher') {
this.router.navigate(['/publisher/dashboard']);
} else if (user.isAdvertiser && accountType === 'advertiser') {
this.router.navigate(['/advertiser/dashboard']);
} else {
this.showStartupPopups(user);
}

const redirectUrl = this.route.snapshot.queryParams['redirectUrl'];
if (redirectUrl) {
if (redirectUrl.includes(SessionService.ACCOUNT_TYPE_ADVERTISER) && user.isAdvertiser) {
this.session.setAccountTypeChoice(SessionService.ACCOUNT_TYPE_ADVERTISER);
this.navigateByUrl(redirectUrl);
return;
}

if (redirectUrl.includes(SessionService.ACCOUNT_TYPE_PUBLISHER) && user.isPublisher) {
this.session.setAccountTypeChoice(SessionService.ACCOUNT_TYPE_PUBLISHER);
this.navigateByUrl(redirectUrl);
return;
}
}

let accountType = this.session.getAccountTypeChoice();
if (!accountType || SessionService.ACCOUNT_TYPE_ADMIN === accountType) {
if (user.isAdvertiser && user.isPublisher) {
this.dialog.open(AccountChooseDialogComponent, {disableClose: true});
return;
}
if (user.isAdvertiser) {
accountType = SessionService.ACCOUNT_TYPE_ADVERTISER;
}
if (user.isPublisher) {
accountType = SessionService.ACCOUNT_TYPE_PUBLISHER;
}
}

if (SessionService.ACCOUNT_TYPE_ADVERTISER === accountType && user.isAdvertiser
|| SessionService.ACCOUNT_TYPE_PUBLISHER === accountType && user.isPublisher) {
this.session.setAccountTypeChoice(accountType);
this.navigateByUrl(`/${accountType}/dashboard`);
}
},
(err) => {
this.criteriaError = true;
this.isLoggingIn = false;
});
}

private navigateByUrl(url: string) {
this.router.navigateByUrl(url).catch(e => window.location.reload());
}

processLogin(user: User) {
const rememberUser = false;//this.rememberUser.nativeElement.checked;
const expirationSeconds = rememberUser ?
Expand All @@ -136,32 +166,4 @@ export class LoginComponent extends HandleSubscription implements OnInit {

this.session.setUser(dataToSave);
}

showStartupPopups(user: User) {
if (user.isAdvertiser && user.isPublisher) {
const chooseAccount = this.session.getAccountTypeChoice();
if (!chooseAccount) {
this.dialog.open(AccountChooseDialogComponent, {disableClose: true});
return;
}
if (chooseAccount == "advertiser") {
this.router.navigate(['/advertiser/dashboard']);
return;
}
if (chooseAccount == "publisher") {
this.router.navigate(['/publisher/dashboard']);
return;
}
}
if (user.isAdvertiser) {
this.session.setAccountTypeChoice('advertiser');
this.router.navigate(['/advertiser/dashboard']);
return;
}
if (user.isPublisher) {
this.session.setAccountTypeChoice('publisher');
this.router.navigate(['/publisher/dashboard']);
return;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
>
<img
src="assets/images/calendar.svg"
alt="Add new icon"
alt="Select date from"
class="
dwmth-icon
dwmth-icon--prepend"
Expand Down Expand Up @@ -121,7 +121,7 @@
>
<img
src="assets/images/calendar.svg"
alt="Add new icon"
alt="Select date to"
class="
dwmth-icon
dwmth-icon--prepend"
Expand Down
17 changes: 9 additions & 8 deletions src/app/common/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { HandleSubscription } from 'common/handle-subscription';
import { AddFundsDialogComponent } from 'common/dialog/add-funds-dialog/add-funds-dialog.component';
import { userRolesEnum } from 'models/enum/user.enum';
import { AuthService } from 'app/auth.service';
import { SessionService } from "app/session.service";
import { Store } from "@ngrx/store";
import { AppState } from "models/app-state.model";
import { SessionService } from 'app/session.service';
import { Store } from '@ngrx/store';
import { AppState } from 'models/app-state.model';
import { environment } from 'environments/environment';
import { SetUser } from "store/auth/auth.actions";
import { UserAdserverWallet } from "models/user.model";
import { CODE, CRYPTO } from "common/utilities/consts";
import { SetUser } from 'store/auth/auth.actions';
import { CODE, CRYPTO } from 'common/utilities/consts';

@Component({
selector: 'app-header',
Expand Down Expand Up @@ -41,8 +40,10 @@ export class HeaderComponent extends HandleSubscription implements OnInit {

ngOnInit() {
this.store.dispatch(new SetUser());
let accountType = this.session.getAccountTypeChoice();
this.activeUserType = accountType === 'admin' ? userRolesEnum.ADMIN : (accountType === 'publisher' ? userRolesEnum.PUBLISHER : userRolesEnum.ADVERTISER);
const accountType = this.session.getAccountTypeChoice();
this.activeUserType = accountType === SessionService.ACCOUNT_TYPE_ADMIN
? userRolesEnum.ADMIN
: (accountType === SessionService.ACCOUNT_TYPE_PUBLISHER ? userRolesEnum.PUBLISHER : userRolesEnum.ADVERTISER);
this.notificationsTotal = this.session.getNotificationsCount();
const userDataStateSubscription = this.store.select('state', 'user', 'data')
.subscribe((data) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { appSettings } from 'app-settings';
import { CalculateWithdrawalItem } from "models/settings.model";
import * as codes from 'common/utilities/codes';
import { ErrorResponseDialogComponent } from "common/dialog/error-response-dialog/error-response-dialog.component";
import { GetBillingHistory } from "store/settings/settings.actions";
import { WithdrawFundsSuccess } from 'store/settings/settings.actions';
import { environment } from "environments/environment";
import { CODE, CRYPTO } from "common/utilities/consts";

Expand Down Expand Up @@ -135,8 +135,8 @@ export class WithdrawFundsDialogComponent extends HandleSubscription implements
)
.subscribe(
() => {
this.store.dispatch(new GetBillingHistory({}));
this.dialogRef.close()
this.store.dispatch(new WithdrawFundsSuccess({}));
this.dialogRef.close();
},
(err: HttpErrorResponse) => {
this.withdrawFormSubmitted = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export class ImpersonationComponent extends HandleSubscription implements OnInit
dropImpersonation(): void {
this.router.navigate(['/admin', 'dashboard', 'users']);
this.impersonationService.dropImpersonationToken();
this.sessionService.setAccountTypeChoice('admin');
this.sessionService.setAccountTypeChoice(SessionService.ACCOUNT_TYPE_ADMIN);
}
}
7 changes: 4 additions & 3 deletions src/app/models/classifier.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ interface BannerClassification {
width: number,
height: number,
sourceHost: string;
landingUrl:string;
landingUrl: string;
budget?: number;
cpm?: number;
cpc?: number;
classifiedGlobal?: boolean;
classifiedSite?: boolean;
}

interface BannerClassificationResponse {
Expand All @@ -30,10 +29,12 @@ interface BannerClassificationStatus {
interface BannerClassificationFilters {
status?: BannerClassificationStatus;
sizes?: Array<string>;
bannerId?: string;
landingUrl?: string;
}

export {
BannerClassification,
BannerClassificationResponse,
BannerClassificationFilters };
BannerClassificationFilters,
};
2 changes: 1 addition & 1 deletion src/app/models/enum/billing-history.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export enum billingHistoryItemStatusEnum {
REJECTED,
BLOCKED,
PROCESSING,
AWAITING,
UNCONFIRMED,
CANCELED,
'SYS_ERROR' = 126,
'NET_ERROR' = 127,
Expand Down
2 changes: 1 addition & 1 deletion src/app/models/initial-state/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const siteInitialState: Site = {
name: '',
primaryLanguage: '',
requireClassified: false,
excludeUnclassified: false,
excludeUnclassified: true,
filtering: {
requires: {},
excludes: {}
Expand Down
9 changes: 9 additions & 0 deletions src/app/models/settings.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Moment } from 'moment';

interface BillingHistoryItem {
amount: number,
status: number;
Expand All @@ -16,6 +18,12 @@ interface BillingHistory {
items: BillingHistoryItem[];
}

interface BillingHistoryFilter {
from: Moment;
to: Moment;
types: number[];
}

interface NotificationItem {
name: string;
notification: string;
Expand Down Expand Up @@ -97,6 +105,7 @@ interface CalculateWithdrawalItem {
export {
BillingHistoryItem,
BillingHistory,
BillingHistoryFilter,
NotificationItem,
Users,
UserInfoStats,
Expand Down
Loading

0 comments on commit 94ae269

Please sign in to comment.