1- import { Component , OnInit , Input , OnDestroy } from '@angular/core' ;
1+ import { Component , OnInit , OnDestroy } from '@angular/core' ;
22import { TranslateService } from '@ngx-translate/core' ;
33import { ActivatedRoute , Router } from '@angular/router' ;
44import { Datatarget } from '../../datatarget.model' ;
5- import { Observable , Subscription } from 'rxjs' ;
5+ import { Subscription } from 'rxjs' ;
66import { Application } from '@applications/application.model' ;
77import { IotDevice } from '@applications/iot-devices/iot-device.model' ;
88import { faTimesCircle } from '@fortawesome/free-solid-svg-icons' ;
@@ -20,11 +20,7 @@ import { HttpErrorResponse } from '@angular/common/http';
2020import { PayloadDecoderMappedResponse } from '@payload-decoder/payload-decoder.model' ;
2121import { DeleteDialogComponent } from '@shared/components/delete-dialog/delete-dialog.component' ;
2222import { ErrorMessageService } from '@shared/error-message.service' ;
23- import { OpendatadkDialogService } from '@shared/components/opendatadk-dialog/opendatadk-dialog.service' ;
24- import { OpendatadkService } from '@shared/services/opendatadk.service' ;
2523import { ScrollToTopService } from '@shared/services/scroll-to-top.service' ;
26- import { OpenDataDkDataset } from '../../opendatadk/opendatadk-dataset.model' ;
27- import { DataTargetType } from '@shared/enums/datatarget-type' ;
2824import { DatatargetEdit } from '@applications/datatarget/datatarget-edit/datatarget-edit' ;
2925import { MeService } from '@shared/services/me.service' ;
3026import { OrganizationAccessScope } from '@shared/enums/access-scopes' ;
@@ -52,13 +48,10 @@ export class HttppushEditComponent
5248 public formFailedSubmit = false ;
5349 public datatargetid : number ;
5450 private applicationId : number ;
55- private applicationName : string ;
5651 public application : Application ;
5752 public devices : IotDevice [ ] ;
5853 public payloadDecoders = [ ] ;
5954 private counter : number ;
60- private dataSetExcists = false ;
61- private isMailDialogAlreadyShown = false ;
6255
6356 payloadDeviceDatatarget : PayloadDeviceDatatarget [ ] ;
6457 newDynamic : any = { } ;
@@ -75,8 +68,6 @@ export class HttppushEditComponent
7568 private saveSnackService : SnackService ,
7669 private dialog : MatDialog ,
7770 private errorMessageService : ErrorMessageService ,
78- private opendatadkService : OpendatadkService ,
79- private opendatadkDialogService : OpendatadkDialogService ,
8071 private scrollToTopService : ScrollToTopService ,
8172 private meService : MeService
8273 ) {
@@ -104,7 +95,6 @@ export class HttppushEditComponent
10495
10596 this . datatargetid = + this . route . snapshot . paramMap . get ( 'datatargetId' ) ;
10697 this . applicationId = + this . route . snapshot . paramMap . get ( 'id' ) ;
107- this . applicationName = this . route . snapshot . paramMap . get ( 'name' ) ;
10898 if ( this . datatargetid !== 0 ) {
10999 this . getDatatarget ( this . datatargetid ) ;
110100 this . getPayloadDeviceDatatarget ( this . datatargetid ) ;
@@ -113,7 +103,6 @@ export class HttppushEditComponent
113103 this . getDevices ( ) ;
114104 }
115105 this . getPayloadDecoders ( ) ;
116- this . setDataSetExcists ( ) ;
117106 this . canEdit = this . meService . hasAccessToTargetOrganization (
118107 OrganizationAccessScope . ApplicationWrite ,
119108 undefined ,
@@ -186,15 +175,8 @@ export class HttppushEditComponent
186175 this . datatargetService . update ( this . datatarget ) . subscribe (
187176 ( response : Datatarget ) => {
188177 this . datatarget = response ;
189- if ( this . datatarget . openDataDkDataset != null ) {
190- this . datatarget . openDataDkDataset . acceptTerms = true ;
191- }
192- this . shouldShowMailDialog ( ) . subscribe ( ( response ) => {
193- this . countToRedirect ( ) ;
194- } ) ;
195178 } ,
196179 ( error : HttpErrorResponse ) => {
197- this . checkDataTargetModelOpendatadkdatasaet ( ) ;
198180 this . handleError ( error ) ;
199181 this . formFailedSubmit = true ;
200182 }
@@ -253,14 +235,10 @@ export class HttppushEditComponent
253235 ( response : Datatarget ) => {
254236 this . datatargetid = response . id ;
255237 this . datatarget = response ;
256- if ( this . datatarget . openDataDkDataset != null ) {
257- this . datatarget . openDataDkDataset . acceptTerms = true ;
258- }
259238 this . showSavedSnack ( ) ;
260239 this . routeToDatatargets ( ) ;
261240 } ,
262241 ( error : HttpErrorResponse ) => {
263- this . checkDataTargetModelOpendatadkdatasaet ( ) ;
264242 this . handleError ( error ) ;
265243 this . formFailedSubmit = true ;
266244 }
@@ -273,12 +251,6 @@ export class HttppushEditComponent
273251 this . formFailedSubmit = false ;
274252 }
275253
276- checkDataTargetModelOpendatadkdatasaet ( ) {
277- if ( ! this . datatarget . openDataDkDataset ) {
278- this . datatarget . openDataDkDataset = new OpenDataDkDataset ( ) ;
279- }
280- }
281-
282254 getDevices ( ) : void {
283255 this . applicationSubscription = this . applicationService
284256 . getApplication ( this . applicationId )
@@ -338,51 +310,8 @@ export class HttppushEditComponent
338310 this . saveSnackService . showSavedSnack ( ) ;
339311 }
340312
341- private setDataSetExcists ( ) {
342- this . opendatadkService . get ( ) . subscribe ( ( response ) => {
343- this . dataSetExcists = response . dataset . length === 0 ? false : true ;
344- } ) ;
345- }
346-
347- private shouldShowMailDialog ( ) : Observable < any > {
348- return new Observable ( ( observer ) => {
349- if (
350- ! this . dataSetExcists &&
351- this . datatarget . setToOpendataDk &&
352- ! this . isMailDialogAlreadyShown
353- ) {
354- this . isMailDialogAlreadyShown = true ;
355- this . opendatadkDialogService . showDialog ( ) . subscribe ( ( response ) => {
356- if ( response ) {
357- this . showMailClient ( ) ;
358- }
359- observer . next ( response ) ;
360- } ) ;
361- } else {
362- observer . next ( true ) ;
363- }
364- } ) ;
365- }
366-
367- private showMailClient ( ) {
368- if ( ! this . datatarget . openDataDkDataset . url ) {
369- this . datatarget . openDataDkDataset . url = this . datatargetService . getOpendataSharingApiUrl ( ) ;
370- }
371- window . location . href =
372- 'mailto:[email protected] ?subject=Oprettelse%20af%20datas%C3%A6t%20i%20OpenDataDK&body=K%C3%A6re%20Frans%0D%0A%0D%0AHermed%20fremsendes%20linket%20til%20DCAT%20kataloget%20%2C%20du%20bedes%20registrere%20p%C3%A5%20Open%20Data%20DK%20platformen.%0D%0A%0D%0ALink%3A ' + 373- this . datatarget . openDataDkDataset . url ;
374- }
375-
376313 disableSaveButton ( ) : boolean {
377- let disable = true ;
378- if ( ! this . datatarget . setToOpendataDk ) {
379- disable = false ;
380- } else if ( this . datatarget . openDataDkDataset ?. acceptTerms ) {
381- disable = false ;
382- } else {
383- disable = true ;
384- }
385- return disable ;
314+ return false ;
386315 }
387316
388317 ngOnDestroy ( ) : void {
0 commit comments