Skip to content

Commit

Permalink
Previously used server and collection are saved when importing parts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole113 committed Jul 6, 2023
1 parent 3a22aa2 commit 1824374
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1 *ngIf="mode != classRef.SELECT_MODE" mat-dialog-title>Download</h1>
<mat-form-field>
<mat-label>Server</mat-label>
<mat-select id="registry" [disabled]="registries == null || registries.length < 1"
(selectionChange)="setRegistry($event.value)">
(selectionChange)="setRegistry($event.value)" value="{{registry}}">
<mat-option *ngFor="let registry of registries" [value]="registry" [matTooltip]="registry">
{{registry}}
</mat-option>
Expand Down
21 changes: 19 additions & 2 deletions frontend/src/app/download-graph/download-graph.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ export class DownloadGraphComponent implements OnInit {
constructor(@Inject(MAT_DIALOG_DATA) public data: any, private dialog: MatDialog, private metadataService: MetadataService, private graphService: GraphService, private filesService: FilesService, private loginService: LoginService, public dialogRef: MatDialogRef<DownloadGraphComponent>) { }

ngOnInit() {
// check if there is a saved registry and collection information
if (this.metadataService.getSavedRegistry() !== undefined) this.registry = this.metadataService.getSavedRegistry();
if (this.metadataService.getSavedCollection() !== undefined) {
this.collection = this.metadataService.getSavedCollection().collection;
this.history = this.metadataService.getSavedCollection().history;
} else {
this.collection = "";
this.history = [];
}

this.working = true;
if (this.data != null) {
if (this.data.mode != null) {
Expand Down Expand Up @@ -108,10 +118,9 @@ export class DownloadGraphComponent implements OnInit {
this.working = false;
});
}

this.updateParts();
this.parts.sort = this.sort;
this.history = [];
this.collection = "";
}

loginDisabled(): boolean {
Expand All @@ -128,6 +137,7 @@ export class DownloadGraphComponent implements OnInit {

setRegistry(registry: string) {
this.registry = registry;
this.metadataService.setSavedRegistry(registry);
this.updateParts();
}

Expand Down Expand Up @@ -172,7 +182,9 @@ export class DownloadGraphComponent implements OnInit {
// only allowed to get here when there is one item selected, and it's a collection
let row = this.selection.selected[0];
this.history.push(row);
this.metadataService.setSavedCollection({ collection: row.uri, history: this.history });
this.selection.clear();

this.updateParts();
}

Expand Down Expand Up @@ -222,6 +234,7 @@ export class DownloadGraphComponent implements OnInit {
if (row.type === DownloadGraphComponent.collectionType) {
this.history.push(row);
this.collection = row.uri;
this.metadataService.setSavedCollection({ collection: this.collection, history: this.history });
this.selection.clear();
this.updateParts();
} else if (row.type === DownloadGraphComponent.componentType) {
Expand Down Expand Up @@ -295,7 +308,9 @@ export class DownloadGraphComponent implements OnInit {
}

changeCollection(collection: string) {
console.log(collection)
this.selection.clear();

let found = false;
for (let i = 0; i < this.history.length; i++) {
if (this.history[i] === collection) {
Expand All @@ -306,7 +321,9 @@ export class DownloadGraphComponent implements OnInit {
}
if (!found)
this.history.length = 0;

this.collection = collection;
this.metadataService.setSavedCollection({ collection: collection, history: this.history });

this.updateParts();
}
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/app/info-editor/info-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ export class InfoEditorComponent implements OnInit {
}

getRoles() {
this.metadataService.loadRoles().subscribe(roles => {
this.partRoles = roles;
});
this.metadataService.loadRoles().subscribe(roles => this.partRoles = roles);
}

getRefinements(role: string) {
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/app/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,32 @@ export class MetadataService {
private componentDefinitionModeSource = new BehaviorSubject(null);
componentDefinitionMode = this.componentDefinitionModeSource.asObservable();

private savedRegistry: string;
private savedCollection: { collection: string, history: Array<object> };

// TODO: DNA strand info

constructor(private http: HttpClient) { }

getSavedRegistry() {
return this.savedRegistry;
}

getSavedCollection() {
return this.savedCollection;
}

setSavedRegistry(registry: string) {
this.savedRegistry = registry;
}

setSavedCollection(collectionInfo: { collection: string, history: Array<object> }) {
this.savedCollection = {
collection: collectionInfo.collection,
history: collectionInfo.history
}
}

loadTypes(): Observable<any> {
return this.http.get(this.typesURL);
}
Expand Down

0 comments on commit 1824374

Please sign in to comment.