fix views

This commit is contained in:
_Bastler 2021-12-04 10:56:57 +01:00
parent 2242d0e267
commit df067fd3cb
21 changed files with 37 additions and 34 deletions

View File

@ -1,7 +1,7 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthGuard, AuthUpdateGuard, AuthenticatedGuard, AnonymousGuard } from './auth/auth.guard';
import { AuthUpdateGuard, AuthenticatedGuard, AnonymousGuard } from './auth/auth.guard';
import { PageBookmarks } from './pages/bookmarks/bookmarks.page';
import { PageComment } from './pages/comment/comment.page';
import { PageEntryEdit } from './pages/entry/edit/edit.page';
@ -25,7 +25,7 @@ import { UiMain } from './ui/main/main.ui';
const routes: Routes = [
{
path: '', component: UiMain, children: [
{ path: '', redirectTo: "/v/TOP", pathMatch: 'full' },
{ path: '', component: PageView, canActivate: [ AuthenticatedGuard ] },
{ path: 'login', component: PageLogin, canActivate: [ AnonymousGuard ] },
{ path: 'search', component: PageSearch, canActivate: [ AuthenticatedGuard ] },
{ path: 'moderation/comments', component: PageModerationComments, canActivate: [ AuthenticatedGuard ] },

View File

@ -1,5 +1,4 @@
import { Directive, ElementRef, OnInit } from '@angular/core';
import { MatInput } from '@angular/material/input';
@Directive({
selector: '[matAutofocus]',

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Input } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { BookmarksService } from '../../services/bookmarks.service';
@ -16,7 +16,7 @@ export class PageBookmarks implements OnInit {
}
fetch(page: number, size: number) {
return this.bookmarksService.getEntries(page,size);
return this.bookmarksService.getEntries(page, size);
}
}

View File

@ -1,9 +1,8 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { CommentService } from '../../services/comment.service';
import { UiComments } from '../../ui/comments/comments.ui';
@Component({
selector: 'page-comment',
@ -15,7 +14,7 @@ export class PageComment implements OnInit {
id: number;
comment: any;
notfound: boolean = false;
ignoreSubcomments : string[] = ['entry'];
ignoreSubcomments: string[] = [ 'entry' ];
constructor(private commentService: CommentService,
private route: ActivatedRoute) { }

View File

@ -1,6 +1,5 @@
import { Component, OnInit, Input } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ModerationService } from '../../../services/moderarion.service';
@Component({

View File

@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
import { PageEvent } from '@angular/material/paginator';
import { ActivatedRoute, Router } from '@angular/router';

View File

@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';

View File

@ -1,6 +1,6 @@
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { FormBuilder, FormGroup, Validators, NgForm } from '@angular/forms';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatSnackBar } from '@angular/material/snack-bar';
import { TagsService } from 'src/app/services/tags.service';
import { SettingsService } from 'src/app/services/settings.service';

View File

@ -1,4 +1,4 @@
<a mat-mini-fab routerLink="/v/{{name}}/edit" matTooltip="{{'views.edit' | i18n}}" color="primary">
<mat-icon inline="true">edit</mat-icon>
</a>
<page-entries #entries [fetch]="boundFetch"></page-entries>
<page-entries *ngIf="name" #entries [fetch]="boundFetch"></page-entries>

View File

@ -31,13 +31,24 @@ export class PageView implements OnInit, OnDestroy {
this.name = params[ 'name' ];
this.username = params[ 'username' ];
this.viewService.getView(this.name, this.username).subscribe((data) => {
if (this.entries) {
this.entries.refresh();
}
}, (error) => {
this.router.navigate([ '/v' ], { queryParams: { name: this.name }, queryParamsHandling: 'merge' });
})
if (!this.name) {
this.viewService.getViews().then((data: any) => {
const views = data.content;
if (!views || views.length == 0) {
this.router.navigate([ '/v' ], { queryParams: { name: this.name }, queryParamsHandling: 'merge' });
} else {
this.router.navigateByUrl('/v/' + views[ 0 ].name);
}
})
} else {
this.viewService.getView(this.name, this.username).subscribe((data) => {
if (this.entries) {
this.entries.refresh();
}
}, (error) => {
this.router.navigate([ '/v' ], { queryParams: { name: this.name }, queryParamsHandling: 'merge' });
})
}
});
this.boundFetch = this.fetch.bind(this);
}

View File

@ -1,4 +1,3 @@
export class RequestError extends Error {
response: any;

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ReplaySubject, of } from 'rxjs';
import { ReplaySubject } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { RequestError } from './requesterror';

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../environments/environment';
@Injectable({

View File

@ -1,6 +1,5 @@
import { Injectable } from '@angular/core';
import { ReplaySubject, of } from 'rxjs';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../environments/environment';

View File

@ -1,6 +1,6 @@
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { FormBuilder, FormGroup, Validators, NgForm } from '@angular/forms';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AuthService } from '../../services/auth.service';
import { VoteService } from '../../services/vote.service';

View File

@ -1,5 +1,4 @@
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { PageEvent } from '@angular/material/paginator';
import { Subscription } from 'rxjs';
import { CommentService } from '../../services/comment.service';

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { Component, OnInit, Input } from '@angular/core';
import { Observable } from 'rxjs';
@Component({

View File

@ -8,7 +8,7 @@ import { BookmarksService } from '../../services/bookmarks.service';
import { ModerationService } from '../../services/moderarion.service';
import { ConfirmDialog } from '../../ui/confirm/confirm.component';
import { EntriesService } from 'src/app/services/entries.service';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
@Component({
selector: 'ui-entry',

View File

@ -1,4 +1,4 @@
import { Component, HostListener, ViewChild } from '@angular/core';
import { Component, HostListener } from '@angular/core';
import { Router } from '@angular/router';
import { DomSanitizer } from '@angular/platform-browser';
import { MatIconRegistry } from '@angular/material/icon';
@ -9,7 +9,6 @@ import { AuthService } from '../../services/auth.service';
import { UserService } from '../../services/user.service';
import { I18nService } from '../../services/i18n.service';
import { SettingsService } from '../../services/settings.service';
import { MatSidenav } from '@angular/material/sidenav';
@Component({
selector: 'ui-main',

View File

@ -3,7 +3,6 @@ import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
import { FormControl } from '@angular/forms';
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
import { MatChipInputEvent } from '@angular/material/chips';
import { MatPaginator } from '@angular/material/paginator';
import { Observable } from 'rxjs';
import { debounceTime, switchMap } from 'rxjs/operators';
import { TagsService } from 'src/app/services/tags.service';