Skip to content

Commit 4eec141

Browse files
authored
Merge pull request #983 from numbersprotocol/feature-add-network-application-page
Feature add network application page
2 parents cc295af + aaacbc8 commit 4eec141

File tree

17 files changed

+331
-4
lines changed

17 files changed

+331
-4
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ jobs:
7474
env:
7575
NUMBERS_STORAGE_BASE_URL: ${{ secrets.NUMBERS_STORAGE_BASE_URL }}
7676
NUMBERS_STORAGE_TRUSTED_CLIENT_KEY: ${{ secrets.NUMBERS_STORAGE_TRUSTED_CLIENT_KEY }}
77+
NUMBERS_BUBBLE_DB_URL: ${{ secrets.NUMBERS_BUBBLE_DB_URL }}
7778
run: npm run build
7879

7980
- name: Build Android
@@ -105,6 +106,7 @@ jobs:
105106
env:
106107
NUMBERS_STORAGE_BASE_URL: ${{ secrets.NUMBERS_STORAGE_BASE_URL }}
107108
NUMBERS_STORAGE_TRUSTED_CLIENT_KEY: ${{ secrets.NUMBERS_STORAGE_TRUSTED_CLIENT_KEY }}
109+
NUMBERS_BUBBLE_DB_URL: ${{ secrets.NUMBERS_BUBBLE_DB_URL }}
108110
run: npm run build
109111

110112
- name: Import the Code-Signing PKCS12 Certificate

.github/workflows/pre-release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
env:
3030
NUMBERS_STORAGE_BASE_URL: ${{ secrets.NUMBERS_STORAGE_BASE_URL }}
3131
NUMBERS_STORAGE_TRUSTED_CLIENT_KEY: ${{ secrets.NUMBERS_STORAGE_TRUSTED_CLIENT_KEY }}
32+
NUMBERS_BUBBLE_DB_URL: ${{ secrets.NUMBERS_BUBBLE_DB_URL }}
3233
run: |
3334
npm install -g @ionic/cli
3435
npm install
@@ -88,6 +89,7 @@ jobs:
8889
env:
8990
NUMBERS_STORAGE_BASE_URL: ${{ secrets.NUMBERS_STORAGE_BASE_URL }}
9091
NUMBERS_STORAGE_TRUSTED_CLIENT_KEY: ${{ secrets.NUMBERS_STORAGE_TRUSTED_CLIENT_KEY }}
92+
NUMBERS_BUBBLE_DB_URL: ${{ secrets.NUMBERS_BUBBLE_DB_URL }}
9193
run: |
9294
npm install -g @ionic/cli
9395
npm install
@@ -170,6 +172,7 @@ jobs:
170172
env:
171173
NUMBERS_STORAGE_BASE_URL: ${{ secrets.NUMBERS_STORAGE_BASE_URL }}
172174
NUMBERS_STORAGE_TRUSTED_CLIENT_KEY: ${{ secrets.NUMBERS_STORAGE_TRUSTED_CLIENT_KEY }}
175+
NUMBERS_BUBBLE_DB_URL: ${{ secrets.NUMBERS_BUBBLE_DB_URL }}
173176
run: |
174177
npm install -g @ionic/cli
175178
npm install
@@ -213,6 +216,7 @@ jobs:
213216
env:
214217
NUMBERS_STORAGE_BASE_URL: ${{ secrets.NUMBERS_STORAGE_QA_BASE_URL }}
215218
NUMBERS_STORAGE_TRUSTED_CLIENT_KEY: ${{ secrets.NUMBERS_STORAGE_TRUSTED_CLIENT_KEY }}
219+
NUMBERS_BUBBLE_DB_URL: ${{ secrets.NUMBERS_BUBBLE_DB_QA_URL }}
216220
run: |
217221
npm install -g @ionic/cli
218222
npm install
@@ -263,6 +267,7 @@ jobs:
263267
env:
264268
NUMBERS_STORAGE_BASE_URL: ${{ secrets.NUMBERS_STORAGE_BASE_URL }}
265269
NUMBERS_STORAGE_TRUSTED_CLIENT_KEY: ${{ secrets.NUMBERS_STORAGE_TRUSTED_CLIENT_KEY }}
270+
NUMBERS_BUBBLE_DB_URL: ${{ secrets.NUMBERS_BUBBLE_DB_URL }}
266271
run: |
267272
npm install -g @ionic/cli
268273
npm install

.github/workflows/uiux-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
env:
2020
NUMBERS_STORAGE_BASE_URL: ${{ secrets.NUMBERS_STORAGE_BASE_URL }}
2121
NUMBERS_STORAGE_TRUSTED_CLIENT_KEY: ${{ secrets.NUMBERS_STORAGE_TRUSTED_CLIENT_KEY }}
22+
NUMBERS_BUBBLE_DB_URL: ${{ secrets.NUMBERS_BUBBLE_DB_URL }}
2223
run: |
2324
npm install -g @ionic/cli
2425
npm install

set-secret.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const targetPath = './src/app/shared/dia-backend/secret.ts';
66
// `secret.ts` file structure
77
const envConfigFile = `
88
export const BASE_URL = '${process.env.NUMBERS_STORAGE_BASE_URL}';
9-
export const TRUSTED_CLIENT_KEY = '${process.env.NUMBERS_STORAGE_TRUSTED_CLIENT_KEY}'
9+
export const TRUSTED_CLIENT_KEY = '${process.env.NUMBERS_STORAGE_TRUSTED_CLIENT_KEY}';
10+
export const BUBBLE_DB_URL = '${process.env.NUMBERS_BUBBLE_DB_URL}';
1011
`;
1112
fs.writeFile(targetPath, envConfigFile, err => {
1213
if (err) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule, Routes } from '@angular/router';
3+
import { ActionsPage } from './actions.page';
4+
5+
const routes: Routes = [
6+
{
7+
path: '',
8+
component: ActionsPage,
9+
},
10+
];
11+
12+
@NgModule({
13+
imports: [RouterModule.forChild(routes)],
14+
exports: [RouterModule],
15+
})
16+
export class ActionsPageRoutingModule {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { NgModule } from '@angular/core';
2+
import { SharedModule } from '../../../../shared/shared.module';
3+
import { ActionsPageRoutingModule } from './actions-routing.module';
4+
import { ActionsPage } from './actions.page';
5+
6+
@NgModule({
7+
imports: [SharedModule, ActionsPageRoutingModule],
8+
declarations: [ActionsPage],
9+
})
10+
export class ActionsPageModule {}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<mat-toolbar *transloco="let t">
2+
<button routerLink=".." routerDirection="back" mat-icon-button>
3+
<mat-icon>arrow_back</mat-icon>
4+
</button>
5+
<span>{{ t('message.moreActions') }}</span>
6+
</mat-toolbar>
7+
8+
<div class="page-content">
9+
<ng-container *ngFor="let action of actions$ | ngrxPush">
10+
<ion-card (click)="openAction(action)">
11+
<ion-card-header>
12+
<div class="wrapper">
13+
<div>
14+
<ion-card-subtitle>{{ action.title_text }}</ion-card-subtitle>
15+
</div>
16+
<div>
17+
<ion-icon
18+
src="/assets/images/numbers_token.svg"
19+
class="numbers-token"
20+
></ion-icon>
21+
x
22+
{{ action.price_number }}
23+
</div>
24+
</div>
25+
</ion-card-header>
26+
27+
<ion-card-content>
28+
{{ action.description_text }}
29+
</ion-card-content>
30+
<ion-img [src]="action.banner_image_url_text"></ion-img>
31+
</ion-card>
32+
</ng-container>
33+
</div>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
mat-toolbar {
2+
span {
3+
padding-right: 40px;
4+
}
5+
}
6+
7+
.page-content {
8+
.wrapper {
9+
display: flex;
10+
justify-content: space-between;
11+
}
12+
13+
ion-card {
14+
margin: 20px 10px;
15+
}
16+
17+
ion-icon.numbers-token {
18+
color: var(--ion-color-primary-contrast);
19+
}
20+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2+
import { SharedTestingModule } from '../../../../shared/shared-testing.module';
3+
import { ActionsPage } from './actions.page';
4+
5+
describe('ActionsPage', () => {
6+
let component: ActionsPage;
7+
let fixture: ComponentFixture<ActionsPage>;
8+
9+
beforeEach(
10+
waitForAsync(() => {
11+
TestBed.configureTestingModule({
12+
declarations: [ActionsPage],
13+
imports: [SharedTestingModule],
14+
}).compileComponents();
15+
16+
fixture = TestBed.createComponent(ActionsPage);
17+
component = fixture.componentInstance;
18+
fixture.detectChanges();
19+
})
20+
);
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import { Component } from '@angular/core';
2+
import { MatSnackBar } from '@angular/material/snack-bar';
3+
import { ActivatedRoute } from '@angular/router';
4+
import { AlertController } from '@ionic/angular';
5+
import { AlertInput } from '@ionic/core';
6+
import { TranslocoService } from '@ngneat/transloco';
7+
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
8+
import { combineLatest } from 'rxjs';
9+
import { catchError, concatMap, map, tap } from 'rxjs/operators';
10+
import {
11+
Action,
12+
ActionsService,
13+
} from '../../../../shared/actions/actions.service';
14+
import { BlockingActionService } from '../../../../shared/blocking-action/blocking-action.service';
15+
import { DiaBackendAuthService } from '../../../../shared/dia-backend/auth/dia-backend-auth.service';
16+
import { ErrorService } from '../../../../shared/error/error.service';
17+
18+
@UntilDestroy()
19+
@Component({
20+
selector: 'app-actions',
21+
templateUrl: './actions.page.html',
22+
styleUrls: ['./actions.page.scss'],
23+
})
24+
export class ActionsPage {
25+
readonly actions$ = this.actionsService
26+
.getActions$()
27+
.pipe(catchError((err: unknown) => this.errorService.toastError$(err)));
28+
29+
private readonly id$ = this.route.paramMap.pipe(
30+
map(params => params.get('id'))
31+
);
32+
33+
constructor(
34+
private readonly actionsService: ActionsService,
35+
private readonly errorService: ErrorService,
36+
private readonly alertController: AlertController,
37+
private readonly translocoService: TranslocoService,
38+
private readonly blockingActionService: BlockingActionService,
39+
private readonly route: ActivatedRoute,
40+
private readonly authService: DiaBackendAuthService,
41+
private readonly snackBar: MatSnackBar
42+
) {}
43+
44+
openAction(action: Action) {
45+
return combineLatest([
46+
this.actionsService.getParams$(action.params_list_custom_param),
47+
this.authService.token$,
48+
this.id$,
49+
])
50+
.pipe(
51+
concatMap(
52+
([params, token, id]) =>
53+
new Promise<void>(resolve => {
54+
this.alertController
55+
.create({
56+
header: action.title_text,
57+
message: action.description_text,
58+
inputs: params.map(
59+
param =>
60+
({
61+
name: param.name_text,
62+
label: param.label_text,
63+
type: param.type_text,
64+
placeholder: param.placeholder_text,
65+
value: param.default_value_text,
66+
disabled: param.disabled_boolean,
67+
} as AlertInput)
68+
),
69+
buttons: [
70+
{
71+
text: this.translocoService.translate('cancel'),
72+
role: 'cancel',
73+
},
74+
{
75+
text: this.translocoService.translate('ok'),
76+
handler: value => {
77+
const body = { ...value, token: token, cid: id };
78+
return this.sendAction(action, body);
79+
},
80+
},
81+
],
82+
})
83+
.then(alert => {
84+
alert.present();
85+
resolve();
86+
});
87+
})
88+
),
89+
untilDestroyed(this)
90+
)
91+
.subscribe();
92+
}
93+
94+
sendAction(action: Action, body: any) {
95+
const action$ = this.actionsService.send$(action.base_url_text, body).pipe(
96+
catchError((err: unknown) => {
97+
return this.errorService.toastError$(err);
98+
}),
99+
tap(() =>
100+
this.snackBar.open(
101+
this.translocoService.translate('message.sentSuccessfully')
102+
)
103+
)
104+
);
105+
this.blockingActionService
106+
.run$(action$)
107+
.pipe(untilDestroyed(this))
108+
.subscribe();
109+
}
110+
}

0 commit comments

Comments
 (0)