1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _extends2 = require('babel-runtime/helpers/extends');
|
8 |
|
9 | var _extends3 = _interopRequireDefault(_extends2);
|
10 |
|
11 | exports.default = function () {
|
12 | var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { loaded: false };
|
13 | var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
14 |
|
15 | switch (action.type) {
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 | case LOAD_SUCCESS:
|
22 | return (0, _extends3.default)({}, state, {
|
23 | components: (0, _extends3.default)({}, action.result.data),
|
24 | loading: false,
|
25 | loaded: true
|
26 | });
|
27 | case LOAD_FAIL:
|
28 | return (0, _extends3.default)({}, state, {
|
29 | loading: false,
|
30 | loaded: false,
|
31 | error: action.error
|
32 | });
|
33 | case SEARCH_SUCCESS:
|
34 | return (0, _extends3.default)({}, state, {
|
35 | searchData: (0, _extends3.default)({}, action.result.data),
|
36 | search_loading: false,
|
37 | search_loaded: true
|
38 | });
|
39 | case SEARCH_FAIL:
|
40 | return (0, _extends3.default)({}, state, {
|
41 | search_loading: false,
|
42 | search_loaded: false,
|
43 | search_error: action.error
|
44 | });
|
45 | default:
|
46 | return state;
|
47 | }
|
48 | };
|
49 |
|
50 | exports.saveConfigHoc = saveConfigHoc;
|
51 | exports.searchConfigHoc = searchConfigHoc;
|
52 |
|
53 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | var LOAD = 'hoc_dynamic-load-component/center/LOAD';
|
59 | var LOAD_SUCCESS = 'hoc_dynamic-load-component/center/LOAD_SUCCESS';
|
60 | var LOAD_FAIL = 'hoc_dynamic-load-component/center/LOAD_FAIL';
|
61 |
|
62 | var SEARCH = 'hoc_dynamic-load-component/SEARCH/LOAD';
|
63 | var SEARCH_SUCCESS = 'hoc_dynamic-load-component/SEARCH/LOAD_SUCCESS';
|
64 | var SEARCH_FAIL = 'hoc_dynamic-load-component/SEARCH/LOAD_FAIL';
|
65 |
|
66 | function saveConfigHoc(values) {
|
67 | return {
|
68 | types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
|
69 | promise: function promise(client) {
|
70 | return client.get('/module-manage-service/operating/modules/componentConf', { params: values }).then(function (ret) {
|
71 | return ret && ret.data;
|
72 | });
|
73 | }
|
74 | };
|
75 | }
|
76 |
|
77 | function searchConfigHoc(values) {
|
78 | return {
|
79 | types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
|
80 | promise: function promise(client) {
|
81 | return client.get('/module-manage-service/operating/modules/queryComponentConfig', { params: values }).then(function (ret) {
|
82 | return ret && ret.data && ret.data.config && JSON.parse(ret.data.config);
|
83 | });
|
84 | }
|
85 | };
|
86 | }
|
87 |
|
\ | No newline at end of file |