diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 13c196d1..1a3e0e33 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -76,7 +76,7 @@ jobs: uses: actions/checkout@v4 with: repository: wri/fti_api - ref: develop + ref: master path: otp_api - name: Save OTP API Commit SHA @@ -171,7 +171,7 @@ jobs: run: yarn cypress run - name: Uploading Test Artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: e2e-tests-artifacts diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index dedfb131..fb75113e 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -108,15 +108,18 @@ export class AuthService { const response = await this.http.get(`${environment.apiUrl}/users/current-user`).toPromise() as any; const relationships = response.data.relationships; const userPermissions = (response.included || []).find(i => i.type === 'user-permissions'); - this.userId = response.data.id; this.userRole = userPermissions && userPermissions.attributes['user-role']; this.qc1ObserverIds = (response.data.attributes['qc1-observer-ids'] || []).map((d) => d.toString()); this.qc2ObserverIds = (response.data.attributes['qc2-observer-ids'] || []).map((d) => d.toString()); const userObserverId = relationships.observer.data && relationships.observer.data.id; - // TODO: remove this we don't need it anymore - // const managedObserverIds = (response.data.attributes['managed-observer-ids'] || []).map((d) => d.toString()); const managedObserverIds = []; + if (this.isBackendAdmin()) { + await this.observersService.getAll({ sort: 'name' }).then(data => { + //set all observers as available + managedObserverIds.push(...data.map(o => o.id)); + }); + } const allManagedOberverIds = uniq([userObserverId, ...managedObserverIds].filter(x => x)); const availableObserverIds = uniq([...allManagedOberverIds, ...this.qc1ObserverIds, ...this.qc2ObserverIds].filter(x => x)); const savedUserObserverId = parseInt(localStorage.getItem('userObserverId'), 10); @@ -127,17 +130,6 @@ export class AuthService { } else { this.userObserverId = availableObserverIds[0]; } - - // if user is backend admin and has no observer context saved in localstorage - // take the first observer id - if (!this.userObserverId && this.isBackendAdmin()) { - await this.observersService.getAll({ sort: 'name' }).then(data => { - //set all observers as available - this.managedObserverIds = data.map(o => o.id); - this.availableObserverIds = data.map(o => o.id); - this.userObserverId = data[0].id; - }); - } this.userCountryId = relationships.country && relationships.country.data && relationships.country.data.id; await this.setObserverCountriesIds();