Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
myhr-portal
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
angular
myhr-portal
Commits
dde94786
Commit
dde94786
authored
Jan 13, 2025
by
Nakarin Luankla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UPDATE list-widgets
parent
32691b69
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
219 additions
and
150 deletions
+219
-150
list-widgets.component.html
src/app/apps/list-widgets/list-widgets.component.html
+26
-41
list-widgets.component.scss
src/app/apps/list-widgets/list-widgets.component.scss
+10
-0
list-widgets.component.spec.ts
src/app/apps/list-widgets/list-widgets.component.spec.ts
+0
-25
list-widgets.component.ts
src/app/apps/list-widgets/list-widgets.component.ts
+44
-83
portal-create-category.component.ts
...ortal-create-category/portal-create-category.component.ts
+10
-1
widgets.model.ts
src/app/model/widgets.model.ts
+59
-0
tag.service.ts
src/app/service/tag.service.ts
+3
-0
widgets.service.ts
src/app/service/widgets.service.ts
+67
-0
No files found.
src/app/apps/list-widgets/list-widgets.component.html
View file @
dde94786
...
...
@@ -15,30 +15,28 @@
<!-- <th scope="col">รหัสเอกสาร</th> -->
<th
scope=
"col"
>
ชื่อ
</th>
<th
scope=
"col"
>
รายละเอียด
</th>
<th
scope=
"col"
class=
"text-center"
>
ลิงค์
</th>
<th
scope=
"col"
class=
"text-center"
>
สถานะ
</th>
<th
scope=
"col"
></th>
</tr>
</thead>
<tbody>
<tr
*
ngFor=
"let data of filterList
Doc
() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index"
>
<tr
*
ngFor=
"let data of filterList
Widget
() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index"
>
<td
class=
"text-center"
>
{{i+1}}
</td>
<td><img
width=
"100"
class=
"border p-1"
src=
"{{data.getImage()}}"
(
click
)="
openEmployeeModal
(
data
.
getImage
())"
></td>
<!-- <td >{{data.id}}</td> -->
<td>
{{ data.
thN
ame }}
</td>
<td>
{{ data.
widgetTn
ame }}
</td>
<td>
{{ data.thDesc }}
</td>
<td
class=
"text-center"
><i
class=
"fas fa-link pointer"
(
click
)="
openLink
(
data
.
link1
)"
></i></td>
<td
class=
"text-center"
>
<span
class=
"fa-stack rt_anim"
*
ngIf=
"data.status == '0'"
ngbTooltip=
"
รออนุมัติ
"
container=
"body"
tooltipClass=
"myhrcolor-1"
>
<span
class=
"fa-stack rt_anim"
*
ngIf=
"data.status == '0'"
ngbTooltip=
"
Private
"
container=
"body"
tooltipClass=
"myhrcolor-1"
>
<i
class=
"fa fa-circle fa-stack-2x text-info"
></i>
<i
class=
" fas fa-
hourglass-half
fa-stack-1x fa-inverse"
></i>
<i
class=
" fas fa-
lock
fa-stack-1x fa-inverse"
></i>
</span>
<span
class=
"fa-stack rt_anim"
*
ngIf=
"data.status == '1'"
ngbTooltip=
"
เปิดใช้งาน
"
container=
"body"
tooltipClass=
"myhrcolor-2"
>
<span
class=
"fa-stack rt_anim"
*
ngIf=
"data.status == '1'"
ngbTooltip=
"
Public
"
container=
"body"
tooltipClass=
"myhrcolor-2"
>
<i
class=
"fa fa-circle fa-stack-2x text-success"
></i>
<i
class=
"
fas fa-check
fa-stack-1x fa-inverse"
></i>
<i
class=
"
fas fa-globe
fa-stack-1x fa-inverse"
></i>
</span>
<span
class=
"fa-stack rt_anim"
*
ngIf=
"data.status == '2'"
ngbTooltip=
"ไม่อนุมัติ"
container=
"body"
tooltipClass=
"myhrcolor-3"
>
...
...
@@ -48,7 +46,7 @@
</td>
<td>
<button
type=
"button"
[
disabled
]="
data
.
status
!=
0
"
class=
"btn btn-circle btn-primary rounded-circle btn-sm mr-2"
(
click
)="
openModal
(
editTemplateModal
,
data
)"
placement=
"top"
ngbTooltip=
"แก้ไข"
>
<button
type=
"button"
class=
"btn btn-circle btn-primary rounded-circle btn-sm mr-2"
(
click
)="
openModal
(
editTemplateModal
,
data
)"
placement=
"top"
ngbTooltip=
"แก้ไข"
>
<i
class=
"fas fa-edit"
></i>
</button>
<button
type=
"button"
class=
"btn btn-circle btn-danger rounded-circle btn-sm mr-2"
(
click
)="
deleteFile
(
data
)"
placement=
"top"
ngbTooltip=
"ลบ"
>
...
...
@@ -66,7 +64,7 @@
<option
[
ngValue
]="
50
"
>
รายการต่อหน้า: 50
</option>
<option
[
ngValue
]="
100
"
>
รายการต่อหน้า: 100
</option>
</select>
<ngb-pagination
[(
page
)]="
page
"
[
pageSize
]="
pageSize
"
[
collectionSize
]="
listDoc
.
length
"
[
maxSize
]="
3
"
[
rotate
]="
true
"
>
<ngb-pagination
[(
page
)]="
page
"
[
pageSize
]="
pageSize
"
[
collectionSize
]="
filterListWidget
()
.
length
"
[
maxSize
]="
3
"
[
rotate
]="
true
"
>
<ng-template
ngbPaginationPrevious
>
ก่อนหน้า
</ng-template>
<ng-template
ngbPaginationNext
>
ถัดไป
</ng-template>
</ngb-pagination>
...
...
@@ -90,40 +88,40 @@
<div
class=
"form-group row"
>
<label
for=
"nameth"
class=
"col-sm-4 col-form-label"
>
ชื่อ (ไทย)
</label>
<div
class=
"col-sm-8"
>
<input
type=
"text"
class=
"form-control"
id=
"nameth"
[(
ngModel
)]="
model
Doc
.
thN
ame
"
>
<input
type=
"text"
class=
"form-control"
id=
"nameth"
[(
ngModel
)]="
model
Widget
.
widgetTn
ame
"
>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"nameeng"
class=
"col-sm-4 col-form-label"
>
ชื่อ (อังกฤษ)
</label>
<div
class=
"col-sm-8"
>
<input
type=
"text"
class=
"form-control"
id=
"nameeng"
[(
ngModel
)]="
model
Doc
.
engN
ame
"
>
<input
type=
"text"
class=
"form-control"
id=
"nameeng"
[(
ngModel
)]="
model
Widget
.
widgetEn
ame
"
>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"position"
class=
"col-sm-4 col-form-label"
>
รายละเอียด (ไทย)
</label>
<div
class=
"col-sm-8"
>
<textarea
class=
"form-control"
[(
ngModel
)]="
model
Doc
.
thDesc
"
></textarea>
<textarea
class=
"form-control"
[(
ngModel
)]="
model
Widget
.
thDesc
"
></textarea>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"position"
class=
"col-sm-4 col-form-label"
>
รายละเอียด (อังกฤษ)
</label>
<div
class=
"col-sm-8"
>
<textarea
class=
"form-control"
[(
ngModel
)]="
model
Doc
.
engDesc
"
></textarea>
<textarea
class=
"form-control"
[(
ngModel
)]="
model
Widget
.
engDesc
"
></textarea>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"position"
class=
"col-sm-4 col-form-label"
>
ภาษาที่รองรับ
</label>
<div
class=
"col-sm-8"
>
<select
class=
"custom-select"
[(
ngModel
)]="
modelDoc
.
langSupport
"
>
<option
value=
"THA"
>
ไทย
</option>
<option
value=
"ENG"
>
English
</option>
</select>
<!-- <input type="text" class="form-control" id="nameeng" [(ngModel)]="modelDoc.langSupport"> -->
</div>
</div>
<label
for=
"position"
class=
"col-sm-4 col-form-label"
>
สถานะ
</label>
<div
class=
"col-sm-8"
>
<select
class=
"custom-select"
[(
ngModel
)]="
modelWidget
.
status
"
>
<option
[
value
]="
0
"
>
Private
</option>
<option
[
value
]="
1
"
>
Public
</option>
</select>
<!-- <input type="text" class="form-control" id="nameeng" [(ngModel)]="modelDoc.langSupport"> -->
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"name"
class=
"col-sm-4 col-form-label"
>
รูปภาพตัวอย่าง
</label>
<div
class=
"col-sm-8"
>
...
...
@@ -132,41 +130,28 @@
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"name"
class=
"col-sm-4 col-form-label"
>
Link ตัวอย่าง
</label>
<div
class=
"col-sm-8"
>
<input
type=
"text"
class=
"form-control"
id=
"nameeng"
[(
ngModel
)]="
modelDoc
.
link1
"
>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"name"
class=
"col-sm-4 col-form-label"
>
แท็ก
</label>
<div
class=
"col-sm-8"
>
<tag-input
[
theme
]="'
bootstrap
'"
[(
ngModel
)]='
model
Doc
.
tags
'
placeholder=
"+แท็ก"
[
onlyFromAutocomplete
]="
true
"
<tag-input
[
theme
]="'
bootstrap
'"
[(
ngModel
)]='
model
Widget
.
tags
'
placeholder=
"+แท็ก"
[
onlyFromAutocomplete
]="
true
"
secondaryPlaceholder=
"กดปุ่ม Enter เพื่อเพิ่มแท็กใหม่"
[
addOnBlur
]="
true
"
[
clearOnBlur
]="
true
"
>
<tag-input-dropdown
[
autocompleteItems
]="
listTag
"
[
showDropdownIfEmpty
]="
true
"
>
</tag-input-dropdown>
</tag-input>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"position"
class=
"col-sm-4 col-form-label"
>
กลุ่ม
</label>
<div
class=
"col-sm-8"
>
<select
class=
"custom-select"
[(
ngModel
)]="
modelDoc
.
group
.
groupId
"
(
change
)="
selectGroup
()"
>
<option
*
ngFor=
"let item of listGroup"
[
ngValue
]="
item
.
groupId
"
>
{{item.thName}}
</option>
</select>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"position"
class=
"col-sm-4 col-form-label"
>
หมายเหตุ
</label>
<div
class=
"col-sm-8"
>
<textarea
class=
"form-control"
[(
ngModel
)]="
model
Doc
.
remark
"
></textarea>
<textarea
class=
"form-control"
[(
ngModel
)]="
model
Widget
.
remark
"
></textarea>
</div>
</div>
<div
class=
"modal-footer "
>
<button
type=
"submit"
class=
"btn btn-info"
(
click
)="
onSumit
()"
[
disabled
]="!
model
Doc
.
thName
||!
modelDoc
.
engN
ame
"
>
บันทึก
</button>
<button
type=
"submit"
class=
"btn btn-info"
(
click
)="
onSumit
()"
[
disabled
]="!
model
Widget
.
widgetTname
||!
modelWidget
.
widgetEn
ame
"
>
บันทึก
</button>
<button
type=
"button"
class=
"btn btn-danger"
(
click
)="
closeBtnClick
()"
>
ปิด
</button>
</div>
</div>
...
...
src/app/apps/list-widgets/list-widgets.component.scss
View file @
dde94786
::ng-deep
ng2-dropdown-menu
{
z-index
:
9999
!
important
;
.ng2-dropdown-menu
{
z-index
:
9999
!
important
;
ng2-menu-item
{
z-index
:
9999
!
important
;
}
}
}
\ No newline at end of file
src/app/apps/list-widgets/list-widgets.component.spec.ts
deleted
100644 → 0
View file @
32691b69
import
{
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
ListWidgetsComponent
}
from
'./list-widgets.component'
;
describe
(
'ListWidgetsComponent'
,
()
=>
{
let
component
:
ListWidgetsComponent
;
let
fixture
:
ComponentFixture
<
ListWidgetsComponent
>
;
beforeEach
(
async
()
=>
{
await
TestBed
.
configureTestingModule
({
declarations
:
[
ListWidgetsComponent
]
})
.
compileComponents
();
});
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
ListWidgetsComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should create'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/apps/list-widgets/list-widgets.component.ts
View file @
dde94786
...
...
@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
import
{
NgbModal
}
from
'@ng-bootstrap/ng-bootstrap'
;
import
{
ConfirmModalComponent
}
from
'../confirm-modal/confirm-modal.component'
;
import
{
AlertModalComponent
}
from
'../alert-modal/alert-modal.component'
;
import
{
DocumentService
}
from
'src/app/service/document.service'
;
import
{
DocumentModel
}
from
'src/app/model/document.model'
;
import
{
UploadService
}
from
'src/app/service/upload.service'
;
import
{
TagService
}
from
'src/app/service/tag.service'
;
...
...
@@ -10,6 +9,8 @@ import { TagModel } from 'src/app/model/tag.mmodel';
import
{
GroupModel
}
from
'src/app/model/group.mmodel'
;
import
{
GroupService
}
from
'src/app/service/group.service'
;
import
{
OpenImageComponent
}
from
'../open-image/open-image.component'
;
import
{
WidgetModel
}
from
'src/app/model/widgets.model'
;
import
{
WidgetService
}
from
'src/app/service/widgets.service'
;
declare
var
require
:
any
const
FileSaver
=
require
(
'file-saver'
);
@
Component
({
...
...
@@ -20,13 +21,15 @@ const FileSaver = require('file-saver');
export
class
ListWidgetsComponent
implements
OnInit
{
page
=
1
;
pageSize
=
10
;
list
Doc
:
Documen
tModel
[]
=
[]
model
Doc
:
DocumentModel
=
new
Documen
tModel
({});
list
Widgets
:
Widge
tModel
[]
=
[]
model
Widget
:
WidgetModel
=
new
Widge
tModel
({});
checkEdit
:
boolean
=
false
search
:
string
=
''
listTag
:
TagModel
[]
=
[]
listGroup
:
GroupModel
[]
=
[]
constructor
(
private
modalService
:
NgbModal
,
private
documentService
:
DocumentService
,
private
uploadService
:
UploadService
,
private
tagService
:
TagService
,
private
groupService
:
GroupService
)
{
constructor
(
private
modalService
:
NgbModal
,
private
widgetService
:
WidgetService
,
private
uploadService
:
UploadService
,
private
tagService
:
TagService
,
private
groupService
:
GroupService
)
{
}
async
onUploadImage
(
event
:
any
)
{
try
{
...
...
@@ -40,7 +43,7 @@ export class ListWidgetsComponent implements OnInit {
}
else
{
const
data
=
await
this
.
uploadService
.
uploadImage
(
formData
).
toPromise
();
if
(
data
)
{
this
.
model
Doc
.
thumbnail
=
data
.
body
.
fileId
this
.
model
Widget
.
picture
=
data
.
body
.
fileId
}
}
}
...
...
@@ -48,49 +51,18 @@ export class ListWidgetsComponent implements OnInit {
console
.
error
(
'Error loading data:'
,
error
);
}
}
onSelectFile
(
event
:
any
,
lang
:
string
)
{
if
(
event
.
target
.
files
&&
event
.
target
.
files
[
0
])
{
const
reader
=
new
FileReader
();
const
file
:
File
=
event
.
target
.
files
[
0
];
reader
.
readAsDataURL
(
event
.
target
.
files
[
0
]);
// read file as data url
reader
.
onload
=
(
event
)
=>
{
// called once readAsDataURL is completed
if
(
event
)
{
const
allowedTypes
=
[
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'application/msword'
];
if
(
!
allowedTypes
.
includes
(
file
.
type
))
{
this
.
openAlertModal
(
'อัพโหลดได้เฉพาะไฟล์ *.doc เท่านั้น'
)
}
else
{
let
base64
=
event
.
target
!
.
result
as
string
if
(
lang
==
'th'
)
{
this
.
modelDoc
.
thDocObj
=
base64
.
split
(
','
)[
1
];
}
else
{
this
.
modelDoc
.
engDocObj
=
base64
.
split
(
','
)[
1
];
}
}
}
}
}
}
async
downloadFile
(
logId
:
string
,
lang
:
string
)
{
try
{
const
data
=
await
this
.
documentService
.
downloadFile
(
logId
,
lang
).
toPromise
();
if
(
data
)
{
FileSaver
.
saveAs
(
new
Blob
([
data
]),
"file_download.doc"
);
}
}
catch
(
error
)
{
console
.
error
(
'Error loading data:'
,
error
);
}
}
deleteFile
(
item
:
DocumentModel
)
{
deleteFile
(
item
:
WidgetModel
)
{
const
modalRef
=
this
.
modalService
.
open
(
ConfirmModalComponent
,
{
centered
:
true
,
backdrop
:
'static'
,
})
modalRef
.
componentInstance
.
message
=
'คุณต้องการลบข้อมูลหรือไม่'
modalRef
.
result
.
then
(
result
=>
{
this
.
documentService
.
deleteExcel
(
item
).
subscribe
(
result
=>
{
this
.
widgetService
.
deleteWidget
(
item
).
subscribe
(
result
=>
{
if
(
result
)
{
this
.
openAlertModal
(
'ลบข้อมูลสำเร็จ'
)
this
.
getList
Doc
();
this
.
getList
Widgets
();
}
else
{
this
.
openAlertModal
(
'ไม่สามารถลบข้อมูลได้'
)
}
...
...
@@ -119,17 +91,18 @@ export class ListWidgetsComponent implements OnInit {
})
modalRef
.
componentInstance
.
message
=
'คุณต้องการอัพเดทข้อมูลหรือไม่'
modalRef
.
result
.
then
(
result
=>
{
this
.
documentService
.
createDoc
(
this
.
modelDoc
).
subscribe
(
result
=>
{
this
.
modelWidget
.
status
=
Number
(
this
.
modelWidget
.
status
)
this
.
widgetService
.
createWidget
(
this
.
modelWidget
).
subscribe
(
result
=>
{
this
.
modalService
.
dismissAll
()
this
.
openAlertModal
(
'อัพเดทข้อมูลสำเร็จ'
)
this
.
getList
Doc
();
//
if (result) {
//
this.modalService.dismissAll()
//
this.openAlertModal('อัพเดทข้อมูลสำเร็จ')
// this.getListDoc
();
//
} else {
//
this.openAlertModal('ไม่สามารถอัพเดทข้อมูลได้')
//
}
this
.
getList
Widgets
();
if
(
result
)
{
this
.
modalService
.
dismissAll
()
this
.
openAlertModal
(
'อัพเดทข้อมูลสำเร็จ'
)
this
.
getListWidgets
();
}
else
{
this
.
openAlertModal
(
'ไม่สามารถอัพเดทข้อมูลได้'
)
}
},
error
=>
{
this
.
openAlertModal
(
error
.
message
)
})
...
...
@@ -142,11 +115,12 @@ export class ListWidgetsComponent implements OnInit {
})
modalRef
.
componentInstance
.
message
=
'คุณต้องการบันทึกข้อมูลหรือไม่'
modalRef
.
result
.
then
(
result
=>
{
this
.
documentService
.
createDoc
(
this
.
modelDoc
).
subscribe
(
result
=>
{
this
.
modelWidget
.
status
=
Number
(
this
.
modelWidget
.
status
)
this
.
widgetService
.
createWidget
(
this
.
modelWidget
).
subscribe
(
result
=>
{
if
(
result
)
{
this
.
modalService
.
dismissAll
()
this
.
openAlertModal
(
'บันทึกข้อมูลสำเร็จ'
)
this
.
getList
Doc
();
this
.
getList
Widgets
();
}
else
{
this
.
openAlertModal
(
'ไม่สามารถสร้างเอกสารได้'
)
}
...
...
@@ -162,10 +136,10 @@ export class ListWidgetsComponent implements OnInit {
this
.
onCreate
();
}
}
async
get
Excel
ById
(
targetModal
:
NgbModal
,
id
:
string
)
{
async
get
Widget
ById
(
targetModal
:
NgbModal
,
id
:
string
)
{
try
{
const
data
=
await
this
.
documentService
.
getDoc
ById
(
id
).
toPromise
();
this
.
model
Doc
=
new
Documen
tModel
(
data
)
const
data
=
await
this
.
widgetService
.
getWidget
ById
(
id
).
toPromise
();
this
.
model
Widget
=
new
Widge
tModel
(
data
)
if
(
data
)
{
this
.
modalService
.
open
(
targetModal
,
{
centered
:
true
,
...
...
@@ -177,12 +151,13 @@ export class ListWidgetsComponent implements OnInit {
console
.
error
(
'Error loading data:'
,
error
);
}
}
openModal
(
targetModal
:
NgbModal
,
item
?:
DocumentModel
)
{
openModal
(
targetModal
:
NgbModal
,
item
?:
WidgetModel
)
{
console
.
log
(
"🚀 ~ ListWidgetsComponent ~ openModal ~ item:"
,
item
)
if
(
item
)
{
this
.
get
ExcelById
(
targetModal
,
item
.
log
Id
)
this
.
get
WidgetById
(
targetModal
,
item
.
widget
Id
)
this
.
checkEdit
=
true
}
else
{
this
.
model
Doc
=
new
Documen
tModel
({});
this
.
model
Widget
=
new
Widge
tModel
({});
this
.
checkEdit
=
false
this
.
modalService
.
open
(
targetModal
,
{
centered
:
true
,
...
...
@@ -194,45 +169,31 @@ export class ListWidgetsComponent implements OnInit {
}
getStatus
(
status
:
string
)
{
if
(
status
==
'0'
)
{
return
'
รออนุมัติ
'
return
'
Private
'
}
else
if
(
status
==
'1'
)
{
return
'เปิดใช้งาน'
}
else
if
(
status
==
'2'
)
{
return
'ไม่อนุมัติ'
}
return
'Public'
}
}
async
getList
Doc
()
{
async
getList
Widgets
()
{
try
{
const
data
=
await
this
.
documentService
.
getListDoc
().
toPromise
();
this
.
list
Doc
=
data
.
map
(
x
=>
new
Documen
tModel
(
x
))
const
data
=
await
this
.
widgetService
.
getListWidgets
().
toPromise
();
this
.
list
Widgets
=
data
.
map
(
x
=>
new
Widge
tModel
(
x
))
}
catch
(
error
)
{
console
.
error
(
'Error loading data:'
,
error
);
}
}
filterList
Doc
()
{
return
this
.
list
Doc
.
filter
(
x
=>
x
.
thName
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
x
.
engN
ame
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
()))
filterList
Widget
()
{
return
this
.
list
Widgets
.
filter
(
x
=>
x
.
widgetTname
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
())
||
x
.
widgetEn
ame
.
toLowerCase
().
includes
(
this
.
search
.
toLowerCase
()))
}
ngOnInit
()
{
this
.
getList
Doc
();
this
.
getList
Widgets
();
this
.
getListTag
();
this
.
getListGroup
();
}
async
getListGroup
()
{
try
{
const
data
=
await
this
.
groupService
.
getList
().
toPromise
();
this
.
listGroup
=
data
.
map
(
x
=>
new
GroupModel
(
x
))
}
catch
(
error
)
{
console
.
error
(
'Error loading data:'
,
error
);
}
}
selectGroup
()
{
let
findData
=
this
.
listGroup
.
find
(
x
=>
x
.
groupId
==
this
.
modelDoc
.
group
.
groupId
)
this
.
modelDoc
.
group
=
findData
?
new
GroupModel
(
findData
)
:
new
GroupModel
({})
}
async
getListTag
()
{
try
{
const
data
=
await
this
.
tagService
.
getList
().
toPromise
();
const
data
=
await
this
.
tagService
.
getList
Widgets
().
toPromise
();
this
.
listTag
=
data
.
map
(
x
=>
new
TagModel
(
x
))
}
catch
(
error
)
{
console
.
error
(
'Error loading data:'
,
error
);
...
...
src/app/apps/portal-create-category/portal-create-category.component.ts
View file @
dde94786
...
...
@@ -6,6 +6,7 @@ import { Router } from '@angular/router';
import
{
ExcelService
}
from
'src/app/service/excel.service'
;
import
{
DocumentService
}
from
'src/app/service/document.service'
;
import
{
CourseService
}
from
'src/app/service/course.service'
;
import
{
WidgetService
}
from
'src/app/service/widgets.service'
;
@
Component
({
selector
:
'app-portal-create-category'
,
...
...
@@ -14,7 +15,12 @@ import { CourseService } from 'src/app/service/course.service';
})
export
class
PortalCreateCategoryComponent
implements
OnInit
{
constructor
(
private
modalService
:
NgbModal
,
private
routes
:
Router
,
private
excelService
:
ExcelService
,
private
documentService
:
DocumentService
,
private
courseService
:
CourseService
)
{}
constructor
(
private
modalService
:
NgbModal
,
private
routes
:
Router
,
private
excelService
:
ExcelService
,
private
documentService
:
DocumentService
,
private
courseService
:
CourseService
,
private
widgetService
:
WidgetService
)
{}
page
=
1
;
pageSize
=
10
;
...
...
@@ -71,6 +77,7 @@ export class PortalCreateCategoryComponent implements OnInit {
const
countExcel
=
await
this
.
excelService
.
getCount
().
toPromise
();
const
countDoc
=
await
this
.
documentService
.
getCount
().
toPromise
();
const
countCourse
=
await
this
.
courseService
.
getCount
().
toPromise
();
const
countWidgets
=
await
this
.
widgetService
.
getCount
().
toPromise
();
this
.
testdata
.
forEach
((
x
,
i
)
=>
{
if
(
i
==
0
){
x
.
document
=
countExcel
.
toString
()
...
...
@@ -78,6 +85,8 @@ export class PortalCreateCategoryComponent implements OnInit {
x
.
document
=
countDoc
.
toString
()
}
else
if
(
i
==
2
){
x
.
document
=
countCourse
.
toString
()
}
else
if
(
i
==
3
){
x
.
document
=
countWidgets
.
toString
()
}
})
}
catch
(
error
)
{
...
...
src/app/model/widgets.model.ts
0 → 100644
View file @
dde94786
import
{
environment
}
from
"src/environments/environment"
import
{
TagModel
}
from
"./tag.mmodel"
import
{
GroupModel
}
from
"./group.mmodel"
export
interface
WidgetModel
{
widgetId
:
string
widgetTname
:
string
widgetEname
:
string
thDesc
:
string
engDesc
:
string
chartType
:
string
widgetHeight
:
number
widgetWidth
:
number
seriesColumn
:
string
picture
:
string
remark
:
string
status
:
number
tags
:
TagModel
[]
}
export
class
WidgetModel
implements
WidgetModel
{
widgetId
:
string
widgetTname
:
string
widgetEname
:
string
thDesc
:
string
engDesc
:
string
chartType
:
string
widgetHeight
:
number
widgetWidth
:
number
seriesColumn
:
string
picture
:
string
remark
:
string
status
:
number
tags
:
TagModel
[]
constructor
(
data
:
Partial
<
any
>
)
{
this
.
widgetId
=
data
.
widgetId
?
data
.
widgetId
:
''
this
.
widgetTname
=
data
.
widgetTname
?
data
.
widgetTname
:
''
this
.
widgetEname
=
data
.
widgetEname
?
data
.
widgetEname
:
''
this
.
thDesc
=
data
.
thDesc
?
data
.
thDesc
:
''
this
.
engDesc
=
data
.
engDesc
?
data
.
engDesc
:
''
this
.
chartType
=
data
.
chartType
?
data
.
chartType
:
''
this
.
widgetHeight
=
data
.
widgetHeight
?
data
.
widgetHeight
:
0
this
.
widgetWidth
=
data
.
widgetWidth
?
data
.
widgetWidth
:
0
this
.
status
=
data
.
status
?
data
.
status
:
0
this
.
seriesColumn
=
data
.
seriesColumn
?
data
.
seriesColumn
:
''
this
.
picture
=
data
.
picture
?
data
.
picture
:
''
this
.
remark
=
data
.
remark
?
data
.
remark
:
''
this
.
tags
=
data
.
tags
?
data
.
tags
:[]
}
getImage
(){
if
(
this
.
picture
){
return
environment
.
url
+
"files/image/"
+
this
.
picture
}
else
{
return
'assets/images/big/auth-bg.jpg'
}
}
}
\ No newline at end of file
src/app/service/tag.service.ts
View file @
dde94786
...
...
@@ -17,4 +17,7 @@ export class TagService {
getList
():
Observable
<
TagModel
[]
>
{
return
this
.
http
.
get
<
TagModel
[]
>
(
this
.
url
+
"tag/lists"
)
}
getListWidgets
():
Observable
<
TagModel
[]
>
{
return
this
.
http
.
get
<
TagModel
[]
>
(
this
.
url
+
"widget-tag/lists"
)
}
}
src/app/service/widgets.service.ts
0 → 100644
View file @
dde94786
import
{
Injectable
}
from
'@angular/core'
;
import
{
environment
}
from
'src/environments/environment'
;
import
{
HttpClient
,
HttpHeaders
}
from
'@angular/common/http'
;
import
{
Observable
,
of
}
from
'rxjs'
;
import
{
map
,
tap
}
from
'rxjs/operators'
;
import
{
DocumentModel
}
from
'../model/document.model'
;
import
{
DocumentContentModel
}
from
'../model/document-content.model'
;
import
{
WidgetModel
}
from
'../model/widgets.model'
;
@
Injectable
({
providedIn
:
'root'
})
export
class
WidgetService
{
url
=
environment
.
url
createStatus
:
boolean
=
true
constructor
(
private
http
:
HttpClient
)
{
}
getListWidgets
(
status
?:
string
):
Observable
<
WidgetModel
[]
>
{
if
(
status
)
{
return
this
.
http
.
get
<
WidgetModel
[]
>
(
this
.
url
+
"widget/lists?status="
+
status
)
}
else
{
return
this
.
http
.
get
<
WidgetModel
[]
>
(
this
.
url
+
"widget/lists"
)
}
}
getListExcelContent
(
status
?:
string
):
Observable
<
DocumentContentModel
[]
>
{
return
this
.
http
.
get
<
DocumentContentModel
[]
>
(
this
.
url
+
"document-center/content/lists"
)
}
getWidgetById
(
widgetId
:
string
):
Observable
<
WidgetModel
>
{
return
this
.
http
.
get
<
WidgetModel
>
(
this
.
url
+
"widget/"
+
widgetId
)
}
createWidget
(
model
:
WidgetModel
):
Observable
<
any
>
{
let
body
:
any
=
model
return
this
.
http
.
post
(
this
.
url
+
'widget'
,
body
)
}
deleteWidget
(
model
:
WidgetModel
):
Observable
<
any
>
{
let
body
=
{
widgetId
:
model
.
widgetId
}
let
option
=
{
headers
:
new
HttpHeaders
({
"Content-Type"
:
"application/json"
,
}),
body
:
body
}
return
this
.
http
.
delete
<
any
>
(
this
.
url
+
'widget'
,
option
)
}
deleteExcelContent
(
model
:
DocumentContentModel
):
Observable
<
any
>
{
let
body
=
{
docId
:
model
.
docId
}
let
option
=
{
headers
:
new
HttpHeaders
({
"Content-Type"
:
"application/json"
,
}),
body
:
body
}
return
this
.
http
.
delete
<
any
>
(
this
.
url
+
'document-center/content'
,
option
)
}
getCount
(
status
?:
string
):
Observable
<
number
>
{
return
this
.
http
.
get
<
number
>
(
this
.
url
+
"widget/count"
)
}
getCountContent
(
status
?:
string
):
Observable
<
number
>
{
return
this
.
http
.
get
<
number
>
(
this
.
url
+
"document-center/content/count"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment