@acorex/core 6.5.23 → 6.5.27
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/karma.conf.js +32 -0
- package/ng-package.json +10 -0
- package/package.json +12 -32
- package/src/lib/classes/base-page.class.ts +29 -0
- package/src/lib/classes/color.class.ts +61 -0
- package/src/lib/classes/datetime.class.ts +373 -0
- package/src/lib/classes/menu.class.ts +37 -0
- package/{lib/classes/navigator.class.d.ts → src/lib/classes/navigator.class.ts} +1 -1
- package/{lib/classes/popup.class.d.ts → src/lib/classes/popup.class.ts} +2 -0
- package/src/lib/classes/promise.class.ts +25 -0
- package/src/lib/classes/select.class.ts +7 -0
- package/src/lib/core.module.ts +21 -0
- package/src/lib/error/error.module.ts +13 -0
- package/src/lib/error/error.service.ts +23 -0
- package/src/lib/error/index.ts +3 -0
- package/{lib/events/keyboard.d.ts → src/lib/events/keyboard.ts} +3 -0
- package/{lib/http/http-error.class.d.ts → src/lib/http/http-error.class.ts} +2 -2
- package/{lib/http/http-events.interceptor.d.ts → src/lib/http/http-events.interceptor.ts} +7 -3
- package/{lib/http/http-request.class.d.ts → src/lib/http/http-request.class.ts} +5 -5
- package/src/lib/http/http-result.class.ts +34 -0
- package/src/lib/http/http.module.ts +25 -0
- package/src/lib/http/http.service.ts +159 -0
- package/{esm2020 → src}/lib/locale/en.json +6 -6
- package/{esm2020 → src}/lib/locale/fa.json +7 -7
- package/src/lib/pipe/datetime.pipe.ts +20 -0
- package/src/lib/pipe/htmlToText.pipe.ts +18 -0
- package/src/lib/platform/index.ts +1 -0
- package/src/lib/platform/platform.service.ts +223 -0
- package/src/lib/services/config.ts +36 -0
- package/src/lib/services/event.service.ts +31 -0
- package/src/lib/services/navigator.service.ts +8 -0
- package/src/lib/services/storage.service.ts +11 -0
- package/src/lib/translator/translator.module.ts +19 -0
- package/src/lib/translator/translator.pipe.ts +22 -0
- package/src/lib/translator/translator.service.ts +19 -0
- package/src/lib/translator/translator.ts +31 -0
- package/src/lib/utils/array/array-util.ts +140 -0
- package/src/lib/utils/html/html-util.ts +264 -0
- package/src/lib/utils/html/html.module.ts +11 -0
- package/src/lib/utils/math/math-util.ts +5 -0
- package/src/lib/utils/object/object-util.ts +87 -0
- package/src/lib/utils/render/on-demand-preload-strategy.service.ts +25 -0
- package/src/lib/utils/render/render.service.ts +110 -0
- package/src/lib/utils/render/rendering.module.ts +25 -0
- package/src/lib/utils/scroll/scroll.directive.ts +35 -0
- package/src/lib/utils/scroll/scroll.module.ts +11 -0
- package/src/lib/utils/separator/separator.module.ts +11 -0
- package/src/lib/utils/separator/separator.pipe.ts +27 -0
- package/{public-api.d.ts → src/public-api.ts} +10 -0
- package/src/test.ts +28 -0
- package/tsconfig.lib.json +25 -0
- package/tsconfig.lib.prod.json +6 -0
- package/tsconfig.spec.json +18 -0
- package/tslint.json +17 -0
- package/acorex-core.d.ts +0 -5
- package/esm2020/acorex-core.mjs +0 -5
- package/esm2020/lib/classes/base-page.class.mjs +0 -28
- package/esm2020/lib/classes/color.class.mjs +0 -49
- package/esm2020/lib/classes/datetime.class.mjs +0 -314
- package/esm2020/lib/classes/menu.class.mjs +0 -27
- package/esm2020/lib/classes/navigator.class.mjs +0 -2
- package/esm2020/lib/classes/popup.class.mjs +0 -2
- package/esm2020/lib/classes/promise.class.mjs +0 -19
- package/esm2020/lib/classes/sectionlist.class.mjs +0 -2
- package/esm2020/lib/classes/select.class.mjs +0 -3
- package/esm2020/lib/core.module.mjs +0 -27
- package/esm2020/lib/error/error.class.mjs +0 -2
- package/esm2020/lib/error/error.module.mjs +0 -19
- package/esm2020/lib/error/error.service.mjs +0 -21
- package/esm2020/lib/events/keyboard.mjs +0 -2
- package/esm2020/lib/http/http-error.class.mjs +0 -2
- package/esm2020/lib/http/http-events.interceptor.mjs +0 -3
- package/esm2020/lib/http/http-request.class.mjs +0 -2
- package/esm2020/lib/http/http-result.class.mjs +0 -21
- package/esm2020/lib/http/http.module.mjs +0 -37
- package/esm2020/lib/http/http.service.mjs +0 -145
- package/esm2020/lib/pipe/datetime.pipe.mjs +0 -25
- package/esm2020/lib/pipe/htmlToText.pipe.mjs +0 -25
- package/esm2020/lib/platform/index.mjs +0 -2
- package/esm2020/lib/platform/platform.service.mjs +0 -150
- package/esm2020/lib/services/config.mjs +0 -29
- package/esm2020/lib/services/event.service.mjs +0 -36
- package/esm2020/lib/services/navigator.service.mjs +0 -10
- package/esm2020/lib/services/storage.service.mjs +0 -16
- package/esm2020/lib/translator/translator.mjs +0 -26
- package/esm2020/lib/translator/translator.module.mjs +0 -25
- package/esm2020/lib/translator/translator.pipe.mjs +0 -24
- package/esm2020/lib/translator/translator.service.mjs +0 -21
- package/esm2020/lib/utils/array/array-util.mjs +0 -133
- package/esm2020/lib/utils/html/html-util.mjs +0 -192
- package/esm2020/lib/utils/html/html.module.mjs +0 -19
- package/esm2020/lib/utils/math/math-util.mjs +0 -6
- package/esm2020/lib/utils/object/object-util.mjs +0 -83
- package/esm2020/lib/utils/render/on-demand-preload-strategy.service.mjs +0 -20
- package/esm2020/lib/utils/render/render.service.mjs +0 -103
- package/esm2020/lib/utils/render/rendering.module.mjs +0 -35
- package/esm2020/lib/utils/scroll/scroll.directive.mjs +0 -54
- package/esm2020/lib/utils/scroll/scroll.module.mjs +0 -19
- package/esm2020/lib/utils/separator/separator.module.mjs +0 -19
- package/esm2020/lib/utils/separator/separator.pipe.mjs +0 -33
- package/esm2020/public-api.mjs +0 -44
- package/fesm2015/acorex-core.mjs +0 -2274
- package/fesm2015/acorex-core.mjs.map +0 -1
- package/fesm2020/acorex-core.mjs +0 -2270
- package/fesm2020/acorex-core.mjs.map +0 -1
- package/lib/classes/base-page.class.d.ts +0 -13
- package/lib/classes/color.class.d.ts +0 -17
- package/lib/classes/datetime.class.d.ts +0 -63
- package/lib/classes/menu.class.d.ts +0 -34
- package/lib/classes/promise.class.d.ts +0 -7
- package/lib/classes/select.class.d.ts +0 -7
- package/lib/core.module.d.ts +0 -9
- package/lib/error/error.module.d.ts +0 -7
- package/lib/error/error.service.d.ts +0 -13
- package/lib/http/http-result.class.d.ts +0 -11
- package/lib/http/http.module.d.ts +0 -10
- package/lib/http/http.service.d.ts +0 -23
- package/lib/pipe/datetime.pipe.d.ts +0 -8
- package/lib/pipe/htmlToText.pipe.d.ts +0 -7
- package/lib/platform/index.d.ts +0 -1
- package/lib/platform/platform.service.d.ts +0 -26
- package/lib/services/config.d.ts +0 -9
- package/lib/services/event.service.d.ts +0 -9
- package/lib/services/navigator.service.d.ts +0 -8
- package/lib/services/storage.service.d.ts +0 -7
- package/lib/translator/translator.d.ts +0 -9
- package/lib/translator/translator.module.d.ts +0 -8
- package/lib/translator/translator.pipe.d.ts +0 -8
- package/lib/translator/translator.service.d.ts +0 -8
- package/lib/utils/array/array-util.d.ts +0 -6
- package/lib/utils/html/html-util.d.ts +0 -62
- package/lib/utils/html/html.module.d.ts +0 -8
- package/lib/utils/math/math-util.d.ts +0 -3
- package/lib/utils/object/object-util.d.ts +0 -7
- package/lib/utils/render/on-demand-preload-strategy.service.d.ts +0 -10
- package/lib/utils/render/render.service.d.ts +0 -18
- package/lib/utils/render/rendering.module.d.ts +0 -8
- package/lib/utils/scroll/scroll.directive.d.ts +0 -18
- package/lib/utils/scroll/scroll.module.d.ts +0 -8
- package/lib/utils/separator/separator.module.d.ts +0 -8
- package/lib/utils/separator/separator.pipe.d.ts +0 -8
- /package/{lib/classes/sectionlist.class.d.ts → src/lib/classes/sectionlist.class.ts} +0 -0
- /package/{lib/error/error.class.d.ts → src/lib/error/error.class.ts} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { InjectionToken, Injectable, Injector } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
export const AX_ERROR_DISPLAY_INTERCEPTOR = new InjectionToken<AXErrorDisplayInterceptor>('ax.error');
|
|
4
|
+
|
|
5
|
+
export interface AXErrorDisplayInterceptor {
|
|
6
|
+
show(message: string);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@Injectable({providedIn: 'root'})
|
|
10
|
+
export class AXErrorService {
|
|
11
|
+
|
|
12
|
+
constructor(private injector: Injector) {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
handle(message: string) {
|
|
17
|
+
const instance = this.injector.get(AX_ERROR_DISPLAY_INTERCEPTOR);
|
|
18
|
+
if (instance) {
|
|
19
|
+
instance.show(message);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { IHttpError } from './http-error.class';
|
|
2
2
|
import { InjectionToken } from '@angular/core';
|
|
3
3
|
import { AXHttpRequestOptions } from './http-request.class';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export const AX_HTTP_EVENT_INTERCEPTOR = new InjectionToken<AXHttpEventInterceptor>('ax.http.events');
|
|
6
|
+
|
|
5
7
|
export interface AXHttpEventInterceptor {
|
|
6
8
|
begin(request: AXHttpRequestOptions): Promise<AXHttpRequestOptions>;
|
|
7
9
|
success(request: AXHttpRequestOptions, result: any): Promise<any>;
|
|
8
|
-
complete(request: AXHttpRequestOptions)
|
|
9
|
-
error(request: AXHttpRequestOptions, error: IHttpError)
|
|
10
|
+
complete(request: AXHttpRequestOptions);
|
|
11
|
+
error(request: AXHttpRequestOptions, error: IHttpError);
|
|
10
12
|
}
|
|
13
|
+
|
|
14
|
+
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export interface AXHttpRequestOptions {
|
|
2
|
-
url?: any
|
|
2
|
+
url?: any,
|
|
3
3
|
params?: {
|
|
4
4
|
[param: string]: any;
|
|
5
|
-
}
|
|
5
|
+
},
|
|
6
6
|
body?: {
|
|
7
7
|
[param: string]: any;
|
|
8
|
-
}
|
|
8
|
+
},
|
|
9
9
|
headers?: {
|
|
10
10
|
[header: string]: any;
|
|
11
|
-
}
|
|
11
|
+
},
|
|
12
12
|
method?: 'get' | 'post' | 'put' | 'delete';
|
|
13
13
|
responseType?: any;
|
|
14
|
-
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IHttpError } from './http-error.class';
|
|
2
|
+
|
|
3
|
+
export class HttpResult<T> {
|
|
4
|
+
private _executor: (result: (e?: T) => void, error: (e?: IHttpError) => void, complete: () => void) => void;
|
|
5
|
+
constructor(
|
|
6
|
+
executor: (
|
|
7
|
+
result: (e?: T) => void,
|
|
8
|
+
error: (e?: IHttpError) => void,
|
|
9
|
+
complete: () => void
|
|
10
|
+
) => void
|
|
11
|
+
) {
|
|
12
|
+
this._executor = executor;
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
this._executor(this.resultAction, this.errorAction, this.completeAction);
|
|
15
|
+
}, 50);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private resultAction: (e?: T) => void;
|
|
19
|
+
private errorAction: (e?: IHttpError) => void;
|
|
20
|
+
private completeAction: () => void;
|
|
21
|
+
|
|
22
|
+
result(action: (e?: T) => void): HttpResult<T> {
|
|
23
|
+
this.resultAction = action;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
error(action: (e?: IHttpError) => void): HttpResult<T> {
|
|
27
|
+
this.errorAction = action;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
complete(action: () => void): HttpResult<T> {
|
|
31
|
+
this.completeAction = action;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NgModule, ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
4
|
+
import { AXHttpService } from './http.service';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@NgModule({
|
|
8
|
+
declarations: [],
|
|
9
|
+
imports: [
|
|
10
|
+
CommonModule,
|
|
11
|
+
HttpClientModule
|
|
12
|
+
],
|
|
13
|
+
exports: [HttpClientModule],
|
|
14
|
+
providers: [
|
|
15
|
+
AXHttpService
|
|
16
|
+
]
|
|
17
|
+
})
|
|
18
|
+
export class AXHttpModule {
|
|
19
|
+
static forRoot(): ModuleWithProviders<AXHttpModule> {
|
|
20
|
+
return {
|
|
21
|
+
ngModule: AXHttpModule,
|
|
22
|
+
providers: [AXHttpService]
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { Injectable, Injector, InjectFlags } from '@angular/core';
|
|
2
|
+
import { HttpClient, HttpHeaders, HttpParams, HttpErrorResponse } from '@angular/common/http';
|
|
3
|
+
import { HttpResult } from './http-result.class';
|
|
4
|
+
import { IHttpError } from './http-error.class';
|
|
5
|
+
import { AXHttpRequestOptions } from './http-request.class';
|
|
6
|
+
import {
|
|
7
|
+
AX_HTTP_EVENT_INTERCEPTOR, AXHttpEventInterceptor
|
|
8
|
+
} from './http-events.interceptor';
|
|
9
|
+
// import { catchError, retry, retryWhen, mergeMap, delay, switchMap, scan, takeWhile, flatMap } from 'rxjs/operators';
|
|
10
|
+
// import { of, concat, throwError } from 'rxjs';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class AXHttpService {
|
|
15
|
+
|
|
16
|
+
private interceptor: AXHttpEventInterceptor;
|
|
17
|
+
constructor(private http: HttpClient, private injector: Injector) {
|
|
18
|
+
this.interceptor = this.injector.get(AX_HTTP_EVENT_INTERCEPTOR);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
get<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {
|
|
23
|
+
config.url = url;
|
|
24
|
+
config.method = "get";
|
|
25
|
+
return this.request(config);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
post<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {
|
|
29
|
+
config.url = url;
|
|
30
|
+
config.method = "post";
|
|
31
|
+
return this.request(config);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
delete<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {
|
|
35
|
+
config.url = url;
|
|
36
|
+
config.method = "delete";
|
|
37
|
+
return this.request(config);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
put<T>(url: string, config: AXHttpRequestOptions = {}): HttpResult<T> {
|
|
41
|
+
config.url = url;
|
|
42
|
+
config.method = "put";
|
|
43
|
+
return this.request(config);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
request<T>(config: AXHttpRequestOptions): HttpResult<T> {
|
|
48
|
+
return new HttpResult<T>((result?, error?, complete?) => {
|
|
49
|
+
this.handleBegin(config).then(c => {
|
|
50
|
+
this.http
|
|
51
|
+
.request<T>(config.method, config.url, this.mapOptions(config))
|
|
52
|
+
//.pipe(this.retry)
|
|
53
|
+
.subscribe(data => {
|
|
54
|
+
this.handleResult(data, result, complete, config);
|
|
55
|
+
}, c => {
|
|
56
|
+
this.handleError(c, error, complete, config);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
private handleResult(data, result, complete, config: AXHttpRequestOptions) {
|
|
64
|
+
if (this.interceptor) {
|
|
65
|
+
this.interceptor.success(config, data).then(c => {
|
|
66
|
+
if (result)
|
|
67
|
+
result(c);
|
|
68
|
+
this.handleComplete(complete, config);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
//
|
|
73
|
+
if (result)
|
|
74
|
+
result(data);
|
|
75
|
+
this.handleComplete(complete, config);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private handleBegin(config: AXHttpRequestOptions): Promise<AXHttpRequestOptions> {
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
if (!config.headers)
|
|
82
|
+
config.headers = {};
|
|
83
|
+
if (!config.params)
|
|
84
|
+
config.params = {};
|
|
85
|
+
//
|
|
86
|
+
if (this.interceptor) {
|
|
87
|
+
this.interceptor.begin(config).then(c => {
|
|
88
|
+
resolve(c);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
resolve(config)
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private handleComplete(complete: Function, config: AXHttpRequestOptions) {
|
|
98
|
+
if (complete)
|
|
99
|
+
complete();
|
|
100
|
+
if (this.interceptor)
|
|
101
|
+
this.interceptor.complete(config);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private handleError(c: HttpErrorResponse, error: Function, complete: Function, config: AXHttpRequestOptions) {
|
|
105
|
+
let r: IHttpError = {
|
|
106
|
+
message: c.message,
|
|
107
|
+
status: c.status,
|
|
108
|
+
code: c.status?.toString(),
|
|
109
|
+
handled: false,
|
|
110
|
+
error: c.error
|
|
111
|
+
}
|
|
112
|
+
if (error) {
|
|
113
|
+
error(r);
|
|
114
|
+
}
|
|
115
|
+
if (!r.handled) {
|
|
116
|
+
if (this.interceptor)
|
|
117
|
+
this.interceptor.error(config, r);
|
|
118
|
+
}
|
|
119
|
+
this.handleComplete(complete, config);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private mapOptions(options: AXHttpRequestOptions) {
|
|
123
|
+
let headers = new HttpHeaders();
|
|
124
|
+
|
|
125
|
+
for (const key in options.headers) {
|
|
126
|
+
if (options.headers.hasOwnProperty(key)) {
|
|
127
|
+
const value = options.headers[key];
|
|
128
|
+
headers = headers.set(key, value)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
let params = new HttpParams();
|
|
132
|
+
for (const key in options.params) {
|
|
133
|
+
if (options.params.hasOwnProperty(key)) {
|
|
134
|
+
const value = options.params[key];
|
|
135
|
+
params = params.set(key, value);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
headers: headers,
|
|
140
|
+
params: params,
|
|
141
|
+
body: options.body,
|
|
142
|
+
responseType: options.responseType || 'json'
|
|
143
|
+
};
|
|
144
|
+
// if (options.method == "get") {
|
|
145
|
+
// return {
|
|
146
|
+
// headers: headers,
|
|
147
|
+
// params: params
|
|
148
|
+
// };
|
|
149
|
+
// }
|
|
150
|
+
// else {
|
|
151
|
+
// return {
|
|
152
|
+
// headers: headers,
|
|
153
|
+
// params: params,
|
|
154
|
+
// body: options.body
|
|
155
|
+
// };
|
|
156
|
+
// }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
}
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"refresh-rate": "Refresh Rate",
|
|
28
28
|
"refresh": "Refresh",
|
|
29
29
|
"reload": "Reload",
|
|
30
|
-
"condition":
|
|
31
|
-
"next":
|
|
32
|
-
"prev":
|
|
30
|
+
"condition":"Condition",
|
|
31
|
+
"next":"Next",
|
|
32
|
+
"prev":"Prev"
|
|
33
33
|
},
|
|
34
34
|
"dateTime": {
|
|
35
35
|
"weekdaysShort": {
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
},
|
|
57
57
|
"queryBuilder": {
|
|
58
58
|
"contains": "contains",
|
|
59
|
-
"not-contains":
|
|
60
|
-
"contains-all":
|
|
59
|
+
"not-contains":"not-contains",
|
|
60
|
+
"contains-all":"contains-all",
|
|
61
61
|
"start-with": "start-with",
|
|
62
62
|
"end-with": "end-with",
|
|
63
63
|
"equal": "equal",
|
|
@@ -252,4 +252,4 @@
|
|
|
252
252
|
"bubbleTooltip": "Bubble",
|
|
253
253
|
"histogramTooltip": "Histogram"
|
|
254
254
|
}
|
|
255
|
-
}
|
|
255
|
+
}
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"refresh-rate": "نرخ بروز رسانی",
|
|
27
27
|
"refresh": "بروز رسانی",
|
|
28
28
|
"reload": "بارگزاری مجدد",
|
|
29
|
-
"condition":
|
|
30
|
-
"next":
|
|
31
|
-
"prev":
|
|
32
|
-
"reset":
|
|
29
|
+
"condition":"شرط",
|
|
30
|
+
"next":"بعدی",
|
|
31
|
+
"prev":"قبلی",
|
|
32
|
+
"reset":"بازنشانی"
|
|
33
33
|
},
|
|
34
34
|
"dateTime": {
|
|
35
35
|
"weekdaysShort": {
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
},
|
|
57
57
|
"queryBuilder": {
|
|
58
58
|
"contains": "شامل",
|
|
59
|
-
"not-contains":
|
|
60
|
-
"contains-all":
|
|
59
|
+
"not-contains":"به غیر از",
|
|
60
|
+
"contains-all":"شامل همه",
|
|
61
61
|
"start-with": "شروع شود با",
|
|
62
62
|
"end-with": "پایان با",
|
|
63
63
|
"equal": "برابر با",
|
|
@@ -242,4 +242,4 @@
|
|
|
242
242
|
"autosizeThiscolumn": "تنظیم اندازه ستون ",
|
|
243
243
|
"autosizeAllColumns": "تنظیم اندازه همه ستون ها"
|
|
244
244
|
}
|
|
245
|
-
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PipeTransform, Pipe } from '@angular/core';
|
|
2
|
+
import { AXDateTime } from '../classes/datetime.class';
|
|
3
|
+
|
|
4
|
+
@Pipe({ name: 'dt' })
|
|
5
|
+
export class AXDateTimePipe implements PipeTransform {
|
|
6
|
+
constructor() { }
|
|
7
|
+
|
|
8
|
+
transform(value: any, format?: string): string {
|
|
9
|
+
const date: AXDateTime = AXDateTime.convert(value);
|
|
10
|
+
if (value == null) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
if (!format) {
|
|
14
|
+
return date.toString();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return date.format(format);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Pipe({ name: 'html2text' })
|
|
4
|
+
export class AXHtmlToTextPipe implements PipeTransform {
|
|
5
|
+
transform(value: string) {
|
|
6
|
+
if (value) {
|
|
7
|
+
const regexHtml = /<\/?[^>]+>/gi;
|
|
8
|
+
const regexNbsp = / /gi;
|
|
9
|
+
const regexAmp = /&/gi;
|
|
10
|
+
return value
|
|
11
|
+
.replace(regexHtml, '')
|
|
12
|
+
.replace(regexNbsp, '')
|
|
13
|
+
.replace(regexAmp, '');
|
|
14
|
+
} else {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './platform.service';
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { Injectable } from "@angular/core";
|
|
2
|
+
import { from, fromEvent, Subject } from "rxjs";
|
|
3
|
+
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export type AXPlatforms = 'Android' | 'Desktop' | 'iOS' | 'Mobile' | '';
|
|
7
|
+
export type AXBrowsers = 'Chrome' | 'Safari' | 'Edge' | 'Firefox' | 'Opera' | 'MSIE';
|
|
8
|
+
export type AXTechnologies = 'PWA' | 'Hybrid' | 'Electron';
|
|
9
|
+
export type AXScreenSizes = 'SM' | 'MD' | 'LG' | 'XL' | '2XL';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const isChrome = (win: Window): boolean =>
|
|
14
|
+
testUserAgent(win, /Chrome/i);
|
|
15
|
+
|
|
16
|
+
const isFirefox = (win: Window): boolean =>
|
|
17
|
+
testUserAgent(win, /Firefox/i);
|
|
18
|
+
|
|
19
|
+
const isEdge = (win: Window): boolean =>
|
|
20
|
+
testUserAgent(win, /Edge/i);
|
|
21
|
+
|
|
22
|
+
const isSafari = (win: Window): boolean =>
|
|
23
|
+
testUserAgent(win, /Safari/i);
|
|
24
|
+
|
|
25
|
+
const isOpera = (win: Window): boolean =>
|
|
26
|
+
testUserAgent(win, /Opera/i) || testUserAgent(win, /OPR/i);
|
|
27
|
+
|
|
28
|
+
const isMSIE = (win: Window): boolean =>
|
|
29
|
+
testUserAgent(win, /MSIE/i) || testUserAgent(win, /Trident/i);
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const isMobileWeb = (win: Window): boolean =>
|
|
33
|
+
isMobile(win) && !isHybrid(win);
|
|
34
|
+
|
|
35
|
+
const isIpad = (win: Window) => {
|
|
36
|
+
// iOS 12 and below
|
|
37
|
+
if (testUserAgent(win, /iPad/i)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// iOS 13+
|
|
42
|
+
if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const isIphone = (win: Window) =>
|
|
50
|
+
testUserAgent(win, /iPhone/i);
|
|
51
|
+
|
|
52
|
+
const isIOS = (win: Window) =>
|
|
53
|
+
testUserAgent(win, /iPhone|iPod/i) || isIpad(win);
|
|
54
|
+
|
|
55
|
+
const isAndroid = (win: Window) =>
|
|
56
|
+
testUserAgent(win, /android|sink/i);
|
|
57
|
+
|
|
58
|
+
const isAndroidTablet = (win: Window) => {
|
|
59
|
+
return isAndroid(win) && !testUserAgent(win, /mobile/i);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const isPhablet = (win: Window) => {
|
|
63
|
+
const width = win.innerWidth;
|
|
64
|
+
const height = win.innerHeight;
|
|
65
|
+
const smallest = Math.min(width, height);
|
|
66
|
+
const largest = Math.max(width, height);
|
|
67
|
+
|
|
68
|
+
return (smallest > 390 && smallest < 520) &&
|
|
69
|
+
(largest > 620 && largest < 800);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const isTablet = (win: Window) => {
|
|
73
|
+
const width = win.innerWidth;
|
|
74
|
+
const height = win.innerHeight;
|
|
75
|
+
const smallest = Math.min(width, height);
|
|
76
|
+
const largest = Math.max(width, height);
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
isIpad(win) ||
|
|
80
|
+
isAndroidTablet(win) ||
|
|
81
|
+
(
|
|
82
|
+
(smallest > 460 && smallest < 820) &&
|
|
83
|
+
(largest > 780 && largest < 1400)
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const isMobile = (win: Window) =>
|
|
89
|
+
matchMedia(win, '(any-pointer:coarse)');
|
|
90
|
+
|
|
91
|
+
const isTouch = (win: Window) => matchMedia(win, '(any-pointer:coarse)');
|
|
92
|
+
|
|
93
|
+
const isDesktop = (win: Window) =>
|
|
94
|
+
!isMobile(win);
|
|
95
|
+
|
|
96
|
+
const isHybrid = (win: Window) =>
|
|
97
|
+
isCordova(win) || isCapacitorNative(win);
|
|
98
|
+
|
|
99
|
+
const isCordova = (win: any): boolean =>
|
|
100
|
+
!!(win['cordova'] || win['phonegap'] || win['PhoneGap']);
|
|
101
|
+
|
|
102
|
+
const isCapacitorNative = (win: any): boolean => {
|
|
103
|
+
const capacitor = win['Capacitor'];
|
|
104
|
+
return !!(capacitor && capacitor.isNative);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const isElectron = (win: Window): boolean =>
|
|
108
|
+
testUserAgent(win, /electron/i);
|
|
109
|
+
|
|
110
|
+
const isPWA = (win: Window): boolean =>
|
|
111
|
+
!!(win.matchMedia('(display-mode: standalone)').matches || (win.navigator as any).standalone);
|
|
112
|
+
|
|
113
|
+
export const testUserAgent = (win: Window, expr: RegExp) =>
|
|
114
|
+
expr.test(win.navigator.userAgent);
|
|
115
|
+
|
|
116
|
+
const matchMedia = (win: Window, query: string): boolean =>
|
|
117
|
+
win.matchMedia(query).matches;
|
|
118
|
+
|
|
119
|
+
const isSMScreen = (win: Window) => matchMedia(win, '(max-width: 640px)');
|
|
120
|
+
const isMDScreen = (win: Window) => matchMedia(win, '(max-width: 768px)');
|
|
121
|
+
const isLGScreen = (win: Window) => matchMedia(win, '(max-width: 1024px)');
|
|
122
|
+
const isXLScreen = (win: Window) => matchMedia(win, '(max-width: 1280px)');
|
|
123
|
+
const is2XLScreen = (win: Window) => matchMedia(win, '(max-width: 1536px)');
|
|
124
|
+
|
|
125
|
+
const PLATFORMS_MAP = {
|
|
126
|
+
'Android': isAndroid,
|
|
127
|
+
'iOS': isIOS,
|
|
128
|
+
'Desktop': isDesktop,
|
|
129
|
+
'Mobile': isMobile,
|
|
130
|
+
'Touch': isTouch,
|
|
131
|
+
'Chrome': isChrome,
|
|
132
|
+
'Firefox': isFirefox,
|
|
133
|
+
'Safari': isSafari,
|
|
134
|
+
'Edge': isEdge,
|
|
135
|
+
'Opera': isOpera,
|
|
136
|
+
'Hybrid': isHybrid,
|
|
137
|
+
'PWA': isPWA,
|
|
138
|
+
'Electron': isElectron,
|
|
139
|
+
SM: isSMScreen,
|
|
140
|
+
MD: isMDScreen,
|
|
141
|
+
LG: isLGScreen,
|
|
142
|
+
XL: isXLScreen,
|
|
143
|
+
"2XL": is2XLScreen,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
export class AXPlatformEvent {
|
|
148
|
+
nativeEvent: UIEvent | Event;
|
|
149
|
+
source: AXPlatform
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@Injectable({
|
|
153
|
+
providedIn: 'root',
|
|
154
|
+
})
|
|
155
|
+
export class AXPlatform {
|
|
156
|
+
resize: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>();
|
|
157
|
+
click: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>()
|
|
158
|
+
scroll: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>()
|
|
159
|
+
|
|
160
|
+
isRtl(): boolean {
|
|
161
|
+
return document.dir == 'rtl' || document.body.dir == 'rtl' || document.body.style.direction == 'rtl';
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
isLandscape(): boolean {
|
|
166
|
+
return window.innerHeight < window.innerWidth;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
isPortrate(): boolean {
|
|
170
|
+
return !this.isLandscape()
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
is(name: AXPlatforms | AXBrowsers | AXTechnologies | AXScreenSizes): boolean {
|
|
174
|
+
return PLATFORMS_MAP[name](window) || false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
switchDarkMode() {
|
|
178
|
+
const _html = document.getElementsByTagName("html")[0];
|
|
179
|
+
_html.classList.add('ax-dark')
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
switchLightMode() {
|
|
184
|
+
const _html = document.getElementsByTagName("html")[0];
|
|
185
|
+
_html.classList.remove('ax-dark')
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private _setFullHeightRatio() {
|
|
189
|
+
document.querySelector<HTMLElement>(':root').style.setProperty('--ax-vh', window.innerHeight / 100 + 'px');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
constructor() {
|
|
193
|
+
|
|
194
|
+
fromEvent<UIEvent>(window, 'resize')
|
|
195
|
+
.pipe(debounceTime(100))
|
|
196
|
+
.pipe(distinctUntilChanged())
|
|
197
|
+
.subscribe((e) => {
|
|
198
|
+
this.resize.next({
|
|
199
|
+
nativeEvent: e,
|
|
200
|
+
source: this
|
|
201
|
+
});
|
|
202
|
+
//
|
|
203
|
+
this._setFullHeightRatio();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
document.addEventListener('click', (e) => {
|
|
208
|
+
this.click.next({
|
|
209
|
+
nativeEvent: e,
|
|
210
|
+
source: this
|
|
211
|
+
});
|
|
212
|
+
}, true)
|
|
213
|
+
|
|
214
|
+
document.addEventListener('scroll', (e) => {
|
|
215
|
+
this.scroll.next({
|
|
216
|
+
nativeEvent: e,
|
|
217
|
+
source: this
|
|
218
|
+
});
|
|
219
|
+
}, true);
|
|
220
|
+
// init functions
|
|
221
|
+
this._setFullHeightRatio();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Subject, Observable } from 'rxjs';
|
|
2
|
+
import { getPropByPath, setPropByPath } from '../utils/object/object-util';
|
|
3
|
+
|
|
4
|
+
// @dynamic
|
|
5
|
+
export class AXConfig {
|
|
6
|
+
private static dataModel: any = {};
|
|
7
|
+
private static dataChangeSubject = new Subject<any>();
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
static get onChange(): Observable<any> {
|
|
11
|
+
return AXConfig.dataChangeSubject.asObservable();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static set(config: any): any;
|
|
15
|
+
static set(path: string, value?: any): void;
|
|
16
|
+
static set(arg1?: any, arg2?: any) {
|
|
17
|
+
|
|
18
|
+
if (arg1 && typeof arg1 == 'string') {
|
|
19
|
+
setPropByPath(AXConfig.dataModel, arg1, arg2);
|
|
20
|
+
AXConfig.dataChangeSubject.next(AXConfig.dataModel);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (arg1 && typeof arg1 == 'object') {
|
|
24
|
+
Object.assign(AXConfig.dataModel, arg1);
|
|
25
|
+
AXConfig.dataChangeSubject.next(AXConfig.dataModel);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!arg1 && !arg2) {
|
|
29
|
+
return AXConfig.dataChangeSubject.asObservable();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static get(path: string): any {
|
|
34
|
+
return getPropByPath(AXConfig.dataModel, path);
|
|
35
|
+
}
|
|
36
|
+
}
|