Skip to content

Commit

Permalink
Merge pull request #72 from SayakMukhopadhyay/wip
Browse files Browse the repository at this point in the history
Added Donation and Credits Page
  • Loading branch information
SayakMukhopadhyay authored Dec 17, 2017
2 parents d800058 + 4c2c9ec commit 4736a12
Show file tree
Hide file tree
Showing 16 changed files with 310 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elitebgs",
"version": "1.2.7",
"version": "1.3.0",
"license": "Apache-2.0",
"scripts": {
"ng": "ng",
Expand Down
9 changes: 9 additions & 0 deletions server/models/ebgs_users.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ module.exports = new Promise((resolve, reject) => {
avatar: String,
discriminator: String,
access: Number,
os_contribution: Number,
patronage: {
level: Number,
since: Date
},
donation: [{
amount: Number,
date: Date
}],
invite: String,
invite_used: Boolean,
guilds: [{
Expand Down
75 changes: 75 additions & 0 deletions server/routes/front_end.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,81 @@ router.get('/backgroundimages', (req, res, next) => {
res.send(fs.readdirSync(pathToFile));
});

router.get('/donors', (req, res, next) => {
require('../models/ebgs_users')
.then(users => {
users.aggregate().unwind('donation').project({
amount: "$donation.amount",
date: "$donation.date",
username: 1
}).sort({
date: -1
}).then(donations => {
res.send(donations);
}).catch(err => {
console.log(err);
res.send();
});
})
.catch(err => {
console.log(err)
res.send();
});
});

router.get('/patrons', (req, res, next) => {
require('../models/ebgs_users')
.then(users => {
users.aggregate().match({
"patronage.level": { $gt: 0 }
}).project({
level: "$patronage.level",
since: "$patronage.since",
username: 1
}).sort({
since: -1
}).then(patrons => {
res.send(patrons);
}).catch(err => {
console.log(err);
res.send();
});
})
.catch(err => {
console.log(err)
res.send();
});
});

router.get('/credits', (req, res, next) => {
require('../models/ebgs_users')
.then(users => {
users.aggregate().match({
$or: [
{ os_contribution: { $gt: 0 } },
{ "patronage.level": { $gt: 1 } }
]
}).project({
username: 1,
avatar: 1,
id: 1,
os_contribution: 1,
level: "$patronage.level"
}).sort({
since: -1
}).then(credits => {
res.send(credits);
}).catch(err => {
console.log(err);
res.send();
});
})
.catch(err => {
console.log(err)
res.send();
});
});

router.post('/edit', (req, res, next) => {
userAllowed(req)
.then(allowed => {
Expand Down
10 changes: 10 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { TandCComponent } from './about/tandc.component';
import { DisclaimerComponent } from './about/disclaimer.component';
import { PrivacyPolicyComponent } from './about/privacy-policy.component';
import { GuideComponent } from './guide/guide.component';
import { DonateComponent } from './donate/donate.component';
import { CreditsComponent } from './credits/credits.component';
import { PageNotFoundComponent } from './page_not_found/page-not-found.component';

const appRoutes: Routes = [
Expand Down Expand Up @@ -34,6 +36,14 @@ const appRoutes: Routes = [
path: 'guide',
component: GuideComponent
},
{
path: 'donate',
component: DonateComponent
},
{
path: 'credits',
component: CreditsComponent
},
{
path: '**',
component: PageNotFoundComponent
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<a routerLink="/bgsbot" routerLinkActive="active" class="nav-link"><span class="nav-text">BGSBot</span></a>
</div>
<div class="header-actions">
<a routerLink="/donate" routerLinkActive="active" class="nav-link"><span class="nav-text">Support Us</span></a>
<clr-dropdown>
<button class="nav-icon" clrDropdownTrigger>
<clr-icon shape="cog" *ngIf="!isAuthenticated && isAuthenticated !== undefined"></clr-icon>
Expand All @@ -22,6 +23,7 @@
<a routerLink="/profile" clrDropdownItem *ngIf="isAuthenticated && isAuthenticated !== undefined">Profile</a>
<a href="/auth/logout" clrDropdownItem *ngIf="isAuthenticated && isAuthenticated !== undefined">Log out</a>
<a routerLink="/guide" clrDropdownItem>Guide</a>
<a routerLink="/credits" clrDropdownItem>Credits</a>
<a routerLink="/about" clrDropdownItem>About</a>
</clr-dropdown-menu>
</clr-dropdown>
Expand Down
4 changes: 4 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { TandCComponent } from './about/tandc.component';
import { DisclaimerComponent } from './about/disclaimer.component';
import { PrivacyPolicyComponent } from './about/privacy-policy.component';
import { GuideComponent } from './guide/guide.component';
import { DonateComponent } from './donate/donate.component';
import { CreditsComponent } from './credits/credits.component';
import { PageNotFoundComponent } from './page_not_found/page-not-found.component';

import { SystemsService } from './services/systems.service';
Expand All @@ -34,6 +36,8 @@ import { ServerService } from './services/server.service';
DisclaimerComponent,
PrivacyPolicyComponent,
GuideComponent,
DonateComponent,
CreditsComponent,
PageNotFoundComponent
],
imports: [
Expand Down
33 changes: 33 additions & 0 deletions src/app/credits/credits.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="content-area">
<h1>Credits</h1>
<h3>Main Developer</h3>
<div class="row">
<div class="col-xs-12 col-sm-3">
<img src="https://cdn.discordapp.com/avatars/169507532316999680/da6940223a3bd1181ea3a3db50773f27.png">
</div>
<div class="col-xs-12 col-sm-9">
<h2>Garud</h2>
</div>
</div>
<h3>Open Source Contributers</h3>
<div class="row" *ngFor="let contributer of contributers">
<div class="col-xs-12 col-sm-3">
<img [src]="'https://cdn.discordapp.com/avatars/'+ contributer?.id + '/' + contributer?.avatar + '.png'">
</div>
<div class="col-xs-9 col-sm-6">
<h2>{{contributer.username}}</h2>
</div>
<div class="col-xs-3 col-sm-3">
<h2>{{contributer.os_contribution}} Commits</h2>
</div>
</div>
<h3>Benefactors</h3>
<div class="row" *ngFor="let patron of patrons">
<div class="col-xs-12 col-sm-3">
<img [src]="'https://cdn.discordapp.com/avatars/'+ patron?.id + '/' + patron?.avatar + '.png'">
</div>
<div class="col-xs-12 col-sm-9">
<h2>{{patron.username}}</h2>
</div>
</div>
</div>
Empty file.
30 changes: 30 additions & 0 deletions src/app/credits/credits.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Component, HostBinding, OnInit } from '@angular/core';
import { ServerService } from '../services/server.service';
import { EBGSCredits } from '../typings';

@Component({
templateUrl: './credits.component.html',
styleUrls: ['./credits.component.scss']
})
export class CreditsComponent implements OnInit {
@HostBinding('class.content-container') contentContainer = true;
contributers: EBGSCredits[];
patrons: EBGSCredits[];
constructor(private serverService: ServerService) {
this.contributers = [];
this.patrons = [];
}

ngOnInit(): void {
this.serverService.getCredits().subscribe(credits => {
credits.forEach(credit => {
if (credit.os_contribution > 0) {
this.contributers.push(credit);
}
if (credit.level > 1) {
this.patrons.push(credit);
}
})
});
}
}
54 changes: 54 additions & 0 deletions src/app/donate/donate.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<div class="content-area">
<h1>Support Elite BGS</h1>
<p>
Hi,
<br> Thank you for showing interest in Elite BGS. Looking forward to suggestions and feedback. But as you might know,
running this website is a costly process. If you like my work, please consider making a donation through the following
channels.
</p>
<div class="row">
<div class="col-xs-6">
<a href="https://www.patreon.com/bePatron?u=6593507" class="patreon-button"></a>
</div>
<div class="col-xs-6">
<a href="https://www.paypal.me/SayakMukhopadhyay" class="paypal-button"></a>
</div>
</div>
<p>
Please make sure to leave message with your registered email id so that I can find my benefactors easily.
</p>
<h3>Patrons</h3>
<table class="table">
<thead>
<tr>
<th>User</th>
<th>Patron Since</th>
<th>Patronage Tier</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let patron of patrons">
<td>{{patron.username}}</td>
<td>{{patron.since}}</td>
<td>{{patron.level}}</td>
</tr>
</tbody>
</table>
<h3>Donors</h3>
<table class="table">
<thead>
<tr>
<th>User</th>
<th>Donated On</th>
<th>Donation</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let donor of donors">
<td>{{donor.username}}</td>
<td>{{donor.date}}</td>
<td>$ {{donor.amount}}</td>
</tr>
</tbody>
</table>
</div>
15 changes: 15 additions & 0 deletions src/app/donate/donate.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
a.patreon-button {
background-image: url(/assets/patreon-button.png);
display: block;
width: 217px;
height: 51px;
margin: auto;
}

a.paypal-button {
background-image: url(https://www.paypalobjects.com/webstatic/en_US/i/buttons/PP_logo_h_200x51.png);
display: block;
width: 200px;
height: 51px;
margin: auto;
}
26 changes: 26 additions & 0 deletions src/app/donate/donate.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Component, HostBinding, OnInit } from '@angular/core';
import { ServerService } from '../services/server.service';
import { EBGSDonor, EBGSPatron } from '../typings';

@Component({
templateUrl: './donate.component.html',
styleUrls: ['./donate.component.scss']
})
export class DonateComponent implements OnInit {
@HostBinding('class.content-container') contentContainer = true;
donors: EBGSDonor[];
patrons: EBGSPatron[];
constructor(private serverService: ServerService) {
this.donors = [];
this.patrons = [];
}

ngOnInit(): void {
this.serverService.getDonors().subscribe(donors => {
this.donors = donors;
});
this.serverService.getPatrons().subscribe(patrons => {
this.patrons = patrons;
});
}
}
13 changes: 13 additions & 0 deletions src/app/services/server.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { EBGSDonor, EBGSPatron, EBGSCredits } from '../typings';


@Injectable()
Expand All @@ -15,4 +16,16 @@ export class ServerService {
postEdit(data): Observable<boolean> {
return this.http.post<boolean>('/frontend/edit', data);
}

getDonors(): Observable<EBGSDonor[]> {
return this.http.get<EBGSDonor[]>('/frontend/donors');
}

getPatrons(): Observable<EBGSPatron[]> {
return this.http.get<EBGSPatron[]>('/frontend/patrons');
}

getCredits(): Observable<EBGSCredits[]> {
return this.http.get<EBGSCredits[]>('/frontend/credits');
}
}
Loading

0 comments on commit 4736a12

Please sign in to comment.