From 651352e4a151529e336dfcf40a7821326f553f7f Mon Sep 17 00:00:00 2001 From: _Bastler <_Bastler@bstly.de> Date: Sat, 5 Jun 2021 19:49:20 +0200 Subject: [PATCH] url shortener, quotas, small improvements --- src/app/app-routing.module.ts | 3 + src/app/app.module.ts | 8 +- src/app/material/autofocus.ts | 15 ++ .../form-login-totp.component.html | 2 +- .../form-login/form-login.component.html | 2 +- src/app/pages/jitsi/jitsi.component.html | 131 ++++++----- src/app/pages/jitsi/jitsi.component.ts | 51 +++-- .../login-totp/login-totp.component.html | 2 +- src/app/pages/login/login.component.html | 2 +- .../pages/register/register.component.html | 2 +- src/app/pages/tokens/tokens.component.html | 2 +- .../urlshortener/urlshortener.component.html | 133 +++++++++++ .../urlshortener/urlshortener.component.scss | 29 +++ .../urlshortener/urlshortener.component.ts | 211 ++++++++++++++++++ .../urlshortener/urlshortener.password.html | 20 ++ .../urlshortener/urlshortener.password.scss | 3 + .../urlshortener/urlshortener.share.html | 37 +++ .../urlshortener/urlshortener.share.scss | 12 + src/app/pages/user/user.component.ts | 2 +- src/app/services/jitsi.service.ts | 7 +- src/app/services/urlshortener.service.ts | 27 +++ src/app/ui/quotas/quotas.component.html | 11 +- src/app/ui/quotas/quotas.component.ts | 2 +- 23 files changed, 616 insertions(+), 98 deletions(-) create mode 100644 src/app/material/autofocus.ts create mode 100644 src/app/pages/urlshortener/urlshortener.component.html create mode 100644 src/app/pages/urlshortener/urlshortener.component.scss create mode 100644 src/app/pages/urlshortener/urlshortener.component.ts create mode 100644 src/app/pages/urlshortener/urlshortener.password.html create mode 100644 src/app/pages/urlshortener/urlshortener.password.scss create mode 100644 src/app/pages/urlshortener/urlshortener.share.html create mode 100644 src/app/pages/urlshortener/urlshortener.share.scss create mode 100644 src/app/services/urlshortener.service.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index a269847..02ba82f 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -22,6 +22,7 @@ import {JitsiComponent} from './pages/jitsi/jitsi.component' import {AliasesComponent} from './pages/account/aliases/aliases.component'; import {DomainsComponent} from './pages/account/domains/domains.component'; import {InvitesComponent} from './pages/invites/invites.component'; +import {UrlShortenerComponent, UrlShortenerPasswordComponent} from './pages/urlshortener/urlshortener.component'; const routes: Routes = [ {path: '', redirectTo: "/services", pathMatch: 'full'}, @@ -49,6 +50,8 @@ const routes: Routes = [ {path: 'register', component: RegisterComponent, canActivate: [AnonymousGuard]}, {path: 'tokens', component: TokensComponent, canActivate: [AuthGuard]}, {path: 'jitsi', component: JitsiComponent, canActivate: [AuthenticatedGuard]}, + {path: 'urlshortener', component: UrlShortenerComponent, canActivate: [AuthenticatedGuard]}, + {path: 'urlshortener/:code', component: UrlShortenerPasswordComponent, canActivate: [AuthUpdateGuard]}, {path: 'invites/:quota', component: InvitesComponent, canActivate: [AuthenticatedGuard]}, {path: 'unavailable', component: UnavailableComponent}, {path: 'p/:username', component: UserComponent, canActivate: [AuthUpdateGuard]}, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index a2f1a0b..43da62b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -9,6 +9,9 @@ import {MaterialModule} from './material/material.module'; import {QRCodeModule} from 'angularx-qrcode'; import { DatePipe } from '@angular/common'; + +import { AutofocusDirective} from './material/autofocus'; + import {I18nPipe} from './utils/i18n.pipe'; import {ImprintComponent, PrivacyPolicyComponent, TermsOfServiceComponent} from './pages/general/general.component'; import {AccountComponent} from './pages/account/account.component'; @@ -41,6 +44,7 @@ import {HtmlComponent} from './utils/html/html.component'; import {ConfirmDialog} from './ui/confirm/confirm.component' import {UserComponent} from './pages/user/user.component' import {JitsiComponent, JitsiShareDialog} from './pages/jitsi/jitsi.component' +import {UrlShortenerComponent, UrlShortenerPasswordComponent, UrlShortenerShareDialog} from './pages/urlshortener/urlshortener.component' import {I18nService} from './services/i18n.service'; @@ -63,6 +67,7 @@ export class XhrInterceptor implements HttpInterceptor { @NgModule({ declarations: [ + AutofocusDirective, I18nPipe, AppComponent, ImprintComponent, PrivacyPolicyComponent, TermsOfServiceComponent, @@ -95,7 +100,8 @@ export class XhrInterceptor implements HttpInterceptor { HtmlComponent, ConfirmDialog, UserComponent, - JitsiComponent, JitsiShareDialog + JitsiComponent, JitsiShareDialog, + UrlShortenerComponent, UrlShortenerShareDialog, UrlShortenerPasswordComponent ], imports: [ BrowserModule, diff --git a/src/app/material/autofocus.ts b/src/app/material/autofocus.ts new file mode 100644 index 0000000..f1df535 --- /dev/null +++ b/src/app/material/autofocus.ts @@ -0,0 +1,15 @@ +import { Directive, OnInit } from '@angular/core'; +import { MatInput } from '@angular/material/input'; + +@Directive({ + selector: '[matInputAutofocus]', +}) +export class AutofocusDirective implements OnInit { + + constructor(private matInput: MatInput) { } + + ngOnInit() { + setTimeout(() => this.matInput.focus()); + } + +} \ No newline at end of file diff --git a/src/app/pages/form-login-totp/form-login-totp.component.html b/src/app/pages/form-login-totp/form-login-totp.component.html index fa2cab8..a09eed1 100644 --- a/src/app/pages/form-login-totp/form-login-totp.component.html +++ b/src/app/pages/form-login-totp/form-login-totp.component.html @@ -8,7 +8,7 @@ {{'security.2fa.totp.invalid' | i18n}} - + {{'security.2fa.totp.missing' | i18n}} diff --git a/src/app/pages/form-login/form-login.component.html b/src/app/pages/form-login/form-login.component.html index 1d10fd9..5d40839 100644 --- a/src/app/pages/form-login/form-login.component.html +++ b/src/app/pages/form-login/form-login.component.html @@ -8,7 +8,7 @@ {{'login.invalid' | i18n}} - + {{'username.missing' | i18n}} diff --git a/src/app/pages/jitsi/jitsi.component.html b/src/app/pages/jitsi/jitsi.component.html index 8c9b608..4838316 100644 --- a/src/app/pages/jitsi/jitsi.component.html +++ b/src/app/pages/jitsi/jitsi.component.html @@ -1,76 +1,83 @@

{{'jitsi.rooms' | i18n}}

- +
+
- - - - + + + + - - - + - + + {{ jitsiRoom.room }} + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - + - + + {{ jitsiRoom.moderationUrl }} + + + - - - - + + + + - - -
{{'jitsi.share' | i18n}} - - {{'jitsi.share' | i18n}} + + {{'jitsi.rooms.room' | i18n}} - - {{ jitsiRoom.room }} - open_in_new - - + + {{'jitsi.rooms.room' | i18n}} + + {{ jitsiRoom.room }} + open_in_new + + - - {{ jitsiRoom.room }} - - {{'jitsi.rooms.starts' | i18n}} {{ jitsiRoom.starts | date:datetimeformat}} {{'jitsi.rooms.starts' | i18n}} {{ jitsiRoom.starts | date:datetimeformat}} {{'jitsi.rooms.moderationStarts' | i18n}} {{ jitsiRoom.moderationStarts | date:datetimeformat}} {{'jitsi.rooms.moderationStarts' | + i18n}} {{ jitsiRoom.moderationStarts | date:datetimeformat}} {{'jitsi.rooms.expires' | i18n}} {{ jitsiRoom.expires | date:datetimeformat}} {{'jitsi.rooms.expires' | i18n}} {{ jitsiRoom.expires | date:datetimeformat}} {{'jitsi.rooms.moderationUrl' | i18n}} - - {{ jitsiRoom.moderationUrl }} - open_in_new - + + {{'jitsi.rooms.moderationUrl' | i18n}} + + + {{ jitsiRoom.moderationUrl }} + open_in_new + - - {{ jitsiRoom.moderationUrl }} - - {{'jitsi.rooms.delete' | i18n}} - - delete - - {{'jitsi.rooms.delete' | i18n}} + + delete + +
+ + + + + +
@@ -98,8 +105,8 @@ - + diff --git a/src/app/pages/jitsi/jitsi.component.ts b/src/app/pages/jitsi/jitsi.component.ts index bf890fc..fb0131d 100644 --- a/src/app/pages/jitsi/jitsi.component.ts +++ b/src/app/pages/jitsi/jitsi.component.ts @@ -4,11 +4,13 @@ import {Sort} from '@angular/material/sort'; import {FormBuilder, FormGroup, Validators, NgForm} from '@angular/forms'; import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; import {DatePipe} from '@angular/common'; +import {PageEvent} from '@angular/material/paginator'; import {QuotaService} from '../../services/quota.service'; import {JitsiService} from '../../services/jitsi.service'; import {ConfirmDialog} from '../../ui/confirm/confirm.component'; import {I18nService} from './../../services/i18n.service'; +import {ThrowStmt} from '@angular/compiler'; @Component({ selector: 'app-account-jitsi', @@ -20,11 +22,13 @@ export class JitsiComponent implements OnInit { form: FormGroup; @ViewChild('formDirective') private formDirective: NgForm; jitsiRoomsQuota: number = 0; - jitsiRooms: any[] = []; + jitsiRooms: any; jitsiRoom: any = {}; success: boolean; working: boolean; datetimeformat: String; + page: any = {page: 0, size: 10, sort: "id", desc: false}; + pageSizeOptions: number[] = [5, 10, 25, 50]; jitsiRoomsColumns = ["share", "room", "starts", "moderationStarts", "expires", "moderationUrl", "delete"]; @@ -85,11 +89,33 @@ export class JitsiComponent implements OnInit { } }) - this.jitsiService.get().subscribe((data: any) => { + this.jitsiService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe((data: any) => { this.jitsiRooms = data; }) } + updatePages(event: PageEvent) { + this.page.page = event.pageIndex; + this.page.size = event.pageSize; + this.jitsiService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe((data: any) => { + this.jitsiRooms = data; + }, (error) => {}) + } + + updateSort(sort: Sort) { + if(sort.direction == "") { + this.page.sort = "id"; + this.page.desc = false; + } else { + this.page.sort = sort.active; + this.page.desc = sort.direction == "desc"; + } + this.jitsiService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe((data: any) => { + this.jitsiRooms = data; + }, (error) => {}) + } + + confirmDelete(jitsiRoom) { const dialogRef = this.dialog.open(ConfirmDialog, { data: { @@ -107,28 +133,9 @@ export class JitsiComponent implements OnInit { }); } - sortData(sort: Sort) { - const data = this.jitsiRooms.slice(); - if(!sort.active || sort.direction === '') { - this.jitsiRooms = data; - return; - } - this.jitsiRooms = data.sort((a, b) => { - const isAsc = sort.direction === 'asc'; - switch(sort.active) { - case 'room': return this.compare(a.room, b.room, isAsc); - case 'starts': return this.compare(a.room, b.room, isAsc); - case 'moderationStarts': return this.compare(a.room, b.room, isAsc); - case 'expires': return this.compare(a.room, b.room, isAsc); - default: return 0; - } - }); - } - compare(a: number | string | String, b: number | string | String, isAsc: boolean) { - return (a < b ? -1 : 1) * (isAsc ? 1 : -1); - } + share(jitsiRoom) { const dialogRef = this.dialog.open(JitsiShareDialog, { diff --git a/src/app/pages/login-totp/login-totp.component.html b/src/app/pages/login-totp/login-totp.component.html index e46772b..597807e 100644 --- a/src/app/pages/login-totp/login-totp.component.html +++ b/src/app/pages/login-totp/login-totp.component.html @@ -7,7 +7,7 @@ + required matInputAutofocus> {{'security.2fa.totp.missing' | i18n}} diff --git a/src/app/pages/login/login.component.html b/src/app/pages/login/login.component.html index 849da7d..382c26d 100644 --- a/src/app/pages/login/login.component.html +++ b/src/app/pages/login/login.component.html @@ -7,7 +7,7 @@ + formControlName="username" required matInputAutofocus> {{'username.missing' | i18n}} diff --git a/src/app/pages/register/register.component.html b/src/app/pages/register/register.component.html index 077d15e..e4a1f9e 100644 --- a/src/app/pages/register/register.component.html +++ b/src/app/pages/register/register.component.html @@ -7,7 +7,7 @@ + [(ngModel)]="model.username" required matInputAutofocus> {{'username.error' | i18n}} diff --git a/src/app/pages/tokens/tokens.component.html b/src/app/pages/tokens/tokens.component.html index a0cb798..92e2bfa 100644 --- a/src/app/pages/tokens/tokens.component.html +++ b/src/app/pages/tokens/tokens.component.html @@ -9,7 +9,7 @@ {{'tokens.redeemed' | i18n}} - + {{'tokens.provide-valid' | i18n}} diff --git a/src/app/pages/urlshortener/urlshortener.component.html b/src/app/pages/urlshortener/urlshortener.component.html new file mode 100644 index 0000000..3067d62 --- /dev/null +++ b/src/app/pages/urlshortener/urlshortener.component.html @@ -0,0 +1,133 @@ +

{{'urlshortener' | i18n}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{'urlshortener.share' | i18n}} + + {{'urlshortener.link' | i18n}} + + vpn_key {{ shortenedUrl.link }} + open_in_new + + + {{'urlshortener.note' | i18n}} + {{shortenedUrl.note}} + {{'urlshortener.url' | i18n}} + + {{ shortenedUrl.url }} + open_in_new + + + {{'urlshortener.expires' | i18n}} {{ shortenedUrl.expires | date:datetimeformat}} {{'urlshortener.delete' | i18n}} + + delete + +
+ + +
+ + + + +

{{'urlshortener.info' | i18n}}

+

{{'urlshortener.noQuota' | i18n}}

+
+

{{'urlshortener.left' | i18n:shortenedUrlQuota}}

+ + + + + {{'urlshortener.error.url' | i18n}} + + + + + + + {{'urlshortener.advanced' | i18n}} + + + + + +
+ {{'password.error.' + error.key | i18n}}
+
+
+
+ + + + {{'password.not-match' | i18n}} + + + + + + + + + {{'urlshortener.error.expires' | i18n}} + + + + + + + {{'urlshortener.error.code' | i18n}} + + +
+
+
+ + + +
+ + \ No newline at end of file diff --git a/src/app/pages/urlshortener/urlshortener.component.scss b/src/app/pages/urlshortener/urlshortener.component.scss new file mode 100644 index 0000000..2640e9b --- /dev/null +++ b/src/app/pages/urlshortener/urlshortener.component.scss @@ -0,0 +1,29 @@ +mat-form-field { + display: block; +} + +.mat-header-cell, +.mat-cell { + &.text-right { + text-align: right; + } +} + +.mat-cell .mat-button { + padding-left: 0px; +} + +.align-right{ + display: flex; + padding: 21px 0; + justify-content: flex-end; +} + +.url { + display: block; + width: 200px; + max-width: 200px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} \ No newline at end of file diff --git a/src/app/pages/urlshortener/urlshortener.component.ts b/src/app/pages/urlshortener/urlshortener.component.ts new file mode 100644 index 0000000..b0b8793 --- /dev/null +++ b/src/app/pages/urlshortener/urlshortener.component.ts @@ -0,0 +1,211 @@ +import {Component, OnInit, ViewChild, Inject} from '@angular/core'; +import {MatSnackBar} from '@angular/material/snack-bar'; +import {Sort} from '@angular/material/sort'; +import {FormBuilder, FormGroup, Validators, NgForm} from '@angular/forms'; +import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; +import {PageEvent} from '@angular/material/paginator'; +import {ActivatedRoute} from '@angular/router'; + +import {MatchingValidator} from './../../utils/matching.validator'; +import {QuotaService} from '../../services/quota.service'; +import {UrlShortenerService} from '../../services/urlshortener.service'; +import {ConfirmDialog} from '../../ui/confirm/confirm.component'; +import {I18nService} from '../../services/i18n.service'; +import {environment} from '../../../environments/environment'; + +@Component({ + selector: 'app-urlshortener', + templateUrl: './urlshortener.component.html', + styleUrls: ['./urlshortener.component.scss'] +}) +export class UrlShortenerComponent implements OnInit { + + form: FormGroup; + @ViewChild('formDirective') private formDirective: NgForm; + shortenedUrlQuota: number = 0; + shortenedUrls: any; + shortenedUrl: any = {}; + success: boolean; + working: boolean; + datetimeformat: String; + page: any = {page: 0, size: 10, sort: "code", desc: false}; + pageSizeOptions: number[] = [5, 10, 25, 50]; + + shortenedUrlColumns = ["share", "link", "note", "url", "expires", "delete"]; + + constructor( + private quotaService: QuotaService, + private formBuilder: FormBuilder, + private urlShortenerService: UrlShortenerService, + private i18n: I18nService, + public dialog: MatDialog) {} + + ngOnInit(): void { + this.datetimeformat = this.i18n.get('format.datetime', []); + + this.form = this.formBuilder.group({ + url: ['', Validators.required], + code: ['', Validators.nullValidator], + password: ['', Validators.nullValidator], + password2: ['', Validators.nullValidator], + expires: ['', Validators.nullValidator], + }, { + validator: MatchingValidator('password', 'password2') + }); + + this.update(); + } + + create(): void { + this.working = true; + + this.urlShortenerService.create(this.shortenedUrl).subscribe(response => { + this.update(); + this.formDirective.resetForm(); + this.shortenedUrl = {}; + this.working = false; + }, (error) => { + this.working = false; + if(error.status == 409) { + let errors = {}; + for(let code of error.error) { + errors[code.field] = errors[code.field] || {}; + errors[code.field][code.code] = true; + } + + for(let code in errors) { + this.form.get(code).setErrors(errors[code]); + } + } + }) + } + + update() { + this.shortenedUrlQuota = 0; + this.quotaService.quotas().subscribe((data: any) => { + for(let quota of data) { + if(quota.name == "url_shortener") { + this.shortenedUrlQuota = quota.value; + } + } + }) + + this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe((data: any) => { + this.shortenedUrls = data; + }) + } + + updatePages(event: PageEvent) { + this.page.page = event.pageIndex; + this.page.size = event.pageSize; + this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe((data: any) => { + this.shortenedUrls = data; + }, (error) => {}) + } + + updateSort(sort: Sort) { + if(sort.direction == "") { + this.page.sort = "code"; + this.page.desc = false; + } else { + this.page.sort = sort.active; + this.page.desc = sort.direction == "desc"; + } + this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe((data: any) => { + this.shortenedUrls = data; + }, (error) => {}) + } + + confirmDelete(shortenedUrl) { + const dialogRef = this.dialog.open(ConfirmDialog, { + data: { + 'label': 'urlshortener.confirmDelete', + 'args': [shortenedUrl.url] + } + }) + + dialogRef.afterClosed().subscribe(result => { + if(result) { + this.urlShortenerService.delete(shortenedUrl.code).subscribe((result: any) => { + this.update(); + }) + } + }); + } + + share(shortenedUrl) { + const dialogRef = this.dialog.open(UrlShortenerShareDialog, { + data: shortenedUrl, + minWidth: '300px', + }); + } + + open(jitsiRoom: any, moderation: boolean) { + return (moderation && jitsiRoom.moderationStarts != null || !jitsiRoom.starts || Date.parse(jitsiRoom.starts) < new Date().getTime()) && (!moderation || jitsiRoom.moderationStarts == null || Date.parse(jitsiRoom.moderationStarts) < new Date().getTime()); + } +} + +@Component({ + selector: 'app-urlshortener-share-dialog', + templateUrl: 'urlshortener.share.html', + styleUrls: ['./urlshortener.share.scss'] +}) +export class UrlShortenerShareDialog { + + shortenedUrl: any; + datetimeformat: string; + + constructor( + private i18n: I18nService, + private snackBar: MatSnackBar, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any) { + this.shortenedUrl = data; + } + + ngOnInit(): void { + this.datetimeformat = this.i18n.get('format.datetime', []); + this.shortenedUrl.shareText = this.i18n.get('urlshortener.share.text', [this.shortenedUrl.link]); + } + + copyToClipboard(text) { + const selBox = document.createElement('textarea'); + selBox.value = text; + document.body.appendChild(selBox); + selBox.focus(); + selBox.select(); + document.execCommand('copy'); + document.body.removeChild(selBox); + this.snackBar.open(this.i18n.get("urlshortener.share.clipboard.copied", []), this.i18n.get("close", []), { + duration: 3000 + }); + } + +} + + +@Component({ + selector: 'app-urlshortener-password', + templateUrl: './urlshortener.password.html', + styleUrls: ['./urlshortener.password.scss'] +}) +export class UrlShortenerPasswordComponent implements OnInit { + + code : string; + apiUrl = environment.apiUrl; + invalidPassword: boolean = false; + + constructor( + private route: ActivatedRoute) {} + + async ngOnInit() { + this.code = this.route.snapshot.paramMap.get('code'); + + this.route.queryParams.subscribe(params => { + if(params['error'] || params['error'] == '') { + this.invalidPassword = true; + } + }); + } + +} \ No newline at end of file diff --git a/src/app/pages/urlshortener/urlshortener.password.html b/src/app/pages/urlshortener/urlshortener.password.html new file mode 100644 index 0000000..9f3455e --- /dev/null +++ b/src/app/pages/urlshortener/urlshortener.password.html @@ -0,0 +1,20 @@ +
+ + +

{{'urlshortener.password' | i18n}} +

+ + + + + {{'urlshortener.password.invalid' | i18n}} + +
+ + + +
+
\ No newline at end of file diff --git a/src/app/pages/urlshortener/urlshortener.password.scss b/src/app/pages/urlshortener/urlshortener.password.scss new file mode 100644 index 0000000..9ee20ad --- /dev/null +++ b/src/app/pages/urlshortener/urlshortener.password.scss @@ -0,0 +1,3 @@ +mat-form-field { + display: block; +} diff --git a/src/app/pages/urlshortener/urlshortener.share.html b/src/app/pages/urlshortener/urlshortener.share.html new file mode 100644 index 0000000..236d720 --- /dev/null +++ b/src/app/pages/urlshortener/urlshortener.share.html @@ -0,0 +1,37 @@ +

+ share {{'urlshortener.share' | i18n}} +

+ +
+ +
\ No newline at end of file diff --git a/src/app/pages/urlshortener/urlshortener.share.scss b/src/app/pages/urlshortener/urlshortener.share.scss new file mode 100644 index 0000000..82f9ec3 --- /dev/null +++ b/src/app/pages/urlshortener/urlshortener.share.scss @@ -0,0 +1,12 @@ +.mat-raised-button { + display: block; + width: 100%; +} + +mat-form-field { + display: block; +} + +textarea { + width: 100%; +} diff --git a/src/app/pages/user/user.component.ts b/src/app/pages/user/user.component.ts index 67db0c5..3c1cf6f 100644 --- a/src/app/pages/user/user.component.ts +++ b/src/app/pages/user/user.component.ts @@ -1,6 +1,6 @@ import {Component, OnInit} from '@angular/core'; -import {ActivatedRoute, Router, ParamMap} from '@angular/router'; +import {ActivatedRoute} from '@angular/router'; import {ProfileService} from '../../services/profile.service'; diff --git a/src/app/services/jitsi.service.ts b/src/app/services/jitsi.service.ts index cff0c74..31a09c4 100644 --- a/src/app/services/jitsi.service.ts +++ b/src/app/services/jitsi.service.ts @@ -1,5 +1,5 @@ import {Injectable} from '@angular/core'; -import {HttpClient} from '@angular/common/http'; +import {HttpClient, HttpParams} from '@angular/common/http'; import {environment} from '../../environments/environment'; @@ -11,8 +11,9 @@ export class JitsiService { constructor(private http: HttpClient) { } - get() { - return this.http.get(environment.apiUrl + "/jitsi/rooms"); + get(page: number, size: number, sort: string, desc: boolean) { + const httpParams = new HttpParams().set("page", "" + page).set("size", "" + size).set("sort", sort).set("desc", "" + desc); + return this.http.get(environment.apiUrl + "/jitsi/rooms", {params: httpParams}); } create(jitsiRoom) { diff --git a/src/app/services/urlshortener.service.ts b/src/app/services/urlshortener.service.ts new file mode 100644 index 0000000..0c5d71e --- /dev/null +++ b/src/app/services/urlshortener.service.ts @@ -0,0 +1,27 @@ +import {Injectable} from '@angular/core'; +import {HttpClient, HttpParams} from '@angular/common/http'; + +import {environment} from '../../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class UrlShortenerService { + + constructor(private http: HttpClient) { + } + + get(page: number, size: number, sort: string, desc: boolean) { + const httpParams = new HttpParams().set("page", "" + page).set("size", "" + size).set("sort", sort).set("desc", "" + desc); + return this.http.get(environment.apiUrl + "/url/shortener", {params: httpParams}); + } + + create(shortendUrlModel) { + return this.http.post(environment.apiUrl + "/url/shortener", shortendUrlModel); + } + + delete(code) { + return this.http.delete(environment.apiUrl + "/url/shortener/" + code); + } + +} \ No newline at end of file diff --git a/src/app/ui/quotas/quotas.component.html b/src/app/ui/quotas/quotas.component.html index 5d9a214..f7586f5 100644 --- a/src/app/ui/quotas/quotas.component.html +++ b/src/app/ui/quotas/quotas.component.html @@ -8,9 +8,16 @@ - + {{'quotas.value' | i18n}} - {{quota.value}} + {{quota.value}} + + + + {{'quotas.fixed_value' | i18n}} info + + {{quota.value}} diff --git a/src/app/ui/quotas/quotas.component.ts b/src/app/ui/quotas/quotas.component.ts index 60d75e5..dbed9f4 100644 --- a/src/app/ui/quotas/quotas.component.ts +++ b/src/app/ui/quotas/quotas.component.ts @@ -11,7 +11,7 @@ export class QuotasComponent implements OnInit { @Input() quotas; - quotaColumns = ["name", "quota", "quotaUnit"]; + quotaColumns = ["name", "value", "fixed_value", "quotaUnit"]; constructor(private i18n: I18nService) {}