Skip to content

Commit

Permalink
circ_policies ui: increase API size limit
Browse files Browse the repository at this point in the history
* Closes rero#405

Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Oct 1, 2019
1 parent e20bb7f commit d8dbbac
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 119 deletions.
2 changes: 0 additions & 2 deletions ui/src/app/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { TranslateModule } from '@ngx-translate/core';

import { ItemTypeService } from './item-type/item-type.service';
import { ItemTypeTool } from './item-type/item-type-tool';
import { LibraryService } from './library/library.service';
import { PatronTypeService } from './patron-type/patron-type.service';
import { PatronTypeTool } from './patron-type/patron-type-tool';
import { OrganisationService } from './organisation/organisation.service';
Expand Down Expand Up @@ -63,7 +62,6 @@ import { TranslateLanguageService } from './translate/translate-language.service
providers: [
ApiService,
ItemTypeService,
LibraryService,
OrganisationService,
OrganisationViewService,
PatronTypeService,
Expand Down
1 change: 0 additions & 1 deletion ui/src/app/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export * from './dialog/dialog.service';
export * from './filter/nl2br';
export * from './item-type/item-type.service';
export * from './item-type/item-type-tool';
export * from './library/library.service';
export * from './organisation/organisation.service';
export * from './organisation/organisation-view.service';
export * from './patron-type/patron-type.service';
Expand Down
31 changes: 0 additions & 31 deletions ui/src/app/core/library/library.service.spec.ts

This file was deleted.

50 changes: 0 additions & 50 deletions ui/src/app/core/library/library.service.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,56 +22,38 @@ import { Injectable } from '@angular/core';
import { forkJoin, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { CirculationPolicy } from './circulation-policy';
import { ItemTypeService, PatronTypeService, ApiService, cleanDictKeys, _ } from '@app/core';
import { ApiService, cleanDictKeys, _ } from '@app/core';
import { RecordsService } from '@app/records/records.service';
import { Router } from '@angular/router';
import { ToastrService } from 'ngx-toastr';

const httpOptions = {
headers: new HttpHeaders({
'Accept': 'application/json',
'Content-Type': 'application/json'
})
};

@Injectable()
export class CirculationPolicyService {

constructor(
private router: Router,
private apiService: ApiService,
private client: HttpClient,
private itemTypeService: ItemTypeService,
private patronTypeService: PatronTypeService,
private recordsService: RecordsService,
private toastService: ToastrService
) { }

loadOrCreateCirculationPolicy(pid: number = null) {
if (pid) {
return this.client.get<any>(
this.apiService.getApiEntryPointByType('circ_policies') + pid,
httpOptions
).pipe(
return this.recordsService.getRecord('circ_policies', '' + pid)
.pipe(
map(data => new CirculationPolicy(data.metadata))
);
} else {
return of(new CirculationPolicy());
}
}

loadAllCirculationPolicy() {
return this.client.get(
this.apiService.getApiEntryPointByType('circ_policies'),
httpOptions
);
}

loadAllItemTypesPatronTypesCirculationPolicies() {
return forkJoin(
this.itemTypeService.itemTypes(),
this.patronTypeService.patronTypes(),
this.loadAllCirculationPolicy()
this.recordsService.getRecords('global', 'item_types', 1, RecordsService.MAX_REST_RESULTS_SIZE),
this.recordsService.getRecords('global', 'patron_types', 1, RecordsService.MAX_REST_RESULTS_SIZE),
this.recordsService.getRecords('global', 'circ_policies', 1, RecordsService.MAX_REST_RESULTS_SIZE)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Component, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';

import { LibraryService, UniqueValidator } from '@app/core';
import { UniqueValidator } from '@app/core';
import { UserService } from '@app/user.service';
import { CirculationPolicyService } from '../circulation-policy.service';
import { CirculationPolicyFormService } from '../circulation-policy-form.service';
Expand Down Expand Up @@ -51,7 +51,6 @@ export class CirculationPolicyComponent implements OnInit {
private circulationPolicyService: CirculationPolicyService,
private circulationPolicyForm: CirculationPolicyFormService,
private userService: UserService,
private libraryService: LibraryService,
private circulationMapping: CirculationMappingService,
private organisationService: OrganisationService,
private recordsService: RecordsService
Expand Down Expand Up @@ -87,14 +86,12 @@ export class CirculationPolicyComponent implements OnInit {
this.circulationMapping.setPolicyLevel(
circulation.policy_library_level
);
this.libraryService
.libraries()
.subscribe((libraries: any) => {
libraries.hits.hits.forEach(library => {
this.librariesOrg.push({
id: library.metadata.pid,
name: library.metadata.name
});
this.recordsService.getRecords('global', 'libraries', 1, RecordsService.MAX_REST_RESULTS_SIZE)
.subscribe((libraries: any) => {
libraries.hits.hits.forEach(library => {
this.librariesOrg.push({
id: library.metadata.pid,
name: library.metadata.name
});
this.circulationPolicyForm.populate(this.circulationPolicy);
this.circulationForm = this.circulationPolicyForm.getForm();
Expand Down
6 changes: 5 additions & 1 deletion ui/src/app/records/records.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import { DialogService, _ } from '@app/core';
providedIn: 'root'
})
export class RecordsService {

public static readonly DEFAULT_REST_RESULTS_SIZE = 10;
public static readonly MAX_REST_RESULTS_SIZE = 9999;

private translatePlural;
constructor(
private http: HttpClient,
Expand All @@ -56,7 +60,7 @@ export class RecordsService {
view: string,
record_type: string,
page: number = 1,
size: number = 10,
size: number = RecordsService.DEFAULT_REST_RESULTS_SIZE,
query: string = '',
mime_type: string = 'application/json',
filters = [],
Expand Down

0 comments on commit d8dbbac

Please sign in to comment.