1 import { Component, OnInit } from '@angular/core';
2 import { ActivatedRoute } from '@angular/router';
3 import { DataGatewayService } from '~/app/shared/services/data-gateway.service';
4 import { BackButtonComponent } from '~/app/shared/components/back-button/back-button.component';
5 import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
6 import { FinishedTask } from '~/app/shared/models/finished-task';
7 import { Location } from '@angular/common';
10 selector: 'cd-crud-form',
11 templateUrl: './crud-form.component.html',
12 styleUrls: ['./crud-form.component.scss']
14 export class CrudFormComponent implements OnInit {
19 cancel: BackButtonComponent
25 defautWidgetOptions: {
27 required: 'This field is required'
32 private dataGatewayService: DataGatewayService,
33 private activatedRoute: ActivatedRoute,
34 private taskWrapper: TaskWrapperService,
35 private location: Location
39 this.activatedRoute.data.subscribe((data: any) => {
40 this.resource = data.resource;
41 this.dataGatewayService.list(`ui-${this.resource}`).subscribe((response: any) => {
42 this.title = response.forms[0].control_schema.title;
43 this.uiSchema = response.forms[0].ui_schema;
44 this.controlSchema = response.forms[0].control_schema;
53 task: new FinishedTask('ceph-user/create', {
54 user_entity: data.user_entity
56 call: this.dataGatewayService.create(this.resource, data)