-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironments.html
More file actions
1551 lines (1382 loc) · 60.1 KB
/
environments.html
File metadata and controls
1551 lines (1382 loc) · 60.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Environments - Sethu Neeli - MA - GIT Portal SQL</title>
<style>
:root{
--blue1:#0b5eff;
--blue2:#3aa0ff;
--yellow1:#ffd24d;
--yellow2:#ffea7f;
--card-bg: rgba(255,255,255,0.85);
--muted:#445;
--success:#2ecc71;
--warning:#f39c12;
--danger:#e74c3c;
}
html,body{height:100%;margin:0;padding:0}
body{
font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: linear-gradient(120deg,var(--blue1),var(--yellow1));
background-size:400% 400%;
animation: bg-anim 12s ease infinite;
color: #07203b;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale;
}
@keyframes bg-anim{
0%{background-position:0% 50%}
50%{background-position:100% 50%}
100%{background-position:0% 50%}
}
.app-container{
max-width:1400px;margin:36px auto;padding:28px;border-radius:16px;background:linear-gradient(180deg, rgba(255,255,255,0.88), rgba(245,249,255,0.7));box-shadow:0 8px 30px rgba(8,20,40,0.35);
backdrop-filter: blur(6px);
}
h1, h2{margin-top:0;color:var(--muted);font-weight:600}
h1{font-size:2.2em;margin-bottom:8px}
h2{font-size:1.6em;margin-bottom:16px;border-bottom:2px solid var(--blue2);padding-bottom:8px}
.nav-bar{
display:flex;gap:12px;margin-bottom:24px;padding:12px 0;border-bottom:1px solid rgba(10,20,40,0.1);
}
.nav-link{
padding:8px 16px;border-radius:8px;text-decoration:none;color:#333;background:rgba(255,255,255,0.7);border:1px solid rgba(10,20,40,0.08);transition:all 0.2s;
}
.nav-link:hover{
background:var(--blue2);color:white;transform:translateY(-1px);
}
.nav-link.active{
background:linear-gradient(90deg,var(--blue2),#6fb8ff);color:white;
}
.env-section{
margin-bottom:32px;
}
.env-grid{
display:grid;grid-template-columns:repeat(auto-fit,minmax(450px,1fr));gap:20px;margin-top:16px;
}
.env-card{
background:var(--card-bg);border-radius:12px;padding:20px;border:1px solid rgba(10,20,40,0.08);
box-shadow:0 4px 12px rgba(8,20,40,0.12);transition:all 0.3s;position:relative;
}
.env-card:hover{
transform:translateY(-2px);box-shadow:0 8px 20px rgba(8,20,40,0.18);
}
.env-header{
display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;
}
.env-name{
font-size:1.3em;font-weight:600;color:var(--muted);
}
.env-status{
width:12px;height:12px;border-radius:50%;background:#ddd;
}
.env-status.connected{background:var(--success);}
.env-status.error{background:var(--danger);}
.env-status.warning{background:var(--warning);}
.env-details{
margin-bottom:16px;
}
.env-detail{
display:flex;margin-bottom:8px;font-size:0.9em;
}
.detail-label{
font-weight:600;min-width:80px;color:#666;
}
.detail-value{
color:#333;font-family:monospace;background:#f8f9fa;padding:2px 6px;border-radius:4px;
word-break:break-all;flex:1;
}
.jdbc-url{
background:#f1f3f4;border-radius:8px;padding:12px;margin-top:8px;
font-family:monospace;font-size:0.85em;word-break:break-all;
border-left:4px solid var(--blue2);
}
.env-actions{
display:flex;gap:8px;margin-top:16px;
}
.btn{
padding:8px 12px;border-radius:6px;border:none;cursor:pointer;font-size:0.9em;
transition:all 0.2s;text-decoration:none;display:inline-block;text-align:center;
}
.btn-primary{background:linear-gradient(90deg,var(--blue2),#6fb8ff);color:white;}
.btn-secondary{background:#6c757d;color:white;}
.btn-success{background:var(--success);color:white;}
.btn-warning{background:var(--warning);color:white;}
.btn-danger{background:var(--danger);color:white;}
.btn:hover{transform:translateY(-1px);opacity:0.9;}
.btn:disabled{opacity:0.6;cursor:not-allowed;transform:none;}
.copy-btn{
position:absolute;top:12px;right:12px;padding:4px 8px;font-size:0.8em;
background:rgba(255,255,255,0.9);border:1px solid #ddd;
}
.section-header{
display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;
}
.section-actions{
display:flex;gap:8px;
}
.working-env .env-card{border-left:4px solid var(--success);}
.deployment-env .env-card{border-left:4px solid var(--blue2);}
.connection-info{
display:flex;align-items:center;gap:8px;margin-top:12px;padding:8px;
background:rgba(0,0,0,0.05);border-radius:6px;font-size:0.85em;
}
.connection-info.connected{background:rgba(46,204,113,0.1);color:var(--success);}
.connection-info.error{background:rgba(231,76,60,0.1);color:var(--danger);}
/* Modal Styles */
.modal{
display:none;position:fixed;top:0;left:0;width:100%;height:100%;
background:rgba(0,0,0,0.7);z-index:1000;backdrop-filter:blur(4px);
}
.modal.show{display:flex;align-items:center;justify-content:center;}
.modal-content{
background:white;border-radius:16px;padding:24px;max-width:600px;width:90%;
max-height:80vh;overflow-y:auto;box-shadow:0 20px 40px rgba(0,0,0,0.3);
}
.modal-header{
display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;
border-bottom:2px solid var(--blue2);padding-bottom:12px;
}
.modal-title{font-size:1.4em;font-weight:600;color:var(--muted);}
.modal-close{
background:none;border:none;font-size:1.5em;cursor:pointer;
width:32px;height:32px;border-radius:50%;display:flex;align-items:center;justify-content:center;
}
.modal-close:hover{background:rgba(0,0,0,0.1);}
.form-group{
margin-bottom:16px;
}
.form-label{
display:block;font-weight:600;margin-bottom:6px;color:#333;
}
.form-input, .form-select, .form-textarea{
width:100%;padding:10px 12px;border-radius:8px;border:1px solid #ddd;
font-family:inherit;font-size:0.9em;box-sizing:border-box;
}
.form-textarea{
resize:vertical;min-height:100px;font-family:monospace;
}
.form-input:focus, .form-select:focus, .form-textarea:focus{
outline:none;border-color:var(--blue2);box-shadow:0 0 0 3px rgba(59,160,255,0.1);
}
.form-row{
display:grid;grid-template-columns:1fr 1fr;gap:12px;
}
.form-checkbox{
display:flex;align-items:center;gap:8px;margin-top:8px;
}
.form-checkbox input{width:auto;}
.modal-actions{
display:flex;justify-content:flex-end;gap:12px;margin-top:24px;
padding-top:16px;border-top:1px solid #eee;
}
.btn-edit{
position:absolute;top:12px;right:60px;padding:4px 8px;font-size:0.8em;
background:var(--warning);color:white;border:none;border-radius:4px;
}
.config-section{
background:rgba(255,255,255,0.9);border-radius:12px;padding:20px;margin-bottom:24px;
border:2px solid var(--blue2);
}
.config-header{
font-size:1.3em;font-weight:600;color:var(--muted);margin-bottom:16px;
display:flex;align-items:center;gap:12px;
}
</style>
</head>
<body>
<div class="app-container">
<h1>🌐 Environment Management</h1>
<nav class="nav-bar">
<a href="index.html" class="nav-link">🏠 Home</a>
<a href="environments.html" class="nav-link active">🌐 Environments</a>
<a href="git-changes.html" class="nav-link">🔄 Git Changes</a>
<a href="#" class="nav-link" onclick="openAddEnvironmentModal()">➕ Add New</a>
<a href="#" class="nav-link" onclick="refreshAllConnections()">🔄 Refresh All</a>
<a href="#" class="nav-link" onclick="testAllConnections()">🧪 Test All</a>
<a href="#" class="nav-link" onclick="openImportModal()">📥 Import</a>
</nav>
<!-- Working Environments Section -->
<section class="env-section working-env">
<div class="section-header">
<h2>🛠️ Working Environments</h2>
<div class="section-actions">
<button class="btn btn-primary" onclick="testWorkingEnvironments()">Test Working Envs</button>
<button class="btn btn-secondary" onclick="exportWorkingConfig()">Export Config</button>
</div>
</div>
<div class="env-grid">
<!-- Development Database -->
<div class="env-card" data-env="dev">
<button class="copy-btn btn" onclick="copyJdbcUrl('dev')" title="Copy JDBC URL">📋</button>
<button class="btn-edit btn" onclick="editEnvironment('dev')" title="Edit Environment">✏️</button>
<div class="env-header">
<div class="env-name">Development Database</div>
<div class="env-status" id="status-dev"></div>
</div>
<div class="env-details">
<div class="env-detail">
<span class="detail-label">Server:</span>
<span class="detail-value">dbms-aipoc01:1433</span>
</div>
<div class="env-detail">
<span class="detail-label">Database:</span>
<span class="detail-value">AutopilotDev</span>
</div>
<div class="env-detail">
<span class="detail-label">Auth:</span>
<span class="detail-value">Integrated Security</span>
</div>
<div class="env-detail">
<span class="detail-label">Encryption:</span>
<span class="detail-value">Enabled (Trust Certificate)</span>
</div>
</div>
<div class="jdbc-url" id="jdbc-dev">
jdbc:sqlserver://dbms-aipoc01:1433;databaseName=AutopilotDev;encrypt=true;integratedSecurity=true;trustServerCertificate=true
</div>
<div class="connection-info" id="conn-dev">
<span>🔍 Connection not tested</span>
</div>
<div class="env-actions">
<button class="btn btn-success" onclick="testConnection('dev')">Test Connection</button>
<button class="btn btn-primary" onclick="connectEnvironment('dev')">Connect</button>
<button class="btn btn-warning" onclick="showDatabaseInfo('dev')">DB Info</button>
</div>
</div>
<!-- Shadow Database -->
<div class="env-card" data-env="shadow">
<button class="copy-btn btn" onclick="copyJdbcUrl('shadow')" title="Copy JDBC URL">📋</button>
<button class="btn-edit btn" onclick="editEnvironment('shadow')" title="Edit Environment">✏️</button>
<div class="env-header">
<div class="env-name">Shadow Database</div>
<div class="env-status" id="status-shadow"></div>
</div>
<div class="env-details">
<div class="env-detail">
<span class="detail-label">Server:</span>
<span class="detail-value">dbms-aipoc01:1433</span>
</div>
<div class="env-detail">
<span class="detail-label">Database:</span>
<span class="detail-value">AutopilotShadow</span>
</div>
<div class="env-detail">
<span class="detail-label">Auth:</span>
<span class="detail-value">Integrated Security</span>
</div>
<div class="env-detail">
<span class="detail-label">Encryption:</span>
<span class="detail-value">Disabled</span>
</div>
</div>
<div class="jdbc-url" id="jdbc-shadow">
jdbc:sqlserver://dbms-aipoc01:1433;databaseName=AutopilotShadow;encrypt=false;integratedSecurity=true;trustServerCertificate=false
</div>
<div class="connection-info" id="conn-shadow">
<span>🔍 Connection not tested</span>
</div>
<div class="env-actions">
<button class="btn btn-success" onclick="testConnection('shadow')">Test Connection</button>
<button class="btn btn-primary" onclick="connectEnvironment('shadow')">Connect</button>
<button class="btn btn-warning" onclick="showDatabaseInfo('shadow')">DB Info</button>
</div>
</div>
</div>
</section>
<!-- Deployment Environments Section -->
<section class="env-section deployment-env">
<div class="section-header">
<h2>🚀 Deployment Environments</h2>
<div class="section-actions">
<button class="btn btn-primary" onclick="testDeploymentEnvironments()">Test Deployment Envs</button>
<button class="btn btn-secondary" onclick="exportDeploymentConfig()">Export Config</button>
</div>
</div>
<div class="env-grid">
<!-- Production Database -->
<div class="env-card" data-env="prod">
<button class="copy-btn btn" onclick="copyJdbcUrl('prod')" title="Copy JDBC URL">📋</button>
<button class="btn-edit btn" onclick="editEnvironment('prod')" title="Edit Environment">✏️</button>
<div class="env-header">
<div class="env-name">Production Database</div>
<div class="env-status" id="status-prod"></div>
</div>
<div class="env-details">
<div class="env-detail">
<span class="detail-label">Server:</span>
<span class="detail-value">localhost</span>
</div>
<div class="env-detail">
<span class="detail-label">Database:</span>
<span class="detail-value">AutopilotProd</span>
</div>
<div class="env-detail">
<span class="detail-label">Auth:</span>
<span class="detail-value">Integrated Security</span>
</div>
<div class="env-detail">
<span class="detail-label">Encryption:</span>
<span class="detail-value">Enabled (Trust Certificate)</span>
</div>
</div>
<div class="jdbc-url" id="jdbc-prod">
jdbc:sqlserver://localhost;databaseName=AutopilotProd;encrypt=true;integratedSecurity=true;trustServerCertificate=true
</div>
<div class="connection-info" id="conn-prod">
<span>🔍 Connection not tested</span>
</div>
<div class="env-actions">
<button class="btn btn-success" onclick="testConnection('prod')">Test Connection</button>
<button class="btn btn-danger" onclick="connectEnvironment('prod')"
onmouseover="this.title='⚠️ PRODUCTION - Use with caution!'"
style="background:var(--danger)">Connect to PROD</button>
<button class="btn btn-warning" onclick="showDatabaseInfo('prod')">DB Info</button>
</div>
</div>
<!-- Test Database -->
<div class="env-card" data-env="test">
<button class="copy-btn btn" onclick="copyJdbcUrl('test')" title="Copy JDBC URL">📋</button>
<button class="btn-edit btn" onclick="editEnvironment('test')" title="Edit Environment">✏️</button>
<div class="env-header">
<div class="env-name">Test Database</div>
<div class="env-status" id="status-test"></div>
</div>
<div class="env-details">
<div class="env-detail">
<span class="detail-label">Server:</span>
<span class="detail-value">dbms-aipoc01:1433</span>
</div>
<div class="env-detail">
<span class="detail-label">Database:</span>
<span class="detail-value">AutopilotTest</span>
</div>
<div class="env-detail">
<span class="detail-label">Auth:</span>
<span class="detail-value">Integrated Security</span>
</div>
<div class="env-detail">
<span class="detail-label">Encryption:</span>
<span class="detail-value">Disabled</span>
</div>
</div>
<div class="jdbc-url" id="jdbc-test">
jdbc:sqlserver://dbms-aipoc01:1433;databaseName=AutopilotTest;encrypt=false;integratedSecurity=true;trustServerCertificate=false
</div>
<div class="connection-info" id="conn-test">
<span>🔍 Connection not tested</span>
</div>
<div class="env-actions">
<button class="btn btn-success" onclick="testConnection('test')">Test Connection</button>
<button class="btn btn-primary" onclick="connectEnvironment('test')">Connect</button>
<button class="btn btn-warning" onclick="showDatabaseInfo('test')">DB Info</button>
</div>
</div>
<!-- Check (Reporting) Database -->
<div class="env-card" data-env="check">
<button class="copy-btn btn" onclick="copyJdbcUrl('check')" title="Copy JDBC URL">📋</button>
<button class="btn-edit btn" onclick="editEnvironment('check')" title="Edit Environment">✏️</button>
<div class="env-header">
<div class="env-name">Check (Reporting) Database</div>
<div class="env-status" id="status-check"></div>
</div>
<div class="env-details">
<div class="env-detail">
<span class="detail-label">Server:</span>
<span class="detail-value">localhost</span>
</div>
<div class="env-detail">
<span class="detail-label">Database:</span>
<span class="detail-value">AutopilotCheck</span>
</div>
<div class="env-detail">
<span class="detail-label">Auth:</span>
<span class="detail-value">Integrated Security</span>
</div>
<div class="env-detail">
<span class="detail-label">Encryption:</span>
<span class="detail-value">Enabled (Trust Certificate)</span>
</div>
</div>
<div class="jdbc-url" id="jdbc-check">
jdbc:sqlserver://localhost;databaseName=AutopilotCheck;encrypt=true;integratedSecurity=true;trustServerCertificate=true
</div>
<div class="connection-info" id="conn-check">
<span>🔍 Connection not tested</span>
</div>
<div class="env-actions">
<button class="btn btn-success" onclick="testConnection('check')">Test Connection</button>
<button class="btn btn-primary" onclick="connectEnvironment('check')">Connect</button>
<button class="btn btn-warning" onclick="showDatabaseInfo('check')">DB Info</button>
</div>
</div>
<!-- Build Database -->
<div class="env-card" data-env="build">
<button class="copy-btn btn" onclick="copyJdbcUrl('build')" title="Copy JDBC URL">📋</button>
<button class="btn-edit btn" onclick="editEnvironment('build')" title="Edit Environment">✏️</button>
<div class="env-header">
<div class="env-name">Build Database</div>
<div class="env-status" id="status-build"></div>
</div>
<div class="env-details">
<div class="env-detail">
<span class="detail-label">Server:</span>
<span class="detail-value">localhost</span>
</div>
<div class="env-detail">
<span class="detail-label">Database:</span>
<span class="detail-value">AutopilotBuild</span>
</div>
<div class="env-detail">
<span class="detail-label">Auth:</span>
<span class="detail-value">Integrated Security</span>
</div>
<div class="env-detail">
<span class="detail-label">Encryption:</span>
<span class="detail-value">Enabled (Trust Certificate)</span>
</div>
</div>
<div class="jdbc-url" id="jdbc-build">
jdbc:sqlserver://localhost;databaseName=AutopilotBuild;encrypt=true;integratedSecurity=true;trustServerCertificate=true
</div>
<div class="connection-info" id="conn-build">
<span>🔍 Connection not tested</span>
</div>
<div class="env-actions">
<button class="btn btn-success" onclick="testConnection('build')">Test Connection</button>
<button class="btn btn-primary" onclick="connectEnvironment('build')">Connect</button>
<button class="btn btn-warning" onclick="showDatabaseInfo('build')">DB Info</button>
</div>
</div>
</div>
</section>
<!-- Configuration Management Section -->
<section class="config-section">
<div class="config-header">
⚙️ Configuration Management
<div style="flex:1"></div>
<button class="btn btn-primary" onclick="openConfigManager()">🛠️ Advanced Config</button>
</div>
<p>Manage environment configurations, connection strings, and import/export settings. Use the buttons above to add new environments or edit existing ones.</p>
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px;margin-top:16px;">
<div style="text-align:center;padding:16px;background:rgba(46,204,113,0.1);border-radius:8px;">
<div style="font-size:1.5em;font-weight:600;color:var(--success);">6</div>
<div>Total Environments</div>
</div>
<div style="text-align:center;padding:16px;background:rgba(52,152,219,0.1);border-radius:8px;">
<div style="font-size:1.5em;font-weight:600;color:var(--blue2);" id="connectedCount">0</div>
<div>Connected</div>
</div>
<div style="text-align:center;padding:16px;background:rgba(231,76,60,0.1);border-radius:8px;">
<div style="font-size:1.5em;font-weight:600;color:var(--danger);" id="errorCount">0</div>
<div>Errors</div>
</div>
<div style="text-align:center;padding:16px;background:rgba(243,156,18,0.1);border-radius:8px;">
<div style="font-size:1.5em;font-weight:600;color:var(--warning);" id="workingCount">2</div>
<div>Working Envs</div>
</div>
</div>
</section>
</div>
<!-- Add/Edit Environment Modal -->
<div class="modal" id="environmentModal">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title" id="modalTitle">Add New Environment</div>
<button class="modal-close" onclick="closeModal('environmentModal')">×</button>
</div>
<form id="environmentForm">
<div class="form-group">
<label class="form-label">Environment Key *</label>
<input type="text" class="form-input" id="envKey" placeholder="e.g., staging, dev2, backup" required>
<small style="color:#666;font-size:0.8em;">Unique identifier for this environment</small>
</div>
<div class="form-group">
<label class="form-label">Display Name *</label>
<input type="text" class="form-input" id="envName" placeholder="e.g., Staging Database" required>
</div>
<div class="form-row">
<div class="form-group">
<label class="form-label">Server Address *</label>
<input type="text" class="form-input" id="envServer" placeholder="localhost or server:port" required>
</div>
<div class="form-group">
<label class="form-label">Database Name *</label>
<input type="text" class="form-input" id="envDatabase" placeholder="DatabaseName" required>
</div>
</div>
<div class="form-group">
<label class="form-label">Environment Type</label>
<select class="form-select" id="envType">
<option value="working">Working Environment</option>
<option value="deployment">Deployment Environment</option>
</select>
</div>
<div class="form-group">
<label class="form-label">Authentication</label>
<select class="form-select" id="envAuth" onchange="toggleAuthFields()">
<option value="integrated">Windows Integrated Security</option>
<option value="sql">SQL Server Authentication</option>
</select>
</div>
<div id="sqlAuthFields" style="display:none;">
<div class="form-row">
<div class="form-group">
<label class="form-label">Username</label>
<input type="text" class="form-input" id="envUsername" placeholder="SQL Username">
</div>
<div class="form-group">
<label class="form-label">Password</label>
<input type="password" class="form-input" id="envPassword" placeholder="SQL Password">
</div>
</div>
</div>
<div class="form-row">
<div class="form-group">
<div class="form-checkbox">
<input type="checkbox" id="envEncrypt" checked>
<label for="envEncrypt">Enable Encryption</label>
</div>
</div>
<div class="form-group">
<div class="form-checkbox">
<input type="checkbox" id="envTrustCert" checked>
<label for="envTrustCert">Trust Server Certificate</label>
</div>
</div>
</div>
<div class="form-group">
<label class="form-label">Additional Connection Parameters</label>
<textarea class="form-textarea" id="envAdditional" placeholder="Additional JDBC parameters (optional)
Example: connectionTimeout=30;commandTimeout=60"></textarea>
</div>
<div class="form-group">
<label class="form-label">Generated JDBC URL</label>
<textarea class="form-textarea" id="envJdbcPreview" readonly style="background:#f8f9fa;font-family:monospace;font-size:0.85em;"></textarea>
</div>
<div class="modal-actions">
<button type="button" class="btn btn-secondary" onclick="closeModal('environmentModal')">Cancel</button>
<button type="button" class="btn btn-warning" onclick="testNewConnection()">🧪 Test Connection</button>
<button type="submit" class="btn btn-primary">💾 Save Environment</button>
</div>
</form>
</div>
</div>
<!-- Import Configuration Modal -->
<div class="modal" id="importModal">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title">Import Environment Configuration</div>
<button class="modal-close" onclick="closeModal('importModal')">×</button>
</div>
<div class="form-group">
<label class="form-label">Upload JSON Configuration File</label>
<input type="file" class="form-input" id="configFile" accept=".json" onchange="previewImport()">
</div>
<div class="form-group">
<label class="form-label">Or Paste JSON Configuration</label>
<textarea class="form-textarea" id="configJson" placeholder="Paste JSON configuration here..." style="min-height:200px;"></textarea>
</div>
<div id="importPreview" style="display:none;">
<h4>Import Preview:</h4>
<div id="importSummary"></div>
</div>
<div class="modal-actions">
<button type="button" class="btn btn-secondary" onclick="closeModal('importModal')">Cancel</button>
<button type="button" class="btn btn-primary" onclick="importConfiguration()">📥 Import</button>
</div>
</div>
</div>
<!-- Advanced Configuration Manager Modal -->
<div class="modal" id="configManagerModal">
<div class="modal-content" style="max-width:800px;">
<div class="modal-header">
<div class="modal-title">Advanced Configuration Manager</div>
<button class="modal-close" onclick="closeModal('configManagerModal')">×</button>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:20px;">
<div>
<h4>Current Configuration</h4>
<textarea id="currentConfig" style="width:100%;height:400px;font-family:monospace;font-size:0.8em;" readonly></textarea>
<button class="btn btn-secondary" onclick="exportFullConfig()">📄 Export All</button>
</div>
<div>
<h4>Server Mappings</h4>
<div id="serverMappings" style="background:#f8f9fa;padding:12px;border-radius:8px;min-height:200px;">
<p><strong>Current API Mappings:</strong></p>
<ul style="font-family:monospace;font-size:0.9em;">
<li>dev, shadow → DEV</li>
<li>test → TEST</li>
<li>prod, check, build → LIVE</li>
</ul>
</div>
<button class="btn btn-warning" onclick="refreshServerConfig()">🔄 Refresh</button>
<button class="btn btn-primary" onclick="saveServerConfig()">💾 Update Server</button>
</div>
</div>
<div class="modal-actions">
<button type="button" class="btn btn-secondary" onclick="closeModal('configManagerModal')">Close</button>
</div>
</div>
</div>
<script>
// Environment configuration
let environments = {
dev: {
name: 'Development Database',
jdbc: 'jdbc:sqlserver://dbms-aipoc01:1433;databaseName=AutopilotDev;encrypt=true;integratedSecurity=true;trustServerCertificate=true',
server: 'dbms-aipoc01:1433',
database: 'AutopilotDev',
type: 'working',
auth: 'integrated',
encrypt: true,
trustCert: true
},
shadow: {
name: 'Shadow Database',
jdbc: 'jdbc:sqlserver://dbms-aipoc01:1433;databaseName=AutopilotShadow;encrypt=false;integratedSecurity=true;trustServerCertificate=false',
server: 'dbms-aipoc01:1433',
database: 'AutopilotShadow',
type: 'working',
auth: 'integrated',
encrypt: false,
trustCert: false
},
prod: {
name: 'Production Database',
jdbc: 'jdbc:sqlserver://localhost;databaseName=AutopilotProd;encrypt=true;integratedSecurity=true;trustServerCertificate=true',
server: 'localhost',
database: 'AutopilotProd',
type: 'deployment',
auth: 'integrated',
encrypt: true,
trustCert: true
},
test: {
name: 'Test Database',
jdbc: 'jdbc:sqlserver://dbms-aipoc01:1433;databaseName=AutopilotTest;encrypt=false;integratedSecurity=true;trustServerCertificate=false',
server: 'dbms-aipoc01:1433',
database: 'AutopilotTest',
type: 'deployment',
auth: 'integrated',
encrypt: false,
trustCert: false
},
check: {
name: 'Check (Reporting) Database',
jdbc: 'jdbc:sqlserver://localhost;databaseName=AutopilotCheck;encrypt=true;integratedSecurity=true;trustServerCertificate=true',
server: 'localhost',
database: 'AutopilotCheck',
type: 'deployment',
auth: 'integrated',
encrypt: true,
trustCert: true
},
build: {
name: 'Build Database',
jdbc: 'jdbc:sqlserver://localhost;databaseName=AutopilotBuild;encrypt=true;integratedSecurity=true;trustServerCertificate=true',
server: 'localhost',
database: 'AutopilotBuild',
type: 'deployment',
auth: 'integrated',
encrypt: true,
trustCert: true
}
};
let isEditing = false;
let currentEditingKey = null;
// Copy JDBC URL to clipboard
async function copyJdbcUrl(envKey) {
const url = environments[envKey]?.jdbc;
if (!url) return;
try {
await navigator.clipboard.writeText(url);
showNotification(`📋 JDBC URL copied for ${environments[envKey].name}`, 'success');
} catch (err) {
// Fallback for older browsers
const textArea = document.createElement('textarea');
textArea.value = url;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
showNotification(`📋 JDBC URL copied for ${environments[envKey].name}`, 'success');
}
}
// Test database connection
async function testConnection(envKey) {
const env = environments[envKey];
if (!env) return;
updateConnectionStatus(envKey, 'testing', '🔄 Testing connection...');
try {
// Map our environment keys to the server's expected keys
const serverEnvMap = {
'dev': 'DEV',
'shadow': 'DEV', // Assuming shadow uses DEV config for now
'test': 'TEST',
'prod': 'LIVE',
'check': 'LIVE', // Assuming check uses LIVE config for now
'build': 'LIVE' // Assuming build uses LIVE config for now
};
const serverEnv = serverEnvMap[envKey];
if (!serverEnv) {
updateConnectionStatus(envKey, 'error', '❌ Environment mapping not found');
updateStatusDot(envKey, 'error');
return;
}
// Call the existing connection API
const response = await fetch(`/sql-connect/${serverEnv}`);
const result = await response.json();
if (result.success) {
updateConnectionStatus(envKey, 'connected', '✅ ' + result.message);
updateStatusDot(envKey, 'connected');
} else {
updateConnectionStatus(envKey, 'error', '❌ ' + result.message);
updateStatusDot(envKey, 'error');
}
} catch (error) {
updateConnectionStatus(envKey, 'error', `❌ Error: ${error.message}`);
updateStatusDot(envKey, 'error');
}
}
// Connect to environment
async function connectEnvironment(envKey) {
const env = environments[envKey];
if (!env) return;
if (envKey === 'prod') {
if (!confirm('⚠️ You are about to connect to PRODUCTION!\n\nThis environment contains live data. Please confirm you want to proceed.')) {
return;
}
}
showNotification(`🔌 Connecting to ${env.name}...`, 'info');
try {
// Map our environment keys to the server's expected keys
const serverEnvMap = {
'dev': 'DEV',
'shadow': 'DEV',
'test': 'TEST',
'prod': 'LIVE',
'check': 'LIVE',
'build': 'LIVE'
};
const serverEnv = serverEnvMap[envKey];
if (!serverEnv) {
showNotification(`❌ Environment mapping not found for ${env.name}`, 'error');
return;
}
// Call the existing connection API
const response = await fetch(`/sql-connect/${serverEnv}`);
const result = await response.json();
if (result.success) {
updateStatusDot(envKey, 'connected');
showNotification(`✅ ${result.message}`, 'success');
// Optionally redirect to main app with this environment selected
setTimeout(() => {
if (confirm('🏠 Would you like to go to the main application with this environment?')) {
window.location.href = `index.html`;
}
}, 1000);
} else {
updateStatusDot(envKey, 'error');
showNotification(`❌ Failed to connect to ${env.name}: ${result.message}`, 'error');
}
} catch (error) {
updateStatusDot(envKey, 'error');
showNotification(`❌ Failed to connect to ${env.name}: ${error.message}`, 'error');
}
}
// Show database information
async function showDatabaseInfo(envKey) {
const env = environments[envKey];
if (!env) return;
try {
// Map environment key to server environment
const serverEnvMap = {
'dev': 'DEV',
'shadow': 'DEV',
'test': 'TEST',
'prod': 'LIVE',
'check': 'LIVE',
'build': 'LIVE'
};
const serverEnv = serverEnvMap[envKey];
if (!serverEnv) {
alert(`Environment mapping not found for ${env.name}`);
return;
}
showNotification(`🔍 Getting database info for ${env.name}...`, 'info');
// Try to get basic database info using existing objects endpoint
const response = await fetch(`/db/objects?env=${serverEnv}`);
const result = await response.json();
let info = `Database Information for ${env.name}:\n\n`;
info += `Server: ${env.server}\n`;
info += `Database: ${env.database}\n`;
info += `JDBC URL: ${env.jdbc}\n\n`;
info += `Connection Details:\n`;
info += `- Authentication: Integrated Security (Windows Auth)\n`;
info += `- Encryption: ${env.jdbc.includes('encrypt=true') ? 'Enabled' : 'Disabled'}\n`;
info += `- Trust Certificate: ${env.jdbc.includes('trustServerCertificate=true') ? 'Yes' : 'No'}\n\n`;
if (result.success) {
const totalObjects = (result.tables?.length || 0) + (result.views?.length || 0) +
(result.procedures?.length || 0) + (result.functions?.length || 0);
info += `Database Objects:\n`;
info += `- Tables: ${result.tables?.length || 0}\n`;
info += `- Views: ${result.views?.length || 0}\n`;
info += `- Stored Procedures: ${result.procedures?.length || 0}\n`;
info += `- Functions: ${result.functions?.length || 0}\n`;
info += `- Total Objects: ${totalObjects}\n`;
} else {
info += `Database Objects: Unable to retrieve (${result.message || 'Connection required'})\n`;
}
alert(info);
} catch (error) {
const basicInfo = `
Database Information for ${env.name}:
Server: ${env.server}
Database: ${env.database}
JDBC URL: ${env.jdbc}
Connection Details:
- Authentication: Integrated Security (Windows Auth)
- Encryption: ${env.jdbc.includes('encrypt=true') ? 'Enabled' : 'Disabled'}
- Trust Certificate: ${env.jdbc.includes('trustServerCertificate=true') ? 'Yes' : 'No'}
Note: Unable to retrieve live database info. Please connect first.
`.trim();
alert(basicInfo);
}
}
// Update connection status
function updateConnectionStatus(envKey, status, message) {
const connElement = document.getElementById(`conn-${envKey}`);
if (connElement) {
connElement.className = `connection-info ${status}`;
connElement.innerHTML = `<span>${message}</span>`;
}
}
// Update status dot
function updateStatusDot(envKey, status) {
const statusElement = document.getElementById(`status-${envKey}`);
if (statusElement) {
statusElement.className = `env-status ${status}`;
}
}
// Test all working environments
async function testWorkingEnvironments() {
showNotification('🧪 Testing all working environments...', 'info');
for (const [key, env] of Object.entries(environments)) {
if (env.type === 'working') {
await testConnection(key);
await new Promise(resolve => setTimeout(resolve, 500)); // Stagger tests
}
}
showNotification('✅ Working environment tests completed', 'success');
}
// Test all deployment environments
async function testDeploymentEnvironments() {
showNotification('🧪 Testing all deployment environments...', 'info');
for (const [key, env] of Object.entries(environments)) {
if (env.type === 'deployment') {
await testConnection(key);
await new Promise(resolve => setTimeout(resolve, 500)); // Stagger tests
}
}
showNotification('✅ Deployment environment tests completed', 'success');
}
// Test all connections
async function testAllConnections() {
showNotification('🧪 Testing all environments...', 'info');
for (const key of Object.keys(environments)) {
await testConnection(key);
await new Promise(resolve => setTimeout(resolve, 300)); // Stagger tests
}
showNotification('✅ All environment tests completed', 'success');
}
// Refresh all connections
async function refreshAllConnections() {
showNotification('🔄 Refreshing all connections...', 'info');
// Reset all status indicators
for (const key of Object.keys(environments)) {
updateConnectionStatus(key, '', '🔍 Connection not tested');
updateStatusDot(key, '');
}
showNotification('✅ All connections refreshed', 'success');
}
// Export configuration
function exportWorkingConfig() {
const workingEnvs = Object.entries(environments)
.filter(([key, env]) => env.type === 'working')
.reduce((obj, [key, env]) => {
obj[key] = env;
return obj;
}, {});
downloadJson(workingEnvs, 'working-environments.json');
}