Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
() => {
this.collectionsStore.setError(true);
}
);
}
/**
* Currently only used from the collection page
* Grabs detailed collection information and navigates to the collection's page
*
* @param {number} organizationId The ID of the organization that the collection belongs to
* @param {number} collectionId The ID of the collection
* @memberof CollectionsService
*/
@transaction()
updateCollectionFromId(organizationId: number, collectionId: number) {
this.collectionsStore.setError(false);
this.collectionsStore.setLoading(true);
this.organizationsService
.getCollectionById(organizationId, collectionId)
.pipe(finalize(() => this.collectionsStore.setLoading(false)))
.subscribe(
(collection: Collection) => {
this.collectionsStore.setError(false);
this.collectionsStore.upsert(collection.id, collection);
this.collectionsStore.setActive(collection.id);
this.organizationService.updateOrganizationFromID(collection.organizationID);
// Navigate to the new collectionName in case the name changes.
this.router.navigate(['/organizations', collection.organizationName, 'collections', collection.name]);
},
() => {
import { BioWorkflow } from '../swagger/model/bioWorkflow';
import { Service } from '../swagger/model/service';
import { ExtendedWorkflowService } from './extended-workflow.service';
import { WorkflowStore } from './workflow.store';
@Injectable({ providedIn: 'root' })
export class WorkflowService {
workflows$: BehaviorSubject = new BehaviorSubject(null); // This contains the list of unsorted workflows
sharedWorkflows$: BehaviorSubject = new BehaviorSubject(null); // This contains the list of unsorted shared workflows
nsSharedWorkflows$: BehaviorSubject = new BehaviorSubject(null); // This contains the list of sorted shared workflows
nsWorkflows$: BehaviorSubject = new BehaviorSubject(null); // This contains the list of sorted workflows
private copyBtnSource = new BehaviorSubject(null); // This is the currently selected copy button.
copyBtn$ = this.copyBtnSource.asObservable();
constructor(private workflowStore: WorkflowStore, private extendedWorkflowService: ExtendedWorkflowService) {}
@transaction()
setWorkflow(workflow: BioWorkflow | Service | null) {
if (workflow) {
this.workflowStore.upsert(workflow.id, workflow);
this.extendedWorkflowService.update(workflow);
this.workflowStore.setActive(workflow.id);
} else {
this.workflowStore.remove();
this.extendedWorkflowService.remove();
}
}
get() {
// Placeholder
// this.http.get('https://akita.com').subscribe((entities) => this.workflowStore.set(entities));
}
import { Observable, throwError } from 'rxjs';
import { Provider } from '../enum/provider.enum';
import { TokensService, UsersService } from '../swagger';
import { Token } from '../swagger/model/token';
import { TokenStore } from './token.store';
@Injectable({ providedIn: 'root' })
export class TokenService {
constructor(
private tokenStore: TokenStore,
private tokensService: TokensService,
private usersService: UsersService,
private httpBackend: HttpBackend
) {}
@transaction()
get(userId: number) {
this.tokenStore.remove();
if (userId) {
this.usersService.getUserTokens(userId).subscribe((tokens: Array) => {
this.tokenStore.add(tokens);
});
}
}
add(token: Token) {
this.tokenStore.add(token);
}
update(id, token: Partial) {
this.tokenStore.update(id, token);
}
) {}
clearState(): void {
this.aliasesStore.update(state => {
return {
...state,
organization: null,
collection: null,
tool: null,
workflow: null,
workflowVersion: null
};
});
}
@transaction()
updateOrganizationFromAlias(alias: string): void {
this.clearState();
this.aliasesStore.setLoading(true);
this.organizationsService
.getOrganizationByAlias(alias)
.pipe(finalize(() => this.aliasesStore.setLoading(false)))
.subscribe(
(organization: Organization) => {
this.aliasesStore.setError(false);
this.updateOrganization(organization);
},
() => {
this.aliasesStore.setError(true);
}
);
}
setTool(tool: DockstoreTool | null) {
if (tool) {
this.toolStore.upsert(tool.id, tool);
this.extendedDockstoreToolService.update(tool);
this.toolStore.setActive(tool.id);
} else {
this.toolStore.remove();
this.extendedDockstoreToolService.remove();
}
}
clearActive() {
this.toolStore.setActive(null);
}
@transaction()
setTags(workflowVersions: Array | null) {
this.toolStore.updateActive(active => {
return {
...active.workflowVersions,
workflowVersions
};
});
this.extendedDockstoreToolService.update(this.toolQuery.getActive());
}
}
this.moviesStore.set(movies);
})
);
return this.moviesQuery.getHasCache() ? of() : request$;
}
updateActorName(id: ID, name: string) {
this.actorsStore.update(id, { name });
}
markAsOpen(id: ID) {
this.moviesStore.ui.update(id, entity => ({ isOpen: !entity.isOpen }));
}
@transaction()
deleteActor(id: ID) {
this.actorsStore.remove(id);
this.moviesStore.update(null, entity => ({ actors: arrayRemove(entity.actors, id) }));
}
}
() => {
this.aliasesStore.setError(true);
}
);
}
updateTool(tool: DockstoreTool) {
this.aliasesStore.update(state => {
return {
...state,
tool: tool
};
});
}
@transaction()
updateWorkflowFromAlias(alias: string): void {
this.clearState();
this.aliasesStore.setLoading(true);
this.workflowsService
.getWorkflowByAlias(alias)
.pipe(finalize(() => this.aliasesStore.setLoading(false)))
.subscribe(
(workflow: Workflow) => {
this.aliasesStore.setError(false);
this.updateWorkflow(workflow);
},
() => {
this.aliasesStore.setError(true);
}
);
}
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ID, transaction } from '@datorama/akita';
import { CollectionOrganization, EntriesService } from '../../shared/swagger';
import { CurrentCollectionsStore } from './current-collections.store';
@Injectable({ providedIn: 'root' })
export class CurrentCollectionsService {
constructor(private currentCollectionsStore: CurrentCollectionsStore, private entriesService: EntriesService, private http: HttpClient) {}
@transaction()
get(id: number) {
if (id) {
this.entriesService.entryCollections(id).subscribe((CollectionOrganizations: Array) => {
this.currentCollectionsStore.remove();
this.currentCollectionsStore.set(CollectionOrganizations);
});
} else {
this.currentCollectionsStore.remove();
}
}
add(currentCollection: CollectionOrganization) {
this.currentCollectionsStore.add(currentCollection);
}
update(id, currentCollection: Partial) {
...state,
user: user
};
});
}
updateExtendedUserData(extendeduserData: ExtendedUserData) {
this.userStore.update(state => {
return {
...state,
extendedUserData: extendeduserData
};
});
}
@transaction()
remove() {
this.userStore.update({ user: null, extendedUserData: null });
this.tokenService.removeAll();
}
setupConfigurationToken(): void {
const token = this.authService.getToken();
this.configuration.apiKeys['Authorization'] = token ? 'Bearer ' + token : null;
}
getExtendedUserData(): void {
this.setupConfigurationToken();
if (this.configuration.apiKeys['Authorization']) {
this.usersService
.getExtendedUserData()
.subscribe(
() => {
this.aliasesStore.setError(true);
}
);
}
updateOrganization(organization: Organization) {
this.aliasesStore.update(state => {
return {
...state,
organization: organization
};
});
}
@transaction()
updateCollectionFromAlias(alias: string): void {
this.clearState();
this.aliasesStore.setLoading(true);
this.organizationsService
.getCollectionByAlias(alias)
.pipe(finalize(() => this.aliasesStore.setLoading(false)))
.subscribe(
(collection: Collection) => {
this.aliasesStore.setError(false);
this.updateCollection(collection);
},
() => {
this.aliasesStore.setError(true);
}
);
}