diff --git a/client/src/app/admin/components/instance/instance-form.component.html b/client/src/app/admin/components/instance/instance-form.component.html index d0a7d76267b2663e6076c791d1a6181f24389853..f03ff1bb9a0ea74f77df10b25bf89a86a50ff43a 100644 --- a/client/src/app/admin/components/instance/instance-form.component.html +++ b/client/src/app/admin/components/instance/instance-form.component.html @@ -3,11 +3,15 @@ <accordion-group heading="General information" [isOpen]="true"> <div class="form-group"> <label for="name">Name</label> - <input id="name" type="text" class="form-control" id="name" name="name" formControlName="name"> + <input type="text" class="form-control" id="name" name="name" formControlName="name"> </div> <div class="form-group"> <label for="label">Label</label> - <input id="label" type="text" class="form-control" id="label" name="label" formControlName="label"> + <input type="text" class="form-control" id="label" name="label" formControlName="label"> + </div> + <div class="form-group"> + <label for="label">Data path</label> + <input type="text" class="form-control" id="data_path" name="data_path" formControlName="data_path"> </div> </accordion-group> <app-design-form-group [form]="designFormGroup"></app-design-form-group> diff --git a/client/src/app/admin/components/instance/instance-form.component.ts b/client/src/app/admin/components/instance/instance-form.component.ts index 04be669d1ea10c9b5facd2736aa094ede73bf720..f6185d62e16c74bff8264dd29eec845094e08522 100644 --- a/client/src/app/admin/components/instance/instance-form.component.ts +++ b/client/src/app/admin/components/instance/instance-form.component.ts @@ -21,7 +21,7 @@ export class InstanceFormComponent implements OnInit { @Output() onSubmit: EventEmitter<Instance> = new EventEmitter(); public designFormGroup = new FormGroup({ - design_color: new FormControl('', [Validators.required]) + design_color: new FormControl('#7AC29A', [Validators.required]) }); public searchFormGroup = new FormGroup({ @@ -37,6 +37,7 @@ export class InstanceFormComponent implements OnInit { public form = new FormGroup({ name: new FormControl('', [Validators.required]), label: new FormControl('', [Validators.required]), + data_path: new FormControl(''), config: new FormGroup({ design: this.designFormGroup, search: this.searchFormGroup, diff --git a/conf-dev/create-db.sh b/conf-dev/create-db.sh index e9dd7ad6a3988990771e0d3829ecee455e9b64c8..31d6ed97d78410a9378d9d3ca7860f1fcbdd8208 100644 --- a/conf-dev/create-db.sh +++ b/conf-dev/create-db.sh @@ -59,7 +59,7 @@ curl -d '{"label":"Spectra graph","value":"spectra_graph","display":20,"select_n curl -d '{"label":"Test","dbname":"anis_test","dbtype":"pdo_pgsql","dbhost":"db","dbport":5432,"dblogin":"anis","dbpassword":"anis"}' --header 'Content-Type: application/json' -X POST http://localhost/database # Add default instance -curl -d '{"name":"default","label":"Default instance","config":{"design":{"design_color":"#7AC29A"},"search":{"search_by_criteria_allowed":true,"search_multiple_allowed":false,"search_multiple_all_datasets_selected":false},"documentation":{"documentation_allowed":false}}}' --header 'Content-Type: application/json' -X POST http://localhost/instance +curl -d '{"name":"default","label":"Default instance","data_path":"\/DEFAULT","config":{"design":{"design_color":"#7AC29A"},"search":{"search_by_criteria_allowed":true,"search_multiple_allowed":false,"search_multiple_all_datasets_selected":false},"documentation":{"documentation_allowed":false}}}' --header 'Content-Type: application/json' -X POST http://localhost/instance # Add ANIS, SVOM and IRIS surveys curl -d '{"name":"anis_survey","label":"ANIS survey","description":"Survey used for testing","link":"https://anis.lam.fr","manager":"F. Agneray","id_database":1}' --header 'Content-Type: application/json' -X POST http://localhost/survey diff --git a/server/doctrine-proxy/__CG__AppEntityInstance.php b/server/doctrine-proxy/__CG__AppEntityInstance.php index 9ca9b1eb7202f2b35ad21a662133252ba3326706..b971ab686cd1cbd46df3c1149c130ab3998ad7bc 100644 --- a/server/doctrine-proxy/__CG__AppEntityInstance.php +++ b/server/doctrine-proxy/__CG__AppEntityInstance.php @@ -66,10 +66,10 @@ class Instance extends \App\Entity\Instance implements \Doctrine\ORM\Proxy\Proxy public function __sleep() { if ($this->__isInitialized__) { - return ['__isInitialized__', 'name', 'label', 'config', 'datasetFamilies']; + return ['__isInitialized__', 'name', 'label', 'dataPath', 'config', 'datasetFamilies']; } - return ['__isInitialized__', 'name', 'label', 'config', 'datasetFamilies']; + return ['__isInitialized__', 'name', 'label', 'dataPath', 'config', 'datasetFamilies']; } /** @@ -213,6 +213,28 @@ class Instance extends \App\Entity\Instance implements \Doctrine\ORM\Proxy\Proxy return parent::setLabel($label); } + /** + * {@inheritDoc} + */ + public function getDataPath() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDataPath', []); + + return parent::getDataPath(); + } + + /** + * {@inheritDoc} + */ + public function setDataPath($dataPath) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDataPath', [$dataPath]); + + return parent::setDataPath($dataPath); + } + /** * {@inheritDoc} */ diff --git a/server/src/Action/InstanceAction.php b/server/src/Action/InstanceAction.php index 6fa73a66359b600e5208cf44eca01d5b727c6288..82442eb8881917e3e9b2c9292758a7c513ec383c 100644 --- a/server/src/Action/InstanceAction.php +++ b/server/src/Action/InstanceAction.php @@ -60,7 +60,7 @@ final class InstanceAction extends AbstractAction $parsedBody = $request->getParsedBody(); // If mandatories empty fields 400 - foreach (array('label') as $a) { + foreach (array('label', 'data_path') as $a) { if ($this->isEmptyField($a, $parsedBody)) { throw new HttpBadRequestException( $request, @@ -94,6 +94,7 @@ final class InstanceAction extends AbstractAction { $instance->setLabel($parsedBody['label']); $instance->setConfig($parsedBody['config']); + $instance->setDataPath($parsedBody['data_path']); $this->em->flush(); } } diff --git a/server/src/Action/InstanceListAction.php b/server/src/Action/InstanceListAction.php index a24392701bd8689b404c855cf1d37dd826732f2f..9e226441a04659f0e18a5ae2b3ce00c08ef3c6a6 100644 --- a/server/src/Action/InstanceListAction.php +++ b/server/src/Action/InstanceListAction.php @@ -48,7 +48,7 @@ final class InstanceListAction extends AbstractAction $parsedBody = $request->getParsedBody(); // To work this action needs user information to update - foreach (array('name', 'label') as $a) { + foreach (array('name', 'label', 'data_path') as $a) { if ($this->isEmptyField($a, $parsedBody)) { throw new HttpBadRequestException( $request, @@ -77,6 +77,7 @@ final class InstanceListAction extends AbstractAction { $instance = new Instance($parsedBody['name'], $parsedBody['label']); $instance->setConfig($parsedBody['config']); + $instance->setDataPath($parsedBody['data_path']); $this->em->persist($instance); $this->em->flush(); diff --git a/server/src/Entity/Instance.php b/server/src/Entity/Instance.php index 7280ef519f9fea8a2d2d4a3cbd7c9b327d182798..d95670e1f5ddbf8e1bb5eb7daf2eb1a584c7e566 100644 --- a/server/src/Entity/Instance.php +++ b/server/src/Entity/Instance.php @@ -38,6 +38,13 @@ class Instance implements \JsonSerializable */ protected $label; + /** + * @var string + * + * @Column(type="string", name="data_path", nullable=true) + */ + protected $dataPath; + /** * @var string * @@ -74,6 +81,16 @@ class Instance implements \JsonSerializable $this->label = $label; } + public function getDataPath() + { + return $this->dataPath; + } + + public function setDataPath($dataPath) + { + $this->dataPath = $dataPath; + } + public function getConfig() { return $this->config; @@ -103,6 +120,7 @@ class Instance implements \JsonSerializable return [ 'name' => $this->getName(), 'label' => $this->getLabel(), + 'data_path' => $this->getDataPath(), 'config' => $this->getConfig(), 'nb_dataset_families' => count($this->getDatasetFamilies()), 'nb_datasets' => $this->getNbDatasets()