Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Yossapol
/
wds-react
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1b5a6d16
authored
Feb 26, 2019
by
jutawuth nantawan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add request api
1 parent
d0dba98e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
34 deletions
README.md
README.md
View file @
1b5a6d1
...
...
@@ -91,7 +91,7 @@
ตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
ทั้งหมด คั่นระหว่างคำด้วย "_" เช่น
```
javascrip
t
```
reac
t
// urlConstant.js
export
const
URI
=
"localhost:3000"
...
...
@@ -108,7 +108,7 @@ export const URL_LOGIN = URI + "/login"
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
```
javascrip
t
```
reac
t
// wdsUtils.js
/**
...
...
@@ -135,7 +135,7 @@ export const _calculateAdd = (input1, input2) => {
การเขียน JS doc
```
javascrip
t
```
reac
t
// parameter input
// @param เว้นวรรค ตามด้วย "{ประเภทตัวแปร}" เว้นวรรค ตามด้วย "ชื่อตัวแปร"
@
param
{
data
type
}
parameter
...
...
@@ -155,6 +155,8 @@ export const _calculateAdd = (input1, input2) => {
### Variable
ขึ้นต้นด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
...
...
@@ -163,7 +165,7 @@ export const _calculateAdd = (input1, input2) => {
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
```
javascrip
t
```
reac
t
const
input1Parameter
let
input2Parameter
```
...
...
@@ -174,7 +176,7 @@ let input2Parameter
ขึ้นต้นด้วยคำว่า "is" หรือ "has" ตามบริบทของการใช้งาน
```
javascrip
t
```
reac
t
const
isValid
=
true
const
hasChild
=
false
```
...
...
@@ -185,7 +187,7 @@ const hasChild = false
ตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
ทั้งหมด คั่นระหว่างคำด้วย "_"
```
javascrip
t
```
reac
t
const
page_name
=
"Home"
;
```
...
...
@@ -201,7 +203,7 @@ const page_name = "Home";
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
```
javascrip
t
```
reac
t
componentDidMount
()
{
// To Do
}
...
...
@@ -217,7 +219,7 @@ componentDidMount() {
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
```
javascrip
t
```
reac
t
onClick
=
(
e
)
=>
{
// Recommended
}
...
...
@@ -238,7 +240,7 @@ function onClick(e) {
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
```
javascrip
t
```
reac
t
_validateFromSubmit
=
(
e
)
=>
{
// Recommended
}
...
...
@@ -253,7 +255,7 @@ function _validateFromSubmit(e) {
### Class
```
javascrip
t
```
reac
t
import
React
,
{
Component
,
Fragment
}
from
'react'
;
export
default
class
HomePage
extends
Component
{
...
...
@@ -278,7 +280,7 @@ export default class HomePage extends Component {
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
ตามด้วยคำว่า "Component"
```
javascrip
t
```
reac
t
import
React
,
{
Component
,
Fragment
}
from
'react'
;
import
{
Input
,
Icon
}
from
'antd'
;
...
...
@@ -298,11 +300,9 @@ export default class WDSUsernameTextfieldComponent extends Component {
ขึ้นต้นด้วย "WDS " ตามด้วย ชื่อของ Template ที่ขึ้นต้นด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
คั่นระหว่างคำด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
ตามด้วยคำว่า "Template"
```
javascrip
t
```
reac
t
import
React
,
{
Component
}
from
'react'
;
import
{
Layout
}
from
'antd'
;
...
...
@@ -335,7 +335,7 @@ export default class WDSFooterTemplate extends Component {
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
ตามด้วยคำว่า "Page"
```
javascrip
t
```
reac
t
import
React
from
'react'
;
import
Axios
from
'axios'
;
...
...
@@ -375,7 +375,7 @@ export default class LoginPage extends React.Component {
### Import
```
javascrip
t
```
reac
t
// กลุ่มของ Dependency Library
import
React
,
{
Component
,
Fragment
}
from
'react'
;
import
Axios
from
'axios'
;
...
...
@@ -414,39 +414,31 @@ import '../../resources/style/css/style.css';
#### Publish (emit)
```
javascrip
t
```
reac
t
this
.
props
.
eventEmitter
.
emit
(
actionName
,
data
)
```
#### Subscription (on)
#### Subscription (on)
```
javascrip
t
```
reac
t
this
.
props
.
eventEmitter
.
on
(
actionName
,
listener
)
```
#### Unsubscription (removeAllListeners)
```
javascrip
t
```
reac
t
this
.
props
.
eventEmitter
.
removeListener
()
```
## 4. Routing
### Switch
Switch เป็นการทำ Route แบบเปลี่ยนทั้งหน้า เมื่อ url เปลี่ยนหน้าจอจะแสดงผลที่ตรงกับ path ที่ระบุไว้เพียงหน้าจอเดียว โดยเรียงลำดับการแสดงผลจากบนลงล่าง
```
javascrip
t
```
reac
t
// app.js
import
React
,
{
Component
}
from
'react'
;
...
...
@@ -467,7 +459,7 @@ export default App;
import ไฟล์ mainRoutes.js เพื่อใช้ในการกำหนดเส้นทาง App.js
```
javascrip
t
```
reac
t
// mainRoutes.js
import
React
from
'react'
;
...
...
@@ -486,7 +478,6 @@ export default ({ eventEmitter }) => (
/>
</
Switch
>
);
```
...
...
@@ -495,7 +486,7 @@ export default ({ eventEmitter }) => (
match เป็นการแสดงผล component เฉพาะส่วน ซึ่งสามารถทำงานภายใต้หน้าจอหลักได้
```
javascrip
t
```
reac
t
// mainPage.jsx
import
React
from
'react'
;
...
...
@@ -530,7 +521,7 @@ export default class MainPage extends React.Component {
import ไฟล์ contentRoutes.js เพื่อใช้ในการกำหนดเส้นทาง App.js
```
javascrip
t
```
reac
t
//contentRoutes.js
import
React
from
'react'
;
...
...
@@ -558,7 +549,52 @@ export default ({ match }) => {
## 5. Calling API
call
#### post
ขึ้นต้นด้วยคำว่า "_request" ตามด้วย ชื่อของ API ที่ขึ้นต้นด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
ตามด้วยคำว่า "Api"
```
react
import
React
,
{
Component
}
from
'react'
;
import
Axios
from
'axios'
;
import
{
Layout
}
from
'antd'
;
import
Header
from
'../../templates/layout/header/WDSHeaderTemplate'
;
import
*
as
UrlConstants
from
'../../resources/js/constants/urlConstants'
;
export
default
class
MainPage
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
collapsed
:
false
};
}
componentDidMount
()
{
this
.
_requestGetSystemInfoApi
();
}
_requestGetSystemInfoApi
=
async
()
=>
{
const
params
=
{};
const
results
=
await
Axios
.
post
(
UrlConstants
.
URL_GET_SYSTEM_INFO
,
params
);
if
(
results
.
data
.
success
)
{
// TO DO
}
};
render
()
{
return
(
<
Layout
style=
{
{
minHeight
:
'100vh'
}
}
>
<
Header
/>
</
Layout
>
);
}
}
```
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment