fix views
This commit is contained in:
parent
2242d0e267
commit
df067fd3cb
@ -1,7 +1,7 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { Routes, RouterModule } from '@angular/router';
|
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 { PageBookmarks } from './pages/bookmarks/bookmarks.page';
|
||||||
import { PageComment } from './pages/comment/comment.page';
|
import { PageComment } from './pages/comment/comment.page';
|
||||||
import { PageEntryEdit } from './pages/entry/edit/edit.page';
|
import { PageEntryEdit } from './pages/entry/edit/edit.page';
|
||||||
@ -25,7 +25,7 @@ import { UiMain } from './ui/main/main.ui';
|
|||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: '', component: UiMain, children: [
|
path: '', component: UiMain, children: [
|
||||||
{ path: '', redirectTo: "/v/TOP", pathMatch: 'full' },
|
{ path: '', component: PageView, canActivate: [ AuthenticatedGuard ] },
|
||||||
{ path: 'login', component: PageLogin, canActivate: [ AnonymousGuard ] },
|
{ path: 'login', component: PageLogin, canActivate: [ AnonymousGuard ] },
|
||||||
{ path: 'search', component: PageSearch, canActivate: [ AuthenticatedGuard ] },
|
{ path: 'search', component: PageSearch, canActivate: [ AuthenticatedGuard ] },
|
||||||
{ path: 'moderation/comments', component: PageModerationComments, canActivate: [ AuthenticatedGuard ] },
|
{ path: 'moderation/comments', component: PageModerationComments, canActivate: [ AuthenticatedGuard ] },
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Directive, ElementRef, OnInit } from '@angular/core';
|
import { Directive, ElementRef, OnInit } from '@angular/core';
|
||||||
import { MatInput } from '@angular/material/input';
|
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[matAutofocus]',
|
selector: '[matAutofocus]',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { BookmarksService } from '../../services/bookmarks.service';
|
import { BookmarksService } from '../../services/bookmarks.service';
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
import { CommentService } from '../../services/comment.service';
|
import { CommentService } from '../../services/comment.service';
|
||||||
import { UiComments } from '../../ui/comments/comments.ui';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-comment',
|
selector: 'page-comment',
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
|
||||||
import { Router, ActivatedRoute } from '@angular/router';
|
|
||||||
import { ModerationService } from '../../../services/moderarion.service';
|
import { ModerationService } from '../../../services/moderarion.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
import { PageEvent } from '@angular/material/paginator';
|
import { PageEvent } from '@angular/material/paginator';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
|
@ -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 { Router, ActivatedRoute } from '@angular/router';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
@ -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 { 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 { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
import { TagsService } from 'src/app/services/tags.service';
|
import { TagsService } from 'src/app/services/tags.service';
|
||||||
import { SettingsService } from 'src/app/services/settings.service';
|
import { SettingsService } from 'src/app/services/settings.service';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<a mat-mini-fab routerLink="/v/{{name}}/edit" matTooltip="{{'views.edit' | i18n}}" color="primary">
|
<a mat-mini-fab routerLink="/v/{{name}}/edit" matTooltip="{{'views.edit' | i18n}}" color="primary">
|
||||||
<mat-icon inline="true">edit</mat-icon>
|
<mat-icon inline="true">edit</mat-icon>
|
||||||
</a>
|
</a>
|
||||||
<page-entries #entries [fetch]="boundFetch"></page-entries>
|
<page-entries *ngIf="name" #entries [fetch]="boundFetch"></page-entries>
|
@ -31,6 +31,16 @@ export class PageView implements OnInit, OnDestroy {
|
|||||||
this.name = params[ 'name' ];
|
this.name = params[ 'name' ];
|
||||||
this.username = params[ 'username' ];
|
this.username = params[ 'username' ];
|
||||||
|
|
||||||
|
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) => {
|
this.viewService.getView(this.name, this.username).subscribe((data) => {
|
||||||
if (this.entries) {
|
if (this.entries) {
|
||||||
this.entries.refresh();
|
this.entries.refresh();
|
||||||
@ -38,6 +48,7 @@ export class PageView implements OnInit, OnDestroy {
|
|||||||
}, (error) => {
|
}, (error) => {
|
||||||
this.router.navigate([ '/v' ], { queryParams: { name: this.name }, queryParamsHandling: 'merge' });
|
this.router.navigate([ '/v' ], { queryParams: { name: this.name }, queryParamsHandling: 'merge' });
|
||||||
})
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.boundFetch = this.fetch.bind(this);
|
this.boundFetch = this.fetch.bind(this);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
export class RequestError extends Error {
|
export class RequestError extends Error {
|
||||||
|
|
||||||
response: any;
|
response: any;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { ReplaySubject, of } from 'rxjs';
|
import { ReplaySubject } from 'rxjs';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
|
||||||
import { RequestError } from './requesterror';
|
import { RequestError } from './requesterror';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { environment } from '../../environments/environment';
|
import { environment } from '../../environments/environment';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { ReplaySubject, of } from 'rxjs';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
||||||
|
|
||||||
import { environment } from '../../environments/environment';
|
import { environment } from '../../environments/environment';
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit, Input, ViewChild } from '@angular/core';
|
import { Component, OnInit, Input, ViewChild } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
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 { AuthService } from '../../services/auth.service';
|
||||||
import { VoteService } from '../../services/vote.service';
|
import { VoteService } from '../../services/vote.service';
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
|
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
|
||||||
import { PageEvent } from '@angular/material/paginator';
|
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
import { CommentService } from '../../services/comment.service';
|
import { CommentService } from '../../services/comment.service';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, Input, ViewChild } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -8,7 +8,7 @@ import { BookmarksService } from '../../services/bookmarks.service';
|
|||||||
import { ModerationService } from '../../services/moderarion.service';
|
import { ModerationService } from '../../services/moderarion.service';
|
||||||
import { ConfirmDialog } from '../../ui/confirm/confirm.component';
|
import { ConfirmDialog } from '../../ui/confirm/confirm.component';
|
||||||
import { EntriesService } from 'src/app/services/entries.service';
|
import { EntriesService } from 'src/app/services/entries.service';
|
||||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ui-entry',
|
selector: 'ui-entry',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, HostListener, ViewChild } from '@angular/core';
|
import { Component, HostListener } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
import { MatIconRegistry } from '@angular/material/icon';
|
import { MatIconRegistry } from '@angular/material/icon';
|
||||||
@ -9,7 +9,6 @@ import { AuthService } from '../../services/auth.service';
|
|||||||
import { UserService } from '../../services/user.service';
|
import { UserService } from '../../services/user.service';
|
||||||
import { I18nService } from '../../services/i18n.service';
|
import { I18nService } from '../../services/i18n.service';
|
||||||
import { SettingsService } from '../../services/settings.service';
|
import { SettingsService } from '../../services/settings.service';
|
||||||
import { MatSidenav } from '@angular/material/sidenav';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ui-main',
|
selector: 'ui-main',
|
||||||
|
@ -3,7 +3,6 @@ import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
|
|||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||||
import { MatChipInputEvent } from '@angular/material/chips';
|
import { MatChipInputEvent } from '@angular/material/chips';
|
||||||
import { MatPaginator } from '@angular/material/paginator';
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { debounceTime, switchMap } from 'rxjs/operators';
|
import { debounceTime, switchMap } from 'rxjs/operators';
|
||||||
import { TagsService } from 'src/app/services/tags.service';
|
import { TagsService } from 'src/app/services/tags.service';
|
||||||
|
Loading…
Reference in New Issue
Block a user