Skip to content

Commit 39594e0

Browse files
committed
add sample angular sdk app
1 parent 95c2a82 commit 39594e0

18 files changed

+275
-0
lines changed

angular.json

+94
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,100 @@
33
"version": 1,
44
"newProjectRoot": "projects",
55
"projects": {
6+
"sdk-sandbox": {
7+
"projectType": "application",
8+
"schematics": {},
9+
"root": "",
10+
"sourceRoot": "src",
11+
"prefix": "app",
12+
"architect": {
13+
"build": {
14+
"builder": "@angular-devkit/build-angular:browser",
15+
"options": {
16+
"outputPath": "dist/sdk-sandbox",
17+
"index": "src/index.html",
18+
"main": "src/main.ts",
19+
"polyfills": [
20+
"zone.js"
21+
],
22+
"tsConfig": "tsconfig.app.json",
23+
"assets": [
24+
"src/favicon.ico",
25+
"src/assets"
26+
],
27+
"styles": [
28+
"src/styles.css"
29+
],
30+
"scripts": [],
31+
"allowedCommonJsDependencies": [
32+
"hash-sum"
33+
]
34+
},
35+
"configurations": {
36+
"production": {
37+
"budgets": [
38+
{
39+
"type": "initial",
40+
"maximumWarning": "500kb",
41+
"maximumError": "2mb"
42+
},
43+
{
44+
"type": "anyComponentStyle",
45+
"maximumWarning": "2kb",
46+
"maximumError": "4kb"
47+
}
48+
],
49+
"outputHashing": "all"
50+
},
51+
"development": {
52+
"buildOptimizer": false,
53+
"optimization": false,
54+
"vendorChunk": true,
55+
"extractLicenses": false,
56+
"sourceMap": true,
57+
"namedChunks": true
58+
}
59+
},
60+
"defaultConfiguration": "production"
61+
},
62+
"serve": {
63+
"builder": "@angular-devkit/build-angular:dev-server",
64+
"configurations": {
65+
"production": {
66+
"browserTarget": "sdk-sandbox:build:production"
67+
},
68+
"development": {
69+
"browserTarget": "sdk-sandbox:build:development"
70+
}
71+
},
72+
"defaultConfiguration": "development"
73+
},
74+
"extract-i18n": {
75+
"builder": "@angular-devkit/build-angular:extract-i18n",
76+
"options": {
77+
"browserTarget": "sdk-sandbox:build"
78+
}
79+
},
80+
"test": {
81+
"builder": "@angular-devkit/build-angular:karma",
82+
"options": {
83+
"polyfills": [
84+
"zone.js",
85+
"zone.js/testing"
86+
],
87+
"tsConfig": "tsconfig.spec.json",
88+
"assets": [
89+
"src/favicon.ico",
90+
"src/assets"
91+
],
92+
"styles": [
93+
"src/styles.css"
94+
],
95+
"scripts": []
96+
}
97+
}
98+
}
99+
},
6100
"fusio-sdk": {
7101
"projectType": "library",
8102
"root": "projects/fusio-sdk",

src/app/account/account.component.css

Whitespace-only changes.
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
<div class="fusio-page">
3+
<nav class="fusio-tabs">
4+
<ul ngbNav [(activeId)]="active" class="nav-tabs">
5+
<li [ngbNavItem]="item.title" *ngFor="let item of items">
6+
<a ngbNavLink [routerLink]="item.path" class="nav-link">{{item.title}}</a>
7+
</li>
8+
</ul>
9+
</nav>
10+
<div class="mt-3">
11+
<router-outlet></router-outlet>
12+
</div>
13+
</div>

src/app/account/account.component.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component } from '@angular/core';
2+
import {
3+
AccountContainerComponent
4+
} from "../../../projects/fusio-sdk/src/lib/component/account-container/account-container.component";
5+
6+
@Component({
7+
selector: 'app-account',
8+
templateUrl: './account.component.html',
9+
styleUrls: ['./account.component.css']
10+
})
11+
export class AccountComponent extends AccountContainerComponent {
12+
13+
}

src/app/api.service.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Injectable } from '@angular/core';
2+
import {CredentialsInterface} from "sdkgen-client";
3+
import {ApiService as SDK} from "../../projects/fusio-sdk/src/lib/service/api.service";
4+
import {Client} from "fusio-sdk/dist/Client";
5+
6+
@Injectable({
7+
providedIn: 'root'
8+
})
9+
export class ApiService extends SDK<Client> {
10+
11+
protected newClient(baseUrl: string, credentials: CredentialsInterface | null | undefined): Client {
12+
return new Client(baseUrl, credentials);
13+
}
14+
15+
}

src/app/app-routing.module.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {NgModule} from '@angular/core';
2+
import {RouterModule, Routes} from '@angular/router';
3+
import {isAuthenticated} from "../../projects/fusio-sdk/src/lib/guard/authentication.guard";
4+
import {AccountRoute} from "../../projects/fusio-sdk/src/lib/route/account-route";
5+
import {AuthorizationRoute} from "../../projects/fusio-sdk/src/lib/route/authorization-route";
6+
import {AccountComponent} from "./account/account.component";
7+
8+
const routes: Routes = [
9+
{ path: '', component: AccountComponent, canActivate: [isAuthenticated] },
10+
{ path: 'account', component: AccountComponent, canActivate: [isAuthenticated], children: AccountRoute.getAll()},
11+
12+
];
13+
14+
routes.push(...AuthorizationRoute.getAll());
15+
16+
@NgModule({
17+
imports: [RouterModule.forRoot(routes)],
18+
exports: [RouterModule]
19+
})
20+
export class AppRoutingModule { }

src/app/app.component.css

Whitespace-only changes.

src/app/app.component.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
<div class="container">
3+
<div class="row">
4+
<div class="col text-center">
5+
<h1 class="mt-4 mb-4">Fusio-SDK Angular</h1>
6+
</div>
7+
</div>
8+
<div class="row" *ngIf="user">
9+
<div class="col">
10+
<div class="btn-group float-end">
11+
<a class="btn btn-secondary disabled">Loggend in as: {{user.name}}</a>
12+
<a routerLink="/logout" class="btn btn-primary">Logout</a>
13+
</div>
14+
</div>
15+
</div>
16+
<div class="row">
17+
<div class="col">
18+
<router-outlet></router-outlet>
19+
</div>
20+
</div>
21+
</div>

src/app/app.component.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Component } from '@angular/core';
2+
import {BackendUser} from "fusio-sdk/dist/BackendUser";
3+
import {UserService} from "../../projects/fusio-sdk/src/lib/service/user.service";
4+
5+
@Component({
6+
selector: 'app-root',
7+
templateUrl: './app.component.html',
8+
styleUrls: ['./app.component.css']
9+
})
10+
export class AppComponent {
11+
title = 'fusio-sdk';
12+
user?: BackendUser;
13+
14+
constructor(private userMeta: UserService) { }
15+
16+
ngOnInit(): void {
17+
this.user = this.userMeta.get();
18+
}
19+
20+
}

src/app/app.module.ts

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {NgModule} from '@angular/core';
2+
import {BrowserModule} from '@angular/platform-browser';
3+
4+
import {AppRoutingModule} from './app-routing.module';
5+
import {AppComponent} from './app.component';
6+
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
7+
import {HttpClientModule} from "@angular/common/http";
8+
import {FusioSdkModule} from "../../projects/fusio-sdk/src/lib/fusio-sdk.module";
9+
import {ApiService as SDK} from "../../projects/fusio-sdk/src/lib/service/api.service";
10+
import {ConfigBuilder} from "./config-builder";
11+
import {ApiService} from "./api.service";
12+
import {AccountComponent} from './account/account.component';
13+
14+
@NgModule({
15+
declarations: [
16+
AppComponent,
17+
AccountComponent
18+
],
19+
imports: [
20+
BrowserModule,
21+
HttpClientModule,
22+
AppRoutingModule,
23+
NgbModule,
24+
FusioSdkModule.forRoot(ConfigBuilder.build())
25+
],
26+
providers: [
27+
{
28+
provide: SDK,
29+
useExisting: ApiService
30+
}
31+
],
32+
bootstrap: [AppComponent]
33+
})
34+
export class AppModule {
35+
}

src/app/config-builder.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {Config} from "../../projects/fusio-sdk/src/lib/config/config";
2+
3+
export class ConfigBuilder {
4+
5+
public static build(): Config {
6+
let baseUrl = 'https://demo.fusio-project.org/';
7+
if (!baseUrl) {
8+
throw new Error('No base url configured, please provide a variable "FUSIO_URL" containing the Fusio base url');
9+
}
10+
11+
return {
12+
baseUrl: baseUrl,
13+
logo: 'fusio_64px.png',
14+
appId: 1,
15+
homePath: '/account',
16+
helpUrl: 'https://docs.fusio-project.org/docs/backend/',
17+
}
18+
}
19+
20+
}

src/assets/.gitkeep

Whitespace-only changes.

src/assets/fusio_32px.png

1006 Bytes
Loading

src/assets/fusio_64px.png

1.78 KB
Loading

src/favicon.ico

948 Bytes
Binary file not shown.

src/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Fusio-SDK Angular Sandbox</title>
6+
<base href="/">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link rel="icon" type="image/x-icon" href="favicon.ico">
9+
<link rel="canonical" href="https://sandbox.typeapi.org/">
10+
</head>
11+
<body>
12+
<app-root></app-root>
13+
</body>
14+
</html>

src/main.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2+
3+
import { AppModule } from './app/app.module';
4+
5+
6+
platformBrowserDynamic().bootstrapModule(AppModule)
7+
.catch(err => console.error(err));

src/styles.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
@import "~bootstrap-icons/font/bootstrap-icons.css";
3+
@import "~bootstrap/dist/css/bootstrap.min.css";

0 commit comments

Comments
 (0)