From 086a77daab402feeb6af2d5a354637863b4b4124 Mon Sep 17 00:00:00 2001 From: pratik Date: Thu, 23 Oct 2025 09:36:24 -0500 Subject: [PATCH] Pull local args into form --- .gitignore | 3 +++ frontend/src/app/app.component.ts | 20 ++++++++++++++-- .../environment.local.template.ts | 24 +++++++++++++++++++ frontend/src/environments/environment.prod.ts | 5 +++- frontend/src/environments/environment.ts | 14 ++++++++++- 5 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 frontend/src/environments/environment.local.template.ts diff --git a/.gitignore b/.gitignore index b8a2b49..1e5bd5f 100644 --- a/.gitignore +++ b/.gitignore @@ -77,3 +77,6 @@ src/main/resources/cf-cli/ test-output/ target/ frontend/package-lock.json + +# Frontend local development environment (contains sensitive credentials) +frontend/src/environments/environment.local.ts diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index 2632a71..848821c 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { DeployService } from './deploy.service'; @@ -11,7 +11,7 @@ import { environment } from '../environments/environment'; templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) -export class AppComponent { +export class AppComponent implements OnInit { // Environment config env = environment; @@ -37,6 +37,22 @@ export class AppComponent { constructor(private deployService: DeployService) {} + ngOnInit(): void { + // Auto-populate form fields from environment.local.ts (development only) + const formDefaults = environment.formDefaults as any; + if (formDefaults && formDefaults.enabled) { + this.apiEndpoint = formDefaults.apiEndpoint || ''; + this.username = formDefaults.username || ''; + this.password = formDefaults.password || ''; + this.organization = formDefaults.organization || ''; + this.space = formDefaults.space || ''; + this.appName = formDefaults.appName || ''; + this.skipSsl = formDefaults.skipSslValidation || false; + + console.log('Form auto-populated from environment.local.ts'); + } + } + onJarFileChange(event: any) { this.jarFile = event.target.files[0]; } diff --git a/frontend/src/environments/environment.local.template.ts b/frontend/src/environments/environment.local.template.ts new file mode 100644 index 0000000..1ca54ad --- /dev/null +++ b/frontend/src/environments/environment.local.template.ts @@ -0,0 +1,24 @@ +/** + * Local Development Form Defaults Template + * + * This file is a template for environment.local.ts which is gitignored. + * To use this feature: + * 1. Copy this file to environment.local.ts + * 2. Fill in your development credentials + * 3. The form will auto-populate in development mode + * + * NOTE: This only works in development. Production builds ignore these defaults. + */ +export const localFormDefaults = { + // Set to true to enable auto-population of form fields + enabled: false, + + // Cloud Foundry / Tanzu Configuration + apiEndpoint: '', // e.g., 'https://api.cf.example.com' + username: '', // Your CF username + password: '', // Your CF password + organization: '', // Your CF organization + space: '', // Your CF space (e.g., 'dev', 'staging') + appName: '', // Default application name + skipSslValidation: false // Skip SSL validation (for development environments) +}; diff --git a/frontend/src/environments/environment.prod.ts b/frontend/src/environments/environment.prod.ts index f08aef4..5449541 100644 --- a/frontend/src/environments/environment.prod.ts +++ b/frontend/src/environments/environment.prod.ts @@ -16,5 +16,8 @@ export const environment = { // UI Configuration defaultLogsExpanded: true, - showDebugInfo: false + showDebugInfo: false, + + // Form Defaults (ALWAYS disabled in production) + formDefaults: { enabled: false } }; diff --git a/frontend/src/environments/environment.ts b/frontend/src/environments/environment.ts index 53365fe..429154d 100644 --- a/frontend/src/environments/environment.ts +++ b/frontend/src/environments/environment.ts @@ -1,3 +1,12 @@ +// Try to import local form defaults (gitignored file with dev credentials) +let localDefaults: any = { enabled: false }; +try { + const imported = require('./environment.local'); + localDefaults = imported.localFormDefaults || { enabled: false }; +} catch (e) { + // environment.local.ts doesn't exist, which is fine +} + export const environment = { production: false, @@ -16,5 +25,8 @@ export const environment = { // UI Configuration defaultLogsExpanded: true, - showDebugInfo: false + showDebugInfo: false, + + // Form Defaults (auto-populated from environment.local.ts in development only) + formDefaults: localDefaults };