-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from austenstone/MattG57/add-predictive-modeling
Add Predictive Modeling page and update settings
- Loading branch information
Showing
16 changed files
with
296 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Request, Response } from 'express'; | ||
import TargetValuesService from '../services/target-values.service.js'; | ||
|
||
class TargetValuesController { | ||
async getTargetValues(req: Request, res: Response): Promise<void> { | ||
try { | ||
const targetValues = await TargetValuesService.getTargetValues(); | ||
res.status(200).json(targetValues); | ||
} catch (error) { | ||
res.status(500).json(error); | ||
} | ||
} | ||
|
||
async updateTargetValues(req: Request, res: Response): Promise<void> { | ||
try { | ||
const updatedTargetValues = await TargetValuesService.updateTargetValues(req.body); | ||
res.status(200).json(updatedTargetValues); | ||
} catch (error) { | ||
res.status(500).json(error); | ||
} | ||
} | ||
} | ||
|
||
export default new TargetValuesController(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Model, DataTypes } from 'sequelize'; | ||
import { sequelize } from '../database.js'; | ||
|
||
class TargetValues extends Model { | ||
public targetedRoomForImprovement!: number; | ||
public targetedNumberOfDevelopers!: number; | ||
public targetedPercentOfTimeSaved!: number; | ||
} | ||
|
||
TargetValues.init({ | ||
targetedRoomForImprovement: { | ||
type: DataTypes.FLOAT, | ||
allowNull: false, | ||
}, | ||
targetedNumberOfDevelopers: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
}, | ||
targetedPercentOfTimeSaved: { | ||
type: DataTypes.FLOAT, | ||
allowNull: false, | ||
} | ||
}, { | ||
sequelize, | ||
modelName: 'TargetValues', | ||
timestamps: false, | ||
}); | ||
|
||
export { TargetValues }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { TargetValues } from '../models/target-values.model.js'; | ||
|
||
class TargetValuesService { | ||
async getTargetValues() { | ||
return await TargetValues.findAll(); | ||
} | ||
|
||
async updateTargetValues(data: { targetedRoomForImprovement: number, targetedNumberOfDevelopers: number, targetedPercentOfTimeSaved: number }) { | ||
const [targetValues] = await TargetValues.findOrCreate({ | ||
where: {}, | ||
defaults: data | ||
}); | ||
|
||
if (!targetValues.isNewRecord) { | ||
await targetValues.update(data); | ||
} | ||
|
||
return targetValues; | ||
} | ||
} | ||
|
||
export default new TargetValuesService(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
frontend/src/app/main/copilot/copilot-calculator/copilot-calculator.component.html
This file was deleted.
Oops, something went wrong.
Empty file removed
0
frontend/src/app/main/copilot/copilot-calculator/copilot-calculator.component.scss
Empty file.
23 changes: 0 additions & 23 deletions
23
frontend/src/app/main/copilot/copilot-calculator/copilot-calculator.component.spec.ts
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
frontend/src/app/main/copilot/copilot-calculator/copilot-calculator.component.ts
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
frontend/src/app/main/copilot/predictive-modeling/predictive-modeling.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<div class="page-container"> | ||
<div class="page-header"> | ||
<h1>Predictive Modeling</h1> | ||
</div> | ||
</div> | ||
<div class="page-container"> | ||
<div class="predictive-modeling-container"> | ||
<div class="left-column"> | ||
<div class="settings-section"> | ||
<h3>Settings</h3> | ||
<form [formGroup]="settingsForm"> | ||
<mat-form-field> | ||
<mat-label>Developer Count</mat-label> | ||
<input matInput formControlName="developerCount" readonly> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Dev Cost Per Year</mat-label> | ||
<input matInput formControlName="devCostPerYear" readonly> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Hours Per Year</mat-label> | ||
<input matInput formControlName="hoursPerYear" readonly> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Percent Coding</mat-label> | ||
<input matInput formControlName="percentCoding" readonly> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Percent Time Saved</mat-label> | ||
<input matInput formControlName="percentTimeSaved" readonly> | ||
</mat-form-field> | ||
</form> | ||
</div> | ||
<div class="targets-section"> | ||
<h3>Targets</h3> | ||
<form [formGroup]="targetForm"> | ||
<mat-form-field> | ||
<mat-label>Number of Developers</mat-label> | ||
<input matInput formControlName="targetedNumberOfDevelopers"> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Room for Improvement</mat-label> | ||
<input matInput formControlName="targetedRoomForImprovement"> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Time saved</mat-label> | ||
<input matInput formControlName="targetedPercentOfTimeSaved"> | ||
</mat-form-field> | ||
</form> | ||
</div> | ||
</div> | ||
<div class="right-column"> | ||
<h3>Calculated Fields</h3> | ||
<!-- <div *ngFor="let field of calculatedFields"> | ||
<p>{{ field.name }}: {{ field.value }}</p> | ||
</div> --> | ||
</div> | ||
</div> | ||
<button mat-raised-button color="primary" (click)="saveTargets()">Save Targets to DB</button> | ||
</div> |
17 changes: 17 additions & 0 deletions
17
frontend/src/app/main/copilot/predictive-modeling/predictive-modeling.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.predictive-modeling-container { | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; // Two equal columns | ||
gap: 20px; // Space between columns | ||
} | ||
|
||
.left-column, .right-column { | ||
width: 100%; // Full width within grid cell | ||
} | ||
|
||
.settings-section, .targets-section { | ||
margin-bottom: 20px; | ||
} | ||
|
||
mat-form-field { | ||
width: 100%; | ||
} |
23 changes: 23 additions & 0 deletions
23
frontend/src/app/main/copilot/predictive-modeling/predictive-modeling.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PredictiveModelingComponent } from './predictive-modeling.component'; | ||
|
||
describe('PredictiveModelingComponent', () => { | ||
let component: PredictiveModelingComponent; | ||
let fixture: ComponentFixture<PredictiveModelingComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PredictiveModelingComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PredictiveModelingComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
70 changes: 70 additions & 0 deletions
70
frontend/src/app/main/copilot/predictive-modeling/predictive-modeling.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { FormControl, FormGroup, Validators } from '@angular/forms'; | ||
import { PredictiveModelingService } from '../../../services/predictive-modeling.service'; | ||
import { MatSnackBar } from '@angular/material/snack-bar'; | ||
import { AppModule } from '../../../app.module'; | ||
import { CommonModule } from '@angular/common'; | ||
import { SettingsHttpService } from '../../../services/settings.service'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'app-predictive-modeling', | ||
templateUrl: './predictive-modeling.component.html', | ||
styleUrls: ['./predictive-modeling.component.scss'], | ||
imports: [ | ||
AppModule, | ||
CommonModule, | ||
] | ||
}) | ||
export class PredictiveModelingComponent implements OnInit { | ||
settingsForm = new FormGroup({ | ||
developerCount: new FormControl({ value: '', disabled: true }), | ||
devCostPerYear: new FormControl({ value: '', disabled: true }), | ||
hoursPerYear: new FormControl({ value: '', disabled: true }), | ||
percentCoding: new FormControl({ value: '', disabled: true }), | ||
percentTimeSaved: new FormControl({ value: '', disabled: true }) | ||
}) | ||
targetForm = new FormGroup({ | ||
targetedRoomForImprovement: new FormControl('', [Validators.required, Validators.min(0)]), | ||
targetedNumberOfDevelopers: new FormControl('', [Validators.required, Validators.min(0)]), | ||
targetedPercentOfTimeSaved: new FormControl('', [Validators.required, Validators.min(0), Validators.max(100)]), | ||
}); | ||
|
||
constructor( | ||
private predictiveModelingService: PredictiveModelingService, | ||
private settingsService: SettingsHttpService, | ||
private snackBar: MatSnackBar | ||
) { } | ||
|
||
ngOnInit(): void { | ||
this.loadSettings(); | ||
this.loadTargets(); | ||
} | ||
|
||
loadSettings(): void { | ||
this.settingsService.getAllSettings().subscribe(settings => { | ||
this.settingsForm.patchValue({ | ||
developerCount: settings.developerCount, | ||
devCostPerYear: settings.devCostPerYear, | ||
hoursPerYear: settings.hoursPerYear, | ||
percentCoding: settings.percentCoding, | ||
percentTimeSaved: settings.percentTimeSaved, | ||
}); | ||
}); | ||
} | ||
|
||
loadTargets(): void { | ||
this.predictiveModelingService.getTargets().subscribe(targets => { | ||
this.targetForm.patchValue(targets); | ||
}); | ||
} | ||
|
||
saveTargets(): void { | ||
const targets = this.targetForm.value; | ||
this.predictiveModelingService.saveTargets(targets).subscribe(() => { | ||
this.snackBar.open('Targets saved successfully', 'Close', { | ||
duration: 2000, | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.