Skip to content
Snippets Groups Projects
Commit ec6570b7 authored by François Agneray's avatar François Agneray
Browse files

#81 => done

parent e6637cec
No related branches found
No related tags found
1 merge request!72Develop
Pipeline #9405 passed
Pipeline: anis-next

#9407

    Pipeline: anis-next

    #9406

      <form [formGroup]="form" (ngSubmit)="submit()" novalidate> <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]="'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"> <div class="form-group mt-3">
      <ng-content></ng-content> <ng-content></ng-content>
      </div> </div>
      ......
      ...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
      import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
      import { UntypedFormGroup, UntypedFormControl } from '@angular/forms'; import { UntypedFormGroup, UntypedFormControl } from '@angular/forms';
      import { Attribute, DetailConfig } from 'src/app/metamodel/models'; import { DetailConfig } from 'src/app/metamodel/models';
      @Component({ @Component({
      selector: 'app-detail-config-form', selector: 'app-detail-config-form',
      ...@@ -22,8 +22,8 @@ export class DetailConfigFormComponent implements OnInit { ...@@ -22,8 +22,8 @@ export class DetailConfigFormComponent implements OnInit {
      @Output() onSubmit: EventEmitter<DetailConfig> = new EventEmitter(); @Output() onSubmit: EventEmitter<DetailConfig> = new EventEmitter();
      public form = new UntypedFormGroup({ public form = new UntypedFormGroup({
      enabled: new UntypedFormControl(false), content: new UntypedFormControl(),
      content: new UntypedFormControl() style_sheet: new UntypedFormControl(null)
      }); });
      ngOnInit() { ngOnInit() {
      ......
      <ngx-dynamic-hooks <ngx-dynamic-hooks
      class="detail-{{datasetName}}"
      [content]="detailConfig.content" [content]="detailConfig.content"
      [parsers]="getParsers()" [parsers]="getParsers()"
      [context]="getContext()"> [context]="getContext()">
      ......
      ...@@ -7,11 +7,12 @@ ...@@ -7,11 +7,12 @@
      * file that was distributed with this source code. * 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 { globalParsers } from 'src/app/shared/dynamic-content';
      import { componentParsers } from '../dynamic-content'; import { componentParsers } from '../dynamic-content';
      import { StyleService } from 'src/app/shared/services/style.service';
      /** /**
      * @class * @class
      ...@@ -22,7 +23,7 @@ import { componentParsers } from '../dynamic-content'; ...@@ -22,7 +23,7 @@ import { componentParsers } from '../dynamic-content';
      templateUrl: 'detail-content.component.html', templateUrl: 'detail-content.component.html',
      changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
      }) })
      export class DetailContentComponent { export class DetailContentComponent implements OnInit {
      @Input() detailConfig: DetailConfig; @Input() detailConfig: DetailConfig;
      @Input() object: any; @Input() object: any;
      @Input() datasetName: string; @Input() datasetName: string;
      ...@@ -30,6 +31,18 @@ export class DetailContentComponent { ...@@ -30,6 +31,18 @@ export class DetailContentComponent {
      @Input() outputFamilyList: OutputFamily[]; @Input() outputFamilyList: OutputFamily[];
      @Input() outputCategoryList: OutputCategory[]; @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() { getParsers() {
      return [ return [
      ...globalParsers, ...globalParsers,
      ......
      ...@@ -14,6 +14,6 @@ ...@@ -14,6 +14,6 @@
      */ */
      export interface DetailConfig { export interface DetailConfig {
      id: number; id: number;
      enabled: boolean;
      content: string; content: string;
      style_sheet: string;
      } }
      \ No newline at end of file
      ...@@ -45,7 +45,7 @@ curl -d '{"id":57,"name":"spec1dnoise","label":"spec1dnoise","form_label":"spec1 ...@@ -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 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 # 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 # 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 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 ...@@ -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 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 # 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 # 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 curl -d '{"label":"Default","display":10,"opened":true}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/vvds_f02_udeep/criteria-family
      ......
      ...@@ -67,10 +67,10 @@ class DetailConfig extends \App\Entity\DetailConfig implements \Doctrine\ORM\Pro ...@@ -67,10 +67,10 @@ class DetailConfig extends \App\Entity\DetailConfig implements \Doctrine\ORM\Pro
      public function __sleep() public function __sleep()
      { {
      if ($this->__isInitialized__) { 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 ...@@ -195,45 +195,45 @@ class DetailConfig extends \App\Entity\DetailConfig implements \Doctrine\ORM\Pro
      /** /**
      * {@inheritDoc} * {@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} * {@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} * {@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} * {@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);
      } }
      /** /**
      ......
      ...@@ -104,8 +104,8 @@ final class DetailConfigAction extends AbstractAction ...@@ -104,8 +104,8 @@ final class DetailConfigAction extends AbstractAction
      private function checkParsedBody($parsedBody, $request) private function checkParsedBody($parsedBody, $request)
      { {
      $fields = array( $fields = array(
      'enabled', 'content',
      'content' 'style_sheet'
      ); );
      // To work this actions needs information // To work this actions needs information
      ...@@ -128,8 +128,8 @@ final class DetailConfigAction extends AbstractAction ...@@ -128,8 +128,8 @@ final class DetailConfigAction extends AbstractAction
      private function postDetailConfig(array $parsedBody, Dataset $dataset): DetailConfig private function postDetailConfig(array $parsedBody, Dataset $dataset): DetailConfig
      { {
      $detailConfig = new DetailConfig(); $detailConfig = new DetailConfig();
      $detailConfig->setEnabled($parsedBody['enabled']);
      $detailConfig->setContent($parsedBody['content']); $detailConfig->setContent($parsedBody['content']);
      $detailConfig->setStyleSheet($parsedBody['style_sheet']);
      $dataset->setDetailConfig($detailConfig); $dataset->setDetailConfig($detailConfig);
      ...@@ -147,8 +147,8 @@ final class DetailConfigAction extends AbstractAction ...@@ -147,8 +147,8 @@ final class DetailConfigAction extends AbstractAction
      */ */
      private function editDetailConfig(detailConfig $detailConfig, array $parsedBody): void private function editDetailConfig(detailConfig $detailConfig, array $parsedBody): void
      { {
      $detailConfig->setEnabled($parsedBody['enabled']);
      $detailConfig->setContent($parsedBody['content']); $detailConfig->setContent($parsedBody['content']);
      $detailConfig->setStyleSheet($parsedBody['style_sheet']);
      $this->em->flush(); $this->em->flush();
      } }
      } }
      ...@@ -31,50 +31,50 @@ class DetailConfig implements \JsonSerializable ...@@ -31,50 +31,50 @@ class DetailConfig implements \JsonSerializable
      protected $id; 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 * @var string
      * *
      * @Column(type="text", name="content", nullable=false) * @Column(type="text", name="style_sheet", nullable=true)
      */ */
      protected $content; protected $styleSheet;
      public function getId() public function getId()
      { {
      return $this->id; 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 public function jsonSerialize(): array
      { {
      return [ return [
      'id' => $this->getId(), 'id' => $this->getId(),
      'enabled' => $this->getEnabled(), 'content' => $this->getContent(),
      'content' => $this->getContent() 'style_sheet' => $this->getStyleSheet()
      ]; ];
      } }
      } }
      0% Loading or .
      You are about to add 0 people to the discussion. Proceed with caution.
      Finish editing this message first!
      Please register or to comment