<div class="form-group row" *ngIf="getProjectType === 'Add'">
<label class="col-sm-4 col-form-label">{{'DOMAIN' | translate}} {{'NAME' | translate}}</label>
<div class="col-sm-8">
- <ng-select [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="domains" bindLabel="text"
- bindValue="id" formControlName="domain_name" id="domain_name"
+ <ng-select [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="domains" bindLabel="title"
+ bindValue="value" formControlName="domain_name" id="domain_name"
[ngClass]="{ 'is-invalid': submitted && f.domain_name.errors }"></ng-select>
</div>
</div>
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { NotifierService } from 'angular-notifier';
-import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel';
+import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, TYPESECTION } from 'CommonModel';
import { DataService } from 'DataService';
import { environment } from 'environment';
-import { ProjectData, ProjectDetails, QUOTA_ITEMS, QUOTAITEM} from 'ProjectModel';
+import { ProjectData, ProjectDetails, QUOTAITEM, QUOTA_ITEMS } from 'ProjectModel';
import { ProjectService } from 'ProjectService';
import { RestService } from 'RestService';
import { SharedService } from 'SharedService';
* @Component takes ProjectCreateUpdateComponent.html as template url
*/
@Component({
- selector: 'app-project-create-update',
- templateUrl: './ProjectCreateUpdateComponent.html',
- styleUrls: ['./ProjectCreateUpdateComponent.scss']
+ selector: 'app-project-create-update',
+ templateUrl: './ProjectCreateUpdateComponent.html',
+ styleUrls: ['./ProjectCreateUpdateComponent.scss']
})
/** Exporting a class @exports ProjectCreateUpdateComponent */
export class ProjectCreateUpdateComponent implements OnInit {
- /** To inject services @public */
- public injector: Injector;
+ /** To inject services @public */
+ public injector: Injector;
- /** Instance of the rest service @public */
- public restService: RestService;
+ /** Instance of the rest service @public */
+ public restService: RestService;
- /** Instance for active modal service @public */
- public activeModal: NgbActiveModal;
+ /** Instance for active modal service @public */
+ public activeModal: NgbActiveModal;
- /** Contains the recently created project details @public */
- public recentProject: ProjectDetails;
+ /** Contains the recently created project details @public */
+ public recentProject: ProjectDetails;
- /** Contains project create or edit @public */
- public getProjectType: string;
+ /** Contains project create or edit @public */
+ public getProjectType: string;
- /** To inject input type services @public */
- @Input() public projectType: string;
+ /** To inject input type services @public */
+ @Input() public projectType: string;
- /** FormGroup user Edit Account added to the form @ html @public */
- public projectForm: FormGroup;
+ /** FormGroup user Edit Account added to the form @ html @public */
+ public projectForm: FormGroup;
- /** Form submission Add */
- public submitted: boolean = false;
+ /** Form submission Add */
+ public submitted: boolean = false;
- /** Check the loading results for loader status @public */
- public isLoadingResults: boolean = false;
+ /** Check the loading results for loader status @public */
+ public isLoadingResults: boolean = false;
- /** Give the message for the loading @public */
- public message: string = 'PLEASEWAIT';
+ /** Give the message for the loading @public */
+ public message: string = 'PLEASEWAIT';
- /** Holds list of domains @public */
- public domains: {}[] = [];
+ /** Holds list of domains @public */
+ public domains: TYPESECTION[] = [];
- /** Holds list of quota items @public */
- public quotaItems: QUOTAITEM[] = QUOTA_ITEMS;
+ /** Holds list of quota items @public */
+ public quotaItems: QUOTAITEM[] = QUOTA_ITEMS;
- /** Holds project reference from response @public */
- public quotaRefs: {} = null;
+ /** Holds project reference from response @public */
+ public quotaRefs: {} = null;
- /** FormBuilder instance added to the formBuilder @private */
- private formBuilder: FormBuilder;
+ /** FormBuilder instance added to the formBuilder @private */
+ private formBuilder: FormBuilder;
- /** DataService to pass the data from one component to another @private */
- private dataService: DataService;
+ /** DataService to pass the data from one component to another @private */
+ private dataService: DataService;
- /** Contains project name ref @private */
- private projectRef: string;
+ /** Contains project name ref @private */
+ private projectRef: string;
- /** Notifier service to popup notification @private */
- private notifierService: NotifierService;
+ /** Notifier service to popup notification @private */
+ private notifierService: NotifierService;
- /** Contains tranlsate instance @private */
- private translateService: TranslateService;
+ /** Contains tranlsate instance @private */
+ private translateService: TranslateService;
- /** Contains all methods related to shared @private */
- private sharedService: SharedService;
+ /** Contains all methods related to shared @private */
+ private sharedService: SharedService;
- /** ModalData instance of modal @private */
- private modalData: MODALCLOSERESPONSEDATA;
+ /** ModalData instance of modal @private */
+ private modalData: MODALCLOSERESPONSEDATA;
- /** Holds all project details @private */
- private projectService: ProjectService;
+ /** Holds all project details @private */
+ private projectService: ProjectService;
- constructor(injector: Injector) {
- this.injector = injector;
- this.formBuilder = this.injector.get(FormBuilder);
- this.restService = this.injector.get(RestService);
- this.activeModal = this.injector.get(NgbActiveModal);
- this.dataService = this.injector.get(DataService);
- this.notifierService = this.injector.get(NotifierService);
- this.translateService = this.injector.get(TranslateService);
- this.sharedService = this.injector.get(SharedService);
- this.projectService = this.injector.get(ProjectService);
- /** Initializing Form Action */
- this.projectForm = this.formBuilder.group({
- project_name: ['', Validators.required],
- domain_name: [null],
- enable_quota: [false, Validators.required]
- });
- }
-
- /** convenience getter for easy access to form fields */
- get f(): FormGroup['controls'] { return this.projectForm.controls; }
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.formBuilder = this.injector.get(FormBuilder);
+ this.restService = this.injector.get(RestService);
+ this.activeModal = this.injector.get(NgbActiveModal);
+ this.dataService = this.injector.get(DataService);
+ this.notifierService = this.injector.get(NotifierService);
+ this.translateService = this.injector.get(TranslateService);
+ this.sharedService = this.injector.get(SharedService);
+ this.projectService = this.injector.get(ProjectService);
+ /** Initializing Form Action */
+ this.projectForm = this.formBuilder.group({
+ project_name: ['', Validators.required],
+ domain_name: [null],
+ enable_quota: [false, Validators.required]
+ });
+ }
- /** Lifecyle Hooks the trigger before component is instantiate @public */
- public ngOnInit(): void {
- this.getProjectType = this.projectType;
- if (this.getProjectType === 'Edit') {
- this.dataService.currentMessage.subscribe((data: ProjectData) => {
- if (data.projectName !== undefined || data.projectName !== '' || data.projectName !== null) {
- this.projectForm.patchValue({ project_name: data.projectName });
- this.projectRef = data.id;
- this.quotaRefs = data.quotas;
- this.patchQuotaInfo(this.quotaRefs);
+ /** convenience getter for easy access to form fields */
+ get f(): FormGroup['controls'] { return this.projectForm.controls; }
+
+ /** Lifecyle Hooks the trigger before component is instantiate @public */
+ public ngOnInit(): void {
+ this.getProjectType = this.projectType;
+ if (this.getProjectType === 'Edit') {
+ this.dataService.currentMessage.subscribe((data: ProjectData): void => {
+ if (data.projectName !== undefined || data.projectName !== '' || data.projectName !== null) {
+ this.projectForm.patchValue({ project_name: data.projectName });
+ this.projectRef = data.id;
+ this.quotaRefs = data.quotas;
+ this.patchQuotaInfo(this.quotaRefs);
+ }
+ });
+ } else {
+ this.patchQuotaInfo();
+ this.getProjects();
}
- });
- } else {
- this.patchQuotaInfo();
- this.getProjects();
}
- }
-
- /** Get the last project name @public */
- public getProjects(): void {
- this.isLoadingResults = true;
- this.restService.getResource(environment.PROJECTS_URL).subscribe((projects: ProjectDetails[]) => {
- this.recentProject = projects.slice(-1).pop();
- this.getDomainName();
- }, (error: ERRORDATA) => {
- this.restService.handleError(error, 'get');
- this.isLoadingResults = false;
- });
- }
-
- /** On modal submit users acction will called @public */
- public projectAction(userType: string): void {
- this.submitted = true;
- this.modalData = {
- message: 'Done'
- };
- this.sharedService.cleanForm(this.projectForm);
- if (!this.projectForm.invalid) {
- if (userType === 'Add') {
- this.createProject();
- } else if (userType === 'Edit') {
- this.editProject();
- }
+
+ /** Get the last project name @public */
+ public getProjects(): void {
+ this.isLoadingResults = true;
+ this.restService.getResource(environment.PROJECTS_URL).subscribe((projects: ProjectDetails[]): void => {
+ this.recentProject = projects.slice(-1).pop();
+ this.getDomainList();
+ }, (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'get');
+ this.isLoadingResults = false;
+ });
+ }
+
+ /** On modal submit users acction will called @public */
+ public projectAction(userType: string): void {
+ this.submitted = true;
+ this.modalData = {
+ message: 'Done'
+ };
+ this.sharedService.cleanForm(this.projectForm);
+ if (!this.projectForm.invalid) {
+ if (userType === 'Add') {
+ this.createProject();
+ } else if (userType === 'Edit') {
+ this.editProject();
+ }
+ }
}
- }
-
- /** Create project @public */
- public createProject(): void {
- this.isLoadingResults = true;
- const apiURLHeader: APIURLHEADER = {
- url: environment.PROJECTS_URL
- };
- const projectPayload: ProjectDetails = {
- name: this.projectForm.value.project_name,
- domain_name: !isNullOrUndefined(this.projectForm.value.domain_name) ? this.projectForm.value.domain_name : undefined
- };
- this.addQuotaLimit(projectPayload);
- this.restService.postResource(apiURLHeader, projectPayload).subscribe(() => {
- this.activeModal.close(this.modalData);
- this.isLoadingResults = false;
- this.notifierService.notify('success', this.translateService.instant('PAGE.PROJECT.CREATEDSUCCESSFULLY'));
- }, (error: ERRORDATA) => {
- this.restService.handleError(error, 'post');
- this.isLoadingResults = false;
- });
- }
- /** Handle enable quota limit checkbox event @public */
- public checkQuota(): void {
- if (this.getFormControl('enable_quota').value) {
- this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
- this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, Validators.required));
- });
- } else {
- this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
- this.getFormControl(quotaItem.value).setValue(quotaItem.minValue);
- });
+
+ /** Create project @public */
+ public createProject(): void {
+ this.isLoadingResults = true;
+ const apiURLHeader: APIURLHEADER = {
+ url: environment.PROJECTS_URL
+ };
+ const projectPayload: ProjectDetails = {
+ name: this.projectForm.value.project_name,
+ domain_name: !isNullOrUndefined(this.projectForm.value.domain_name) ? this.projectForm.value.domain_name : undefined
+ };
+ this.addQuotaLimit(projectPayload);
+ this.restService.postResource(apiURLHeader, projectPayload).subscribe((): void => {
+ this.activeModal.close(this.modalData);
+ this.isLoadingResults = false;
+ this.notifierService.notify('success', this.translateService.instant('PAGE.PROJECT.CREATEDSUCCESSFULLY'));
+ }, (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'post');
+ this.isLoadingResults = false;
+ });
}
- }
- /** Edit project @public */
- public editProject(): void {
- this.isLoadingResults = true;
- const apiURLHeader: APIURLHEADER = {
- url: environment.PROJECTS_URL + '/' + this.projectRef
- };
- const projectPayload: ProjectDetails = {
- name: this.projectForm.value.project_name
- };
- this.addQuotaLimit(projectPayload);
- this.restService.patchResource(apiURLHeader, projectPayload).subscribe(() => {
- this.activeModal.close(this.modalData);
- this.isLoadingResults = false;
- this.projectService.setHeaderProjects();
- this.notifierService.notify('success', this.translateService.instant('PAGE.PROJECT.UPDATEDSUCCESSFULLY'));
- }, (error: ERRORDATA) => {
- this.restService.handleError(error, 'patch');
- this.isLoadingResults = false;
- });
- }
- /** Get domain name @private */
- private getDomainName(): void {
- this.restService.getResource(environment.DOMAIN_URL).subscribe((domains: { project_domain_name: string, user_domain_name: string }) => {
- let domainNames: string[] = [];
- if (!isNullOrUndefined(domains.project_domain_name)) {
- domainNames = domainNames.concat(domains.project_domain_name.split(','));
- }
- if (!isNullOrUndefined(domains.user_domain_name)) {
- domainNames = domainNames.concat(domains.user_domain_name.split(','));
- }
- domainNames = Array.from(new Set(domainNames));
- this.checkDomainNames(domainNames);
- this.isLoadingResults = false;
- }, (error: ERRORDATA) => {
- this.restService.handleError(error, 'get');
- this.isLoadingResults = false;
- });
- }
-
- /** Check the domain names and create modal for domain select @private */
- private checkDomainNames(domainNames: string[]): void {
- if (domainNames.length > 0) {
- domainNames.forEach((domainName: string) => {
- if (!domainName.endsWith(':ro')) {
- this.domains.push({ id: domainName, text: domainName });
+ /** Handle enable quota limit checkbox event @public */
+ public checkQuota(): void {
+ if (this.getFormControl('enable_quota').value) {
+ this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
+ this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, Validators.required));
+ });
+ } else {
+ this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
+ this.getFormControl(quotaItem.value).setValue(quotaItem.minValue);
+ });
}
- });
}
- }
-
- /** Used to get the AbstractControl of controlName passed @private */
- private getFormControl(controlName: string): AbstractControl {
- return this.projectForm.controls[controlName];
- }
-
- /** Add quota information to payload @private */
- private addQuotaLimit(payload: ProjectDetails): void {
- if (this.getFormControl('enable_quota').value) {
- payload.quotas = {};
- this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
- payload.quotas[quotaItem.value] = this.getFormControl(quotaItem.value).value;
- });
+ /** Edit project @public */
+ public editProject(): void {
+ this.isLoadingResults = true;
+ const apiURLHeader: APIURLHEADER = {
+ url: environment.PROJECTS_URL + '/' + this.projectRef
+ };
+ const projectPayload: ProjectDetails = {
+ name: this.projectForm.value.project_name
+ };
+ this.addQuotaLimit(projectPayload);
+ this.restService.patchResource(apiURLHeader, projectPayload).subscribe((): void => {
+ this.activeModal.close(this.modalData);
+ this.isLoadingResults = false;
+ this.projectService.setHeaderProjects();
+ this.notifierService.notify('success', this.translateService.instant('PAGE.PROJECT.UPDATEDSUCCESSFULLY'));
+ }, (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'patch');
+ this.isLoadingResults = false;
+ });
+ }
+ /** Get domain name list @private */
+ private getDomainList(): void {
+ this.isLoadingResults = true;
+ this.sharedService.getDomainName().subscribe((domainList: TYPESECTION[]): void => {
+ this.domains = domainList;
+ this.isLoadingResults = false;
+ }, (error: ERRORDATA): void => {
+ this.isLoadingResults = false;
+ this.restService.handleError(error, 'get');
+ });
+ }
+
+ /** Used to get the AbstractControl of controlName passed @private */
+ private getFormControl(controlName: string): AbstractControl {
+ return this.projectForm.controls[controlName];
+ }
+
+ /** Add quota information to payload @private */
+ private addQuotaLimit(payload: ProjectDetails): void {
+ if (this.getFormControl('enable_quota').value) {
+ payload.quotas = {};
+ this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
+ payload.quotas[quotaItem.value] = this.getFormControl(quotaItem.value).value;
+ });
+ }
}
- }
-
- /** Set quota information in project form model @private */
- private patchQuotaInfo(quotaRef?: {}): void {
- if (quotaRef !== null && this.getProjectType === 'Edit') {
- this.getFormControl('enable_quota').setValue(true);
- this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
- if (!isNullOrUndefined(quotaRef[quotaItem.value])) {
- this.projectForm.addControl(quotaItem.value, new FormControl(quotaRef[quotaItem.value],
- [Validators.required, Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)]));
+
+ /** Set quota information in project form model @private */
+ private patchQuotaInfo(quotaRef?: {}): void {
+ if (quotaRef !== null && this.getProjectType === 'Edit') {
+ this.getFormControl('enable_quota').setValue(true);
+ this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
+ if (!isNullOrUndefined(quotaRef[quotaItem.value])) {
+ this.projectForm.addControl(quotaItem.value, new FormControl(quotaRef[quotaItem.value],
+ [Validators.required, Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)]));
+ } else {
+ this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, [Validators.required,
+ Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)]));
+ }
+ });
} else {
- this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, [Validators.required,
- Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)]));
+ this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
+ this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, [Validators.required,
+ Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)]));
+ });
}
- });
- } else {
- this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
- this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, [Validators.required,
- Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)]));
- });
}
- }
}
<div class="form-group row" *ngIf="userType === 'add'">
<label class="col-sm-4 col-form-label">{{'DOMAIN' | translate}} {{'NAME' | translate}}</label>
<div class="col-sm-8">
- <ng-select [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="domains" bindLabel="text"
- bindValue="id" formControlName="domain_name" id="domain_name"
+ <ng-select [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="domains" bindLabel="title"
+ bindValue="value" formControlName="domain_name" id="domain_name"
[ngClass]="{ 'is-invalid': submitted && f.domain_name.errors }"></ng-select>
</div>
</div>
import { TranslateService } from '@ngx-translate/core';
import { NotifierService } from 'angular-notifier';
import { AuthenticationService } from 'AuthenticationService';
-import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel';
+import { APIURLHEADER, ERRORDATA, LOGINPARAMS, MODALCLOSERESPONSEDATA, TYPESECTION } from 'CommonModel';
import { environment } from 'environment';
import { RestService } from 'RestService';
import { SharedService } from 'SharedService';
* @Component takes AddEditUserComponent.html as template url
*/
@Component({
- templateUrl: './AddEditUserComponent.html',
- styleUrls: ['./AddEditUserComponent.scss']
+ templateUrl: './AddEditUserComponent.html',
+ styleUrls: ['./AddEditUserComponent.scss']
})
/** Exporting a class @exports AddEditUserComponent */
export class AddEditUserComponent implements OnInit {
- /** To inject services @public */
- public injector: Injector;
+ /** To inject services @public */
+ public injector: Injector;
- /** Instance for active modal service @public */
- public activeModal: NgbActiveModal;
+ /** Instance for active modal service @public */
+ public activeModal: NgbActiveModal;
- /** FormGroup user Edit Account added to the form @ html @public */
- public userForm: FormGroup;
+ /** FormGroup user Edit Account added to the form @ html @public */
+ public userForm: FormGroup;
- /** Form submission Add */
- public submitted: boolean = false;
+ /** Form submission Add */
+ public submitted: boolean = false;
- /** Input contains Modal dialog component Instance @public */
- @Input() public userTitle: string;
+ /** Input contains Modal dialog component Instance @public */
+ @Input() public userTitle: string;
- /** Input contains Modal dialog component Instance @public */
- @Input() public userType: string;
+ /** Input contains Modal dialog component Instance @public */
+ @Input() public userType: string;
- /** Input contains Modal dialog component Instance @public */
- @Input() public userID: string;
+ /** Input contains Modal dialog component Instance @public */
+ @Input() public userID: string;
- /** Input contains Modal dialog component Instance @public */
- @Input() public userName: string;
+ /** Input contains Modal dialog component Instance @public */
+ @Input() public userName: string;
- /** Check the loading results for loader status @public */
- public isLoadingResults: boolean = false;
+ /** Check the loading results for loader status @public */
+ public isLoadingResults: boolean = false;
- /** Give the message for the loading @public */
- public message: string = 'PLEASEWAIT';
+ /** Give the message for the loading @public */
+ public message: string = 'PLEASEWAIT';
- /** Holds list of domains @public */
- public domains: {}[] = [];
+ /** Holds list of domains @public */
+ public domains: TYPESECTION[] = [];
- /** Instance of the rest service @private */
- private restService: RestService;
+ /** Instance of the rest service @private */
+ private restService: RestService;
- /** FormBuilder instance added to the formBuilder @private */
- private formBuilder: FormBuilder;
+ /** FormBuilder instance added to the formBuilder @private */
+ private formBuilder: FormBuilder;
- /** Controls the header form @private */
- private headers: HttpHeaders;
+ /** Controls the header form @private */
+ private headers: HttpHeaders;
- /** Notifier service to popup notification @private */
- private notifierService: NotifierService;
+ /** Notifier service to popup notification @private */
+ private notifierService: NotifierService;
- /** Contains tranlsate instance @private */
- private translateService: TranslateService;
+ /** Contains tranlsate instance @private */
+ private translateService: TranslateService;
- /** Contains all methods related to shared @private */
- private sharedService: SharedService;
+ /** Contains all methods related to shared @private */
+ private sharedService: SharedService;
- /** ModalData instance of modal @private */
- private modalData: MODALCLOSERESPONSEDATA;
+ /** ModalData instance of modal @private */
+ private modalData: MODALCLOSERESPONSEDATA;
- /** Utilizes auth service for any auth operations @private */
- private authService: AuthenticationService;
+ /** Utilizes auth service for any auth operations @private */
+ private authService: AuthenticationService;
- constructor(injector: Injector) {
- this.injector = injector;
- this.formBuilder = this.injector.get(FormBuilder);
- this.restService = this.injector.get(RestService);
- this.activeModal = this.injector.get(NgbActiveModal);
- this.notifierService = this.injector.get(NotifierService);
- this.translateService = this.injector.get(TranslateService);
- this.sharedService = this.injector.get(SharedService);
- this.authService = this.injector.get(AuthenticationService);
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.formBuilder = this.injector.get(FormBuilder);
+ this.restService = this.injector.get(RestService);
+ this.activeModal = this.injector.get(NgbActiveModal);
+ this.notifierService = this.injector.get(NotifierService);
+ this.translateService = this.injector.get(TranslateService);
+ this.sharedService = this.injector.get(SharedService);
+ this.authService = this.injector.get(AuthenticationService);
- /** Initializing Form Action */
- this.userForm = this.formBuilder.group({
- userName: ['', Validators.required],
- password: [null, [Validators.required, Validators.pattern(this.sharedService.REGX_PASSWORD_PATTERN)]],
- password2: [null, Validators.required],
- domain_name: [null]
- });
- }
+ /** Initializing Form Action */
+ this.userForm = this.formBuilder.group({
+ userName: ['', Validators.required],
+ password: [null, [Validators.required, Validators.pattern(this.sharedService.REGX_PASSWORD_PATTERN)]],
+ password2: [null, Validators.required],
+ domain_name: [null]
+ });
+ }
+
+ /** convenience getter for easy access to form fields */
+ get f(): FormGroup['controls'] { return this.userForm.controls; }
+
+ /** Lifecyle Hooks the trigger before component is instantiate @public */
+ public ngOnInit(): void {
+ this.headers = new HttpHeaders({
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0'
+ });
+ if (this.userType === 'add') {
+ this.getDomainList();
+ } else if (this.userType === 'editUserName') {
+ this.userForm.patchValue({ userName: this.userName });
+ }
+ }
- /** convenience getter for easy access to form fields */
- get f(): FormGroup['controls'] { return this.userForm.controls; }
+ /** On modal submit users acction will called @public */
+ public userAction(userType: string): void {
+ if (userType === 'editPassword') {
+ this.getFormControl('userName').setValidators([]);
+ this.getFormControl('userName').updateValueAndValidity();
+ } else if (userType === 'editUserName') {
+ this.getFormControl('password').setValidators([]);
+ this.getFormControl('password').updateValueAndValidity();
+ this.getFormControl('password2').setValidators([]);
+ this.getFormControl('password2').updateValueAndValidity();
+ }
+ this.submitted = true;
+ this.modalData = {
+ message: 'Done'
+ };
+ this.sharedService.cleanForm(this.userForm);
+ if (!this.userForm.invalid) {
+ if (this.userForm.value.password !== this.userForm.value.password2) {
+ this.notifierService.notify('error', this.translateService.instant('PAGE.USERS.PASSWORDCONFLICT'));
+ return;
+ }
+ if (userType === 'add') {
+ this.addUser();
+ } else if (userType === 'editUserName' || userType === 'editPassword') {
+ this.editUser();
+ }
+ }
+ }
- /** Lifecyle Hooks the trigger before component is instantiate @public */
- public ngOnInit(): void {
- this.headers = new HttpHeaders({
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0'
- });
- if (this.userType === 'add') {
- this.getDomainName();
- } else if (this.userType === 'editUserName') {
- this.userForm.patchValue({ userName: this.userName });
+ /** Add user @public */
+ public addUser(): void {
+ this.isLoadingResults = true;
+ const payLoad: {} = JSON.stringify({
+ username: (this.userForm.value.userName).toLowerCase(),
+ password: (this.userForm.value.password),
+ domain_name: !isNullOrUndefined(this.userForm.value.domain_name) ? this.userForm.value.domain_name : undefined
+ });
+ const apiURLHeader: APIURLHEADER = {
+ url: environment.USERS_URL,
+ httpOptions: { headers: this.headers }
+ };
+ this.restService.postResource(apiURLHeader, payLoad).subscribe((result: {}): void => {
+ this.activeModal.close(this.modalData);
+ this.isLoadingResults = false;
+ this.notifierService.notify('success', this.translateService.instant('PAGE.USERS.CREATEDSUCCESSFULLY'));
+ }, (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'post');
+ this.isLoadingResults = false;
+ });
}
- }
-
- /** On modal submit users acction will called @public */
- public userAction(userType: string): void {
- if (userType === 'editPassword') {
- this.getFormControl('userName').setValidators([]);
- this.getFormControl('userName').updateValueAndValidity();
- } else if (userType === 'editUserName') {
- this.getFormControl('password').setValidators([]);
- this.getFormControl('password').updateValueAndValidity();
- this.getFormControl('password2').setValidators([]);
- this.getFormControl('password2').updateValueAndValidity();
+
+ /** Edit user @public */
+ public editUser(): void {
+ this.isLoadingResults = true;
+ const payLoad: LOGINPARAMS = {};
+ if (this.userType === 'editPassword') {
+ payLoad.password = (this.userForm.value.password);
+ } else {
+ payLoad.username = this.userForm.value.userName.toLowerCase();
+ }
+ const apiURLHeader: APIURLHEADER = {
+ url: environment.USERS_URL + '/' + this.userID,
+ httpOptions: { headers: this.headers }
+ };
+ this.restService.patchResource(apiURLHeader, payLoad).subscribe((result: {}): void => {
+ this.checkUsername(payLoad);
+ this.activeModal.close(this.modalData);
+ this.isLoadingResults = false;
+ this.notifierService.notify('success', this.translateService.instant('PAGE.USERS.EDITEDSUCCESSFULLY'));
+ }, (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'put');
+ this.isLoadingResults = false;
+ });
}
- this.submitted = true;
- this.modalData = {
- message: 'Done'
- };
- this.sharedService.cleanForm(this.userForm);
- if (!this.userForm.invalid) {
- if (this.userForm.value.password !== this.userForm.value.password2) {
- this.notifierService.notify('error', this.translateService.instant('PAGE.USERS.PASSWORDCONFLICT'));
- return;
- }
- if (userType === 'add') {
- this.addUser();
- } else if (userType === 'editUserName' || userType === 'editPassword') {
- this.editUser();
- }
+ /** Get domain name list @private */
+ private getDomainList(): void {
+ this.isLoadingResults = true;
+ this.sharedService.getDomainName().subscribe((domainList: TYPESECTION[]): void => {
+ this.domains = domainList;
+ this.isLoadingResults = false;
+ }, (error: ERRORDATA): void => {
+ this.isLoadingResults = false;
+ this.restService.handleError(error, 'get');
+ });
}
- }
-
- /** Add user @public */
- public addUser(): void {
- this.isLoadingResults = true;
- const payLoad: {} = JSON.stringify({
- username: (this.userForm.value.userName).toLowerCase(),
- password: (this.userForm.value.password),
- domain_name: !isNullOrUndefined(this.userForm.value.domain_name) ? this.userForm.value.domain_name : undefined
- });
- const apiURLHeader: APIURLHEADER = {
- url: environment.USERS_URL,
- httpOptions: { headers: this.headers }
- };
- this.restService.postResource(apiURLHeader, payLoad).subscribe((result: {}) => {
- this.activeModal.close(this.modalData);
- this.isLoadingResults = false;
- this.notifierService.notify('success', this.translateService.instant('PAGE.USERS.CREATEDSUCCESSFULLY'));
- }, (error: ERRORDATA) => {
- this.restService.handleError(error, 'post');
- this.isLoadingResults = false;
- });
- }
-
- /** Edit user @public */
- public editUser(): void {
- this.isLoadingResults = true;
- const payLoad: { username?: string, password?: string } = {};
- if (this.userType === 'editPassword') {
- payLoad.password = (this.userForm.value.password);
- } else {
- payLoad.username = this.userForm.value.userName.toLowerCase();
+
+ /** Used to get the AbstractControl of controlName passed @private */
+ private getFormControl(controlName: string): AbstractControl {
+ return this.userForm.controls[controlName];
}
- const apiURLHeader: APIURLHEADER = {
- url: environment.USERS_URL + '/' + this.userID,
- httpOptions: { headers: this.headers }
- };
- this.restService.patchResource(apiURLHeader, payLoad).subscribe((result: {}) => {
- this.checkUsername(payLoad);
- this.activeModal.close(this.modalData);
- this.isLoadingResults = false;
- this.notifierService.notify('success', this.translateService.instant('PAGE.USERS.EDITEDSUCCESSFULLY'));
- }, (error: ERRORDATA) => {
- this.restService.handleError(error, 'put');
- this.isLoadingResults = false;
- });
- }
- /** Get domain name @private */
- private getDomainName(): void {
- this.isLoadingResults = true;
- this.restService.getResource(environment.DOMAIN_URL).subscribe((domains: { project_domain_name: string, user_domain_name: string }) => {
- let domainNames: string[] = [];
- if (!isNullOrUndefined(domains.project_domain_name)) {
- domainNames = domainNames.concat(domains.project_domain_name.split(','));
- }
- if (!isNullOrUndefined(domains.user_domain_name)) {
- domainNames = domainNames.concat(domains.user_domain_name.split(','));
- }
- domainNames = Array.from(new Set(domainNames));
- this.checkDomainNames(domainNames);
- this.isLoadingResults = false;
- }, (error: ERRORDATA) => {
- this.restService.handleError(error, 'get');
- this.isLoadingResults = false;
- });
- }
-
- /** Check the domain names and create modal for domain select @private */
- private checkDomainNames(domainNames: string[]): void {
- if (domainNames.length > 0) {
- domainNames.forEach((domainName: string) => {
- if (!domainName.endsWith(':ro')) {
- this.domains.push({ id: domainName, text: domainName });
+
+ /** Method to check loggedin username and update @private */
+ private checkUsername(payLoad: LOGINPARAMS): void {
+ const logUsername: string = localStorage.getItem('username');
+ if (this.userType === 'editUserName' && logUsername === this.userName) {
+ this.authService.userName.next(payLoad.username);
+ localStorage.setItem('username', payLoad.username);
}
- });
- }
- }
-
- /** Used to get the AbstractControl of controlName passed @private */
- private getFormControl(controlName: string): AbstractControl {
- return this.userForm.controls[controlName];
- }
-
- /** Method to check loggedin username and update @private */
- private checkUsername(payLoad: { username?: string }): void {
- const logUsername: string = localStorage.getItem('username');
- if (this.userType === 'editUserName' && logUsername === this.userName) {
- this.authService.userName.next(payLoad.username);
- localStorage.setItem('username', payLoad.username);
}
- }
}
additional_conf: '',
use_existing_flavors: ''
};
-/** Interface for VIM type AWS's Config */
+/** Constant for VIM type AWS's Config */
export const TYPEAWS: {} = {
sdn_controller: '',
vpc_cidr_block: '',
flavor_info: '',
additional_conf: ''
};
-/** Interface for VIM type VMWARE's Config */
+/** Constant for VIM type VMWARE's Config */
export const TYPEVMWARE: {} = {
sdn_controller: '',
orgname: '',
vrops_password: '',
additional_conf: ''
};
-/** Interface for VIM type OPENVIMNEBULA's Config */
+/** Constant for VIM type OPENVIMNEBULA's Config */
export const TYPEOPENVIMNEBULA: {} = {
sdn_controller: '',
sdn_port_mapping: '',
vim_network_name: '',
additional_conf: ''
};
-/** Interface for VIM type AZURE's Config */
+/** Constant for VIM type AZURE's Config */
export const TYPEAZURE: {} = {
subscription_id: '',
region_name: '',
vnet_name: '',
flavors_pattern: ''
};
-/** Interface for VIM other type Config */
+/** Constant for VIM other type Config */
export const TYPEOTERS: {} = {
sdn_controller: '',
sdn_port_mapping: '',
additional_conf: '',
use_existing_flavors: ''
};
+/** Interface for Domains */
+export interface DOMAINS {
+ project_domain_name: string;
+ user_domain_name: string;
+}
+/** Interface for Login */
+export interface LOGINPARAMS {
+ username?: string;
+ password?: string;
+}
import { FormArray, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
-import { CONSTANTNUMBER, ERRORDATA, FILESETTINGS, GETAPIURLHEADER, PACKAGEINFO, PAGERSMARTTABLE, SMARTTABLECLASS, TARSETTINGS } from 'CommonModel';
+import {
+ CONSTANTNUMBER,
+ DOMAINS,
+ ERRORDATA,
+ FILESETTINGS,
+ GETAPIURLHEADER,
+ PACKAGEINFO,
+ PAGERSMARTTABLE,
+ SMARTTABLECLASS,
+ TARSETTINGS,
+ TYPESECTION
+} from 'CommonModel';
import { environment } from 'environment';
import * as HttpStatus from 'http-status-codes';
import * as untar from 'js-untar';
import * as pako from 'pako';
import { RestService } from 'RestService';
+import { Observable } from 'rxjs';
+import { map } from 'rxjs/operators';
import { isNullOrUndefined } from 'util';
/** This is added globally by the tar.js library */
}
return result;
}
+
/** Function to read uploaded file String @public */
public async getFileString(files: FileList, fileType: string): Promise<string | ArrayBuffer> {
const reader: FileReader = new FileReader();
};
});
}
+
/** Method to handle tar and tar.gz file for shared YAML file content @public */
public async targzFile(packageInfo: PACKAGEINFO): Promise<string | ArrayBuffer> {
return new Promise<string | ArrayBuffer>((resolve: Function, reject: Function): void => {
let apiUrl: string = '';
apiUrl = packageInfo.packageType === 'nsd' ? environment.NSDESCRIPTORS_URL + '/' + packageInfo.id + '/nsd_content' :
environment.VNFPACKAGES_URL + '/' + packageInfo.id + '/package_content';
- this.restService.getResource(apiUrl, httpOptions).subscribe((response: ArrayBuffer) => {
+ this.restService.getResource(apiUrl, httpOptions).subscribe((response: ArrayBuffer): void => {
try {
// tslint:disable-next-line: no-any
const tar: any = new Tar();
const originalInput: Uint8Array = pako.inflate(response, { to: 'Uint8Array' });
- untar(originalInput.buffer).then((extractedFiles: TARSETTINGS[]) => {
+ untar(originalInput.buffer).then((extractedFiles: TARSETTINGS[]): void => {
const getFoldersFiles: {}[] = extractedFiles;
const folderNameStr: string = extractedFiles[0].name;
- getFoldersFiles.forEach((value: TARSETTINGS) => {
+ getFoldersFiles.forEach((value: TARSETTINGS): void => {
const fileValueObj: FILESETTINGS = this.createFileValueObject(value);
const getRootFolder: string[] = value.name.split('/');
if (value.name.startsWith(folderNameStr) &&
const out: Uint8Array = tar.out;
const originalOutput: Uint8Array = pako.gzip(out);
resolve(originalOutput.buffer);
- }, (err: string) => {
+ }, (err: string): void => {
reject('');
});
} catch (e) {
reject('');
}
- }, (error: HttpErrorResponse) => {
+ }, (error: HttpErrorResponse): void => {
if (error.status === HttpStatus.NOT_FOUND || error.status === HttpStatus.UNAUTHORIZED) {
this.router.navigateByUrl('404', { skipLocationChange: true }).catch();
} else {
});
});
}
+
/** Method to return the file information @public */
public createFileValueObject(value: TARSETTINGS): FILESETTINGS {
return {
group: value.gname
};
}
+
/** Method to check given string is JSON or not @public */
public checkJson(jsonString: string): boolean {
jsonString = jsonString.replace(/'/g, '"');
}
return true;
}
+
/** Clean the form before submit @public */
public cleanForm(formGroup: FormGroup, formName?: String): void {
Object.keys(formGroup.controls).forEach((key: string) => {
}
});
}
+
/** Method to return the config of pager value for ngSmarttable @public */
public paginationPagerConfig(): PAGERSMARTTABLE {
return {
perPage: environment.paginationNumber
};
}
+
/** Method to return the class for the table for ngSmarttable @public */
public tableClassConfig(): SMARTTABLECLASS {
return {
class: 'table list-data'
};
}
+
/** Method to return all languages name and its code @public */
public languageCodeList(): {}[] {
return [
{ code: 'de', language: 'German' }
];
}
+
/** Fetch OSM Version @public */
public fetchOSMVersion(): void {
- this.restService.getResource(environment.OSM_VERSION_URL).subscribe((res: { version: string }) => {
+ this.restService.getResource(environment.OSM_VERSION_URL).subscribe((res: { version: string }): void => {
const version: string[] = res.version.split('+');
if (!isNullOrUndefined(version[0])) {
this.osmVersion = version[0];
} else {
this.osmVersion = null;
}
- }, (error: ERRORDATA) => {
+ }, (error: ERRORDATA): void => {
this.osmVersion = null;
this.restService.handleError(error, 'get');
});
}
+
/** Random RGB color code generator @public */
public generateColor(): string {
const x: number = Math.floor(Math.random() * this.colorStringLength);
return fileInfo[0].name.substring(fileInfo[0].name.lastIndexOf('.') + 1);
}
+ /** Get domain name @private */
+ public getDomainName(): Observable<TYPESECTION[]> {
+ return this.restService.getResource(environment.DOMAIN_URL).pipe(map((domains: DOMAINS): TYPESECTION[] => {
+ const domainList: TYPESECTION[] = [];
+ try {
+ let domainNames: string[] = [];
+ if (!isNullOrUndefined(domains.project_domain_name)) {
+ domainNames = domainNames.concat(domains.project_domain_name.split(','));
+ }
+ if (!isNullOrUndefined(domains.user_domain_name)) {
+ domainNames = domainNames.concat(domains.user_domain_name.split(','));
+ }
+ domainNames = Array.from(new Set(domainNames));
+ if (domainNames.length > 0) {
+ domainNames.forEach((domainName: string): void => {
+ if (!domainName.endsWith(':ro')) {
+ domainList.push({ title: domainName, value: domainName });
+ }
+ });
+ }
+ return domainList;
+ } catch (e) {
+ return domainList;
+ }
+ }));
+ }
+
/** Method to validate file extension and size @private */
private vaildataFileInfo(fileInfo: File, fileType: string): boolean {
const extension: string = fileInfo.name.substring(fileInfo.name.lastIndexOf('.') + 1);
}
return false;
}
+
/** Method to read file content based on type @private */
private readFileContent(reader: FileReader, fileInfo: File, fileType: string): void {
if (fileType === 'gz') {
reader.readAsText(fileInfo);
}
}
+
/** Method to handle http options @public */
private getHttpOptions(): GETAPIURLHEADER {
return {