import { Injectable } from '@angular/core' ; declare var LabelStudio ; @ Injectable ( { providedIn : 'root' , } ) export class LabelStudioService { imageLabelInfo : any ; constructor ( ) { } initLabelStudio ( option ) { this . imageLabelInfo = new LabelStudio ( option . dom , { config : `
        <View >
          <Image name="image" value="$image"/>
          ${ option . annotationQuestion }
          <RectangleLabels name="rect" toName="image" strokeWidth="5" opacity="0.9" canRotate="false" fillOpacity="0.3">
          ${ option . imageRectLabelTemplate }
          </RectangleLabels>
          <PolygonLabels name="poly" toName="image" strokeWidth="5" pointSize="large" opacity="0.9" fillOpacity="0.3">
          ${ option . imagePolyLabelTemplate }
          </PolygonLabels>
        </View>
      ` , interfaces : [ ] , task : { completions : option . historyCompletions , predictions : [ ] , id : 1 , data : { image : option . url , } , } , onSubmitCompletion ( ls , completion ) { const bb = ls . completionStore . completions [ 0 ] . serializeCompletion ( ) ; } , updateCompletion ( ls , completion ) { } , onDeleteCompletion ( ls , completion ) { } , onEntityCreate ( region ) { } , onEntityDelete ( region ) { } , onSkipTask ( ls ) { } , onLabelStudioLoad ( LS ) { const c = LS . completionStore . addCompletion ( { userGenerate : true , } ) ; this . onLabelStudioLoadInfo = LS . completionStore . selectCompletion ( c . id ) ; } , } ) ; if ( option . from == 'annotate' ) { if ( ! this . imageLabelInfo . settings . enableTooltips ) { this . imageLabelInfo . settings . toggleLabelTooltips ( ) ; } if ( this . imageLabelInfo . settings . enableHotkeys ) { this . imageLabelInfo . settings . toggleHotkeys ( ) ; } if ( ! this . imageLabelInfo . settings . showLabels ) { this . imageLabelInfo . settings . toggleShowLabels ( ) ; } if ( ! this . imageLabelInfo . settings . continuousLabeling ) { this . imageLabelInfo . settings . toggleContinuousLabeling ( ) ; } } else { if ( ! this . imageLabelInfo . settings . enableTooltips ) { this . imageLabelInfo . settings . toggleLabelTooltips ( ) ; } if ( ! this . imageLabelInfo . settings . showLabels ) { this . imageLabelInfo . settings . toggleShowLabels ( ) ; } this . imageLabelInfo . completionStore . selectCompletion ( ) . setEdit ( false ) ; } } }