Skip to content

Feature devices lookup #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions __tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,16 @@ Object {
"getAllCountriesInit": [Function],
"getCountriesDone": [Function],
"getCountriesInit": [Function],
"getManufacturersDone": [Function],
"getManufacturersInit": [Function],
"getModelsDone": [Function],
"getModelsInit": [Function],
"getOsesDone": [Function],
"getOsesInit": [Function],
"getSkillTagsDone": [Function],
"getSkillTagsInit": [Function],
"getTypesDone": [Function],
"getTypesInit": [Function],
},
"memberTasks": Object {
"dropAll": [Function],
Expand Down
8 changes: 8 additions & 0 deletions __tests__/actions/__snapshots__/lookup.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ Object {
"getAllCountriesInit": [Function],
"getCountriesDone": [Function],
"getCountriesInit": [Function],
"getManufacturersDone": [Function],
"getManufacturersInit": [Function],
"getModelsDone": [Function],
"getModelsInit": [Function],
"getOsesDone": [Function],
"getOsesInit": [Function],
"getSkillTagsDone": [Function],
"getSkillTagsInit": [Function],
"getTypesDone": [Function],
"getTypesInit": [Function],
},
}
`;
Expand Down
80 changes: 80 additions & 0 deletions __tests__/reducers/__snapshots__/lookup.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ Object {
"countryCode": "AFG",
},
],
"hasMoreModels": false,
"hasMoreOses": false,
"loadingCountriesError": false,
"loadingSkillTagsError": true,
"manufacturers": Array [],
"modelPage": 1,
"models": Array [],
"osPage": 1,
"oses": Array [],
"skillTags": Array [
Object {
"domain": "SKILLS",
Expand All @@ -19,6 +26,7 @@ Object {
"status": "APPROVED",
},
],
"types": Array [],
}
`;

Expand All @@ -31,8 +39,15 @@ Object {
"countryCode": "AFG",
},
],
"hasMoreModels": false,
"hasMoreOses": false,
"loadingCountriesError": true,
"loadingSkillTagsError": true,
"manufacturers": Array [],
"modelPage": 1,
"models": Array [],
"osPage": 1,
"oses": Array [],
"skillTags": Array [
Object {
"domain": "SKILLS",
Expand All @@ -41,14 +56,22 @@ Object {
"status": "APPROVED",
},
],
"types": Array [],
}
`;

exports[`Default reducer Get skill tags 1`] = `
Object {
"allCountries": Array [],
"countries": Array [],
"hasMoreModels": false,
"hasMoreOses": false,
"loadingSkillTagsError": false,
"manufacturers": Array [],
"modelPage": 1,
"models": Array [],
"osPage": 1,
"oses": Array [],
"skillTags": Array [
Object {
"domain": "SKILLS",
Expand All @@ -57,14 +80,22 @@ Object {
"status": "APPROVED",
},
],
"types": Array [],
}
`;

exports[`Default reducer Get skill tags error 1`] = `
Object {
"allCountries": Array [],
"countries": Array [],
"hasMoreModels": false,
"hasMoreOses": false,
"loadingSkillTagsError": true,
"manufacturers": Array [],
"modelPage": 1,
"models": Array [],
"osPage": 1,
"oses": Array [],
"skillTags": Array [
Object {
"domain": "SKILLS",
Expand All @@ -73,14 +104,23 @@ Object {
"status": "APPROVED",
},
],
"types": Array [],
}
`;

exports[`Default reducer Initial state 1`] = `
Object {
"allCountries": Array [],
"countries": Array [],
"hasMoreModels": false,
"hasMoreOses": false,
"manufacturers": Array [],
"modelPage": 1,
"models": Array [],
"osPage": 1,
"oses": Array [],
"skillTags": Array [],
"types": Array [],
}
`;

Expand All @@ -93,8 +133,15 @@ Object {
"countryCode": "AFG",
},
],
"hasMoreModels": false,
"hasMoreOses": false,
"loadingCountriesError": false,
"loadingSkillTagsError": true,
"manufacturers": Array [],
"modelPage": 1,
"models": Array [],
"osPage": 1,
"oses": Array [],
"skillTags": Array [
Object {
"domain": "SKILLS",
Expand All @@ -103,6 +150,7 @@ Object {
"status": "APPROVED",
},
],
"types": Array [],
}
`;

Expand All @@ -115,8 +163,15 @@ Object {
"countryCode": "AFG",
},
],
"hasMoreModels": false,
"hasMoreOses": false,
"loadingCountriesError": true,
"loadingSkillTagsError": true,
"manufacturers": Array [],
"modelPage": 1,
"models": Array [],
"osPage": 1,
"oses": Array [],
"skillTags": Array [
Object {
"domain": "SKILLS",
Expand All @@ -125,14 +180,22 @@ Object {
"status": "APPROVED",
},
],
"types": Array [],
}
`;

exports[`Factory without server side rendering Get skill tags 1`] = `
Object {
"allCountries": Array [],
"countries": Array [],
"hasMoreModels": false,
"hasMoreOses": false,
"loadingSkillTagsError": false,
"manufacturers": Array [],
"modelPage": 1,
"models": Array [],
"osPage": 1,
"oses": Array [],
"skillTags": Array [
Object {
"domain": "SKILLS",
Expand All @@ -141,14 +204,22 @@ Object {
"status": "APPROVED",
},
],
"types": Array [],
}
`;

exports[`Factory without server side rendering Get skill tags error 1`] = `
Object {
"allCountries": Array [],
"countries": Array [],
"hasMoreModels": false,
"hasMoreOses": false,
"loadingSkillTagsError": true,
"manufacturers": Array [],
"modelPage": 1,
"models": Array [],
"osPage": 1,
"oses": Array [],
"skillTags": Array [
Object {
"domain": "SKILLS",
Expand All @@ -157,13 +228,22 @@ Object {
"status": "APPROVED",
},
],
"types": Array [],
}
`;

exports[`Factory without server side rendering Initial state 1`] = `
Object {
"allCountries": Array [],
"countries": Array [],
"hasMoreModels": false,
"hasMoreOses": false,
"manufacturers": Array [],
"modelPage": 1,
"models": Array [],
"osPage": 1,
"oses": Array [],
"skillTags": Array [],
"types": Array [],
}
`;
100 changes: 100 additions & 0 deletions src/actions/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,98 @@
import { createActions } from 'redux-actions';
import { getService } from '../services/lookup';

/*
* device api PAGE_SIZE
*/
export const PAGE_SIZE = 100;

/**
* @static
* @desc Creates an action that signals beginning of getting all deveice types
* @return {Action}
*/
function getTypesInit() {}

/**
* @static
* @desc Creates an action that get all deveice types
* @return {Action}
*/
function getTypesDone() {
return getService().getTypes();
}


/**
* @static
* @desc Creates an action that signals beginning of getting all manufacturers
* @return {Action}
*/
function getManufacturersInit() {}

/**
* @static
* @desc Creates an action that get all deveice manufacturers
* @param {String} type
* @return {Action}
*/
function getManufacturersDone(type) {
return getService().getManufacturers(type);
}


/**
* @static
* @desc Creates an action that signals beginning of getting models
* @param {Number} page
* @return {Action}
*/
function getModelsInit(page) {
return {
page,
};
}

/**
* @static
* @desc Creates an action that get all deveice models
* @param {Number} page
* @param {String} manufacturer
* @param {String} type
* @return {Action}
*/
function getModelsDone(page, type, manufacturer) {
return getService().getDevices(page, PAGE_SIZE, type, manufacturer);
}


/**
* @static
* @desc Creates an action that signals beginning of getting operation systems
*
* @param {Number} page
* @return {Action}
*/
function getOsesInit(page) {
return {
page,
};
}

/**
* @static
* @desc Creates an action that get all operation systems
* @param {Number} page
* @param {String} manufacturer
* @param {String} type
* @param {String} model
* @return {Action}
*/
function getOsesDone(page, type, manufacturer, model) {
return getService().getDevices(page, PAGE_SIZE, type, manufacturer, model);
}


/**
* @static
* @desc Creates an action that signals beginning of getting all skill tags.
Expand Down Expand Up @@ -61,6 +153,14 @@ function getAllCountriesDone(tokenV3) {

export default createActions({
LOOKUP: {
GET_TYPES_INIT: getTypesInit,
GET_TYPES_DONE: getTypesDone,
GET_MANUFACTURERS_INIT: getManufacturersInit,
GET_MANUFACTURERS_DONE: getManufacturersDone,
GET_MODELS_INIT: getModelsInit,
GET_MODELS_DONE: getModelsDone,
GET_OSES_INIT: getOsesInit,
GET_OSES_DONE: getOsesDone,
GET_SKILL_TAGS_INIT: getSkillTagsInit,
GET_SKILL_TAGS_DONE: getSkillTagsDone,
GET_COUNTRIES_INIT: getCountriesInit,
Expand Down
Loading