mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACA-1637] update searchApi to use alfresco-js-api-node (#561)
This commit is contained in:
committed by
Denys Vuika
parent
a7abe9c422
commit
7c08488323
@@ -23,19 +23,16 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { RepoApiNew } from '../repo-api-new';
|
||||
import { Utils } from '../../../../utilities/utils';
|
||||
|
||||
export class SearchApi extends RepoApi {
|
||||
apiDefinition = 'search';
|
||||
export class SearchApi extends RepoApiNew {
|
||||
|
||||
search(data: any[]): Promise<any> {
|
||||
return this
|
||||
.post(`/search`, { data }, this.apiDefinition)
|
||||
.catch(this.handleError);
|
||||
constructor(username?, password?) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
queryRecentFiles(username: string): Promise<any> {
|
||||
async queryRecentFiles(username: string) {
|
||||
const data = {
|
||||
query: {
|
||||
query: '*',
|
||||
@@ -48,22 +45,19 @@ export class SearchApi extends RepoApi {
|
||||
]
|
||||
};
|
||||
|
||||
return this
|
||||
.post(`/search`, { data }, this.apiDefinition)
|
||||
.catch(this.handleError);
|
||||
await this.apiAuth();
|
||||
return this.alfrescoJsApi.search.searchApi.search(data);
|
||||
|
||||
}
|
||||
|
||||
waitForApi(username, data) {
|
||||
const recentFiles = () => {
|
||||
return this.queryRecentFiles(username)
|
||||
.then(response => response.data.list.pagination.totalItems)
|
||||
.then(totalItems => {
|
||||
if ( totalItems < data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
return Promise.resolve(totalItems);
|
||||
}
|
||||
});
|
||||
async waitForApi(username, data) {
|
||||
const recentFiles = async () => {
|
||||
const totalItems = (await this.queryRecentFiles(username)).list.pagination.totalItems;
|
||||
if ( totalItems < data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
return Promise.resolve(totalItems);
|
||||
}
|
||||
};
|
||||
|
||||
return Utils.retryCall(recentFiles);
|
||||
|
||||
@@ -70,7 +70,7 @@ export class RepoClient {
|
||||
}
|
||||
|
||||
get search() {
|
||||
return new SearchApi(this.auth, this.config);
|
||||
return new SearchApi(this.auth.username, this.auth.password);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user