Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Delete references to latest image and page in storeService #76
Browse files Browse the repository at this point in the history
  • Loading branch information
carrosa committed Jan 29, 2019
1 parent 4fef8c0 commit 1b44ea3
Showing 1 changed file with 32 additions and 40 deletions.
72 changes: 32 additions & 40 deletions src/angular_frontend/src/app/services/store.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import {Injectable} from '@angular/core';
import {Router, ParamMap} from '@angular/router';
import {HttpHeaders} from '@angular/common/http';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {Subject} from 'rxjs/Subject';
import {Observable} from 'rxjs/Observable';
import {ApiService} from 'app/services/api.service';
import {
IResponse, IPhoto, IUser, IFilters, ILoginRequest, IForeignKey, IOrder, IStatistics, ILatestImageAndPage, PermissionEnum
IResponse, IPhoto, IUser, IFilters, ILoginRequest, IForeignKey, IOrder, IStatistics, PermissionEnum
} from 'app/model';
import {DELTA} from 'app/config';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/skip';
import {ToastrService} from 'ngx-toastr';
Expand All @@ -35,17 +33,14 @@ export class StoreService {
* No point in having this as a behaviorsubject afaik
*/

public lastSearchedString = '';
public lastSearchedString = '';

public photoRouteActive$ = new Subject<boolean>();
public photoModal$ = new BehaviorSubject<[IPhoto[], number]>(null);

public foreignKeys$: { [type: string]: BehaviorSubject<IForeignKey[]>; } = {};
public fgUsers$ = new BehaviorSubject<IUser[]>(null);
public powerUsers$ = new BehaviorSubject<IUser[]>(null);

public latestPageAndImageNumber = new BehaviorSubject<ILatestImageAndPage>(null);

public orders$: { [type: string]: BehaviorSubject<IOrder[]>; } = {};


Expand Down Expand Up @@ -278,41 +273,42 @@ export class StoreService {
)
);
}
/*
loginAction(data: ILoginRequest) {
const encodedCredentials = 'Basic ' + btoa(`${data.username}:${data.password}`);
this.api.login(encodedCredentials).subscribe(res => {
this.storeEncodedCredentials(res.username, res.groups, encodedCredentials);
/!*
navigation after login based on group
TODO?: make this more dynamic instead of hardcoding routes here.
*!/
if (res.groups.indexOf('FG') !== -1) {

/*
loginAction(data: ILoginRequest) {
const encodedCredentials = 'Basic ' + btoa(`${data.username}:${data.password}`);
this.api.login(encodedCredentials).subscribe(res => {
this.storeEncodedCredentials(res.username, res.groups, encodedCredentials);
/!*
navigation after login based on group
TODO?: make this more dynamic instead of hardcoding routes here.
*!/
if (res.groups.indexOf('FG') !== -1) {
this.router.navigateByUrl('/intern/opplasting');
} else if (res.groups.indexOf('POWER') !== -1 || res.groups.indexOf('HUSFOLK') !== -1) {
this.router.navigateByUrl('/intern/søk');
}
this._loginModal$.next(null);
this.toastr.success(`Velkommen ${res.username} 😊`);
}, err => {
this._loginModal$.next({username: null, password: null, hasFailed: true});
});
}
*/

// New loginaction
loginAction() {
this.api.login().subscribe(res => {
this.storeCredentials(res.username, res.permission);
if (res.permission === PermissionEnum.FG) {
this.router.navigateByUrl('/intern/opplasting');
} else if (res.groups.indexOf('POWER') !== -1 || res.groups.indexOf('HUSFOLK') !== -1) {
} else if (res.permission === PermissionEnum.HUSFOLK) {
this.router.navigateByUrl('/intern/søk');
}
this._loginModal$.next(null);
this.toastr.success(`Velkommen ${res.username} 😊`);
}, err => {
this._loginModal$.next({username: null, password: null, hasFailed: true});
});
}, err => this._loginModal$.next({username: null, password: null, hasFailed: true}));
}
*/

// New loginaction
loginAction() {
this.api.login().subscribe(res => {
this.storeCredentials(res.username, res.permission);
if (res.permission === PermissionEnum.FG) {
this.router.navigateByUrl('/intern/opplasting');
} else if (res.permission === PermissionEnum.HUSFOLK) {
this.router.navigateByUrl('/intern/søk');
}
this._loginModal$.next(null);
this.toastr.success(`Velkommen ${res.username} 😊`);
}, err => this._loginModal$.next({username: null, password: null, hasFailed: true}));
}

logoutAction() {
this.toastr.info(null, `På gjensyn ${localStorage.getItem('username')}! 👋`);
Expand Down Expand Up @@ -354,10 +350,6 @@ loginAction() {
return albums;
}

getAnalogNotScannedIdsAction(album: string, page: string, image_numbers: string[]) {
return this.api.getPhotosFromAlbumPageAndNumber(album, page, image_numbers);
}

postPhotoAction(data) {
const formData = new FormData();
for (const key of Object.keys(data)) {
Expand Down

0 comments on commit 1b44ea3

Please sign in to comment.