diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 1d9bd69..3b476e5 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -17,8 +17,8 @@ import { PageUser } from './pages/user/user.page'; import { PageUserComments } from './pages/user/usercomments/usercomments.page'; import { PageUserEntries } from './pages/user/userentries/userentries.page'; -import { PageUserPageEdit } from './pages/userpage/edit/edit.page'; -import { PageUserPage } from './pages/userpage/userpage.page'; +import { PageViewEdit } from './pages/view/edit/edit.page'; +import { PageView } from './pages/view/view.page'; import { UiMain } from './ui/main/main.ui'; @@ -40,10 +40,10 @@ const routes: Routes = [ { path: 'u/c/:username', component: PageUserComments, canActivate: [ AuthenticatedGuard ] }, { path: 'u/e/:username', component: PageUserEntries, canActivate: [ AuthenticatedGuard ] }, { path: 'unavailable', component: PageUnavailable }, - { path: 'p', component: PageUserPageEdit, canActivate: [ AuthenticatedGuard ] }, - { path: 'p/:name', component: PageUserPage, canActivate: [ AuthenticatedGuard ] }, - { path: 'p/:name/edit', component: PageUserPageEdit, canActivate: [ AuthenticatedGuard ] }, - { path: 'p/:name/:username', component: PageUserPage, canActivate: [ AuthenticatedGuard ] }, + { path: 'p', component: PageViewEdit, canActivate: [ AuthenticatedGuard ] }, + { path: 'p/:name', component: PageView, canActivate: [ AuthenticatedGuard ] }, + { path: 'p/:name/edit', component: PageViewEdit, canActivate: [ AuthenticatedGuard ] }, + { path: 'p/:name/:username', component: PageView, canActivate: [ AuthenticatedGuard ] }, { path: '**', component: PageNotFound, pathMatch: 'full', canActivate: [ AuthUpdateGuard ] }, ] }, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d1870cd..3268643 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -45,9 +45,9 @@ import { I18nService, I18nPaginatorIntl } from './services/i18n.service'; import { ServiceWorkerModule } from '@angular/service-worker'; import { environment } from '../environments/environment'; import { UiTagsPicker } from './ui/tags/tagspicker.ui'; -import { UiUserPageMenu } from './ui/userpagemenu/userpagemenu.ui'; -import { PageUserPage } from './pages/userpage/userpage.page'; -import { PageUserPageEdit } from './pages/userpage/edit/edit.page'; +import { UiViewMenu } from './ui/viewmenu/viewmenu.ui'; +import { PageView } from './pages/view/view.page'; +import { PageViewEdit } from './pages/view/edit/edit.page'; import { PageSearch } from './pages/search/search.page'; @@ -99,8 +99,8 @@ export class XhrInterceptor implements HttpInterceptor { PageSettings, PageUnavailable, PageUser, PageUserComments, PageUserEntries, - PageUserPage, - PageUserPageEdit, + PageView, + PageViewEdit, UiComment, UiCommentCount, UiCommentForm, @@ -110,7 +110,7 @@ export class XhrInterceptor implements HttpInterceptor { UiMain, UiPoints, UiTagsPicker, - UiUserPageMenu, + UiViewMenu, ConfirmDialog ], imports: [ diff --git a/src/app/pages/userpage/edit/edit.page.html b/src/app/pages/view/edit/edit.page.html similarity index 61% rename from src/app/pages/userpage/edit/edit.page.html rename to src/app/pages/view/edit/edit.page.html index c4f70fc..8d259bd 100644 --- a/src/app/pages/userpage/edit/edit.page.html +++ b/src/app/pages/view/edit/edit.page.html @@ -1,21 +1,21 @@
- -
+ + -

{{ (userpage.id ? 'userpages.edit' : 'userpages.create') | i18n}}

+

{{ (view.id ? 'views.edit' : 'views.create') | i18n}}

- +
- {{'userpages.name.error.' + error.key | i18n}}
+ {{'views.name.error.' + error.key | i18n}}
- + {{'sorting.' + sorting + '.icon' | i18n}} {{'sorting.' + sorting | i18n}} @@ -25,14 +25,14 @@ - + - + - + {{'entryType.' + entryType + '.icon' | i18n}} {{'entryType.' + @@ -51,30 +51,30 @@ - +
- {{'userpages.index.error.' + error.key | i18n}}
+ {{'views.index.error.' + error.key | i18n}}
- {{'userpages.divider' + {{'views.divider' | i18n}}
- {{ 'userpages.goTo' | + {{ 'views.goTo' | i18n}} - + delete {{ - 'userpages.delete' | + 'views.delete' | i18n}} diff --git a/src/app/pages/userpage/edit/edit.page.scss b/src/app/pages/view/edit/edit.page.scss similarity index 100% rename from src/app/pages/userpage/edit/edit.page.scss rename to src/app/pages/view/edit/edit.page.scss diff --git a/src/app/pages/userpage/edit/edit.page.ts b/src/app/pages/view/edit/edit.page.ts similarity index 65% rename from src/app/pages/userpage/edit/edit.page.ts rename to src/app/pages/view/edit/edit.page.ts index 1a0ccf4..065966a 100644 --- a/src/app/pages/userpage/edit/edit.page.ts +++ b/src/app/pages/view/edit/edit.page.ts @@ -5,20 +5,20 @@ import { MatSnackBar } from '@angular/material/snack-bar'; import { TagsService } from 'src/app/services/tags.service'; import { SettingsService } from 'src/app/services/settings.service'; import { Subscription } from 'rxjs'; -import { UserPageService } from 'src/app/services/userpage.service'; +import { ViewService } from 'src/app/services/view.service'; import { I18nService } from 'src/app/services/i18n.service'; import { ConfirmDialog } from 'src/app/ui/confirm/confirm.component'; import { MatDialog } from '@angular/material/dialog'; @Component({ - selector: 'page-userpage-edit', + selector: 'page-view-edit', templateUrl: './edit.page.html', styleUrls: [ './edit.page.scss' ] }) -export class PageUserPageEdit implements OnInit, OnDestroy { +export class PageViewEdit implements OnInit, OnDestroy { name: string; - userpage: any; + view: any; entryTypes: string[] = [ undefined, 'LINK', 'DISCUSSION', 'QUESTION', 'INTERN' ]; entryType: string = this.entryTypes[ 0 ]; sortings: string[] = [ 'NEW', 'TOP', 'HOT', 'LAST' ]; @@ -30,7 +30,7 @@ export class PageUserPageEdit implements OnInit, OnDestroy { settingsSubscription: Subscription; - constructor(private userPageService: UserPageService, + constructor(private viewService: ViewService, private tagsService: TagsService, private settingsService: SettingsService, private formBuilder: FormBuilder, @@ -65,7 +65,7 @@ export class PageUserPageEdit implements OnInit, OnDestroy { this.sorting = value; }); this.form.get('index').valueChanges.subscribe((value) => { - this.userpage.index = value; + this.view.index = value; }); this.name = this.route.snapshot.paramMap.get('name'); @@ -78,30 +78,30 @@ export class PageUserPageEdit implements OnInit, OnDestroy { refresh() { if (this.name) { - this.userPageService.getUserPage(this.name, undefined).subscribe((data) => { - this.userpage = data; - this.entryType = this.userpage.entryType; - this.sorting = this.userpage.sorting; - this.form.get("name").setValue(this.userpage.name); - this.form.get("entryType").setValue(this.userpage.entryType); - this.form.get("sorting").setValue(this.userpage.sorting); - this.form.get("index").setValue(this.userpage.index); + this.viewService.getView(this.name, undefined).subscribe((data) => { + this.view = data; + this.entryType = this.view.entryType; + this.sorting = this.view.sorting; + this.form.get("name").setValue(this.view.name); + this.form.get("entryType").setValue(this.view.entryType); + this.form.get("sorting").setValue(this.view.sorting); + this.form.get("index").setValue(this.view.index); }, (error) => { if (error.status == 404) { this.notfound = true; } }) } else { - this.userpage = {}; - this.userpage.entryType = this.entryType; - this.userpage.sorting = this.sorting; - this.userpage.tags = []; - this.userpage.excludedTags = []; - this.userpage.index = 99; - this.form.get("name").setValue(this.userpage.name); - this.form.get("entryType").setValue(this.userpage.entryType); - this.form.get("sorting").setValue(this.userpage.sorting); - this.form.get("index").setValue(this.userpage.index); + this.view = {}; + this.view.entryType = this.entryType; + this.view.sorting = this.sorting; + this.view.tags = []; + this.view.excludedTags = []; + this.view.index = 99; + this.form.get("name").setValue(this.view.name); + this.form.get("entryType").setValue(this.view.entryType); + this.form.get("sorting").setValue(this.view.sorting); + this.form.get("index").setValue(this.view.index); } } @@ -117,19 +117,19 @@ export class PageUserPageEdit implements OnInit, OnDestroy { this.working = true; - this.userpage.name = this.form.get("name").value; - this.userpage.entryType = this.entryType; - this.userpage.sorting = this.sorting; - this.userpage.index = this.form.get("index").value; + this.view.name = this.form.get("name").value; + this.view.entryType = this.entryType; + this.view.sorting = this.sorting; + this.view.index = this.form.get("index").value; - this.userPageService.createOrUpdate(this.userpage).subscribe((data) => { - this.userpage = data; + this.viewService.createOrUpdate(this.view).subscribe((data) => { + this.view = data; this.working = false; - this.snackBar.open(this.i18n.get('userpages.success', []), this.i18n.get("close", []), { + this.snackBar.open(this.i18n.get('views.success', []), this.i18n.get("close", []), { duration: 3000 }); - this.router.navigateByUrl('/p/' + this.userpage.name); - this.userPageService.getUserPages(); + this.router.navigateByUrl('/p/' + this.view.name); + this.viewService.getViews(); }, (error) => { this.working = false; if (error.status == 403) { @@ -149,21 +149,21 @@ export class PageUserPageEdit implements OnInit, OnDestroy { }) } - deleteUserPage() { + deleteView() { const dialogRef = this.dialog.open(ConfirmDialog, { data: { - 'label': 'userpages.confirmDelete', - 'args': [ this.userpage.name ] + 'label': 'views.confirmDelete', + 'args': [ this.view.name ] } }) dialogRef.afterClosed().subscribe(result => { if (result) { this.working = true; - this.userPageService.deleteUserPage(this.userpage.name).subscribe(() => { + this.viewService.deleteView(this.view.name).subscribe(() => { this.working = false; this.router.navigateByUrl('/'); - this.userPageService.getUserPages(); + this.viewService.getViews(); }) } }); diff --git a/src/app/pages/userpage/userpage.page.html b/src/app/pages/view/view.page.html similarity index 59% rename from src/app/pages/userpage/userpage.page.html rename to src/app/pages/view/view.page.html index b8a76d8..d040f9b 100644 --- a/src/app/pages/userpage/userpage.page.html +++ b/src/app/pages/view/view.page.html @@ -1,5 +1,5 @@
- + edit diff --git a/src/app/pages/userpage/userpage.page.scss b/src/app/pages/view/view.page.scss similarity index 100% rename from src/app/pages/userpage/userpage.page.scss rename to src/app/pages/view/view.page.scss diff --git a/src/app/pages/userpage/userpage.page.ts b/src/app/pages/view/view.page.ts similarity index 73% rename from src/app/pages/userpage/userpage.page.ts rename to src/app/pages/view/view.page.ts index f039cdf..eb98495 100644 --- a/src/app/pages/userpage/userpage.page.ts +++ b/src/app/pages/view/view.page.ts @@ -1,17 +1,17 @@ import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { Subscription } from 'rxjs'; -import { UserPageService } from 'src/app/services/userpage.service'; +import { ViewService } from 'src/app/services/view.service'; import { EntriesService } from '../../services/entries.service'; import { PageEntries } from '../entries/entries.page'; @Component({ - selector: 'page-userpage', - templateUrl: './userpage.page.html', - styleUrls: [ './userpage.page.scss' ] + selector: 'page-view', + templateUrl: './view.page.html', + styleUrls: [ './view.page.scss' ] }) -export class PageUserPage implements OnInit, OnDestroy { +export class PageView implements OnInit, OnDestroy { boundFetch: Function; name: string; @@ -21,7 +21,7 @@ export class PageUserPage implements OnInit, OnDestroy { constructor( private entriesService: EntriesService, - private userPageService: UserPageService, + private viewService: ViewService, private router: Router, private route: ActivatedRoute) { } @@ -31,7 +31,7 @@ export class PageUserPage implements OnInit, OnDestroy { this.name = params[ 'name' ]; this.username = params[ 'username' ]; - this.userPageService.getUserPage(this.name, this.username).subscribe((data) => { + this.viewService.getView(this.name, this.username).subscribe((data) => { if (this.entries) { this.entries.refresh(); } @@ -53,7 +53,7 @@ export class PageUserPage implements OnInit, OnDestroy { filter.username = this.username; } - return this.entriesService.getByUserPage(this.name, page, size, asc, filter); + return this.entriesService.getByView(this.name, page, size, asc, filter); } } diff --git a/src/app/services/entries.service.ts b/src/app/services/entries.service.ts index 7aabcfb..8f3e336 100644 --- a/src/app/services/entries.service.ts +++ b/src/app/services/entries.service.ts @@ -34,7 +34,7 @@ export class EntriesService { return this.http.get(environment.apiUrl + "/entries" + path, { params: httpParams }); } - getByUserPage(name: string, page: number, size: number, asc: boolean, filter: any) { + getByView(name: string, page: number, size: number, asc: boolean, filter: any) { return this.fetch("/" + name, page, size, asc, filter); } diff --git a/src/app/services/userpage.service.ts b/src/app/services/view.service.ts similarity index 54% rename from src/app/services/userpage.service.ts rename to src/app/services/view.service.ts index e5cb226..3711c97 100644 --- a/src/app/services/userpage.service.ts +++ b/src/app/services/view.service.ts @@ -7,23 +7,23 @@ import { RequestError } from './requesterror'; @Injectable({ providedIn: 'root', }) -export class UserPageService { +export class ViewService { - userPages: ReplaySubject = new ReplaySubject(1); + views: ReplaySubject = new ReplaySubject(1); constructor(private http: HttpClient) { } - getUserPages() { - return this.http.get(environment.apiUrl + "/userpages").toPromise().then((data: any) => { - this.userPages.next(data); + getViews() { + return this.http.get(environment.apiUrl + "/views").toPromise().then((data: any) => { + this.views.next(data); return data; }, error => { throw new RequestError(error); });; } - getPublicUserPages(page: number, size: number, desc: boolean) { + getPublicViews(page: number, size: number, desc: boolean) { let httpParams = new HttpParams(); if (page != undefined) { httpParams = httpParams.set("page", "" + page); @@ -35,24 +35,24 @@ export class UserPageService { httpParams = httpParams.set("desc", "" + desc); } - return this.http.get(environment.apiUrl + "/userpages/public", { params: httpParams }); + return this.http.get(environment.apiUrl + "/views/public", { params: httpParams }); } - getUserPage(name: string, username: string) { + getView(name: string, username: string) { let httpParams = new HttpParams(); if (username != undefined) { httpParams = httpParams.set("user", "" + username); } - return this.http.get(environment.apiUrl + "/userpages/userpage/" + name, { params: httpParams }); + return this.http.get(environment.apiUrl + "/views/view/" + name, { params: httpParams }); } - createOrUpdate(userPage: any) { - return this.http.post(environment.apiUrl + "/userpages/userpage", userPage); + createOrUpdate(view: any) { + return this.http.post(environment.apiUrl + "/views/view", view); } - deleteUserPage(name: string) { - return this.http.delete(environment.apiUrl + "/userpages/userpage/" + name); + deleteView(name: string) { + return this.http.delete(environment.apiUrl + "/views/view/" + name); } } \ No newline at end of file diff --git a/src/app/ui/main/main.ui.html b/src/app/ui/main/main.ui.html index a637487..ea9ac21 100644 --- a/src/app/ui/main/main.ui.html +++ b/src/app/ui/main/main.ui.html @@ -42,7 +42,7 @@ - + report {{'moderation.entries' | i18n}} diff --git a/src/app/ui/userpagemenu/userpagemenu.ui.html b/src/app/ui/userpagemenu/userpagemenu.ui.html deleted file mode 100644 index 1b26dc4..0000000 --- a/src/app/ui/userpagemenu/userpagemenu.ui.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - {{'sorting.' + userpage.sorting + '.icon' | i18n}} {{'sorting.' + userpage.name | i18nEmpty}} - - - - - add - - \ No newline at end of file diff --git a/src/app/ui/userpagemenu/userpagemenu.ui.ts b/src/app/ui/userpagemenu/userpagemenu.ui.ts deleted file mode 100644 index 67b4df3..0000000 --- a/src/app/ui/userpagemenu/userpagemenu.ui.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Subscription } from 'rxjs'; -import { SettingsService } from 'src/app/services/settings.service'; -import { UserPageService } from 'src/app/services/userpage.service'; - -@Component({ - selector: 'ui-userpagemenu', - templateUrl: 'userpagemenu.ui.html', - styleUrls: [ './userpagemenu.ui.scss' ] -}) -export class UiUserPageMenu implements OnInit { - - - userpages: any[] = []; - settings: any; - settingsSubscription: Subscription; - - constructor(private userPageService: UserPageService, private settingsService: SettingsService) { - } - - ngOnInit(): void { - this.settingsSubscription = this.settingsService.settings.subscribe((settings) => { - this.settings = settings; - this.userPageService.userPages.subscribe((data: any) => { - this.userpages = data.content; - }) - this.userPageService.getUserPages(); - }) - } - -} - diff --git a/src/app/ui/viewmenu/viewmenu.ui.html b/src/app/ui/viewmenu/viewmenu.ui.html new file mode 100644 index 0000000..f3ee191 --- /dev/null +++ b/src/app/ui/viewmenu/viewmenu.ui.html @@ -0,0 +1,13 @@ + + + + + {{'sorting.' + view.sorting + '.icon' | i18n}} {{'sorting.' + view.name | i18nEmpty}} + + + + + add + + \ No newline at end of file diff --git a/src/app/ui/userpagemenu/userpagemenu.ui.scss b/src/app/ui/viewmenu/viewmenu.ui.scss similarity index 100% rename from src/app/ui/userpagemenu/userpagemenu.ui.scss rename to src/app/ui/viewmenu/viewmenu.ui.scss diff --git a/src/app/ui/viewmenu/viewmenu.ui.ts b/src/app/ui/viewmenu/viewmenu.ui.ts new file mode 100644 index 0000000..cc15ea1 --- /dev/null +++ b/src/app/ui/viewmenu/viewmenu.ui.ts @@ -0,0 +1,32 @@ +import { Component, OnInit } from '@angular/core'; +import { Subscription } from 'rxjs'; +import { SettingsService } from 'src/app/services/settings.service'; +import { ViewService } from 'src/app/services/view.service'; + +@Component({ + selector: 'ui-viewmenu', + templateUrl: 'viewmenu.ui.html', + styleUrls: [ './viewmenu.ui.scss' ] +}) +export class UiViewMenu implements OnInit { + + + views: any[] = []; + settings: any; + settingsSubscription: Subscription; + + constructor(private viewService: ViewService, private settingsService: SettingsService) { + } + + ngOnInit(): void { + this.settingsSubscription = this.settingsService.settings.subscribe((settings) => { + this.settings = settings; + this.viewService.views.subscribe((data: any) => { + this.views = data.content; + }) + this.viewService.getViews(); + }) + } + +} +