jitsi shortened urls

This commit is contained in:
_Bastler 2021-06-09 09:16:47 +02:00
parent 86492f3590
commit e6742f1cc5
7 changed files with 40 additions and 19 deletions

View File

@ -21,10 +21,14 @@
</mat-icon> </mat-icon>
</a> </a>
<a *ngIf="!open(jitsiRoom, false)" mat-button disabled matTooltip="{{'jitsi.rooms.notStarted' | i18n}}" <a *ngIf="!open(jitsiRoom, false)" mat-button disabled matTooltip="{{'jitsi.rooms.notStarted' | i18n}}">
matTooltipPosition="above">
{{ jitsiRoom.room }} {{ jitsiRoom.room }}
</a> </a>
<a *ngIf="!jitsiRoom.code && shortenedUrlQuota" mat-icon-button (click)="createShortenedUrl(jitsiRoom)" inline
matTooltip="{{'urlshortener.create' | i18n}}">
<mat-icon>add_link</mat-icon>
</a>
</td> </td>
</ng-container> </ng-container>
@ -49,15 +53,14 @@
<th mat-header-cell *matHeaderCellDef mat-sort-header="moderationUrl"> {{'jitsi.rooms.moderationUrl' | i18n}} <th mat-header-cell *matHeaderCellDef mat-sort-header="moderationUrl"> {{'jitsi.rooms.moderationUrl' | i18n}}
</th> </th>
<td mat-cell *matCellDef="let jitsiRoom"> <td mat-cell *matCellDef="let jitsiRoom">
<a *ngIf="open(jitsiRoom, true)" mat-button color="primary" class="url" href="{{ jitsiRoom.moderationUrl}}" <a *ngIf="open(jitsiRoom, true)" mat-button color="primary" href="{{ jitsiRoom.moderationUrl}}" target="_blank">
target="_blank"> <span class="url">{{ jitsiRoom.moderationUrl }}</span>
{{ jitsiRoom.moderationUrl }}
<mat-icon style="font-size: 1em;">open_in_new</mat-icon> <mat-icon style="font-size: 1em;">open_in_new</mat-icon>
</a> </a>
<a *ngIf="!open(jitsiRoom, true)" mat-button color="primary" class="url" disabled <a *ngIf="!open(jitsiRoom, true)" mat-button color="primary" disabled
matTooltip="{{'jitsi.rooms.notStarted' | i18n}}" matTooltipPosition="above"> matTooltip="{{'jitsi.rooms.notStarted' | i18n}}" matTooltipPosition="above">
{{ jitsiRoom.moderationUrl }} <span class="url">{{ jitsiRoom.moderationUrl }}</span>
</a> </a>
</td> </td>
</ng-container> </ng-container>
@ -74,8 +77,8 @@
<tr mat-header-row *matHeaderRowDef="jitsiRoomsColumns"></tr> <tr mat-header-row *matHeaderRowDef="jitsiRoomsColumns"></tr>
<tr mat-row *matRowDef="let myRowData; columns: jitsiRoomsColumns"></tr> <tr mat-row *matRowDef="let myRowData; columns: jitsiRoomsColumns"></tr>
</table> </table>
<mat-paginator [pageSizeOptions]="pageSizeOptions" [length]="jitsiRooms.totalElements" <mat-paginator [pageSizeOptions]="pageSizeOptions" [length]="jitsiRooms.totalElements" [pageSize]="jitsiRooms.size"
[pageSize]="jitsiRooms.size" (page)="updatePages($event)" showFirstLastButtons></mat-paginator> (page)="updatePages($event)" showFirstLastButtons></mat-paginator>
</div> </div>

View File

@ -11,6 +11,7 @@ mat-form-field {
.mat-cell .mat-button { .mat-cell .mat-button {
padding-left: 0px; padding-left: 0px;
padding-right: 0px;
} }
.align-right{ .align-right{
@ -20,7 +21,7 @@ mat-form-field {
} }
.url { .url {
display: block; display: inline-block;
width: 200px; width: 200px;
max-width: 200px; max-width: 200px;
white-space: nowrap; white-space: nowrap;

View File

@ -8,9 +8,9 @@ import {PageEvent} from '@angular/material/paginator';
import {QuotaService} from '../../services/quota.service'; import {QuotaService} from '../../services/quota.service';
import {JitsiService} from '../../services/jitsi.service'; import {JitsiService} from '../../services/jitsi.service';
import {UrlShortenerService} from '../../services/urlshortener.service';
import {ConfirmDialog} from '../../ui/confirm/confirm.component'; import {ConfirmDialog} from '../../ui/confirm/confirm.component';
import {I18nService} from './../../services/i18n.service'; import {I18nService} from './../../services/i18n.service';
import {ThrowStmt} from '@angular/compiler';
@Component({ @Component({
selector: 'app-account-jitsi', selector: 'app-account-jitsi',
@ -26,6 +26,7 @@ export class JitsiComponent implements OnInit {
jitsiRoom: any = {}; jitsiRoom: any = {};
success: boolean; success: boolean;
working: boolean; working: boolean;
shortenedUrlQuota: number = 0;
datetimeformat: String; datetimeformat: String;
page: any = {page: 0, size: 10, sort: "id", desc: false}; page: any = {page: 0, size: 10, sort: "id", desc: false};
pageSizeOptions: number[] = [5, 10, 25, 50]; pageSizeOptions: number[] = [5, 10, 25, 50];
@ -36,6 +37,7 @@ export class JitsiComponent implements OnInit {
private quotaService: QuotaService, private quotaService: QuotaService,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private jitsiService: JitsiService, private jitsiService: JitsiService,
private snackBar: MatSnackBar,
private i18n: I18nService, private i18n: I18nService,
public dialog: MatDialog) {} public dialog: MatDialog) {}
@ -81,10 +83,13 @@ export class JitsiComponent implements OnInit {
update() { update() {
this.jitsiRoomsQuota = 0; this.jitsiRoomsQuota = 0;
this.shortenedUrlQuota = 0;
this.quotaService.quotas().subscribe((data: any) => { this.quotaService.quotas().subscribe((data: any) => {
for(let quota of data) { for(let quota of data) {
if(quota.name == "jitsi") { if(quota.name == "jitsi") {
this.jitsiRoomsQuota = quota.value; this.jitsiRoomsQuota = quota.value;
} else if(quota.name == "url_shortener") {
this.shortenedUrlQuota = quota.value;
} }
} }
}) })
@ -115,7 +120,6 @@ export class JitsiComponent implements OnInit {
}, (error) => {}) }, (error) => {})
} }
confirmDelete(jitsiRoom) { confirmDelete(jitsiRoom) {
const dialogRef = this.dialog.open(ConfirmDialog, { const dialogRef = this.dialog.open(ConfirmDialog, {
data: { data: {
@ -133,10 +137,6 @@ export class JitsiComponent implements OnInit {
}); });
} }
share(jitsiRoom) { share(jitsiRoom) {
const dialogRef = this.dialog.open(JitsiShareDialog, { const dialogRef = this.dialog.open(JitsiShareDialog, {
data: jitsiRoom, data: jitsiRoom,
@ -147,6 +147,14 @@ export class JitsiComponent implements OnInit {
open(jitsiRoom: any, moderation: boolean) { 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()); 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());
} }
createShortenedUrl(jitsiRoom: any) {
this.jitsiService.createShortUrl(jitsiRoom.id).subscribe((result: any) => {
this.update();
}, (error: any) => {
this.snackBar.open(this.i18n.get("urlshortener.noQuota", []), this.i18n.get("close", []));
});
}
} }
@Component({ @Component({

View File

@ -36,8 +36,8 @@
<ng-container matColumnDef="url"> <ng-container matColumnDef="url">
<th mat-header-cell *matHeaderCellDef mat-sort-header="url"> {{'urlshortener.url' | i18n}} </th> <th mat-header-cell *matHeaderCellDef mat-sort-header="url"> {{'urlshortener.url' | i18n}} </th>
<td mat-cell *matCellDef="let shortenedUrl"> <td mat-cell *matCellDef="let shortenedUrl">
<a mat-button color="accent" href="{{ shortenedUrl.url }}" target="_blank"> <a mat-button color="primary" href="{{ shortenedUrl.url }}" target="_blank">
{{ shortenedUrl.url }} <span class="url">{{ shortenedUrl.url }}</span>
<mat-icon style="font-size: 1em;">open_in_new <mat-icon style="font-size: 1em;">open_in_new
</mat-icon> </mat-icon>
</a> </a>

View File

@ -11,6 +11,7 @@ mat-form-field {
.mat-cell .mat-button { .mat-cell .mat-button {
padding-left: 0px; padding-left: 0px;
padding-right: 0px;
} }
.align-right{ .align-right{
@ -20,7 +21,7 @@ mat-form-field {
} }
.url { .url {
display: block; display: inline-block;
width: 200px; width: 200px;
max-width: 200px; max-width: 200px;
white-space: nowrap; white-space: nowrap;

View File

@ -20,6 +20,10 @@ export class JitsiService {
return this.http.post(environment.apiUrl + "/jitsi/rooms", jitsiRoom); return this.http.post(environment.apiUrl + "/jitsi/rooms", jitsiRoom);
} }
createShortUrl(id) {
return this.http.patch(environment.apiUrl + "/jitsi/rooms/" + id, null);
}
delete(id) { delete(id) {
return this.http.delete(environment.apiUrl + "/jitsi/rooms/" + id); return this.http.delete(environment.apiUrl + "/jitsi/rooms/" + id);
} }

View File

@ -11,6 +11,10 @@ export class UrlShortenerService {
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
} }
getModel(code: string): Promise<Object> {
return this.http.get(environment.apiUrl + "/url/shortener/model/" + code).toPromise();
}
get(page: number, size: number, sort: string, desc: boolean, search: string) { get(page: number, size: number, sort: string, desc: boolean, search: string) {
const httpParams = new HttpParams().set("page", "" + page).set("size", "" + size).set("sort", sort).set("desc", "" + desc).set("search", search); const httpParams = new HttpParams().set("page", "" + page).set("size", "" + size).set("sort", sort).set("desc", "" + desc).set("search", search);
return this.http.get(environment.apiUrl + "/url/shortener", {params: httpParams}); return this.http.get(environment.apiUrl + "/url/shortener", {params: httpParams});