|
|
|
@ -32,7 +32,7 @@ import { |
|
|
|
} from '@shared/models/resource.models'; |
|
|
|
import { startWith, takeUntil } from 'rxjs/operators'; |
|
|
|
import { ActionNotificationShow } from '@core/notification/notification.actions'; |
|
|
|
import { isDefinedAndNotNull } from '@core/utils'; |
|
|
|
import { base64toString, isDefinedAndNotNull, stringToBase64 } from '@core/utils'; |
|
|
|
import { getCurrentAuthState } from '@core/auth/auth.selectors'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
@ -84,13 +84,13 @@ export class JsResourceComponent extends EntityComponent<Resource> implements On |
|
|
|
resourceSubType: [entity?.resourceSubType ? entity.resourceSubType : ResourceSubType.EXTENSION, Validators.required], |
|
|
|
fileName: [entity ? entity.fileName : null, Validators.required], |
|
|
|
data: [entity ? entity.data : null, this.isAdd ? [Validators.required] : []], |
|
|
|
content: [entity?.data?.length ? window.atob(entity.data) : '', Validators.required] |
|
|
|
content: [entity?.data?.length ? base64toString(entity.data) : '', Validators.required] |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
updateForm(entity: Resource): void { |
|
|
|
this.entityForm.patchValue(entity); |
|
|
|
const content = entity.resourceSubType === ResourceSubType.MODULE && entity?.data?.length ? window.atob(entity.data) : ''; |
|
|
|
const content = entity.resourceSubType === ResourceSubType.MODULE && entity?.data?.length ? base64toString(entity.data) : ''; |
|
|
|
this.entityForm.get('content').patchValue(content); |
|
|
|
} |
|
|
|
|
|
|
|
@ -110,7 +110,7 @@ export class JsResourceComponent extends EntityComponent<Resource> implements On |
|
|
|
if (!formValue.fileName) { |
|
|
|
formValue.fileName = formValue.title + '.js'; |
|
|
|
} |
|
|
|
formValue.data = window.btoa((formValue as any).content); |
|
|
|
formValue.data = stringToBase64((formValue as any).content); |
|
|
|
delete (formValue as any).content; |
|
|
|
} |
|
|
|
return super.prepareFormValue(formValue); |
|
|
|
|