Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
359bff0
commit 688361b
Showing
43 changed files
with
412 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/data-layer/about/index.js → src/data-layer/service/about/origins.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { origins } from "reactive-data-source"; | ||
|
||
import { authConfig } from "../../setup"; | ||
|
||
export const config = new origins.Api( | ||
"/config", | ||
{}, | ||
{ | ||
...authConfig, | ||
defaultValue: {} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./about/origins"; | ||
export * from "./config/origins"; | ||
export * from "./config/selectors"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,6 @@ | ||
import { origins, Selector } from "reactive-data-source"; | ||
import sortBy from "lodash.sortby"; | ||
|
||
import { authConfig } from "../setup"; | ||
import { byIdFilter } from "../helpers"; | ||
|
||
// SERVICES COLLECTION | ||
|
||
const typeFilter = serviceType => { | ||
if (serviceType && serviceType.length) { | ||
return { | ||
query: { | ||
type: serviceType | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
export const servicesCollection = new origins.Api( | ||
"/services", | ||
{}, | ||
{ | ||
...authConfig, | ||
defaultValue: [] | ||
} | ||
); | ||
|
||
servicesCollection.addCustomFilter({ | ||
type: typeFilter | ||
}); | ||
|
||
// SELECTORS | ||
|
||
export const modulesCollection = new Selector( | ||
{ | ||
source: servicesCollection, | ||
filter: () => typeFilter("module") | ||
}, | ||
servicesResults => servicesResults, | ||
[] | ||
); | ||
|
||
export const pluginsCollection = new Selector( | ||
{ | ||
source: servicesCollection, | ||
filter: () => typeFilter("plugin") | ||
}, | ||
servicesResults => servicesResults, | ||
[] | ||
); | ||
|
||
const searchByNameAndDesc = (servicesResults, search) => { | ||
if (!search) { | ||
return servicesResults; | ||
} | ||
return servicesResults.filter( | ||
service => service.name.indexOf(search) > -1 || service.description.indexOf(search) > -1 | ||
); | ||
}; | ||
|
||
export const modulesCollectionFiltered = new Selector(modulesCollection, searchByNameAndDesc, []); | ||
export const pluginsCollectionFiltered = new Selector(pluginsCollection, searchByNameAndDesc, []); | ||
|
||
const sortAndOrderBy = (servicesResults, filter) => { | ||
const results = sortBy(servicesResults, (filter && filter.sortBy) || "name"); | ||
if (filter.reverse) { | ||
return results.reverse(); | ||
} | ||
return results; | ||
}; | ||
|
||
export const modulesCollectionFilteredAndSorted = new Selector( | ||
{ | ||
source: modulesCollectionFiltered, | ||
filter: ({ search }) => search | ||
}, | ||
sortAndOrderBy, | ||
[] | ||
); | ||
|
||
export const pluginsCollectionFilteredAndSorted = new Selector( | ||
{ | ||
source: pluginsCollectionFiltered, | ||
filter: ({ search }) => search | ||
}, | ||
sortAndOrderBy, | ||
[] | ||
); | ||
|
||
// SERVICE MODEL | ||
|
||
export const servicesModel = new origins.Api( | ||
"/services/:id", | ||
{}, | ||
{ | ||
...authConfig, | ||
defaultValue: {} | ||
} | ||
); | ||
|
||
servicesModel.addCustomFilter({ | ||
byId: byIdFilter | ||
}); | ||
export * from "./abilities/origins"; | ||
export * from "./logs/origins"; | ||
export * from "./logs/selectors"; | ||
export * from "./service/origins"; | ||
export * from "./services/origins"; | ||
export * from "./services/selectors"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { origins } from "reactive-data-source"; | ||
|
||
import { authConfig } from "../../setup"; | ||
|
||
export const logs = new origins.Api( | ||
"/logs", | ||
{}, | ||
{ | ||
...authConfig, | ||
defaultValue: [] | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { origins } from "reactive-data-source"; | ||
|
||
import { authConfig } from "../../setup"; | ||
|
||
import { byIdFilter } from "../../helpers"; | ||
|
||
// SERVICE MODELS | ||
|
||
export const serviceModels = new origins.Api( | ||
"/services/:id", | ||
{}, | ||
{ | ||
...authConfig, | ||
defaultValue: {} | ||
} | ||
); | ||
|
||
serviceModels.addCustomFilter({ | ||
byId: byIdFilter | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const typeFilter = serviceType => { | ||
if (serviceType && serviceType.length) { | ||
return { | ||
query: { | ||
type: serviceType | ||
} | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { origins } from "reactive-data-source"; | ||
|
||
import { authConfig } from "../../setup"; | ||
|
||
import { typeFilter } from "./filters"; | ||
|
||
// SERVICES COLLECTION | ||
|
||
export const servicesCollection = new origins.Api( | ||
"/services", | ||
{}, | ||
{ | ||
...authConfig, | ||
defaultValue: [] | ||
} | ||
); | ||
|
||
servicesCollection.addCustomFilter({ | ||
type: typeFilter | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Selector } from "reactive-data-source"; | ||
import sortBy from "lodash.sortby"; | ||
|
||
import { servicesCollection } from "./origins"; | ||
|
||
import { typeFilter } from "./filters"; | ||
|
||
export const modulesCollection = new Selector( | ||
{ | ||
source: servicesCollection, | ||
filter: () => typeFilter("module") | ||
}, | ||
servicesResults => servicesResults, | ||
[] | ||
); | ||
|
||
export const pluginsCollection = new Selector( | ||
{ | ||
source: servicesCollection, | ||
filter: () => typeFilter("plugin") | ||
}, | ||
servicesResults => servicesResults, | ||
[] | ||
); | ||
|
||
const searchByNameAndDesc = (servicesResults, search) => { | ||
if (!search) { | ||
return servicesResults; | ||
} | ||
return servicesResults.filter( | ||
service => service.name.indexOf(search) > -1 || service.description.indexOf(search) > -1 | ||
); | ||
}; | ||
|
||
export const modulesCollectionFiltered = new Selector(modulesCollection, searchByNameAndDesc, []); | ||
export const pluginsCollectionFiltered = new Selector(pluginsCollection, searchByNameAndDesc, []); | ||
|
||
const sortAndOrderBy = (servicesResults, filter) => { | ||
const results = sortBy(servicesResults, (filter && filter.sortBy) || "name"); | ||
if (filter.reverse) { | ||
return results.reverse(); | ||
} | ||
return results; | ||
}; | ||
|
||
export const modulesCollectionFilteredAndSorted = new Selector( | ||
{ | ||
source: modulesCollectionFiltered, | ||
filter: ({ search }) => search | ||
}, | ||
sortAndOrderBy, | ||
[] | ||
); | ||
|
||
export const pluginsCollectionFilteredAndSorted = new Selector( | ||
{ | ||
source: pluginsCollectionFiltered, | ||
filter: ({ search }) => search | ||
}, | ||
sortAndOrderBy, | ||
[] | ||
); |
Oops, something went wrong.