Skip to content

Commit

Permalink
fixing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
siewer committed Jul 31, 2024
1 parent f2de15c commit 17f440d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<ng-template #showConfigTemplate let-data let-ref="dialogRef">
<nb-card>
<nb-card-header>Config for asset</nb-card-header>
<nb-card-body>
<nb-card-body style="max-height: 60vh;overflow-y: scroll;">
<div>This is config that has to be put in <pre>mixeway.yaml</pre> file in root directory of GIT repository in order to
properly perform scanning.<br/> Make sure to remove all comments and fill proper values.
In some scenarios You will have to generate link between SCA scanner and mixeway before proceeding.</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<ng2-smart-table [settings]="settings" [source]="source" (custom)="onCustomAction($event)"></ng2-smart-table>

<ng-template #addAsset let-data let-ref="dialogRef">
<nb-card>
<nb-card [nbSpinner]="showSpinner" nbSpinnerStatus="primary" nbSpinnerSize="large">
<nb-card-header>Create asset</nb-card-header>
<nb-card-body>
<nb-card-body style="max-height: 60vh;overflow-y: scroll;" >
<form [formGroup]="assetForm" class="form">
<nb-select fullWidth placeholder="Select Asset Type" formControlName="assetType" class="form-field">
<nb-option value="sourceCodeApp">Source Code App</nb-option>
Expand Down Expand Up @@ -107,16 +107,23 @@
<nb-option value="2">2</nb-option>
<nb-option value="3">3</nb-option>
</nb-select>
<button nbButton *ngIf="assetForm.get('assetType').valid" (click)="onSubmit(ref)" status="primary">Submit</button>
<button nbButton status="primary"
[disabled]="isSubmitting"
(click)="onSubmit(ref)">
<nb-icon *ngIf="isSubmitting" icon="spinner-outline" pack="eva" status="info"></nb-icon>
<span *ngIf="!isSubmitting">Submit</span>
<span *ngIf="isSubmitting">Submitting...</span>
</button>
</div>
</form>
</nb-card-body>
</nb-card>
</ng-template>
<ng-template #editAsset let-data let-ref="dialogRef">
<nb-card>
<nb-card >
<nb-card-header>Edit Asset</nb-card-header>
<nb-card-body>
<nb-card-body >

<form [formGroup]="editForm" (ngSubmit)="onSaveEdit(ref)" class="form">
<div *ngIf="selectedAsset.type === 'codeProject'" class="form-group">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@import '../../../@theme/styles/themes';

@include nb-install-component() {
.scrollable-form-container {
overflow-y: auto;
}


.picture {
background-position: center;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Input, OnInit, TemplateRef, ViewChild} from '@angular/core';
import {ChangeDetectorRef, Component, Input, NgZone, OnInit, TemplateRef, ViewChild} from '@angular/core';
import { LocalDataSource } from 'ng2-smart-table';
import { NbDialogService, NbToastrService } from '@nebular/theme';
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
Expand Down Expand Up @@ -30,11 +30,15 @@ export class ManageAssetsComponent implements OnInit {
editForm: FormGroup;
_entityId: any;
selectedAsset: any; // To store the selected asset for editing
isSubmitting = false;
showSpinner = false;


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

constructor(private dialogService: NbDialogService, private toastrService: NbToastrService, private fb: FormBuilder,
private router: Router, private assetService: AssetService, private _route: ActivatedRoute) {
private router: Router, private assetService: AssetService, private _route: ActivatedRoute,
private cdr: ChangeDetectorRef) {
this._entityId = +this._route.snapshot.paramMap.get('projectid');
if (!this._entityId) {
this.router.navigate(['/pages/dashboard']);
Expand Down Expand Up @@ -185,18 +189,35 @@ export class ManageAssetsComponent implements OnInit {
}
}
onSubmit(ref) {
return this.assetService.saveAsset(this._entityId, this.assetForm.value).subscribe(() => {

// Disable the submit button and show the spinner
this.isSubmitting = true;
this.showSpinner = true;
this.cdr.detectChanges(); // Manually trigger change detection

// Make the request
this.assetService.saveAsset(this._entityId, this.assetForm.value).subscribe(
() => {
this.toastrService.show('Asset created', 'Success', { status: 'success' });
this.clearForm();
this.loadAssets();
ref.close();
},
() => {
(error) => {
this.toastrService.show('Asset not created, check all fields', 'Failure', { status: 'danger' });
});
ref.close();
// Handle the error case here
},
() => {
// Reset the submit button and hide the spinner once the request is complete
this.isSubmitting = false;
this.showSpinner = false;
this.loadAssets();
ref.close();
},
);
}



onSaveEdit(ref) {
if (this.editForm.valid) {
// Update the data source with the edited values
Expand Down

0 comments on commit 17f440d

Please sign in to comment.