cluedin-widget
Version:
This project contains all the pages needed for browsing entities and searching them. The aim is to replace the CluedIn.Webapp project with this one when all the pages ( including the Admin page ) will be ported to REACT.
47 lines (33 loc) • 1.29 kB
JavaScript
/* eslint no-underscore-dangle: ["error", { "allow": ["__cluedIn"] }]*/
import { apiRequest } from '../helpers/request';
import entityAPI from '../../iso/entity';
import wms from '../../wms';
export function getWidgetConfiguration(type, org) {
return new Promise(function (resolve) {
if (type) {
let layout = wms.getWidgetConfiguration(type, org);
if (layout.widgets) {
layout.widgets = layout.widgets.slice(0);
}
if (layout.tabs && layout.tabs.children) {
layout.tabs.children = layout.tabs.children.slice(0);
}
let result = Object.assign({}, layout);
const layoutName = ( result.layout && result.layout.name) ? result.layout.name : 'Default';
const layoutConfiguration = wms.getLayout(layoutName);
return resolve({widget: result, layout: layoutConfiguration});
}
__cluedIn = __cluedIn || {};
let result = Object.assign({}, __cluedIn.widgetConfiguration) || {};
resolve({widget: result, layout: wms.getLayout('Default')});
})
}
export function getMostConnectedData() {
return apiRequest('GET', 'api/onboarding/mostconnected').then((resp) => (
resp.body.map((entity) => (entityAPI.toVM(entity)))
));
}
export default {
getWidgetConfiguration,
getMostConnectedData,
};