ywana-core8 0.0.681 → 0.0.683
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +92 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +92 -91
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +92 -91
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionAPI.js +1 -1
- package/src/domain/CollectionPage.js +3 -63
- package/src/incubator/task.js +10 -38
package/package.json
CHANGED
@@ -46,7 +46,7 @@ import { isEmpty} from '../commons'
|
|
46
46
|
|
47
47
|
return {
|
48
48
|
|
49
|
-
all(filters, likes, page) {
|
49
|
+
all(filters, likes = [], page) {
|
50
50
|
let queryParams = page ? `?page=${page}&` : "?"
|
51
51
|
const filterQuery = objectToQueryParamString(filters, likes)
|
52
52
|
queryParams = `${queryParams}${filterQuery}`
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import equal from 'deep-equal'
|
2
2
|
import React, { Fragment, useContext, useEffect, useRef, useState, useMemo } from 'react'
|
3
|
-
import { HTTPClient, Session } from '../http'
|
4
3
|
import { PageContext } from '../site'
|
4
|
+
import { SiteContext } from '../site/siteContext'
|
5
5
|
import { Button, Header, Icon, List, Menu, MenuIcon, MenuItem, Text, Tree, TreeItem, TreeNode, TextField, Chip, Tooltip } from '../html'
|
6
|
-
import { Content, TYPES } from './ContentType'
|
7
6
|
import { ContentEditor, TabbedContentEditor, TreededContentEditor } from './ContentEditor'
|
8
7
|
import { CreateContentDialog } from './CreateContentDialog'
|
9
|
-
import {
|
8
|
+
import { CollectionAPI } from './CollectionAPI'
|
9
|
+
import { Content, TYPES } from './ContentType'
|
10
10
|
import "./CollectionPage.css"
|
11
11
|
|
12
12
|
/**
|
@@ -523,63 +523,3 @@ export const CollectionContext = (url, field, host, page, fetching, versioning =
|
|
523
523
|
}
|
524
524
|
}
|
525
525
|
|
526
|
-
/**
|
527
|
-
* Collection API
|
528
|
-
*/
|
529
|
-
const CollectionAPI = (url, host) => {
|
530
|
-
|
531
|
-
const http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
|
532
|
-
|
533
|
-
return {
|
534
|
-
all(filters, page) {
|
535
|
-
let queryParams = page ? `?page=${page}&` : "?"
|
536
|
-
if (filters) {
|
537
|
-
const filterQuery = Object.keys(filters).reduce((query, key) => {
|
538
|
-
const value = filters[key]
|
539
|
-
if (typeof (value) === 'boolean') {
|
540
|
-
return query.concat(`${key}=${value}&`)
|
541
|
-
} else if (Array.isArray(value)) {
|
542
|
-
const param = value.length === 0 ? '' : value.reduce((param, item) => {
|
543
|
-
param = param.concat(`${key}=${item}&`)
|
544
|
-
return param
|
545
|
-
}, "")
|
546
|
-
return query.concat(param)
|
547
|
-
} else {
|
548
|
-
return query.concat(`${key}=%${filters[key]}%&`)
|
549
|
-
}
|
550
|
-
}, "")
|
551
|
-
queryParams = queryParams.concat(filterQuery)
|
552
|
-
}
|
553
|
-
return http.GET(url + queryParams)
|
554
|
-
},
|
555
|
-
|
556
|
-
find(id) {
|
557
|
-
return http.GET(`${url}/${id}`)
|
558
|
-
},
|
559
|
-
|
560
|
-
create(form) {
|
561
|
-
const body = JSON.stringify(form)
|
562
|
-
return http.POST(url, body)
|
563
|
-
},
|
564
|
-
|
565
|
-
update(form) {
|
566
|
-
const body = JSON.stringify(form)
|
567
|
-
return http.PUT(`${url}/${form.id}`, body)
|
568
|
-
},
|
569
|
-
|
570
|
-
patch(id, form) {
|
571
|
-
const body = JSON.stringify(form)
|
572
|
-
return http.PATCH(`${url}/${id}`, body)
|
573
|
-
},
|
574
|
-
|
575
|
-
updateProperty(id, propertyName, form) {
|
576
|
-
const body = JSON.stringify(form)
|
577
|
-
return http.PUT(`${url}/${id}/${propertyName}`, body)
|
578
|
-
},
|
579
|
-
|
580
|
-
remove(id) {
|
581
|
-
return http.DELETE(`${url}/${id}`)
|
582
|
-
}
|
583
|
-
|
584
|
-
}
|
585
|
-
}
|
package/src/incubator/task.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import React, { useEffect, useContext, useState } from 'react'
|
2
2
|
import { LinearProgress, Header, DataTable, Icon } from '../html'
|
3
|
-
import { HTTPClient, Session } from '../http'
|
4
3
|
import "./task.css"
|
5
4
|
|
6
5
|
/**
|
@@ -13,12 +12,12 @@ export const TaskContext = React.createContext({})
|
|
13
12
|
*/
|
14
13
|
export const TaskContextProvider = (props) => {
|
15
14
|
|
16
|
-
const { host, url, children } = props
|
17
|
-
const API =
|
15
|
+
const { host, url = "tasks", children } = props
|
16
|
+
const API = CollectionAPI(url, host)
|
18
17
|
|
19
|
-
async function tasks() {
|
18
|
+
async function tasks(filters, likes) {
|
20
19
|
try {
|
21
|
-
const response = await API.
|
20
|
+
const response = await API.all(filters, likes);
|
22
21
|
return response;
|
23
22
|
} catch (error) {
|
24
23
|
console.log("tasks error", error);
|
@@ -27,7 +26,7 @@ export const TaskContextProvider = (props) => {
|
|
27
26
|
|
28
27
|
async function task(id) {
|
29
28
|
try {
|
30
|
-
const response = await API.
|
29
|
+
const response = await API.find(id);
|
31
30
|
return response;
|
32
31
|
} catch (error) {
|
33
32
|
console.log("task error", error);
|
@@ -36,7 +35,7 @@ export const TaskContextProvider = (props) => {
|
|
36
35
|
|
37
36
|
async function createTask(task) {
|
38
37
|
try {
|
39
|
-
const response = await API.
|
38
|
+
const response = await API.create(task);
|
40
39
|
return response;
|
41
40
|
} catch (error) {
|
42
41
|
console.log("createTask error", error);
|
@@ -45,7 +44,7 @@ export const TaskContextProvider = (props) => {
|
|
45
44
|
|
46
45
|
async function removeTask(id) {
|
47
46
|
try {
|
48
|
-
const response = await API.
|
47
|
+
const response = await API.remove(id);
|
49
48
|
return response;
|
50
49
|
} catch (error) {
|
51
50
|
console.log("removeTask error", error);
|
@@ -66,35 +65,6 @@ export const TaskContextProvider = (props) => {
|
|
66
65
|
)
|
67
66
|
}
|
68
67
|
|
69
|
-
/**
|
70
|
-
* API
|
71
|
-
*/
|
72
|
-
const TaskAPI = (url = "/tasks", host) => {
|
73
|
-
|
74
|
-
const http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
|
75
|
-
|
76
|
-
return {
|
77
|
-
|
78
|
-
tasks() {
|
79
|
-
return http.GET(url)
|
80
|
-
},
|
81
|
-
|
82
|
-
task(id) {
|
83
|
-
return http.GET(`${url}/${id}`)
|
84
|
-
},
|
85
|
-
|
86
|
-
createTask(task) {
|
87
|
-
const body = JSON.stringify(task)
|
88
|
-
return http.POST(url, body)
|
89
|
-
},
|
90
|
-
|
91
|
-
removeTask(id) {
|
92
|
-
return http.DELETE(`${url}/${id}`)
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
}
|
97
|
-
|
98
68
|
/**
|
99
69
|
* TaskProgress
|
100
70
|
*/
|
@@ -127,6 +97,8 @@ export const TaskProgress = (props) => {
|
|
127
97
|
*/
|
128
98
|
export const TaskMonitor = (props) => {
|
129
99
|
|
100
|
+
const { title = "Task Monitor" } = props
|
101
|
+
|
130
102
|
const context = useContext(TaskContext)
|
131
103
|
const [tasks = [], setTasks] = useState([])
|
132
104
|
|
@@ -180,7 +152,7 @@ export const TaskMonitor = (props) => {
|
|
180
152
|
|
181
153
|
return (
|
182
154
|
<div className="task-manager">
|
183
|
-
<Header icon="list" title=
|
155
|
+
<Header icon="list" title={title} />
|
184
156
|
<main>
|
185
157
|
<DataTable {...table} />
|
186
158
|
</main>
|