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.
54 lines (45 loc) • 1.56 kB
JavaScript
var request = require( '../helpers/request' );
import iso from '../../iso';
module.exports = {
clearCount: ( id ) => {
let url = 'api/insight/count?id=' + id;
return request.apiRequest( 'PUT', url ).then( function( resp ) {
return resp.body;
} );
},
getAll: () => {
let url = 'api/insight/all';
return request.apiRequest( 'GET', url ).then( function( resp ) {
return resp.body;
} );
},
getAllSearches: () => {
let url = 'api/search/subscribe';
return request.apiRequest( 'GET', url ).then( function( resp ) {
if( resp.body && resp.body.length > 0 ) {
resp.body.forEach( ( s ) => {
s.Name = iso.string.hasStartAsLastCharacter( s.Query ) ? iso.string.removeLastCharacter( s.Query ) : s.Query;
} );
}
return resp.body;
} );
},
clearSearchCount: ( id ) => {
let url = 'api/v1/search/clear?id=' + id;
return request.apiRequest( 'PUT', url ).then( function( resp ) {
return resp.body;
} );
},
subscribeSearch: ( q ) => {
let url = 'api/search/subscribe?q=' + q;
return request.apiRequest( 'POST', url ).then( function( resp ) {
return resp.body;
} );
},
unSubscribeSearch: ( q ) => {
let url = 'api/search/unsubscribe?q=' + q;
return request.apiRequest( 'POST', url ).then( function( resp ) {
return resp.body;
} );
}
};