You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

59 lines
1.7 KiB

  1. import {Component, OnInit} from '@angular/core';
  2. import { User } from '@app/_models';
  3. import { AccountService } from '@app/_services';
  4. import {MatCardModule} from "@angular/material/card";
  5. import {Subscription} from "rxjs";
  6. import {PostJsonld, PostService, UserJsonld, UserService} from "@app/core/api/v1";
  7. @Component({
  8. templateUrl: 'home.component.html',
  9. styleUrl: 'home.component.scss'
  10. })
  11. export class HomeComponent implements OnInit{
  12. user: User | null;
  13. protected postSub: Subscription;
  14. protected posts: Array<PostJsonld>;
  15. protected usersSub: Subscription;
  16. protected users: Array<UserJsonld>;
  17. constructor(
  18. private accountService: AccountService,
  19. private postService: PostService,
  20. private userService: UserService
  21. ) {
  22. this.user = this.accountService.userValue;
  23. // this.accountService.user.subscribe(x => this.user = x);
  24. this.postSub = new Subscription();
  25. this.posts = [];
  26. this.usersSub = new Subscription();
  27. this.users = [];
  28. }
  29. ngOnInit(): void {
  30. this.postSub = this.postService.postsGetCollection().subscribe(
  31. data => {
  32. this.posts = data["hydra:member"];
  33. }
  34. );
  35. this.usersSub = this.userService.usersGetCollection().subscribe(
  36. data => {
  37. this.users = data["hydra:member"];
  38. }
  39. );
  40. }
  41. copyTokenToClipboard()
  42. {
  43. const el = document.createElement('textarea');
  44. el.value = this.user?.token !== undefined ? this.user.token : "";
  45. document.body.appendChild(el);
  46. el.select();
  47. document.execCommand('copy');
  48. document.body.removeChild(el);
  49. }
  50. }