-
Notifications
You must be signed in to change notification settings - Fork 6
Implemented some pages of administration #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<ksi-admin-sidebar></ksi-admin-sidebar> | ||
|
||
<div class="content-container"> | ||
<div class="content"> | ||
<h2>Work in progress...</h2> | ||
<a [routerLink]="['/', routes.routes.admin._, routes.routes.admin.waves._]"> Zpět na přehled</a> | ||
|
||
<div class=""> | ||
<img src="https://media1.giphy.com/media/v1.Y2lkPTc5MGI3NjExaWxremdsOW1mcmJtY3hxZ3BieTczZWN3ODB5MW8zY3BkcDVzeHl4ZyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/VHOF8pfPZOt9p018zw/giphy.gif" | ||
alt="Work in progress" /> | ||
</div> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import "src/app/styles/vars"; | ||
@import "src/app/styles/mixins"; | ||
|
||
@include page-admin; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PageAdminArticleEditComponent } from './page-admin-article-edit.component'; | ||
|
||
describe('PageAdminArticleEditComponent', () => { | ||
let component: PageAdminArticleEditComponent; | ||
let fixture: ComponentFixture<PageAdminArticleEditComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ PageAdminArticleEditComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(PageAdminArticleEditComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Component, OnInit, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; | ||
import { FormBuilder } from '@angular/forms'; | ||
import { Router } from '@angular/router'; | ||
import { EditMode } from 'src/app/models/EditMode'; | ||
import { IconService, RoutesService, YearsService } from 'src/app/services'; | ||
import { AdminArticlesService } from 'src/app/services/admin/admin-articles.service'; | ||
import { AdminWavesService } from 'src/app/services/admin/admin-waves.service'; | ||
|
||
@Component({ | ||
selector: 'ksi-page-admin-article-edit', | ||
templateUrl: './page-admin-article-edit.component.html', | ||
styleUrls: ['./page-admin-article-edit.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class PageAdminArticleEditComponent implements OnInit { | ||
editMode: EditMode; | ||
EditMode = { | ||
New: 'New', | ||
Edit: 'Edit' | ||
}; | ||
|
||
articleId: number; | ||
|
||
form = this.fb.group({ | ||
title: [''], | ||
body: [''], | ||
published: [false], | ||
year: [this.years.selected?.id], // User won't set this - it's for better DevEx when submitting | ||
time_published: [null], // Store as ISO string | ||
picture: [null] | ||
}); | ||
|
||
constructor( | ||
public icon: IconService, | ||
public routes: RoutesService, | ||
public years: YearsService, | ||
public router: Router, | ||
public fb: FormBuilder, | ||
private cdRef: ChangeDetectorRef, | ||
private adminArticlesService: AdminArticlesService | ||
) { } | ||
|
||
ngOnInit(): void { | ||
this.articleId = Number.parseInt(this.router.url.split('/').pop() || '0', 10); | ||
|
||
this.editMode = this.articleId == 0 ? EditMode.New : EditMode.Update; | ||
|
||
if (this.editMode === EditMode.Update) { | ||
this.adminArticlesService.getArticleById(this.articleId).subscribe({ | ||
next: (article) => { | ||
if (article) { | ||
this.form.patchValue(article); | ||
this.cdRef.markForCheck(); | ||
} else { | ||
alert('Article not found'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Místo |
||
this.router.navigate([this.routes.routes.admin._, this.routes.routes.admin.articles._]); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,38 @@ | ||||||
<ksi-admin-sidebar></ksi-admin-sidebar> | ||||||
<div class="content-container"> | ||||||
<div class="content"> | ||||||
|
||||||
<h2>Správa článků</h2> | ||||||
<a class="btn btn-ksi" | ||||||
[routerLink]="['/', routes.routes.admin._, routes.routes.admin.articles._, routes.routes.admin.articles.edit, '0']"> | ||||||
{{ icon.ADD }} {{ 'admin.articles.new' | translate }}</a> | ||||||
|
||||||
<table class="table table-striped table-hover table-responsive-md threads table-dark"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Místo table-dark používej prosím
Suggested change
|
||||||
<thead> | ||||||
<tr style="height:45px"> | ||||||
<th>{{ 'admin.articles.head.title' | translate}}</th> | ||||||
<th>{{ 'admin.articles.head.published_date' | translate}}</th> | ||||||
<th>{{ 'admin.articles.head.released' | translate}}</th> | ||||||
<th>{{ 'admin.articles.head.actions' | translate}}</th> | ||||||
</tr> | ||||||
</thead> | ||||||
<tbody> | ||||||
<tr *ngFor="let article of articles$ | async"> | ||||||
<td><a | ||||||
[routerLink]="['/', routes.routes.admin._, routes.routes.admin.articles._, routes.routes.admin.articles.edit, article.id]">{{article.title}}</a> | ||||||
</td> | ||||||
<td>{{(article.time_published | date : 'medium') || "---"}}</td> | ||||||
<td>{{article.published ? icon.CHECKMARK : icon.CROSS}}</td> | ||||||
<td> | ||||||
<a class="btn btn-outline-primary" | ||||||
[routerLink]="['/', routes.routes.admin._, routes.routes.admin.articles._, routes.routes.admin.articles.edit, article.id]">{{ | ||||||
icon.EDIT }} </a> | ||||||
|
||||||
<button class="btn btn-outline-primary" (click)="notImplemented()"> | ||||||
{{ icon.DELETE }} {{ 'admin.articles.delete.btn' | translate }} </button> | ||||||
</td> | ||||||
</tr> | ||||||
</tbody> | ||||||
</table> | ||||||
</div> | ||||||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
je mi to líto, je to krásný gif, ale poprosím tě, abys nepoužíval externí obrázky. Externí obrázky zpomalují stránku a prozrazují tvoji IP adresu a fakt, že jsi na KSI webu ostatním službám.