-
Notifications
You must be signed in to change notification settings - Fork 2
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 #123 from e-picsa/feat/crop-prob-tool-integration
feat: integrate crop probability tool into main app
- Loading branch information
Showing
20 changed files
with
230 additions
and
32 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
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
26 changes: 26 additions & 0 deletions
26
apps/picsa-tools/crop-probability-tool/src/app/app-routing.module.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,26 @@ | ||
import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
export const ROUTES_COMMON: Routes = [ | ||
{ | ||
path: '', | ||
loadChildren: () => | ||
import('./pages/home/home.module').then((m) => m.HomeModule), | ||
title: 'Crop Probability', | ||
}, | ||
]; | ||
/** Routes only registered in standalone mode */ | ||
const ROUTES_STANDALONE: Routes = [{ path: '**', redirectTo: '' }]; | ||
|
||
/******************************************************************* | ||
* Standalone Version | ||
******************************************************************/ | ||
@NgModule({ | ||
imports: [ | ||
RouterModule.forRoot([...ROUTES_COMMON, ...ROUTES_STANDALONE], { | ||
preloadingStrategy: PreloadAllModules, | ||
}), | ||
], | ||
exports: [RouterModule], | ||
}) | ||
export class AppRoutingModule {} |
5 changes: 4 additions & 1 deletion
5
apps/picsa-tools/crop-probability-tool/src/app/app.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 |
---|---|---|
@@ -1 +1,4 @@ | ||
<picsa-crop-probability-table></picsa-crop-probability-table> | ||
<div class="page"> | ||
<picsa-header></picsa-header> | ||
<router-outlet></router-outlet> | ||
</div> |
13 changes: 11 additions & 2 deletions
13
apps/picsa-tools/crop-probability-tool/src/app/app.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 |
---|---|---|
@@ -1,10 +1,19 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'picsa-root', | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'picsa-crop-probability-tool', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.scss'], | ||
}) | ||
export class AppComponent { | ||
title = 'picsa-tools-crop-probability-tool'; | ||
title = 'picsa-crop-probability'; | ||
} | ||
|
||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'picsa-crop-probability-tool', | ||
template: '', | ||
}) | ||
// eslint-disable-next-line @angular-eslint/component-class-suffix | ||
export class AppComponentEmbedded extends AppComponent {} |
53 changes: 53 additions & 0 deletions
53
apps/picsa-tools/crop-probability-tool/src/app/app.module-embedded.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,53 @@ | ||
import { ModuleWithProviders, NgModule } from '@angular/core'; | ||
import { Router, RouterModule } from '@angular/router'; | ||
import { PicsaTranslateService } from '@picsa/shared/modules'; | ||
|
||
import { registerEmbeddedRoutes } from '@picsa/utils'; | ||
|
||
import { APP_COMMON_IMPORTS } from './app.module'; | ||
import { AppComponentEmbedded } from './app.component'; | ||
import { ROUTES_COMMON } from './app-routing.module'; | ||
|
||
export class EmbeddedConfig { | ||
/** Path app routed through, e.g. 'budget' */ | ||
urlPrefix: string; | ||
} | ||
|
||
/******************************************************************* | ||
* Routes | ||
******************************************************************/ | ||
@NgModule({ | ||
imports: [RouterModule.forChild([])], | ||
}) | ||
export class EmbeddedRoutingModule { | ||
constructor(router: Router, embeddedConfig: EmbeddedConfig) { | ||
registerEmbeddedRoutes(ROUTES_COMMON, router, embeddedConfig.urlPrefix); | ||
} | ||
} | ||
|
||
/******************************************************************* | ||
* Module | ||
******************************************************************/ | ||
@NgModule({ | ||
declarations: [AppComponentEmbedded], | ||
imports: [...APP_COMMON_IMPORTS, EmbeddedRoutingModule], | ||
bootstrap: [AppComponentEmbedded], | ||
}) | ||
export class BaseModule { | ||
// ensure translate has been initiated | ||
constructor(public translate: PicsaTranslateService) {} | ||
} | ||
|
||
/** Use to import directly into another app via lazy-loading */ | ||
@NgModule() | ||
export class CropProbabilityToolModule { | ||
static forRoot(config: EmbeddedConfig): ModuleWithProviders<BaseModule> { | ||
return { | ||
ngModule: BaseModule, | ||
providers: [ | ||
PicsaTranslateService, | ||
{ provide: EmbeddedConfig, useValue: config }, | ||
], | ||
}; | ||
} | ||
} |
61 changes: 42 additions & 19 deletions
61
apps/picsa-tools/crop-probability-tool/src/app/app.module.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 |
---|---|---|
@@ -1,27 +1,50 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { | ||
BrowserAnimationsModule, | ||
NoopAnimationsModule, | ||
} from '@angular/platform-browser/animations'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { | ||
PicsaDbModule, | ||
PicsaTranslateModule, | ||
PicsaTranslateService, | ||
} from '@picsa/shared/modules'; | ||
import { PicsaCommonComponentsModule } from '@picsa/components'; | ||
|
||
import { AppComponent } from './app.component'; | ||
import { RouterModule } from '@angular/router'; | ||
import { appRoutes } from './app.routes'; | ||
import { CropProbabilityTableComponent } from './components/crop-probability-table/crop-probability-table.component'; | ||
import { AppRoutingModule } from './app-routing.module'; | ||
import { CropProbabilityMaterialModule } from './components/material.module'; | ||
import { CropProbabilityTableHeaderComponent } from './components/crop-probability-table-header/crop-probability-table-header.component'; | ||
|
||
/** Core imports only required when running standalone */ | ||
const StandaloneImports = [ | ||
AppRoutingModule, | ||
BrowserModule, | ||
BrowserAnimationsModule, | ||
NoopAnimationsModule, | ||
PicsaTranslateModule.forRoot(), | ||
]; | ||
|
||
/** Common imports used in both standalone and embedded formats */ | ||
export const APP_COMMON_IMPORTS = [ | ||
HttpClientModule, | ||
CropProbabilityMaterialModule, | ||
PicsaTranslateModule, | ||
PicsaDbModule.forRoot(), | ||
PicsaCommonComponentsModule, | ||
]; | ||
|
||
/******************************************************************* | ||
* Standalone Version | ||
******************************************************************/ | ||
@NgModule({ | ||
declarations: [ | ||
AppComponent, | ||
CropProbabilityTableComponent, | ||
CropProbabilityTableHeaderComponent, | ||
], | ||
imports: [ | ||
BrowserModule, | ||
BrowserAnimationsModule, | ||
RouterModule.forRoot(appRoutes, { initialNavigation: 'enabledBlocking' }), | ||
CropProbabilityMaterialModule, | ||
], | ||
providers: [], | ||
declarations: [AppComponent], | ||
imports: [...StandaloneImports, ...APP_COMMON_IMPORTS], | ||
bootstrap: [AppComponent], | ||
schemas: [], | ||
}) | ||
export class AppModule {} | ||
export class AppModule { | ||
// ensure translate service initialised | ||
constructor(public translate: PicsaTranslateService) {} | ||
} |
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
apps/picsa-tools/crop-probability-tool/src/app/components/components.module.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,20 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { CropProbabilityTableComponent } from './crop-probability-table/crop-probability-table.component'; | ||
import { CropProbabilityMaterialModule } from './material.module'; | ||
import { CropProbabilityTableHeaderComponent } from './crop-probability-table-header/crop-probability-table-header.component'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
const components = [ | ||
CropProbabilityTableComponent, | ||
CropProbabilityTableHeaderComponent, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, FormsModule, CropProbabilityMaterialModule], | ||
exports: components, | ||
declarations: components, | ||
providers: [], | ||
}) | ||
export class CropProbabilityToolComponentsModule {} |
1 change: 1 addition & 0 deletions
1
apps/picsa-tools/crop-probability-tool/src/app/pages/home/home.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 @@ | ||
<picsa-crop-probability-table></picsa-crop-probability-table> |
Empty file.
22 changes: 22 additions & 0 deletions
22
apps/picsa-tools/crop-probability-tool/src/app/pages/home/home.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,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { HomeComponent } from './home.component'; | ||
|
||
describe('HomeComponent', () => { | ||
let component: HomeComponent; | ||
let fixture: ComponentFixture<HomeComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [HomeComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(HomeComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
apps/picsa-tools/crop-probability-tool/src/app/pages/home/home.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,8 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'picsa-home', | ||
templateUrl: './home.component.html', | ||
styleUrls: ['./home.component.scss'], | ||
}) | ||
export class HomeComponent {} |
27 changes: 27 additions & 0 deletions
27
apps/picsa-tools/crop-probability-tool/src/app/pages/home/home.module.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,27 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { Route, RouterModule } from '@angular/router'; | ||
|
||
import { CropProbabilityToolComponentsModule } from '../../components/components.module'; | ||
import { HomeComponent } from './home.component'; | ||
import { CommonModule } from '@angular/common'; | ||
import { PicsaTranslateModule } from '@picsa/shared/modules'; | ||
|
||
const routes: Route[] = [ | ||
{ | ||
path: '', | ||
component: HomeComponent, | ||
}, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
CropProbabilityToolComponentsModule, | ||
RouterModule.forChild(routes), | ||
PicsaTranslateModule, | ||
], | ||
exports: [], | ||
declarations: [HomeComponent], | ||
providers: [], | ||
}) | ||
export class HomeModule {} |
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
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
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