Commit 4af442d4 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Add authentication as instance config parameter

parent 0b2653bd
......@@ -13,16 +13,23 @@
</div>
<hr class="mt-4">
<h4>Authentication: </h4>
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="authentication" name="authentication" [ngModel]="getConfig('authentication', 'allowed')">
<label class="form-check-label" for="authentication">User authentication available</label>
</div>
<hr>
<h4>Search: </h4>
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="search" name="search" [ngModel]="getConfig('search')">
<input class="form-check-input" type="checkbox" id="search" name="search" [ngModel]="getConfig('search', 'allowed')">
<label class="form-check-label" for="search">Classic search allowed</label>
</div>
<hr>
<h4>Search multiple: </h4>
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="search_multiple" name="search_multiple" [ngModel]="getConfigSearchMultiple('allowed')">
<input class="form-check-input" type="checkbox" id="search_multiple" name="search_multiple" [ngModel]="getConfig('search_multiple', 'allowed')">
<label class="form-check-label" for="search_multiple">Search multiple allowed</label>
</div>
<div class="form-check mb-2">
......@@ -31,14 +38,14 @@
id="all_datasets_selected"
name="all_datasets_selected"
[disabled]="!ngForm.form.value.search_multiple"
[ngModel]="getConfigSearchMultiple('all_datasets_selected')">
[ngModel]="getConfig('search_multiple', 'all_datasets_selected')">
<label class="form-check-label" for="all_datasets_selected">All datasets with cone search enabled selected by default</label>
</div>
<hr>
<h4>Documentation: </h4>
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="documentation" name="documentation" [ngModel]="getConfig('documentation')">
<input class="form-check-input" type="checkbox" id="documentation" name="documentation" [ngModel]="getConfig('documentation', 'allowed')">
<label class="form-check-label" for="documentation">Documentation allowed</label>
</div>
......
......@@ -12,30 +12,31 @@ export class FormInstanceComponent {
@Input() model: Instance = new Instance();
@Output() submitted: EventEmitter<Instance> = new EventEmitter();
getConfig(key: string): boolean {
if (this.model.config && this.model.config[key]) {
return this.model.config[key];
}
return false;
}
getConfigSearchMultiple(key: string): boolean {
if (this.model.config && this.model.config.search_multiple && this.model.config.search_multiple[key]) {
return this.model.config.search_multiple[key];
getConfig(prop: string, key: string): boolean {
if (this.model.config && this.model.config[prop] && this.model.config[prop][key]) {
return this.model.config[prop][key];
}
return false;
}
emit(instance: Instance) {
let instanceEmitted: Instance;
(this.model.name) ? instanceEmitted = {name: this.model.name, ...instance} : instanceEmitted = instance;
(this.model.name) ? instanceEmitted = { name: this.model.name, ...instance } : instanceEmitted = instance;
instanceEmitted.config = {
search: this.ngForm.form.value.search,
authentication: {
allowed: this.ngForm.form.value.authentication
},
search: {
allowed: this.ngForm.form.value.search
},
search_multiple: {
allowed: this.ngForm.form.value.search_multiple,
all_datasets_selected: this.ngForm.form.value.all_datasets_selected
},
documentation: this.ngForm.value.documentation
documentation: {
allowed: this.ngForm.value.documentation
}
};
this.submitted.emit(instanceEmitted);
}
......
import { Component, OnInit} from '@angular/core';
import { Observable } from 'rxjs';
import { Component, OnInit } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { Instance } from '../../store/model';
import * as instanceActions from '../../store/action/instance.action';
......
......@@ -3,11 +3,18 @@ export class Instance {
label: string;
client_url: string;
config: {
search: boolean;
authentication: {
allowed: boolean;
};
search: {
allowed: boolean;
};
search_multiple: {
allowed: boolean;
all_datasets_selected: boolean;
};
documentation: boolean;
documentation: {
allowed: boolean;
};
};
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment