|
|
|
@ -5,12 +5,12 @@ |
|
|
|
* Copyright (c) Sebastian Stehle. All rights reserved |
|
|
|
*/ |
|
|
|
|
|
|
|
import { Component, EventEmitter, Input, Output } from '@angular/core'; |
|
|
|
import { Component, EventEmitter, Output } from '@angular/core'; |
|
|
|
import { FormBuilder, Validators } from '@angular/forms'; |
|
|
|
|
|
|
|
import { |
|
|
|
ApiUrlConfig, |
|
|
|
AuthService, |
|
|
|
AppContext, |
|
|
|
DateTime, |
|
|
|
fadeAnimation, |
|
|
|
SchemaDetailsDto, |
|
|
|
@ -24,6 +24,9 @@ const FALLBACK_NAME = 'my-schema'; |
|
|
|
selector: 'sqx-schema-form', |
|
|
|
styleUrls: ['./schema-form.component.scss'], |
|
|
|
templateUrl: './schema-form.component.html', |
|
|
|
providers: [ |
|
|
|
AppContext |
|
|
|
], |
|
|
|
animations: [ |
|
|
|
fadeAnimation |
|
|
|
] |
|
|
|
@ -35,9 +38,6 @@ export class SchemaFormComponent { |
|
|
|
@Output() |
|
|
|
public cancelled = new EventEmitter(); |
|
|
|
|
|
|
|
@Input() |
|
|
|
public appName: string; |
|
|
|
|
|
|
|
public showImport = false; |
|
|
|
|
|
|
|
public createFormError = ''; |
|
|
|
@ -59,9 +59,9 @@ export class SchemaFormComponent { |
|
|
|
|
|
|
|
constructor( |
|
|
|
public readonly apiUrl: ApiUrlConfig, |
|
|
|
public readonly ctx: AppContext, |
|
|
|
private readonly schemas: SchemasService, |
|
|
|
private readonly formBuilder: FormBuilder, |
|
|
|
private readonly authService: AuthService |
|
|
|
private readonly formBuilder: FormBuilder |
|
|
|
) { |
|
|
|
} |
|
|
|
|
|
|
|
@ -85,9 +85,7 @@ export class SchemaFormComponent { |
|
|
|
const schemaName = this.createForm.controls['name'].value; |
|
|
|
const schemaDto = Object.assign(this.createForm.controls['import'].value || {}, { name: schemaName }); |
|
|
|
|
|
|
|
const me = this.authService.user!.token; |
|
|
|
|
|
|
|
this.schemas.postSchema(this.appName, schemaDto, me, DateTime.now()) |
|
|
|
this.schemas.postSchema(this.ctx.appName, schemaDto, this.ctx.userToken, DateTime.now()) |
|
|
|
.subscribe(dto => { |
|
|
|
this.emitCreated(dto); |
|
|
|
this.resetCreateForm(); |
|
|
|
|