diff --git a/client/src/app/admin/instance/dataset/components/detail-page/detail-config-form.component.html b/client/src/app/admin/instance/dataset/components/detail-page/detail-config-form.component.html index f553fd7cd347a737fa8426cdc826ff85e1d9c206..a7ff4270763cbebddc331f66b6dbd60c58a5772d 100644 --- a/client/src/app/admin/instance/dataset/components/detail-page/detail-config-form.component.html +++ b/client/src/app/admin/instance/dataset/components/detail-page/detail-config-form.component.html @@ -1,9 +1,6 @@ <form [formGroup]="form" (ngSubmit)="submit()" novalidate> - <div class="custom-control custom-switch"> - <input class="custom-control-input" type="checkbox" id="enabled" name="enabled" formControlName="enabled"> - <label class="custom-control-label" for="enabled">Enabled</label> - </div> <app-webpage-form-content [form]="form" [controlName]="'content'" [controlLabel]="'Content'" [codeType]="'html'"></app-webpage-form-content> + <app-webpage-form-content [form]="form" [controlName]="'style_sheet'" [controlLabel]="'Style sheet css'" [codeType]="'css'"></app-webpage-form-content> <div class="form-group mt-3"> <ng-content></ng-content> </div> diff --git a/client/src/app/admin/instance/dataset/components/detail-page/detail-config-form.component.ts b/client/src/app/admin/instance/dataset/components/detail-page/detail-config-form.component.ts index 38a92d469d89f3514823e6ba21787e04ea2bb934..b52ba9a4ea0afceab88d1709a165db9adac5dbb2 100644 --- a/client/src/app/admin/instance/dataset/components/detail-page/detail-config-form.component.ts +++ b/client/src/app/admin/instance/dataset/components/detail-page/detail-config-form.component.ts @@ -10,7 +10,7 @@ import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; import { UntypedFormGroup, UntypedFormControl } from '@angular/forms'; -import { Attribute, DetailConfig } from 'src/app/metamodel/models'; +import { DetailConfig } from 'src/app/metamodel/models'; @Component({ selector: 'app-detail-config-form', @@ -22,8 +22,8 @@ export class DetailConfigFormComponent implements OnInit { @Output() onSubmit: EventEmitter<DetailConfig> = new EventEmitter(); public form = new UntypedFormGroup({ - enabled: new UntypedFormControl(false), - content: new UntypedFormControl() + content: new UntypedFormControl(), + style_sheet: new UntypedFormControl(null) }); ngOnInit() { diff --git a/client/src/app/instance/search/detail/components/detail-content.component.html b/client/src/app/instance/search/detail/components/detail-content.component.html index b0961d8fb18ce48ec3ba35de925aa73c81ba1435..ab86c2cb330ff13217b5be25c6a9c5b47fca8fab 100644 --- a/client/src/app/instance/search/detail/components/detail-content.component.html +++ b/client/src/app/instance/search/detail/components/detail-content.component.html @@ -1,4 +1,5 @@ <ngx-dynamic-hooks + class="detail-{{datasetName}}" [content]="detailConfig.content" [parsers]="getParsers()" [context]="getContext()"> diff --git a/client/src/app/instance/search/detail/components/detail-content.component.ts b/client/src/app/instance/search/detail/components/detail-content.component.ts index ca7dfd6084994540ef89324a035ded66e5620c1f..3923f1a88ed1f4bf03ba7c9d5dcd5b980c61d01f 100644 --- a/client/src/app/instance/search/detail/components/detail-content.component.ts +++ b/client/src/app/instance/search/detail/components/detail-content.component.ts @@ -7,11 +7,12 @@ * file that was distributed with this source code. */ -import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; +import { Component, OnInit, Input, ChangeDetectionStrategy } from '@angular/core'; -import { DetailConfig, Dataset, Attribute, OutputFamily, OutputCategory } from 'src/app/metamodel/models'; +import { DetailConfig, Attribute, OutputFamily, OutputCategory } from 'src/app/metamodel/models'; import { globalParsers } from 'src/app/shared/dynamic-content'; import { componentParsers } from '../dynamic-content'; +import { StyleService } from 'src/app/shared/services/style.service'; /** * @class @@ -22,7 +23,7 @@ import { componentParsers } from '../dynamic-content'; templateUrl: 'detail-content.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) -export class DetailContentComponent { +export class DetailContentComponent implements OnInit { @Input() detailConfig: DetailConfig; @Input() object: any; @Input() datasetName: string; @@ -30,6 +31,18 @@ export class DetailContentComponent { @Input() outputFamilyList: OutputFamily[]; @Input() outputCategoryList: OutputCategory[]; + constructor(private style: StyleService) { } + + ngOnInit() { + this.style.addCSS( + this.detailConfig.style_sheet.replace( + /(.+{)/g, + (match, $1) => `.detail-${this.datasetName} ${$1}` + ), + 'detail' + ); + } + getParsers() { return [ ...globalParsers, diff --git a/client/src/app/metamodel/models/detail-config.model.ts b/client/src/app/metamodel/models/detail-config.model.ts index 52f3e6559af5db34257bf1fd7bc6a997715e0b59..a771632a63ef0f14059bdb22a7753dc240648e38 100644 --- a/client/src/app/metamodel/models/detail-config.model.ts +++ b/client/src/app/metamodel/models/detail-config.model.ts @@ -14,6 +14,6 @@ */ export interface DetailConfig { id: number; - enabled: boolean; content: string; + style_sheet: string; } \ No newline at end of file diff --git a/conf-dev/create-db.sh b/conf-dev/create-db.sh index 38e26bcce02944627c2b524a54f5613372270116..5375f265fba8f6083b3c1271ec6a9a1ca3e9ee1f 100644 --- a/conf-dev/create-db.sh +++ b/conf-dev/create-db.sh @@ -45,7 +45,7 @@ curl -d '{"id":57,"name":"spec1dnoise","label":"spec1dnoise","form_label":"spec1 curl -d '{"id":58,"name":"spec1dsky","label":"spec1dsky","form_label":"spec1dsky","description":null,"primary_key":false,"output_display":580,"criteria_display":580,"search_type":null,"type":"text","operator":null,"dynamic_operator":true,"min":null,"max":null,"placeholder_min":null,"placeholder_max":null,"renderer":"download","renderer_config":{"display":"icon-button","text":"DOWNLOAD","icon":"fas fa-download"},"detail_display":580,"selected":true,"order_by":false,"archive":false,"options":null,"vo_utype":null,"vo_ucd":null,"vo_unit":null,"vo_description":null,"vo_datatype":null,"vo_size":null,"id_criteria_family":null,"id_output_category":1,"id_detail_output_category":null}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/vipers_dr2_w1/attribute # Add vipers_dr2_w1 detail config -curl -d '{"enabled":true,"content":"<div class=\"row\">\n <div class=\"col col-md-8 col-sm-12\">\n <app-display-spectra\n [object]=\"context.object\"\n [datasetName]=\"context.datasetName\"\n [attributeList]=\"context.attributeList\"\n [attributeSpectraId]=\"56\"\n [attributeZId]=\"8\">\n </app-display-spectra>\n </div>\n <div class=\"col col-md-4 col-sm-12\">\n <app-display-ra-dec\n [object]=\"context.object\"\n [attributeList]=\"context.attributeList\"\n [attributeRaId]=\"2\"\n [attributeDecId]=\"3\">\n </app-display-ra-dec>\n <app-display-object \n [object]=\"context.object\"\n [attributeList]=\"context.attributeList\"\n [outputFamilyList]=\"context.outputFamilyList\"\n [outputCategoryList]=\"context.outputCategoryList\">\n </app-display-object>\n </div>\n</div>"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/vipers_dr2_w1/detail-config +curl -d '{"content":"<div class=\"row\">\n <div class=\"col col-md-8 col-sm-12\">\n <app-display-spectra\n [object]=\"context.object\"\n [datasetName]=\"context.datasetName\"\n [attributeList]=\"context.attributeList\"\n [attributeSpectraId]=\"56\"\n [attributeZId]=\"8\">\n </app-display-spectra>\n </div>\n <div class=\"col col-md-4 col-sm-12\">\n <app-display-ra-dec\n [object]=\"context.object\"\n [attributeList]=\"context.attributeList\"\n [attributeRaId]=\"2\"\n [attributeDecId]=\"3\">\n </app-display-ra-dec>\n <app-display-object \n [object]=\"context.object\"\n [attributeList]=\"context.attributeList\"\n [outputFamilyList]=\"context.outputFamilyList\"\n [outputCategoryList]=\"context.outputCategoryList\">\n </app-display-object>\n </div>\n</div>","style_sheet":""}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/vipers_dr2_w1/detail-config # Add sp_cards attributes curl -d '{"label":"Card","display":10,"opened":true}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/sp_cards/criteria-family @@ -80,7 +80,7 @@ curl -d '{"id":9,"name":"fits_png","label":"fits_png","form_label":"fits_png","d curl -d '{"id":10,"name":"id_obspack","label":"id_obspack","form_label":"id_obspack","description":null,"primary_key":false,"type":"integer","search_type":null,"operator":null,"dynamic_operator":null,"min":null,"max":null,"options":null,"placeholder_min":null,"placeholder_max":null,"criteria_display":100,"output_display":100,"selected":true,"renderer":"link","renderer_config":{"href":"/instance/default/search/result/iris_obspack?s=100&a=1;2;3&c=1::eq::$value","display":"text","text":"$value","icon":"fas fa-link","blank":false},"order_by":true,"archive":false,"detail_display":100,"vo_utype":null,"vo_ucd":null,"vo_unit":null,"vo_description":null,"vo_datatype":null,"vo_size":null,"id_criteria_family":null,"id_output_category":4,"id_detail_output_category":null}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/observations/attribute # Add observations detail config -curl -d '{"enabled":true,"content":"<div class=\"row justify-content-center\">\n <div class=\"col col-lg-10 col-xl-8 mt-4\">\n <div class=\"row\">\n <div class=\"col-12\">\n <app-display-ra-dec\n [object]=\"context.object\"\n [attributeList]=\"context.attributeList\"\n [attributeRaId]=\"2\"\n [attributeDecId]=\"3\">\n </app-display-ra-dec>\n </div>\n </div>\n\n <app-display-object \n [object]=\"context.object\"\n [attributeList]=\"context.attributeList\"\n [outputFamilyList]=\"context.outputFamilyList\"\n [outputCategoryList]=\"context.outputCategoryList\">\n </app-display-object>\n </div>\n</div>"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/observations/detail-config +curl -d '{"content":"<div class=\"row justify-content-center\">\n <div class=\"col col-lg-10 col-xl-8 mt-4\">\n <div class=\"row\">\n <div class=\"col-12\">\n <app-display-ra-dec\n [object]=\"context.object\"\n [attributeList]=\"context.attributeList\"\n [attributeRaId]=\"2\"\n [attributeDecId]=\"3\">\n </app-display-ra-dec>\n </div>\n </div>\n\n <app-display-object \n [object]=\"context.object\"\n [attributeList]=\"context.attributeList\"\n [outputFamilyList]=\"context.outputFamilyList\"\n [outputCategoryList]=\"context.outputCategoryList\">\n </app-display-object>\n </div>\n</div>","style_sheet":""}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/observations/detail-config # Add vvds_f02_udeep attributes curl -d '{"label":"Default","display":10,"opened":true}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/vvds_f02_udeep/criteria-family diff --git a/server/doctrine-proxy/__CG__AppEntityDetailConfig.php b/server/doctrine-proxy/__CG__AppEntityDetailConfig.php index 45fb9beb72f23dc4407d16a627f62218b360833b..0b6f8d81714afe9627168ee2c0a92998b7120699 100644 --- a/server/doctrine-proxy/__CG__AppEntityDetailConfig.php +++ b/server/doctrine-proxy/__CG__AppEntityDetailConfig.php @@ -67,10 +67,10 @@ class DetailConfig extends \App\Entity\DetailConfig implements \Doctrine\ORM\Pro public function __sleep() { if ($this->__isInitialized__) { - return ['__isInitialized__', 'id', 'enabled', 'content']; + return ['__isInitialized__', 'id', 'content', 'styleSheet']; } - return ['__isInitialized__', 'id', 'enabled', 'content']; + return ['__isInitialized__', 'id', 'content', 'styleSheet']; } /** @@ -195,45 +195,45 @@ class DetailConfig extends \App\Entity\DetailConfig implements \Doctrine\ORM\Pro /** * {@inheritDoc} */ - public function getEnabled() + public function getContent() { - $this->__initializer__ && $this->__initializer__->__invoke($this, 'getEnabled', []); + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getContent', []); - return parent::getEnabled(); + return parent::getContent(); } /** * {@inheritDoc} */ - public function setEnabled($enabled) + public function setContent($content) { - $this->__initializer__ && $this->__initializer__->__invoke($this, 'setEnabled', [$enabled]); + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setContent', [$content]); - return parent::setEnabled($enabled); + return parent::setContent($content); } /** * {@inheritDoc} */ - public function getContent() + public function getStyleSheet() { - $this->__initializer__ && $this->__initializer__->__invoke($this, 'getContent', []); + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getStyleSheet', []); - return parent::getContent(); + return parent::getStyleSheet(); } /** * {@inheritDoc} */ - public function setContent($content) + public function setStyleSheet($styleSheet) { - $this->__initializer__ && $this->__initializer__->__invoke($this, 'setContent', [$content]); + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setStyleSheet', [$styleSheet]); - return parent::setContent($content); + return parent::setStyleSheet($styleSheet); } /** diff --git a/server/src/Action/DetailConfigAction.php b/server/src/Action/DetailConfigAction.php index 38877b680c223c67f67ce097096cb457c3a2027f..051df08492fd6eeac32d221bc651c05a23c9cff8 100644 --- a/server/src/Action/DetailConfigAction.php +++ b/server/src/Action/DetailConfigAction.php @@ -104,8 +104,8 @@ final class DetailConfigAction extends AbstractAction private function checkParsedBody($parsedBody, $request) { $fields = array( - 'enabled', - 'content' + 'content', + 'style_sheet' ); // To work this actions needs information @@ -128,8 +128,8 @@ final class DetailConfigAction extends AbstractAction private function postDetailConfig(array $parsedBody, Dataset $dataset): DetailConfig { $detailConfig = new DetailConfig(); - $detailConfig->setEnabled($parsedBody['enabled']); $detailConfig->setContent($parsedBody['content']); + $detailConfig->setStyleSheet($parsedBody['style_sheet']); $dataset->setDetailConfig($detailConfig); @@ -147,8 +147,8 @@ final class DetailConfigAction extends AbstractAction */ private function editDetailConfig(detailConfig $detailConfig, array $parsedBody): void { - $detailConfig->setEnabled($parsedBody['enabled']); $detailConfig->setContent($parsedBody['content']); + $detailConfig->setStyleSheet($parsedBody['style_sheet']); $this->em->flush(); } } diff --git a/server/src/Entity/DetailConfig.php b/server/src/Entity/DetailConfig.php index 768e3ee18eacf7223cf5dd07373bed8c8e8300ef..a6ae6d00b1effa4bed6831c0a5b20437c33b72bb 100644 --- a/server/src/Entity/DetailConfig.php +++ b/server/src/Entity/DetailConfig.php @@ -31,50 +31,50 @@ class DetailConfig implements \JsonSerializable protected $id; /** - * @var bool + * @var string * - * @Column(type="boolean", name="enabled", nullable=false) + * @Column(type="text", name="content", nullable=false) */ - protected $enabled; + protected $content; /** * @var string * - * @Column(type="text", name="content", nullable=false) + * @Column(type="text", name="style_sheet", nullable=true) */ - protected $content; + protected $styleSheet; public function getId() { return $this->id; } - public function getEnabled() + public function getContent() { - return $this->enabled; + return $this->content; } - public function setEnabled($enabled) + public function setContent($content) { - $this->enabled = $enabled; + $this->content = $content; } - public function getContent() + public function getStyleSheet() { - return $this->content; + return $this->styleSheet; } - public function setContent($content) + public function setStyleSheet($styleSheet) { - $this->content = $content; + $this->styleSheet = $styleSheet; } public function jsonSerialize(): array { return [ 'id' => $this->getId(), - 'enabled' => $this->getEnabled(), - 'content' => $this->getContent() + 'content' => $this->getContent(), + 'style_sheet' => $this->getStyleSheet() ]; } }