File

widgets/implementations/image/image-widget-config/image-widget-config.component.ts

Implements

OnInit OnDestroy OnBeforeSave

Metadata

Index

Properties
Methods
Inputs

Constructor

constructor(formBuilder: FormBuilder, form: NgForm, fileService: FilesService, alert: AlertService, imageWidget: ImageWidgetService, widgetConfig: WidgetConfigComponent)
Parameters :
Name Type Optional
formBuilder FormBuilder No
form NgForm No
fileService FilesService No
alert AlertService No
imageWidget ImageWidgetService No
widgetConfig WidgetConfigComponent No

Inputs

config
Type : ImageWidgetConfig

Methods

ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
Async onBeforeSave
onBeforeSave(config?: ImageWidgetConfig)
Parameters :
Name Type Optional
config ImageWidgetConfig Yes
Returns : Promise<boolean>

Properties

destroyed$
Default value : new Subject<void>()
fileFromConfig
Type : File
formGroup
Type : FormGroup
imageBinaryId$
Default value : new BehaviorSubject<string>(null)
imageSrc$
Type : Observable<string>
loading
Default value : false
objectFitOptions
Type : []
Default value : [ { label: gettext('Contain`verb, image fitting option`'), value: 'contain', description: gettext( 'The image is entirely displayed within the widget while preserving the aspect ratio.' ) }, { label: gettext('Cover`verb, image fitting option`'), value: 'cover', description: gettext( 'The image is resized to fill the widget while preserving the aspect ratio. Overflowing areas are clipped.' ) }, { label: gettext('Fill`verb, image fitting option`'), value: 'fill', description: gettext( 'The image is stretched to fill the widget, overriding the aspect-ratio.' ) }, { label: gettext('Full width`image fitting option`'), value: 'full-width', description: gettext( `The image is resized to fit the widget's width while preserving the aspect ratio. Overflowing area is scrollable.` ) } ]
styling
Type : ImageWidgetStyle | null
<div class="p-l-24 p-r-24">
  <div [formGroup]="formGroup" class="row p-t-8">
    <div class="col-md-12">
      <c8y-form-group>
        <label>{{ 'Image' | translate }}</label>
        <c8y-drop-area
          formControlName="images"
          class="drop-area-sm"
          [icon]="'upload'"
          [accept]="'image'"
          [maxAllowedFiles]="1"
        ></c8y-drop-area>
        <c8y-messages>
          <c8y-message
            name="maxFileSizeReached"
            [text]="
              'The maximum image size is {{ maxFileSize }} kB. The selected image has a size of {{ actualFileSize }} kB.'
                | translate
            "
          ></c8y-message>
          <c8y-message
            name="wrongFileType"
            [text]="'Wrong file type, select an image.' | translate"
          ></c8y-message>
          <c8y-message name="maxlength" [text]="'Only select one image.' | translate"></c8y-message>
          <c8y-message name="required" [text]="'An image is required.' | translate"></c8y-message>
          <c8y-message name="minlength" [text]="'An image is required.' | translate"></c8y-message>
        </c8y-messages>
      </c8y-form-group>
    </div>
    <ng-container *ngIf="imageSrc$ | async as src">
      <div class="col-md-6">
        <div class="legend form-block">
          {{ 'Size and alignment' | translate }}
        </div>
        <div [formGroupName]="'styling'">
          <c8y-form-group>
            <label>
              {{ 'Image display' | translate }}
            </label>
            <ul class="list-group separator-top-bottom">
              <li
                class="list-group-item d-flex a-i-center p-l-0"
                *ngFor="let objectFitOption of objectFitOptions; let i = index"
              >
                <label class="c8y-radio">
                  <input
                    type="radio"
                    [id]="'groupradiocontentclass' + i"
                    formControlName="objectFit"
                    [value]="objectFitOption.value"
                  />
                  <span></span>
                  <span class="l-h-1">
                    {{ objectFitOption.label | translate }}
                    <br />
                    <small class="text-muted">
                      {{ objectFitOption.description | translate }}
                    </small>
                  </span>
                </label>
              </li>
            </ul>
          </c8y-form-group>
          <div class="row">
            <div class="col-md-6">
              <c8y-form-group>
                <label>{{ 'Horizontal alignment' | translate }}</label>
                <div class="c8y-select-wrapper">
                  <select class="form-control" formControlName="objectPositionX">
                    <option [ngValue]="'left'">
                      {{ 'left`horizontal alignment`' | translate }}
                    </option>
                    <option [ngValue]="'center'">
                      {{ 'center`horizontal alignment`' | translate }}
                    </option>
                    <option [ngValue]="'right'">
                      {{ 'right`horizontal alignment`' | translate }}
                    </option>
                  </select>
                </div>
              </c8y-form-group>
            </div>
            <div class="col-md-6">
              <c8y-form-group>
                <label>{{ 'Vertical alignment' | translate }}</label>
                <div class="c8y-select-wrapper">
                  <select class="form-control" formControlName="objectPositionY">
                    <option [ngValue]="'top'">
                      {{ 'top`vertical alignment`' | translate }}
                    </option>
                    <option [ngValue]="'center'">
                      {{ 'center`vertical alignment`' | translate }}
                    </option>
                    <option [ngValue]="'bottom'">
                      {{ 'bottom`vertical alignment`' | translate }}
                    </option>
                  </select>
                </div>
              </c8y-form-group>
            </div>
          </div>
        </div>
      </div>
      <div class="col-md-6">
        <div class="legend form-block">{{ 'Preview' | translate }}</div>
        <div class="form-group">
          <div
            class="border-top border-right border-bottom border-left inner-scroll"
            style="height: 300px"
          >
            <img
              [src]="src"
              [ngClass]="styling ? 'fit-h fit-w' : 'img-responsive'"
              [ngStyle]="styling"
            />
          </div>
        </div>
      </div>
    </ng-container>
    <div class="col-md-12 d-flex j-c-center" *ngIf="loading">
      <c8y-loading></c8y-loading>
    </div>
  </div>
</div>

results matching ""

    No results matching ""