-
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.
- Loading branch information
1 parent
daf0783
commit 35a08da
Showing
8 changed files
with
132 additions
and
11 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
29 changes: 29 additions & 0 deletions
29
.../src/app/modules/deployment/components/deployment-select/deployment-select.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,29 @@ | ||
<button mat-button [matMenuTriggerFor]="menu" [style.visibility]="deployments.length > 0 ? 'visible' : 'hidden'"> | ||
@if(service.activeDeployment(); as deployment){ | ||
<ng-container *ngTemplateOutlet="deploymentSummary; context: { $implicit: deployment }"></ng-container> | ||
} @else { | ||
<div>Select Deployment</div> | ||
} | ||
<mat-icon iconPositionEnd>unfold_more</mat-icon> | ||
</button> | ||
|
||
<mat-menu #menu="matMenu"> | ||
@for(deployment of deployments; track deployment.id){ | ||
<button mat-menu-item class="menu-button" (click)="service.setActiveDeployment(deployment.id)"> | ||
<ng-container *ngTemplateOutlet="deploymentSummary; context: { $implicit: deployment }"></ng-container> | ||
</button> | ||
|
||
} | ||
</mat-menu> | ||
|
||
<ng-template #deploymentSummary let-deployment> | ||
<div style="display: flex; align-items: center"> | ||
@if(deployment.icon_path){ | ||
<img | ||
[src]="deployment.icon_path | storagePath" | ||
style="height: 30px; width: 30px; object-fit: contain; margin-right: 8px" | ||
/> | ||
} | ||
<span>{{ deployment.label }}</span> | ||
</div> | ||
</ng-template> |
Empty file.
22 changes: 22 additions & 0 deletions
22
...c/app/modules/deployment/components/deployment-select/deployment-select.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 { DeploymentSelectComponent } from './deployment-select.component'; | ||
|
||
describe('DeploymentSelectComponent', () => { | ||
let component: DeploymentSelectComponent; | ||
let fixture: ComponentFixture<DeploymentSelectComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [DeploymentSelectComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DeploymentSelectComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
...rd/src/app/modules/deployment/components/deployment-select/deployment-select.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,38 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { Component, effect, OnInit } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatMenuModule } from '@angular/material/menu'; | ||
import { StoragePathPipe } from '@picsa/shared/services/core/supabase'; | ||
|
||
import { DeploymentDashboardService } from '../../deployment.service'; | ||
import { IDeploymentRow } from '../../types'; | ||
|
||
@Component({ | ||
selector: 'dashboard-deployment-select', | ||
standalone: true, | ||
imports: [CommonModule, MatButtonModule, MatIconModule, MatMenuModule, StoragePathPipe], | ||
templateUrl: './deployment-select.component.html', | ||
styleUrls: ['./deployment-select.component.scss'], | ||
}) | ||
export class DeploymentSelectComponent implements OnInit { | ||
public deployments: IDeploymentRow[] = []; | ||
constructor(public service: DeploymentDashboardService) { | ||
effect(() => { | ||
const allDeployments = service.deployments(); | ||
this.deployments = allDeployments.sort(this.sortDeployments); | ||
}); | ||
} | ||
|
||
async ngOnInit() { | ||
await this.service.ready(); | ||
} | ||
|
||
// Sort deployments so global (no country code) appear on bottom of list, and otherwise | ||
// group by variant | ||
private sortDeployments(a: IDeploymentRow, b: IDeploymentRow) { | ||
if (a.country_code === b.country_code) return a.variant! > b.variant! ? 1 : -1; | ||
if (!a.country_code) return 1; | ||
return -1; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
id,country_code,label,configuration,variant,access_key_md5,public | ||
demo_admin,,Admin Demo,{},other,,true | ||
global,,Global,{},extension,,true | ||
global_translators,,Translators,{},other,,true | ||
mw_extension,mw,Extension,{},extension,,true | ||
mw_farmer,mw,Farmer,{},farmer,,true | ||
zm_extension,zm,Zambia,{},extension,,true | ||
zm_extension_demo,zm,ZM Admin Demo,{},other,,true | ||
zm_farmer,zm,Farmer,{},farmer,,true | ||
id,country_code,label,configuration,variant,access_key_md5,public,icon_path | ||
demo_admin,,Admin Demo,{},other,,true,global/images/flags/global.svg | ||
global,,Extension,{},extension,,true,global/images/flags/global.svg | ||
global_translators,,Translators,{},other,,true,global/images/flags/global.svg | ||
mw_admin_demo,mw,Admin Demo,{},other,,true,global/images/flags/mw.svg | ||
mw_extension,mw,Extension,{},extension,,true,global/images/flags/mw.svg | ||
mw_farmer,mw,Farmer,{},farmer,,true,global/images/flags/mw.svg | ||
zm_admin_demo,zm,Admin Demo,{},other,,true,global/images/flags/zm.svg | ||
zm_extension,zm,Extension,{},extension,,true,global/images/flags/zm.svg | ||
zm_farmer,zm,Farmer,{},farmer,,true,global/images/flags/zm.svg |