show quota in stats, display quota on the about page, fixes #405 (#421)

move videoQuota under a user object, use byte PipeTransform
This commit is contained in:
Rigel Kent 2018-03-27 13:42:57 +02:00 committed by Chocobozzz
parent fc27b17c6b
commit 1869c87535
5 changed files with 24 additions and 1 deletions

View File

@ -13,6 +13,14 @@
<div class="section-title">Terms</div> <div class="section-title">Terms</div>
<div [innerHTML]="termsHTML"></div> <div [innerHTML]="termsHTML"></div>
<div *ngIf="userVideoQuota !== -1;else noQuota">
This instance provides a baseline quota of {{ userVideoQuota | bytes: 0 }} space for the videos of its users.
</div>
<ng-template #noQuota>
This instance provides unlimited space for the videos of its users.
</ng-template>
</div> </div>
<div id="p2p-privacy"> <div id="p2p-privacy">

View File

@ -23,6 +23,10 @@ export class AboutComponent implements OnInit {
return this.serverService.getConfig().instance.name return this.serverService.getConfig().instance.name
} }
get userVideoQuota () {
return this.serverService.getConfig().user.videoQuota
}
ngOnInit () { ngOnInit () {
this.serverService.getAbout() this.serverService.getAbout()
.subscribe( .subscribe(
@ -31,7 +35,7 @@ export class AboutComponent implements OnInit {
this.termsHTML = this.markdownService.textMarkdownToHTML(res.instance.terms) this.termsHTML = this.markdownService.textMarkdownToHTML(res.instance.terms)
}, },
err => this.notificationsService.error('Error', err) err => this.notificationsService.error('Error getting about from server', err)
) )
} }

View File

@ -5,6 +5,7 @@ import 'rxjs/add/operator/do'
import { ReplaySubject } from 'rxjs/ReplaySubject' import { ReplaySubject } from 'rxjs/ReplaySubject'
import { ServerConfig } from '../../../../../shared' import { ServerConfig } from '../../../../../shared'
import { About } from '../../../../../shared/models/server/about.model' import { About } from '../../../../../shared/models/server/about.model'
import { ServerStats } from '../../../../../shared/models/server/server-stats.model'
import { environment } from '../../../environments/environment' import { environment } from '../../../environments/environment'
@Injectable() @Injectable()
@ -51,6 +52,9 @@ export class ServerService {
file: { file: {
extensions: [] extensions: []
} }
},
user: {
videoQuota: -1
} }
} }
private videoCategories: Array<{ id: number, label: string }> = [] private videoCategories: Array<{ id: number, label: string }> = []

View File

@ -76,6 +76,9 @@ async function getConfig (req: express.Request, res: express.Response, next: exp
file: { file: {
extensions: CONSTRAINTS_FIELDS.VIDEOS.EXTNAME extensions: CONSTRAINTS_FIELDS.VIDEOS.EXTNAME
} }
},
user: {
videoQuota: CONFIG.USER.VIDEO_QUOTA
} }
} }

View File

@ -39,4 +39,8 @@ export interface ServerConfig {
extensions: string[] extensions: string[]
} }
} }
user: {
videoQuota: number
}
} }