update clipboard, fix timeslots

This commit is contained in:
_Bastler 2021-11-18 17:48:28 +01:00
parent 2cede86ea8
commit 86d352f549
7 changed files with 103 additions and 128 deletions

View File

@ -8,7 +8,7 @@ import { HttpClientModule, HttpInterceptor, HttpHandler, HttpRequest, HTTP_INTER
import { MaterialModule } from './material/material.module'; import { MaterialModule } from './material/material.module';
import { QrCodeModule } from 'ng-qrcode'; import { QrCodeModule } from 'ng-qrcode';
import { DatePipe } from '@angular/common'; import { DatePipe } from '@angular/common';
import { ClipboardModule } from '@angular/cdk/clipboard';
import { AutofocusDirective } from './material/autofocus'; import { AutofocusDirective } from './material/autofocus';
@ -125,6 +125,7 @@ export class XhrInterceptor implements HttpInterceptor {
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
ClipboardModule,
AppRoutingModule, AppRoutingModule,
BrowserAnimationsModule, BrowserAnimationsModule,
MaterialModule, MaterialModule,
@ -132,6 +133,7 @@ export class XhrInterceptor implements HttpInterceptor {
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
QrCodeModule, QrCodeModule,
], ],
exports: [ MaterialModule ], exports: [ MaterialModule ],
providers: [ { provide: APP_INITIALIZER, useFactory: init_app, deps: [ I18nService ], multi: true }, { provide: HTTP_INTERCEPTORS, useClass: XhrInterceptor, multi: true }, DatePipe, providers: [ { provide: APP_INITIALIZER, useFactory: init_app, deps: [ I18nService ], multi: true }, { provide: HTTP_INTERCEPTORS, useClass: XhrInterceptor, multi: true }, DatePipe,

View File

@ -6,6 +6,7 @@ import {FormBuilder, FormGroup, Validators, NgForm} from '@angular/forms';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { ConfirmDialog } from '../../../ui/confirm/confirm.component'; import { ConfirmDialog } from '../../../ui/confirm/confirm.component';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { Clipboard } from '@angular/cdk/clipboard';
@Component({ @Component({
selector: 'app-account-domains', selector: 'app-account-domains',
@ -31,7 +32,8 @@ export class DomainsComponent implements OnInit {
private userDomainService: UserDomainService, private userDomainService: UserDomainService,
private i18n: I18nService, private i18n: I18nService,
private snackBar: MatSnackBar, private snackBar: MatSnackBar,
public dialog: MatDialog) {} public dialog: MatDialog,
private clipboard: Clipboard) { }
ngOnInit(): void { ngOnInit(): void {
this.form = this.formBuilder.group({ this.form = this.formBuilder.group({
@ -97,13 +99,7 @@ export class DomainsComponent implements OnInit {
} }
copySecret(domain: any) { copySecret(domain: any) {
const selBox = document.createElement('textarea'); this.clipboard.copy(domain.secret);
selBox.value = domain.secret;
document.body.appendChild(selBox);
selBox.focus();
selBox.select();
document.execCommand('copy');
document.body.removeChild(selBox);
this.snackBar.open(this.i18n.get("user.domains.secret.copied", []), this.i18n.get("close", []), { this.snackBar.open(this.i18n.get("user.domains.secret.copied", []), this.i18n.get("close", []), {
duration: 3000 duration: 3000
}); });

View File

@ -5,10 +5,10 @@ import { FormBuilder, FormGroup, Validators, NgForm } from '@angular/forms';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { DatePipe } from '@angular/common'; import { DatePipe } from '@angular/common';
import { PageEvent } from '@angular/material/paginator'; import { PageEvent } from '@angular/material/paginator';
import { Clipboard } from '@angular/cdk/clipboard';
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';
@ -39,7 +39,8 @@ export class JitsiComponent implements OnInit {
private jitsiService: JitsiService, private jitsiService: JitsiService,
private snackBar: MatSnackBar, private snackBar: MatSnackBar,
private i18n: I18nService, private i18n: I18nService,
public dialog: MatDialog) { } public dialog: MatDialog,
private clipboard: Clipboard) { }
ngOnInit(): void { ngOnInit(): void {
this.datetimeformat = this.i18n.get('format.datetime', []); this.datetimeformat = this.i18n.get('format.datetime', []);
@ -157,13 +158,7 @@ export class JitsiComponent implements OnInit {
} }
copyRoomUrlToClipboard(jitsiRoom: any) { copyRoomUrlToClipboard(jitsiRoom: any) {
const selBox = document.createElement('textarea'); this.clipboard.copy(jitsiRoom.url);
selBox.value = jitsiRoom.url;
document.body.appendChild(selBox);
selBox.focus();
selBox.select();
document.execCommand('copy');
document.body.removeChild(selBox);
this.snackBar.open(this.i18n.get("jitsi.rooms.clipboard.copied", []), this.i18n.get("close", []), { this.snackBar.open(this.i18n.get("jitsi.rooms.clipboard.copied", []), this.i18n.get("close", []), {
duration: 3000 duration: 3000
}); });
@ -259,6 +254,7 @@ export class JitsiShareDialog {
constructor( constructor(
private i18n: I18nService, private i18n: I18nService,
private snackBar: MatSnackBar, private snackBar: MatSnackBar,
private clipboard: Clipboard,
private datePipe: DatePipe, private datePipe: DatePipe,
public dialogRef: MatDialogRef<JitsiShareDialog>, public dialogRef: MatDialogRef<JitsiShareDialog>,
@Inject(MAT_DIALOG_DATA) public data: any) { @Inject(MAT_DIALOG_DATA) public data: any) {
@ -279,13 +275,7 @@ export class JitsiShareDialog {
} }
copyToClipboard(text) { copyToClipboard(text) {
const selBox = document.createElement('textarea'); this.clipboard.copy(text);
selBox.value = text;
document.body.appendChild(selBox);
selBox.focus();
selBox.select();
document.execCommand('copy');
document.body.removeChild(selBox);
this.snackBar.open(this.i18n.get("jitsi.share.clipboard.copied", []), this.i18n.get("close", []), { this.snackBar.open(this.i18n.get("jitsi.share.clipboard.copied", []), this.i18n.get("close", []), {
duration: 3000 duration: 3000
}); });

View File

@ -7,6 +7,7 @@ import { DatePipe } from '@angular/common';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { debounceTime } from 'rxjs/operators'; import { debounceTime } from 'rxjs/operators';
import { PageEvent } from '@angular/material/paginator'; import { PageEvent } from '@angular/material/paginator';
import { Clipboard } from '@angular/cdk/clipboard';
import { ParteyTimeslotsService } from '../../../services/partey.service'; import { ParteyTimeslotsService } from '../../../services/partey.service';
import { ConfirmDialog } from '../../../ui/confirm/confirm.component'; import { ConfirmDialog } from '../../../ui/confirm/confirm.component';
@ -49,7 +50,8 @@ export class ParteyTimeslotsComponent implements OnInit {
private i18n: I18nService, private i18n: I18nService,
private datePipe: DatePipe, private datePipe: DatePipe,
private snackBar: MatSnackBar, private snackBar: MatSnackBar,
public dialog: MatDialog) { } public dialog: MatDialog,
private clipboard: Clipboard) { }
ngOnInit(): void { ngOnInit(): void {
@ -182,13 +184,7 @@ export class ParteyTimeslotsComponent implements OnInit {
} }
copySecretToClipboard(secret) { copySecretToClipboard(secret) {
const selBox = document.createElement('textarea'); this.clipboard.copy(secret);
selBox.value = secret;
document.body.appendChild(selBox);
selBox.focus();
selBox.select();
document.execCommand('copy');
document.body.removeChild(selBox);
this.snackBar.open(this.i18n.get("partey.timeslots.secret.copied", []), this.i18n.get("close", []), { this.snackBar.open(this.i18n.get("partey.timeslots.secret.copied", []), this.i18n.get("close", []), {
duration: 3000 duration: 3000
}); });
@ -209,7 +205,7 @@ export class ParteyTimeslotDialog {
timeslot; timeslot;
visibilities = [ "PRIVATE", "PROTECTED", "PUBLIC" ]; visibilities = [ "PRIVATE", "PROTECTED", "PUBLIC" ];
types = [ "VIDEO", "AUDIO" ]; types = [ "VIDEO", "AUDIO", "AUDIO_STREAM", "VIDEO_STREAM" ];
constructor( constructor(
private parteyTimeslotsService: ParteyTimeslotsService, private parteyTimeslotsService: ParteyTimeslotsService,
@ -226,12 +222,11 @@ export class ParteyTimeslotDialog {
ends: [ '', Validators.required ], ends: [ '', Validators.required ],
title: [ '', Validators.nullValidator ], title: [ '', Validators.nullValidator ],
description: [ '', Validators.nullValidator ], description: [ '', Validators.nullValidator ],
stream: [ '', this.timeslot.type == 'VIDEO' ? Validators.required : Validators.nullValidator ], stream: [ '', this.timeslot.type == 'VIDEO_STREAM' ? Validators.required : Validators.nullValidator ],
share: [ '', (this.timeslot.type == 'VIDEO' || this.timeslot.type == 'AUDIO') ? Validators.required : Validators.nullValidator ],
}); });
} }
create(timeslot) { create(timeslot) {
this.parteyTimeslotsService.create(timeslot).subscribe((result: any) => { this.parteyTimeslotsService.create(timeslot).subscribe((result: any) => {
this.dialogRef.close(timeslot); this.dialogRef.close(timeslot);

View File

@ -3,6 +3,7 @@ import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { Clipboard } from '@angular/cdk/clipboard';
import { UserService } from './../../services/user.service'; import { UserService } from './../../services/user.service';
import { ItemService } from './../../services/item.service'; import { ItemService } from './../../services/item.service';
@ -173,6 +174,7 @@ export class RegisterDialog {
constructor(private router: Router, constructor(private router: Router,
private i18n: I18nService, private i18n: I18nService,
private snackBar: MatSnackBar, private snackBar: MatSnackBar,
private clipboard: Clipboard,
public dialogRef: MatDialogRef<RegisterDialog>, public dialogRef: MatDialogRef<RegisterDialog>,
@Inject(MAT_DIALOG_DATA) public data: any) { @Inject(MAT_DIALOG_DATA) public data: any) {
} }
@ -187,10 +189,7 @@ export class RegisterDialog {
} }
copyKey(inputElement) { copyKey(inputElement) {
inputElement.select(); this.clipboard.copy(inputElement.value);
document.execCommand('copy');
inputElement.setSelectionRange(0, 0);
this.downloaded = true;
this.snackBar.open(this.i18n.get("pgp.privateKey.copied", []), this.i18n.get("close", []), { this.snackBar.open(this.i18n.get("pgp.privateKey.copied", []), this.i18n.get("close", []), {
duration: 3000 duration: 3000
}); });

View File

@ -5,6 +5,7 @@ import { FormBuilder, FormGroup, Validators, NgForm, FormControl } from '@angula
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { PageEvent } from '@angular/material/paginator'; import { PageEvent } from '@angular/material/paginator';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Clipboard } from '@angular/cdk/clipboard';
import { MatchingValidator } from './../../utils/matching.validator'; import { MatchingValidator } from './../../utils/matching.validator';
import { QuotaService } from '../../services/quota.service'; import { QuotaService } from '../../services/quota.service';
@ -268,6 +269,7 @@ export class UrlShortenerShareDialog {
constructor( constructor(
private i18n: I18nService, private i18n: I18nService,
private snackBar: MatSnackBar, private snackBar: MatSnackBar,
private clipboard: Clipboard,
public dialogRef: MatDialogRef<UrlShortenerShareDialog>, public dialogRef: MatDialogRef<UrlShortenerShareDialog>,
@Inject(MAT_DIALOG_DATA) public data: any) { @Inject(MAT_DIALOG_DATA) public data: any) {
this.shortenedUrl = data; this.shortenedUrl = data;
@ -279,13 +281,7 @@ export class UrlShortenerShareDialog {
} }
copyToClipboard(text) { copyToClipboard(text) {
const selBox = document.createElement('textarea'); this.clipboard.copy(text);
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", []), { this.snackBar.open(this.i18n.get("urlshortener.share.clipboard.copied", []), this.i18n.get("close", []), {
duration: 3000 duration: 3000
}); });

View File

@ -1,12 +1,11 @@
import { Component, OnInit, ElementRef, ViewChild } from '@angular/core'; import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog'; import { MatDialogRef } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { Clipboard } from '@angular/cdk/clipboard';
import { AuthService } from '../../../../services/auth.service'; import { AuthService } from '../../../../services/auth.service';
import { I18nService } from '../../../../services/i18n.service'; import { I18nService } from '../../../../services/i18n.service';
var openpgp = require('openpgp'); var openpgp = require('openpgp');
@Component({ @Component({
@ -24,7 +23,8 @@ export class ProfileFieldPgpBlob implements OnInit {
public dialogRef: MatDialogRef<ProfileFieldPgpBlob>, public dialogRef: MatDialogRef<ProfileFieldPgpBlob>,
private i18n: I18nService, private i18n: I18nService,
private authService: AuthService, private authService: AuthService,
private snackBar: MatSnackBar) { private snackBar: MatSnackBar,
private clipboard: Clipboard) {
this.data = {}; this.data = {};
} }
@ -56,10 +56,7 @@ export class ProfileFieldPgpBlob implements OnInit {
} }
copyKey(inputElement) { copyKey(inputElement) {
inputElement.select(); this.clipboard.copy(inputElement.value);
document.execCommand('copy');
inputElement.setSelectionRange(0, 0);
this.downloaded = true;
this.snackBar.open(this.i18n.get("pgp.privateKey.copied", []), this.i18n.get("close", []), { this.snackBar.open(this.i18n.get("pgp.privateKey.copied", []), this.i18n.get("close", []), {
duration: 3000 duration: 3000
}); });