Skip to content

Commit 7a44939

Browse files
author
Danilo Otavio Lima Salve
committed
feat(apps): adiciona bandeja de aplicativos e remove do dashboard da home
1 parent 556192a commit 7a44939

10 files changed

Lines changed: 109 additions & 20 deletions

File tree

src/app/core/components/home/currency-quotes/currency-quotes.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<po-widget
2-
class="po-sm-12 po-md-12 po-lg-4 po-xl-3 po-mb-2"
32
p-title="Cotações"
43
p-primary-label="Obter Cotações"
54
(p-primary-action)="getCurrencyQuotes()"
@@ -39,3 +38,5 @@
3938
</div>
4039
</po-modal>
4140
</po-widget>
41+
42+
<po-loading-overlay p-text="Buscando Cotações" [hidden]="isHideLoading" />

src/app/core/components/home/currency-quotes/currency-quotes.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
PoFieldModule,
33
PoInfoModule,
4+
PoLoadingModule,
45
PoModalComponent,
56
PoModalModule,
67
PoNotificationService,
@@ -9,7 +10,7 @@ import {
910
} from '@po-ui/ng-components';
1011
import { ChangeDetectionStrategy, Component, inject, signal, viewChild } from '@angular/core';
1112
import { FormsModule } from '@angular/forms';
12-
import { map, take } from 'rxjs';
13+
import { finalize, map, take } from 'rxjs';
1314

1415
import { CurrencyQuotesService } from './shared/services/currency-quotes.service';
1516
import { CurrencyInfo } from './shared/interfaces/currency-info';
@@ -18,7 +19,7 @@ import { CurrencyInfoMapper } from './shared/helpers/currency-info-mapper';
1819
import { CurrencyFormatter } from './shared/helpers/currency-formatter';
1920
@Component({
2021
selector: 'app-currency-quotes',
21-
imports: [PoFieldModule, PoWidgetModule, FormsModule, PoInfoModule, PoModalModule, PoTooltipModule],
22+
imports: [PoFieldModule, PoWidgetModule, FormsModule, PoInfoModule, PoModalModule, PoTooltipModule, PoLoadingModule],
2223
templateUrl: './currency-quotes.component.html',
2324
changeDetection: ChangeDetectionStrategy.Default
2425
})
@@ -28,16 +29,19 @@ export class CurrencyQuotesComponent {
2829
private readonly poNotification = inject(PoNotificationService);
2930
readonly options = this.currencyQuotesServices.getCurrencyOptions();
3031
readonly currencyIds = signal<string[]>([]);
32+
protected isHideLoading = true;
3133
currencyInfo: CurrencyInfo[] = [];
3234
private readonly currencyInfoMapper = new CurrencyInfoMapper(new CurrencyFormatter());
3335

3436
getCurrencyQuotes(): void {
3537
if ((this.currencyIds()?.length ?? 0) > 0) {
38+
this.isHideLoading = false;
3639
this.currencyQuotesServices
3740
.getByCurrencyIds(this.currencyIds()!)
3841
.pipe(
3942
map((currencys: CurrencyQuotes) => this.currencyInfoMapper.mapFromQuotes(currencys)),
40-
take(1)
43+
take(1),
44+
finalize(() => this.isHideLoading = true)
4145
)
4246
.subscribe({
4347
next: (infos: CurrencyInfo[]) => {

src/app/core/components/home/dashboard/coins/coins.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<po-widget
22
appIsDeveloperMode
33
resourceName="'Informações de Cripto Moedas'"
4-
class="po-sm-12 po-md-12 po-lg-4 po-xl-3 po-mb-2"
54
p-title="Cripto Moedas"
65
[p-height]="220"
76
>

src/app/core/components/home/dashboard/dashboard.component.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,5 @@
1010
/>
1111
}
1212
</po-container>
13-
<po-container class="po-sm-12 po-md-12 po-lg-12 po-xl-12" p-title="Aplicativos">
14-
<app-coins />
15-
<app-currency-quotes />
16-
<app-weather />
17-
</po-container>
1813
</div>
1914
</po-page-default>

src/app/core/components/home/dashboard/dashboard.component.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { Component } from '@angular/core';
22
import { PoContainerModule, PoPageModule } from '@po-ui/ng-components';
33

4-
import { CoinsComponent } from './coins/coins.component';
5-
import { WeatherComponent } from '../weather/weather.component';
6-
import { CurrencyQuotesComponent } from '../currency-quotes/currency-quotes.component';
74
import { SamplesComponent } from './samples/samples.component';
85
import { SampleHome } from './samples/shared/interfaces/sample-home';
96

@@ -12,9 +9,6 @@ import { SampleHome } from './samples/shared/interfaces/sample-home';
129
imports: [
1310
PoPageModule,
1411
PoContainerModule,
15-
CoinsComponent,
16-
WeatherComponent,
17-
CurrencyQuotesComponent,
1812
SamplesComponent
1913
],
2014
templateUrl: './dashboard.component.html'

src/app/core/components/home/weather/weather.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<po-widget class="po-sm-12 po-md-12 po-lg-6 po-xl-6 po-mb-2" style="position: relative" p-title="Previsão do tempo">
1+
<po-container style="position: relative" p-title="Previsão do tempo" >
22
<po-input
33
class="po-sm-12 po-md-12 po-lg-12 po-xl-12 po-mb-1"
44
p-icon="an an-map-pin"
@@ -19,7 +19,7 @@
1919
<p class="po-sm-12 po-md-12 po-lg-12 po-xl-12 po-mb-2">Tente novamente mais tarde.</p>
2020
} @else {
2121
@if (hasValue) {
22-
<po-container class="po-sm-12 po-md-12 po-lg-12 po-xl-12 po-mb-2">
22+
<po-container class="po-sm-12 po-md-12 po-lg-12 po-xl-12 po-mb-2" [p-no-padding]="true" [p-no-border]="true">
2323
@if (weather.temperature && weather.wind) {
2424
<p class="po-font-text-large-bold" style="text-align: center">{{ city() }}</p>
2525
<p class="po-font-subtitle" style="text-align: center">{{ weather.temperature }}</p>
@@ -50,4 +50,4 @@
5050
}
5151
}
5252
}
53-
</po-widget>
53+
</po-container>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<div #appElement>
2+
<po-icon class="po-toolbar-icon" p-icon="an an-dots-nine" p-tooltip="Meus aplicativos" />
3+
</div>
4+
5+
<po-popover p-trigger="click" [p-target]="appElement" [p-hide-arrow]="true">
6+
@for (app of apps; track app.icon) {
7+
<po-button
8+
class="po-mr-2"
9+
[p-icon]="app.icon"
10+
(p-click)="app.action()"
11+
[p-tooltip]="app.tooltip"
12+
[p-aria-label]="app.label"
13+
/>
14+
}
15+
</po-popover>
16+
17+
<!-- Aplicativos -->
18+
<po-modal #coins p-title="Cripto Moedas">
19+
@defer (when !(coinsModal().isHidden)) {
20+
<app-coins />
21+
}
22+
</po-modal>
23+
24+
<po-modal #currencyQuotes p-title="Moedas">
25+
@defer (when !(currencyModal().isHidden)) {
26+
<app-currency-quotes />
27+
}
28+
</po-modal>
29+
30+
<po-modal #weather p-title="Previsão do tempo">
31+
@defer (when !(weatherModal().isHidden)) {
32+
<app-weather />
33+
}
34+
</po-modal>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { Component, viewChild } from '@angular/core';
2+
import { PoIconModule, PoPopoverModule, PoTooltipModule, PoButtonModule, PoModalComponent, PoModalModule } from '@po-ui/ng-components';
3+
4+
import { CurrencyQuotesComponent } from '../../../../core/components/home/currency-quotes/currency-quotes.component';
5+
import { CoinsComponent } from '../../../../core/components/home/dashboard/coins/coins.component';
6+
import { WeatherComponent } from '../../../../core/components/home/weather/weather.component';
7+
8+
@Component({
9+
selector: 'app-app-menu',
10+
imports: [
11+
PoButtonModule,
12+
PoIconModule,
13+
PoModalModule,
14+
PoPopoverModule,
15+
PoTooltipModule,
16+
CoinsComponent,
17+
WeatherComponent,
18+
CurrencyQuotesComponent
19+
],
20+
templateUrl: './app-menu.component.html'
21+
})
22+
export class AppMenuComponent {
23+
readonly coinsModal = viewChild.required('coins', { read: PoModalComponent });
24+
readonly currencyModal = viewChild.required('currencyQuotes', { read: PoModalComponent });
25+
readonly weatherModal = viewChild.required('weather', { read: PoModalComponent });
26+
27+
readonly apps = [
28+
{
29+
icon: 'an an-currency-btc',
30+
action: this.onClickCoins.bind(this),
31+
label: 'Valores das cripto moedas',
32+
tooltip: 'Abrir aplicativo para consultar valor de cripto moedas em tempo real'
33+
},
34+
{
35+
icon: 'an an-coins',
36+
action: this.onClickCurrency.bind(this),
37+
label: 'Valores das moedas',
38+
tooltip: 'Abrir aplicativo para consultar Valores das moedas'
39+
},
40+
{
41+
icon: 'an an-cloud-sun',
42+
action: this.onClickWealther.bind(this),
43+
label: 'Previsão do tempo',
44+
tooltip: 'Abrir aplicatio para consultar previsão do tempo'
45+
}
46+
];
47+
48+
49+
onClickCoins(): void {
50+
this.coinsModal().open();
51+
}
52+
53+
onClickCurrency(): void {
54+
this.currencyModal().open()
55+
}
56+
57+
onClickWealther(): void {
58+
this.weatherModal().open();
59+
}
60+
}

src/app/shared/components/toolbar/toolbar.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div class="po-toolbar">
22
<div class="po-toolbar-title">Exemplos Angular</div>
33
<div class="po-toolbar-group-icon">
4+
<app-app-menu class="po-toolbar-actions po-clickable" />
45
<app-theme-button class="po-toolbar-actions po-clickable" />
56
<app-notification-button class="po-toolbar-notification po-clickable" />
67
<app-profile-menu class="po-toolbar-profile po-clickable" />

src/app/shared/components/toolbar/toolbar.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { Component } from '@angular/core';
33
import { ThemeButtonComponent } from './theme-button/theme-button.component';
44
import { NotificationButtonComponent } from './notification-button/notification-button.component';
55
import { ProfileMenuComponent } from './profile-menu/profile-menu.component';
6+
import { AppMenuComponent } from './app-menu/app-menu.component';
67

78
@Component({
89
selector: 'app-toolbar',
910
templateUrl: './toolbar.component.html',
10-
imports: [ThemeButtonComponent, NotificationButtonComponent, ProfileMenuComponent]
11+
imports: [AppMenuComponent, ThemeButtonComponent, NotificationButtonComponent, ProfileMenuComponent]
1112
})
1213
export class ToolbarComponent {}

0 commit comments

Comments
 (0)