Commit a2ae82b1 by DESKTOP-E3GSHH7\myhr

การจัดการบทความ

parent ec2177a8
:host {
display: block;
}
.small-html {
font-size: 0.85rem; /* ลดขนาดฟอนต์ */
line-height: 1.2; /* ลดระยะบรรทัด */
max-height: 150px; /* จำกัดความสูง */
overflow-y: auto; /* ถ้าเนื้อหายาวเกิน ให้เลื่อนดูได้ */
display: block;
}
.border-radius-1{
border-radius: 0.50rem;
}
.font-14{
font-size: 14px;
}
.font-16{
font-size: 16px;
}
.font-24{
font-size: 24px;
}
.font-36{
font-size: 36px;
}
\ No newline at end of file
...@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common'; ...@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
import { CommonComponent } from './common.component'; import { CommonComponent } from './common.component';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { SharedModule } from '../../shared/shared.module'; import { SharedModule } from '../../shared/shared.module';
import { QuillModule } from 'ngx-quill';
export const admin: Routes = [ export const admin: Routes = [
{ {
path: 'admin', children: [{ path: 'admin', children: [{
...@@ -21,6 +22,11 @@ export const admin: Routes = [ ...@@ -21,6 +22,11 @@ export const admin: Routes = [
import('./company-manage/company-manage.component').then((m) => m.CompanyManageComponent), import('./company-manage/company-manage.component').then((m) => m.CompanyManageComponent),
}, },
{ {
path: 'manage-articles',
loadComponent: () =>
import('./article-manage/article-manage.component').then((m) => m.ArticleManageComponent),
},
{
path: 'admin-manage', path: 'admin-manage',
loadComponent: () => loadComponent: () =>
import('./admin-manage/admin-manage.component').then((m) => m.AdminManageComponent), import('./admin-manage/admin-manage.component').then((m) => m.AdminManageComponent),
...@@ -54,7 +60,8 @@ export const admin: Routes = [ ...@@ -54,7 +60,8 @@ export const admin: Routes = [
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
RouterModule.forChild(admin) RouterModule.forChild(admin),
QuillModule.forRoot(),
], ],
exports: [RouterModule], exports: [RouterModule],
declarations: [CommonComponent] declarations: [CommonComponent]
......
import { TranslateService } from "@ngx-translate/core"
import { BaseModel, dataToArray } from "./base.model"
import { CompanyModel } from "./company.model"
import { environment } from "../../../environments/environment";
export interface ArticleModel {
articleId: string
companyId: CompanyModel[]
title: string
content: string
excerpt: string
category: string
author: string
picture: string
createdDate: string
lastModifiedDate: string
publish: number
viewCount: number
}
export class ArticleModel extends BaseModel implements ArticleModel {
articleId: string
companyId: CompanyModel[]
title: string
content: string
excerpt: string
category: string
author: string
picture: string
createdDate: string
lastModifiedDate: string
publish: number
viewCount: number
constructor(data?: Partial<ArticleModel>, translateService?: TranslateService) {
super(data, translateService)
this.articleId = data?.articleId!
this.companyId = dataToArray(data?.companyId).map((x:CompanyModel) => new CompanyModel(x,translateService))
this.title = data?.title!
this.content = data?.content!
this.excerpt = data?.excerpt!
this.category = data?.category!
this.author = data?.author!
this.picture = data?.picture!
this.createdDate = data?.createdDate!
this.lastModifiedDate = data?.lastModifiedDate!
this.publish = data?.publish!
this.viewCount = data?.viewCount!
}
getPicture(): string {
if (this.picture) {
return environment.baseUrl + "/files/image/" + this.picture
} else {
return ""
}
}
}
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from "../../../environments/environment";
import { CompanyModelS } from '../models/companys.mode';
import { ArticleModel } from '../models/article.model';
@Injectable({
providedIn: 'root'
})
export class ArticleService {
api = "/article"
urlApi = environment.baseUrl + "/article"
constructor(private http: HttpClient) { }
getById(articleId: string): Observable<ArticleModel> {
return this.http.get<ArticleModel>(this.urlApi + "/" + articleId)
}
getList(): Observable<ArticleModel[]> {
return this.http.get<ArticleModel[]>(this.urlApi + "/lists")
}
getListByCompany(companyId: CompanyModelS[]): Observable<ArticleModel[]> {
return this.http.get<ArticleModel[]>(this.urlApi + "/lists/" + companyId);
}
postArticle(body: ArticleModel): Observable<any> {
return this.http.post(this.urlApi, body)
}
deletearticle(body: ArticleModel) {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body,
};
return this.http.delete(this.urlApi, options)
}
deletearticleById(articleId: string) {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: {articleId : articleId},
};
return this.http.delete(this.urlApi, options)
}
}
...@@ -109,6 +109,13 @@ export class NavService implements OnDestroy { ...@@ -109,6 +109,13 @@ export class NavService implements OnDestroy {
}, },
{ {
icon: 'buildings',
path: '/admin/manage-articles',
title: 'จัดการบทความ',
type: 'link',
},
{
icon: 'user-check', icon: 'user-check',
path: '/admin/admin-manage', path: '/admin/admin-manage',
title: 'จัดการสิทธิ์ผู้ดูแลระบบ', title: 'จัดการสิทธิ์ผู้ดูแลระบบ',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment