Skip to content

Commit 17f440d

Browse files
committed
fixing bugs
1 parent f2de15c commit 17f440d

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

src/app/pages/show-asset/asset-cicd/asset-cicd.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<ng-template #showConfigTemplate let-data let-ref="dialogRef">
7171
<nb-card>
7272
<nb-card-header>Config for asset</nb-card-header>
73-
<nb-card-body>
73+
<nb-card-body style="max-height: 60vh;overflow-y: scroll;">
7474
<div>This is config that has to be put in <pre>mixeway.yaml</pre> file in root directory of GIT repository in order to
7575
properly perform scanning.<br/> Make sure to remove all comments and fill proper values.
7676
In some scenarios You will have to generate link between SCA scanner and mixeway before proceeding.</div>

src/app/pages/show-project/manage-assets/manage-assets.component.html

+12-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<ng2-smart-table [settings]="settings" [source]="source" (custom)="onCustomAction($event)"></ng2-smart-table>
77

88
<ng-template #addAsset let-data let-ref="dialogRef">
9-
<nb-card>
9+
<nb-card [nbSpinner]="showSpinner" nbSpinnerStatus="primary" nbSpinnerSize="large">
1010
<nb-card-header>Create asset</nb-card-header>
11-
<nb-card-body>
11+
<nb-card-body style="max-height: 60vh;overflow-y: scroll;" >
1212
<form [formGroup]="assetForm" class="form">
1313
<nb-select fullWidth placeholder="Select Asset Type" formControlName="assetType" class="form-field">
1414
<nb-option value="sourceCodeApp">Source Code App</nb-option>
@@ -107,16 +107,23 @@
107107
<nb-option value="2">2</nb-option>
108108
<nb-option value="3">3</nb-option>
109109
</nb-select>
110-
<button nbButton *ngIf="assetForm.get('assetType').valid" (click)="onSubmit(ref)" status="primary">Submit</button>
110+
<button nbButton status="primary"
111+
[disabled]="isSubmitting"
112+
(click)="onSubmit(ref)">
113+
<nb-icon *ngIf="isSubmitting" icon="spinner-outline" pack="eva" status="info"></nb-icon>
114+
<span *ngIf="!isSubmitting">Submit</span>
115+
<span *ngIf="isSubmitting">Submitting...</span>
116+
</button>
111117
</div>
112118
</form>
113119
</nb-card-body>
114120
</nb-card>
115121
</ng-template>
116122
<ng-template #editAsset let-data let-ref="dialogRef">
117-
<nb-card>
123+
<nb-card >
118124
<nb-card-header>Edit Asset</nb-card-header>
119-
<nb-card-body>
125+
<nb-card-body >
126+
120127
<form [formGroup]="editForm" (ngSubmit)="onSaveEdit(ref)" class="form">
121128
<div *ngIf="selectedAsset.type === 'codeProject'" class="form-group">
122129

src/app/pages/show-project/manage-assets/manage-assets.component.scss

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
@import '../../../@theme/styles/themes';
22

33
@include nb-install-component() {
4+
.scrollable-form-container {
5+
overflow-y: auto;
6+
}
7+
48

59
.picture {
610
background-position: center;

src/app/pages/show-project/manage-assets/manage-assets.component.ts

+28-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Input, OnInit, TemplateRef, ViewChild} from '@angular/core';
1+
import {ChangeDetectorRef, Component, Input, NgZone, OnInit, TemplateRef, ViewChild} from '@angular/core';
22
import { LocalDataSource } from 'ng2-smart-table';
33
import { NbDialogService, NbToastrService } from '@nebular/theme';
44
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
@@ -30,11 +30,15 @@ export class ManageAssetsComponent implements OnInit {
3030
editForm: FormGroup;
3131
_entityId: any;
3232
selectedAsset: any; // To store the selected asset for editing
33+
isSubmitting = false;
34+
showSpinner = false;
35+
3336

3437
data: ProjectAsset[] = []; // Initialize as an empty array
3538

3639
constructor(private dialogService: NbDialogService, private toastrService: NbToastrService, private fb: FormBuilder,
37-
private router: Router, private assetService: AssetService, private _route: ActivatedRoute) {
40+
private router: Router, private assetService: AssetService, private _route: ActivatedRoute,
41+
private cdr: ChangeDetectorRef) {
3842
this._entityId = +this._route.snapshot.paramMap.get('projectid');
3943
if (!this._entityId) {
4044
this.router.navigate(['/pages/dashboard']);
@@ -185,18 +189,35 @@ export class ManageAssetsComponent implements OnInit {
185189
}
186190
}
187191
onSubmit(ref) {
188-
return this.assetService.saveAsset(this._entityId, this.assetForm.value).subscribe(() => {
192+
193+
// Disable the submit button and show the spinner
194+
this.isSubmitting = true;
195+
this.showSpinner = true;
196+
this.cdr.detectChanges(); // Manually trigger change detection
197+
198+
// Make the request
199+
this.assetService.saveAsset(this._entityId, this.assetForm.value).subscribe(
200+
() => {
189201
this.toastrService.show('Asset created', 'Success', { status: 'success' });
190-
this.clearForm();
191202
this.loadAssets();
192203
ref.close();
193204
},
194-
() => {
205+
(error) => {
195206
this.toastrService.show('Asset not created, check all fields', 'Failure', { status: 'danger' });
196-
});
197-
ref.close();
207+
// Handle the error case here
208+
},
209+
() => {
210+
// Reset the submit button and hide the spinner once the request is complete
211+
this.isSubmitting = false;
212+
this.showSpinner = false;
213+
this.loadAssets();
214+
ref.close();
215+
},
216+
);
198217
}
199218

219+
220+
200221
onSaveEdit(ref) {
201222
if (this.editForm.valid) {
202223
// Update the data source with the edited values

0 commit comments

Comments
 (0)