@falcon-ng/tailwind 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -0
- package/ng-package.json +7 -0
- package/package.json +11 -0
- package/src/lib/base-control.ts +142 -0
- package/src/lib/base-form-component.ts +363 -0
- package/src/lib/component/auto-complete/auto-complete.component.html +39 -0
- package/src/lib/component/auto-complete/auto-complete.component.scss +0 -0
- package/src/lib/component/auto-complete/auto-complete.component.spec.ts +23 -0
- package/src/lib/component/auto-complete/auto-complete.component.ts +31 -0
- package/src/lib/component/bottom-sheet/bottom-sheet.component.html +9 -0
- package/src/lib/component/bottom-sheet/bottom-sheet.component.scss +0 -0
- package/src/lib/component/bottom-sheet/bottom-sheet.component.spec.ts +23 -0
- package/src/lib/component/bottom-sheet/bottom-sheet.component.ts +19 -0
- package/src/lib/component/button/button.component.css +0 -0
- package/src/lib/component/button/button.component.html +54 -0
- package/src/lib/component/button/button.component.spec.ts +23 -0
- package/src/lib/component/button/button.component.ts +17 -0
- package/src/lib/component/button-toggle/button-toggle.component.html +21 -0
- package/src/lib/component/button-toggle/button-toggle.component.scss +0 -0
- package/src/lib/component/button-toggle/button-toggle.component.spec.ts +23 -0
- package/src/lib/component/button-toggle/button-toggle.component.ts +26 -0
- package/src/lib/component/checkbox/checkbox.component.html +6 -0
- package/src/lib/component/checkbox/checkbox.component.scss +0 -0
- package/src/lib/component/checkbox/checkbox.component.spec.ts +23 -0
- package/src/lib/component/checkbox/checkbox.component.ts +17 -0
- package/src/lib/component/chips/chip.component.html +75 -0
- package/src/lib/component/chips/chip.component.scss +3 -0
- package/src/lib/component/chips/chip.component.spec.ts +23 -0
- package/src/lib/component/chips/chip.component.ts +125 -0
- package/src/lib/component/date-picker/date-picker.component.html +18 -0
- package/src/lib/component/date-picker/date-picker.component.scss +0 -0
- package/src/lib/component/date-picker/date-picker.component.spec.ts +23 -0
- package/src/lib/component/date-picker/date-picker.component.ts +13 -0
- package/src/lib/component/dialog/dialog.component.html +12 -0
- package/src/lib/component/dialog/dialog.component.scss +3 -0
- package/src/lib/component/dialog/dialog.component.spec.ts +23 -0
- package/src/lib/component/dialog/dialog.component.ts +12 -0
- package/src/lib/component/pagination/pagination.component.html +10 -0
- package/src/lib/component/pagination/pagination.component.scss +0 -0
- package/src/lib/component/pagination/pagination.component.spec.ts +23 -0
- package/src/lib/component/pagination/pagination.component.ts +86 -0
- package/src/lib/component/progress-bar/progress-bar.component.html +1 -0
- package/src/lib/component/progress-bar/progress-bar.component.scss +0 -0
- package/src/lib/component/progress-bar/progress-bar.component.spec.ts +23 -0
- package/src/lib/component/progress-bar/progress-bar.component.ts +15 -0
- package/src/lib/component/progress-spinner/progress-spinner.component.html +7 -0
- package/src/lib/component/progress-spinner/progress-spinner.component.scss +0 -0
- package/src/lib/component/progress-spinner/progress-spinner.component.spec.ts +23 -0
- package/src/lib/component/progress-spinner/progress-spinner.component.ts +16 -0
- package/src/lib/component/radio/radio.component.html +13 -0
- package/src/lib/component/radio/radio.component.scss +14 -0
- package/src/lib/component/radio/radio.component.spec.ts +23 -0
- package/src/lib/component/radio/radio.component.ts +29 -0
- package/src/lib/component/rich-text-editor/rich-text-editor.component.html +10 -0
- package/src/lib/component/rich-text-editor/rich-text-editor.component.scss +0 -0
- package/src/lib/component/rich-text-editor/rich-text-editor.component.spec.ts +23 -0
- package/src/lib/component/rich-text-editor/rich-text-editor.component.ts +13 -0
- package/src/lib/component/select/select.component.html +25 -0
- package/src/lib/component/select/select.component.scss +0 -0
- package/src/lib/component/select/select.component.spec.ts +23 -0
- package/src/lib/component/select/select.component.ts +32 -0
- package/src/lib/component/slide-toggle/slide-toggle.component.html +7 -0
- package/src/lib/component/slide-toggle/slide-toggle.component.scss +0 -0
- package/src/lib/component/slide-toggle/slide-toggle.component.spec.ts +23 -0
- package/src/lib/component/slide-toggle/slide-toggle.component.ts +13 -0
- package/src/lib/component/slider/slider.component.html +11 -0
- package/src/lib/component/slider/slider.component.scss +0 -0
- package/src/lib/component/slider/slider.component.spec.ts +23 -0
- package/src/lib/component/slider/slider.component.ts +13 -0
- package/src/lib/component/snack-bar/snack-bar.component.html +1 -0
- package/src/lib/component/snack-bar/snack-bar.component.scss +0 -0
- package/src/lib/component/snack-bar/snack-bar.component.spec.ts +23 -0
- package/src/lib/component/snack-bar/snack-bar.component.ts +10 -0
- package/src/lib/component/table/table.component.html +82 -0
- package/src/lib/component/table/table.component.scss +17 -0
- package/src/lib/component/table/table.component.spec.ts +23 -0
- package/src/lib/component/table/table.component.ts +54 -0
- package/src/lib/component/textarea/textarea.component.html +22 -0
- package/src/lib/component/textarea/textarea.component.scss +3 -0
- package/src/lib/component/textarea/textarea.component.spec.ts +23 -0
- package/src/lib/component/textarea/textarea.component.ts +13 -0
- package/src/lib/component/textbox/textbox.component.html +27 -0
- package/src/lib/component/textbox/textbox.component.scss +3 -0
- package/src/lib/component/textbox/textbox.component.spec.ts +23 -0
- package/src/lib/component/textbox/textbox.component.ts +13 -0
- package/src/lib/control-builder/control-builder.component.html +5 -0
- package/src/lib/control-builder/control-builder.component.scss +0 -0
- package/src/lib/control-builder/control-builder.component.ts +14 -0
- package/src/lib/control-type/AutoComplete.ts +6 -0
- package/src/lib/control-type/Button.ts +6 -0
- package/src/lib/control-type/ButtonToggle.ts +6 -0
- package/src/lib/control-type/CheckBox.ts +6 -0
- package/src/lib/control-type/Chip.ts +6 -0
- package/src/lib/control-type/DatePicker.ts +6 -0
- package/src/lib/control-type/Divider.ts +6 -0
- package/src/lib/control-type/Editor.ts +6 -0
- package/src/lib/control-type/Radio.ts +6 -0
- package/src/lib/control-type/RichTextEditor.ts +6 -0
- package/src/lib/control-type/SlideToggle.ts +6 -0
- package/src/lib/control-type/Slider.ts +6 -0
- package/src/lib/control-type/select.ts +6 -0
- package/src/lib/control-type/textarea.ts +6 -0
- package/src/lib/control-type/textbox.ts +6 -0
- package/src/lib/falcon-core.module.ts +141 -0
- package/src/lib/model/constant.ts +32 -0
- package/src/lib/model/enum.ts +151 -0
- package/src/lib/model/environments.ts +28 -0
- package/src/lib/model/interface.ts +310 -0
- package/src/lib/model/ivalidator.ts +18 -0
- package/src/lib/module/angularmaterial.module.ts +98 -0
- package/src/lib/reactive-field.directive.ts +24 -0
- package/src/lib/service/appsetting.service.ts +57 -0
- package/src/lib/service/http/generic-http-client.ts +205 -0
- package/src/lib/service/http/httpInterceptor.ts +36 -0
- package/src/lib/service/http/igeneric-http-client.ts +110 -0
- package/src/lib/service/logger.service.ts +75 -0
- package/src/lib/service/open-id/TokenHelperService.ts +76 -0
- package/src/lib/service/open-id/auth-guard.service.ts +25 -0
- package/src/lib/service/open-id/auth.service.ts +179 -0
- package/src/public-api.ts +35 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {Injectable} from '@angular/core';
|
|
2
|
+
import {Profile, User, UserManager, UserManagerSettings} from 'oidc-client';
|
|
3
|
+
import {LoggerService} from '../logger.service';
|
|
4
|
+
import {TokenHelperService} from './TokenHelperService';
|
|
5
|
+
import {EnvironmentViewModel} from "../../model/environments";
|
|
6
|
+
import {AppSettingService} from "../appsetting.service";
|
|
7
|
+
|
|
8
|
+
@Injectable({
|
|
9
|
+
providedIn: 'root'
|
|
10
|
+
})
|
|
11
|
+
export class AuthService {
|
|
12
|
+
static USER_LOADED_EVENT = "USER_LOADED";
|
|
13
|
+
static USER_UNLOADED_EVENT = "USER_UNLOADED";
|
|
14
|
+
|
|
15
|
+
private initialized: boolean = false;
|
|
16
|
+
private userManager!: UserManager;
|
|
17
|
+
private user: any;
|
|
18
|
+
public settings!: UserManagerSettings;
|
|
19
|
+
|
|
20
|
+
private accessToken!: Object;
|
|
21
|
+
private signingOut: boolean = false;
|
|
22
|
+
|
|
23
|
+
constructor(private logger: LoggerService, private tokenHelperService: TokenHelperService) {
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async initialize(environment: EnvironmentViewModel): Promise<void> {
|
|
28
|
+
if (this.initialized) return;
|
|
29
|
+
this.settings = this.getClientSettings(environment);
|
|
30
|
+
this.userManager = new UserManager(this.settings);
|
|
31
|
+
this.userManager.events.addUserLoaded(user => {
|
|
32
|
+
this.user = user;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
this.userManager.events.addAccessTokenExpiring(() => {
|
|
37
|
+
this.logger.info("IdSvr token expiring " + new Date().toLocaleString());
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
this.userManager.events.addAccessTokenExpired(() => {
|
|
41
|
+
this.logger.info("IdSvr token expired " + new Date().toLocaleString());
|
|
42
|
+
this.logout(false);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
this.userManager.events.addSilentRenewError(e => {
|
|
46
|
+
this.logger.error("IdSvr silent renew error " + e.message + new Date().toLocaleString());
|
|
47
|
+
this.logout(false);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
this.userManager.events.addUserLoaded(user => {
|
|
51
|
+
this.logger.info("IdSvr user session is ready " + new Date().toLocaleString());
|
|
52
|
+
this.accessToken = this.tokenHelperService.getPayloadFromToken(user.access_token, false);
|
|
53
|
+
this.user = user;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
this.userManager.events.addUserUnloaded(() => {
|
|
57
|
+
this.logger.info("IdSvr user session has ended " + new Date().toLocaleString());
|
|
58
|
+
|
|
59
|
+
if (!this.signingOut) {
|
|
60
|
+
this.startAuthentication(window.location.pathname + window.location.search);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
this.userManager.events.addUserSignedOut(() => {
|
|
65
|
+
this.logger.info("IdSvr user signed out " + new Date().toLocaleString());
|
|
66
|
+
this.logout(false);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
this.user = await this.userManager.getUser();
|
|
70
|
+
this.initialized = true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public isLoggedIn(): boolean {
|
|
74
|
+
return this.user != null && !this.user.expired;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public getUser(): Promise<User | null> {
|
|
78
|
+
return this.userManager.getUser();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public getProfile(): Profile {
|
|
82
|
+
return this.user.profile;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public getClaims(): Profile {
|
|
86
|
+
return this.user.profile;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public getAuthorizationHeaderValue(): string {
|
|
90
|
+
if (this.user != null)
|
|
91
|
+
return `${this.user.token_type} ${this.user.access_token}`;
|
|
92
|
+
return '';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getAccessToken(): any {
|
|
96
|
+
return this.accessToken || this.tokenHelperService.getPayloadFromToken(this.user.access_token, false);
|
|
97
|
+
;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async startAuthentication(returnUrl: string): Promise<void> {
|
|
101
|
+
this.logger.info("[AuthService] startAuthentication", returnUrl);
|
|
102
|
+
await this.userManager.clearStaleState();
|
|
103
|
+
await this.userManager.signinRedirect({data: {returnUrl: returnUrl}}).catch(err => {
|
|
104
|
+
//this.$log.debug("IdSvr sign in failed", err);
|
|
105
|
+
return err;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async completeAuthentication(): Promise<Oidc.User> {
|
|
110
|
+
this.logger.info("[AuthService] completeAuthentication");
|
|
111
|
+
let user = await new Promise<Oidc.User>((resolve, reject) => {
|
|
112
|
+
this.userManager.signinRedirectCallback().then(user => {
|
|
113
|
+
resolve(user)
|
|
114
|
+
}).catch(error => {
|
|
115
|
+
reject(error);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
this.user = user;
|
|
119
|
+
return this.user;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public login(): Promise<void> {
|
|
123
|
+
return this.userManager.signinRedirect();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public renewToken(): Promise<User> {
|
|
127
|
+
return this.userManager.signinSilent();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public logout(signoutRedirect?: boolean): Promise<void> {
|
|
131
|
+
|
|
132
|
+
if (signoutRedirect === undefined || signoutRedirect !== false) {
|
|
133
|
+
this.signingOut = true;
|
|
134
|
+
signoutRedirect = true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return this.userManager.signoutRedirect();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private getClientSettings(environment: EnvironmentViewModel): UserManagerSettings {
|
|
141
|
+
return {
|
|
142
|
+
authority: environment?.openID?.authority,
|
|
143
|
+
client_id: environment?.openID?.client_id,
|
|
144
|
+
redirect_uri: environment?.openID?.redirect_uri,
|
|
145
|
+
post_logout_redirect_uri: environment?.openID?.post_logout_redirect_uri,
|
|
146
|
+
response_type: environment?.openID?.response_type,
|
|
147
|
+
scope: environment?.openID?.scope,
|
|
148
|
+
filterProtocolClaims: environment?.openID?.filterProtocolClaims,
|
|
149
|
+
loadUserInfo: true,
|
|
150
|
+
monitorSession: true,
|
|
151
|
+
silent_redirect_uri: environment?.openID?.silent_redirect_uri,
|
|
152
|
+
automaticSilentRenew: environment?.openID?.automaticSilentRenew,
|
|
153
|
+
accessTokenExpiringNotificationTime: 20, //default 60
|
|
154
|
+
checkSessionInterval: 2000, //default 2000
|
|
155
|
+
silentRequestTimeout: 20000,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async isServiceReady(): Promise<boolean> {
|
|
160
|
+
return new Promise(async (resolve, reject) => {
|
|
161
|
+
if (this.initialized) {
|
|
162
|
+
this.logger.info("[AuthService] isServiceReady", true);
|
|
163
|
+
resolve(true);
|
|
164
|
+
} else {
|
|
165
|
+
this.logger.info("[AuthService] isServiceReady", false);
|
|
166
|
+
reject(false);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function authServiceFactory(authService: AuthService, appSettings: AppSettingService, environment: EnvironmentViewModel) {
|
|
173
|
+
return async () => {
|
|
174
|
+
appSettings.isServiceReady.subscribe(item => {
|
|
175
|
+
if (item)
|
|
176
|
+
authService.initialize(environment);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of tailwind
|
|
3
|
+
*/
|
|
4
|
+
export * from './lib/control-type/select';
|
|
5
|
+
export * from './lib/control-type/textarea';
|
|
6
|
+
export * from './lib/control-type/textbox';
|
|
7
|
+
export * from './lib/model/enum';
|
|
8
|
+
export * from './lib/model/constant';
|
|
9
|
+
export * from './lib/model/environments';
|
|
10
|
+
export * from './lib/model/ivalidator';
|
|
11
|
+
export * from './lib/control-builder/control-builder.component';
|
|
12
|
+
export * from './lib/base-form-component';
|
|
13
|
+
export * from './lib/module/angularmaterial.module';
|
|
14
|
+
export * from './lib/falcon-core.module';
|
|
15
|
+
|
|
16
|
+
export * from './lib/component/auto-complete/auto-complete.component';
|
|
17
|
+
export * from './lib/component/snack-bar/snack-bar.component';
|
|
18
|
+
export * from './lib/component/chips/chip.component';
|
|
19
|
+
export * from './lib/component/table/table.component';
|
|
20
|
+
export * from './lib/component/pagination/pagination.component';
|
|
21
|
+
export * from './lib/component/rich-text-editor/rich-text-editor.component';
|
|
22
|
+
export * from './lib/component/textbox/textbox.component';
|
|
23
|
+
export * from './lib/component/textarea/textarea.component';
|
|
24
|
+
export * from './lib/component/radio/radio.component';
|
|
25
|
+
export * from './lib/component/select/select.component';
|
|
26
|
+
export * from './lib/component/slide-toggle/slide-toggle.component';
|
|
27
|
+
export * from './lib/component/slider/slider.component';
|
|
28
|
+
export * from './lib/component/date-picker/date-picker.component';
|
|
29
|
+
export * from './lib/component/dialog/dialog.component';
|
|
30
|
+
export * from './lib/component/checkbox/checkbox.component';
|
|
31
|
+
export * from './lib/component/progress-bar/progress-bar.component';
|
|
32
|
+
export * from './lib/component/progress-spinner/progress-spinner.component';
|
|
33
|
+
export * from './lib/component/bottom-sheet/bottom-sheet.component';
|
|
34
|
+
export * from './lib/component/button-toggle/button-toggle.component';
|
|
35
|
+
export * from './lib/component/button/button.component';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"extends": "../../../tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "../../../out-tsc/lib",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"inlineSources": true,
|
|
9
|
+
"types": [],
|
|
10
|
+
"strictPropertyInitialization": false,
|
|
11
|
+
},
|
|
12
|
+
"exclude": [
|
|
13
|
+
"**/*.spec.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"extends": "../../../tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "../../../out-tsc/spec",
|
|
6
|
+
"types": [
|
|
7
|
+
"jasmine"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"include": [
|
|
11
|
+
"**/*.spec.ts",
|
|
12
|
+
"**/*.d.ts"
|
|
13
|
+
]
|
|
14
|
+
}
|