Skip to content

Commit 3dcb234

Browse files
authored
Merge pull request #126 from yoution/feature-devices-lookup
Feature devices lookup
2 parents 43c61a5 + 28cba7f commit 3dcb234

File tree

6 files changed

+419
-1
lines changed

6 files changed

+419
-1
lines changed

__tests__/__snapshots__/index.js.snap

+8
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ Object {
6262
"getAllCountriesInit": [Function],
6363
"getCountriesDone": [Function],
6464
"getCountriesInit": [Function],
65+
"getManufacturersDone": [Function],
66+
"getManufacturersInit": [Function],
67+
"getModelsDone": [Function],
68+
"getModelsInit": [Function],
69+
"getOsesDone": [Function],
70+
"getOsesInit": [Function],
6571
"getSkillTagsDone": [Function],
6672
"getSkillTagsInit": [Function],
73+
"getTypesDone": [Function],
74+
"getTypesInit": [Function],
6775
},
6876
"memberTasks": Object {
6977
"dropAll": [Function],

__tests__/actions/__snapshots__/lookup.js.snap

+8
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ Object {
77
"getAllCountriesInit": [Function],
88
"getCountriesDone": [Function],
99
"getCountriesInit": [Function],
10+
"getManufacturersDone": [Function],
11+
"getManufacturersInit": [Function],
12+
"getModelsDone": [Function],
13+
"getModelsInit": [Function],
14+
"getOsesDone": [Function],
15+
"getOsesInit": [Function],
1016
"getSkillTagsDone": [Function],
1117
"getSkillTagsInit": [Function],
18+
"getTypesDone": [Function],
19+
"getTypesInit": [Function],
1220
},
1321
}
1422
`;

__tests__/reducers/__snapshots__/lookup.js.snap

+80
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ Object {
99
"countryCode": "AFG",
1010
},
1111
],
12+
"hasMoreModels": false,
13+
"hasMoreOses": false,
1214
"loadingCountriesError": false,
1315
"loadingSkillTagsError": true,
16+
"manufacturers": Array [],
17+
"modelPage": 1,
18+
"models": Array [],
19+
"osPage": 1,
20+
"oses": Array [],
1421
"skillTags": Array [
1522
Object {
1623
"domain": "SKILLS",
@@ -19,6 +26,7 @@ Object {
1926
"status": "APPROVED",
2027
},
2128
],
29+
"types": Array [],
2230
}
2331
`;
2432

@@ -31,8 +39,15 @@ Object {
3139
"countryCode": "AFG",
3240
},
3341
],
42+
"hasMoreModels": false,
43+
"hasMoreOses": false,
3444
"loadingCountriesError": true,
3545
"loadingSkillTagsError": true,
46+
"manufacturers": Array [],
47+
"modelPage": 1,
48+
"models": Array [],
49+
"osPage": 1,
50+
"oses": Array [],
3651
"skillTags": Array [
3752
Object {
3853
"domain": "SKILLS",
@@ -41,14 +56,22 @@ Object {
4156
"status": "APPROVED",
4257
},
4358
],
59+
"types": Array [],
4460
}
4561
`;
4662

4763
exports[`Default reducer Get skill tags 1`] = `
4864
Object {
4965
"allCountries": Array [],
5066
"countries": Array [],
67+
"hasMoreModels": false,
68+
"hasMoreOses": false,
5169
"loadingSkillTagsError": false,
70+
"manufacturers": Array [],
71+
"modelPage": 1,
72+
"models": Array [],
73+
"osPage": 1,
74+
"oses": Array [],
5275
"skillTags": Array [
5376
Object {
5477
"domain": "SKILLS",
@@ -57,14 +80,22 @@ Object {
5780
"status": "APPROVED",
5881
},
5982
],
83+
"types": Array [],
6084
}
6185
`;
6286

6387
exports[`Default reducer Get skill tags error 1`] = `
6488
Object {
6589
"allCountries": Array [],
6690
"countries": Array [],
91+
"hasMoreModels": false,
92+
"hasMoreOses": false,
6793
"loadingSkillTagsError": true,
94+
"manufacturers": Array [],
95+
"modelPage": 1,
96+
"models": Array [],
97+
"osPage": 1,
98+
"oses": Array [],
6899
"skillTags": Array [
69100
Object {
70101
"domain": "SKILLS",
@@ -73,14 +104,23 @@ Object {
73104
"status": "APPROVED",
74105
},
75106
],
107+
"types": Array [],
76108
}
77109
`;
78110

79111
exports[`Default reducer Initial state 1`] = `
80112
Object {
81113
"allCountries": Array [],
82114
"countries": Array [],
115+
"hasMoreModels": false,
116+
"hasMoreOses": false,
117+
"manufacturers": Array [],
118+
"modelPage": 1,
119+
"models": Array [],
120+
"osPage": 1,
121+
"oses": Array [],
83122
"skillTags": Array [],
123+
"types": Array [],
84124
}
85125
`;
86126

@@ -93,8 +133,15 @@ Object {
93133
"countryCode": "AFG",
94134
},
95135
],
136+
"hasMoreModels": false,
137+
"hasMoreOses": false,
96138
"loadingCountriesError": false,
97139
"loadingSkillTagsError": true,
140+
"manufacturers": Array [],
141+
"modelPage": 1,
142+
"models": Array [],
143+
"osPage": 1,
144+
"oses": Array [],
98145
"skillTags": Array [
99146
Object {
100147
"domain": "SKILLS",
@@ -103,6 +150,7 @@ Object {
103150
"status": "APPROVED",
104151
},
105152
],
153+
"types": Array [],
106154
}
107155
`;
108156

@@ -115,8 +163,15 @@ Object {
115163
"countryCode": "AFG",
116164
},
117165
],
166+
"hasMoreModels": false,
167+
"hasMoreOses": false,
118168
"loadingCountriesError": true,
119169
"loadingSkillTagsError": true,
170+
"manufacturers": Array [],
171+
"modelPage": 1,
172+
"models": Array [],
173+
"osPage": 1,
174+
"oses": Array [],
120175
"skillTags": Array [
121176
Object {
122177
"domain": "SKILLS",
@@ -125,14 +180,22 @@ Object {
125180
"status": "APPROVED",
126181
},
127182
],
183+
"types": Array [],
128184
}
129185
`;
130186

131187
exports[`Factory without server side rendering Get skill tags 1`] = `
132188
Object {
133189
"allCountries": Array [],
134190
"countries": Array [],
191+
"hasMoreModels": false,
192+
"hasMoreOses": false,
135193
"loadingSkillTagsError": false,
194+
"manufacturers": Array [],
195+
"modelPage": 1,
196+
"models": Array [],
197+
"osPage": 1,
198+
"oses": Array [],
136199
"skillTags": Array [
137200
Object {
138201
"domain": "SKILLS",
@@ -141,14 +204,22 @@ Object {
141204
"status": "APPROVED",
142205
},
143206
],
207+
"types": Array [],
144208
}
145209
`;
146210

147211
exports[`Factory without server side rendering Get skill tags error 1`] = `
148212
Object {
149213
"allCountries": Array [],
150214
"countries": Array [],
215+
"hasMoreModels": false,
216+
"hasMoreOses": false,
151217
"loadingSkillTagsError": true,
218+
"manufacturers": Array [],
219+
"modelPage": 1,
220+
"models": Array [],
221+
"osPage": 1,
222+
"oses": Array [],
152223
"skillTags": Array [
153224
Object {
154225
"domain": "SKILLS",
@@ -157,13 +228,22 @@ Object {
157228
"status": "APPROVED",
158229
},
159230
],
231+
"types": Array [],
160232
}
161233
`;
162234

163235
exports[`Factory without server side rendering Initial state 1`] = `
164236
Object {
165237
"allCountries": Array [],
166238
"countries": Array [],
239+
"hasMoreModels": false,
240+
"hasMoreOses": false,
241+
"manufacturers": Array [],
242+
"modelPage": 1,
243+
"models": Array [],
244+
"osPage": 1,
245+
"oses": Array [],
167246
"skillTags": Array [],
247+
"types": Array [],
168248
}
169249
`;

src/actions/lookup.js

+100
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,98 @@
66
import { createActions } from 'redux-actions';
77
import { getService } from '../services/lookup';
88

9+
/*
10+
* device api PAGE_SIZE
11+
*/
12+
export const PAGE_SIZE = 100;
13+
14+
/**
15+
* @static
16+
* @desc Creates an action that signals beginning of getting all deveice types
17+
* @return {Action}
18+
*/
19+
function getTypesInit() {}
20+
21+
/**
22+
* @static
23+
* @desc Creates an action that get all deveice types
24+
* @return {Action}
25+
*/
26+
function getTypesDone() {
27+
return getService().getTypes();
28+
}
29+
30+
31+
/**
32+
* @static
33+
* @desc Creates an action that signals beginning of getting all manufacturers
34+
* @return {Action}
35+
*/
36+
function getManufacturersInit() {}
37+
38+
/**
39+
* @static
40+
* @desc Creates an action that get all deveice manufacturers
41+
* @param {String} type
42+
* @return {Action}
43+
*/
44+
function getManufacturersDone(type) {
45+
return getService().getManufacturers(type);
46+
}
47+
48+
49+
/**
50+
* @static
51+
* @desc Creates an action that signals beginning of getting models
52+
* @param {Number} page
53+
* @return {Action}
54+
*/
55+
function getModelsInit(page) {
56+
return {
57+
page,
58+
};
59+
}
60+
61+
/**
62+
* @static
63+
* @desc Creates an action that get all deveice models
64+
* @param {Number} page
65+
* @param {String} manufacturer
66+
* @param {String} type
67+
* @return {Action}
68+
*/
69+
function getModelsDone(page, type, manufacturer) {
70+
return getService().getDevices(page, PAGE_SIZE, type, manufacturer);
71+
}
72+
73+
74+
/**
75+
* @static
76+
* @desc Creates an action that signals beginning of getting operation systems
77+
*
78+
* @param {Number} page
79+
* @return {Action}
80+
*/
81+
function getOsesInit(page) {
82+
return {
83+
page,
84+
};
85+
}
86+
87+
/**
88+
* @static
89+
* @desc Creates an action that get all operation systems
90+
* @param {Number} page
91+
* @param {String} manufacturer
92+
* @param {String} type
93+
* @param {String} model
94+
* @return {Action}
95+
*/
96+
function getOsesDone(page, type, manufacturer, model) {
97+
return getService().getDevices(page, PAGE_SIZE, type, manufacturer, model);
98+
}
99+
100+
9101
/**
10102
* @static
11103
* @desc Creates an action that signals beginning of getting all skill tags.
@@ -61,6 +153,14 @@ function getAllCountriesDone(tokenV3) {
61153

62154
export default createActions({
63155
LOOKUP: {
156+
GET_TYPES_INIT: getTypesInit,
157+
GET_TYPES_DONE: getTypesDone,
158+
GET_MANUFACTURERS_INIT: getManufacturersInit,
159+
GET_MANUFACTURERS_DONE: getManufacturersDone,
160+
GET_MODELS_INIT: getModelsInit,
161+
GET_MODELS_DONE: getModelsDone,
162+
GET_OSES_INIT: getOsesInit,
163+
GET_OSES_DONE: getOsesDone,
64164
GET_SKILL_TAGS_INIT: getSkillTagsInit,
65165
GET_SKILL_TAGS_DONE: getSkillTagsDone,
66166
GET_COUNTRIES_INIT: getCountriesInit,

0 commit comments

Comments
 (0)