@elite.framework/ng.core 1.0.65 → 2.0.1
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 +2 -22
- package/directives/README.md +3 -0
- package/fesm2022/{elite.framework-ng.core-src-lib-directives.mjs → elite.framework-ng.core-directives.mjs} +7 -7
- package/fesm2022/elite.framework-ng.core-directives.mjs.map +1 -0
- package/fesm2022/elite.framework-ng.core-models.mjs +47 -0
- package/fesm2022/elite.framework-ng.core-models.mjs.map +1 -0
- package/fesm2022/{elite.framework-ng.core-src-lib-pipes.mjs → elite.framework-ng.core-pipes.mjs} +7 -7
- package/fesm2022/elite.framework-ng.core-pipes.mjs.map +1 -0
- package/fesm2022/elite.framework-ng.core-providers.mjs +18 -0
- package/fesm2022/elite.framework-ng.core-providers.mjs.map +1 -0
- package/fesm2022/elite.framework-ng.core-services.mjs +509 -0
- package/fesm2022/elite.framework-ng.core-services.mjs.map +1 -0
- package/fesm2022/elite.framework-ng.core-tokens.mjs +17 -0
- package/fesm2022/elite.framework-ng.core-tokens.mjs.map +1 -0
- package/fesm2022/elite.framework-ng.core.mjs +7 -2239
- package/fesm2022/elite.framework-ng.core.mjs.map +1 -1
- package/index.d.ts +4 -648
- package/models/README.md +3 -0
- package/models/index.d.ts +135 -0
- package/package.json +26 -170
- package/pipes/README.md +3 -0
- package/providers/README.md +3 -0
- package/providers/index.d.ts +6 -0
- package/services/README.md +3 -0
- package/services/index.d.ts +250 -0
- package/tokens/README.md +3 -0
- package/tokens/index.d.ts +15 -0
- package/fesm2022/elite.framework-ng.core-src-lib-components-attachments.mjs +0 -204
- package/fesm2022/elite.framework-ng.core-src-lib-components-attachments.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-breadcrumb.mjs +0 -132
- package/fesm2022/elite.framework-ng.core-src-lib-components-breadcrumb.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-color-picker.mjs +0 -76
- package/fesm2022/elite.framework-ng.core-src-lib-components-color-picker.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-column-settings-popover.mjs +0 -172
- package/fesm2022/elite.framework-ng.core-src-lib-components-column-settings-popover.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-condition-editor.mjs +0 -794
- package/fesm2022/elite.framework-ng.core-src-lib-components-condition-editor.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-custom-switch.mjs +0 -110
- package/fesm2022/elite.framework-ng.core-src-lib-components-custom-switch.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-deactivation-reason.mjs +0 -130
- package/fesm2022/elite.framework-ng.core-src-lib-components-deactivation-reason.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-form-button.mjs +0 -50
- package/fesm2022/elite.framework-ng.core-src-lib-components-form-button.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-form-field.mjs +0 -154
- package/fesm2022/elite.framework-ng.core-src-lib-components-form-field.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-form-template.mjs +0 -24
- package/fesm2022/elite.framework-ng.core-src-lib-components-form-template.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-avatar-image.mjs +0 -100
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-avatar-image.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-avatar-label.mjs +0 -78
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-avatar-label.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-button-selector.mjs +0 -167
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-button-selector.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-button.mjs +0 -62
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-button.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-split-button.mjs +0 -50
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-split-button.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-username-with-domain.mjs +0 -76
- package/fesm2022/elite.framework-ng.core-src-lib-components-formly-username-with-domain.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-autocomplete.mjs +0 -163
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-autocomplete.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-button.mjs +0 -133
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-button.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-card.mjs +0 -214
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-card.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-crud-table.mjs +0 -385
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-crud-table.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-errormessage.mjs +0 -23
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-errormessage.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-formly-fields.mjs +0 -53
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-formly-fields.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-loadingspinner.mjs +0 -23
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-loadingspinner.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-search.mjs +0 -85
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-search.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-selector.mjs +0 -430
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-selector.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-table.mjs +0 -216
- package/fesm2022/elite.framework-ng.core-src-lib-components-generic-table.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-header-wrapper.mjs +0 -18
- package/fesm2022/elite.framework-ng.core-src-lib-components-header-wrapper.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-icon-picker.mjs +0 -195
- package/fesm2022/elite.framework-ng.core-src-lib-components-icon-picker.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-input-switch.mjs +0 -94
- package/fesm2022/elite.framework-ng.core-src-lib-components-input-switch.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-input-with-icon.mjs +0 -55
- package/fesm2022/elite.framework-ng.core-src-lib-components-input-with-icon.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-label-type.mjs +0 -112
- package/fesm2022/elite.framework-ng.core-src-lib-components-label-type.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-odata-query-builder.mjs +0 -297
- package/fesm2022/elite.framework-ng.core-src-lib-components-odata-query-builder.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-repeat.mjs +0 -135
- package/fesm2022/elite.framework-ng.core-src-lib-components-repeat.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-sidebar-cards.mjs +0 -40
- package/fesm2022/elite.framework-ng.core-src-lib-components-sidebar-cards.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-sidebar-toggles.mjs +0 -41
- package/fesm2022/elite.framework-ng.core-src-lib-components-sidebar-toggles.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-tabs.mjs +0 -45
- package/fesm2022/elite.framework-ng.core-src-lib-components-tabs.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-tag-type.mjs +0 -192
- package/fesm2022/elite.framework-ng.core-src-lib-components-tag-type.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-text-editor.mjs +0 -44
- package/fesm2022/elite.framework-ng.core-src-lib-components-text-editor.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-components-wrappers.mjs +0 -174
- package/fesm2022/elite.framework-ng.core-src-lib-components-wrappers.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-directives.mjs.map +0 -1
- package/fesm2022/elite.framework-ng.core-src-lib-pipes.mjs.map +0 -1
- package/src/lib/components/attachments/index.d.ts +0 -31
- package/src/lib/components/breadcrumb/index.d.ts +0 -10
- package/src/lib/components/color-picker/index.d.ts +0 -9
- package/src/lib/components/column-settings-popover/index.d.ts +0 -39
- package/src/lib/components/condition-editor/index.d.ts +0 -73
- package/src/lib/components/custom-switch/index.d.ts +0 -12
- package/src/lib/components/deactivation-reason/index.d.ts +0 -24
- package/src/lib/components/form-button/index.d.ts +0 -10
- package/src/lib/components/form-field/index.d.ts +0 -30
- package/src/lib/components/form-template/index.d.ts +0 -9
- package/src/lib/components/formly-avatar-image/index.d.ts +0 -11
- package/src/lib/components/formly-avatar-label/index.d.ts +0 -29
- package/src/lib/components/formly-button/index.d.ts +0 -13
- package/src/lib/components/formly-button-selector/index.d.ts +0 -28
- package/src/lib/components/formly-split-button/index.d.ts +0 -16
- package/src/lib/components/formly-username-with-domain/index.d.ts +0 -12
- package/src/lib/components/generic-autocomplete/index.d.ts +0 -34
- package/src/lib/components/generic-button/index.d.ts +0 -35
- package/src/lib/components/generic-card/index.d.ts +0 -90
- package/src/lib/components/generic-crud-table/index.d.ts +0 -120
- package/src/lib/components/generic-errormessage/index.d.ts +0 -10
- package/src/lib/components/generic-formly-fields/index.d.ts +0 -22
- package/src/lib/components/generic-loadingspinner/index.d.ts +0 -9
- package/src/lib/components/generic-search/index.d.ts +0 -29
- package/src/lib/components/generic-selector/index.d.ts +0 -66
- package/src/lib/components/generic-table/index.d.ts +0 -60
- package/src/lib/components/header-wrapper/index.d.ts +0 -8
- package/src/lib/components/icon-picker/index.d.ts +0 -23
- package/src/lib/components/input-switch/index.d.ts +0 -9
- package/src/lib/components/input-with-icon/index.d.ts +0 -10
- package/src/lib/components/label-type/index.d.ts +0 -19
- package/src/lib/components/odata-query-builder/index.d.ts +0 -81
- package/src/lib/components/repeat/index.d.ts +0 -17
- package/src/lib/components/sidebar-cards/index.d.ts +0 -18
- package/src/lib/components/sidebar-toggles/index.d.ts +0 -18
- package/src/lib/components/tabs/index.d.ts +0 -10
- package/src/lib/components/tag-type/index.d.ts +0 -27
- package/src/lib/components/text-editor/index.d.ts +0 -9
- package/src/lib/components/wrappers/index.d.ts +0 -24
- /package/{src/lib/directives → directives}/index.d.ts +0 -0
- /package/{src/lib/pipes → pipes}/index.d.ts +0 -0
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Inject, Injectable, InjectionToken, PLATFORM_ID, Optional } from '@angular/core';
|
|
3
|
+
import { throwError, catchError, map } from 'rxjs';
|
|
4
|
+
import * as i1 from '@angular/common/http';
|
|
5
|
+
import { HttpParams } from '@angular/common/http';
|
|
6
|
+
import { ENVIRONMENT, CORE_OPTIONS } from '@elite.framework/ng.core/tokens';
|
|
7
|
+
import { isPlatformBrowser, DOCUMENT } from '@angular/common';
|
|
8
|
+
import Swal from 'sweetalert2';
|
|
9
|
+
|
|
10
|
+
class RestService {
|
|
11
|
+
options;
|
|
12
|
+
http;
|
|
13
|
+
environment = inject(ENVIRONMENT);
|
|
14
|
+
constructor(options, http) {
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.http = http;
|
|
17
|
+
}
|
|
18
|
+
getApiFromStore(apiName) {
|
|
19
|
+
return this.environment.apiUrl;
|
|
20
|
+
}
|
|
21
|
+
handleError(err) {
|
|
22
|
+
// this.httpErrorReporter.reportError(err);
|
|
23
|
+
return throwError(() => err);
|
|
24
|
+
}
|
|
25
|
+
request(request, config, api) {
|
|
26
|
+
// debugger
|
|
27
|
+
config = config || {};
|
|
28
|
+
api = api || this.getApiFromStore(config.apiName);
|
|
29
|
+
const { method, params, ...options } = request;
|
|
30
|
+
const { observe = "body" /* Rest.Observe.Body */, skipHandleError } = config;
|
|
31
|
+
const url = this.removeDuplicateSlashes(api + request.url);
|
|
32
|
+
const httpClient = this.getHttpClient(config.skipAddingHeader ?? false);
|
|
33
|
+
return httpClient
|
|
34
|
+
.request(method, url, {
|
|
35
|
+
observe,
|
|
36
|
+
...(params && {
|
|
37
|
+
params: this.getParams(params, config.httpParamEncoder),
|
|
38
|
+
}),
|
|
39
|
+
...options,
|
|
40
|
+
})
|
|
41
|
+
.pipe(catchError(err => (skipHandleError ? throwError(() => err) : this.handleError(err))));
|
|
42
|
+
}
|
|
43
|
+
getHttpClient(isExternal) {
|
|
44
|
+
return /* isExternal ? this.externalHttp : */ this.http;
|
|
45
|
+
}
|
|
46
|
+
getParams(params, encoder) {
|
|
47
|
+
const filteredParams = Object.entries(params).reduce((acc, [key, value]) => {
|
|
48
|
+
if (isUndefinedOrEmptyString(value))
|
|
49
|
+
return acc;
|
|
50
|
+
if (value === null && !this.options.sendNullsAsQueryParam)
|
|
51
|
+
return acc;
|
|
52
|
+
acc[key] = value;
|
|
53
|
+
return acc;
|
|
54
|
+
}, {});
|
|
55
|
+
return encoder
|
|
56
|
+
? new HttpParams({ encoder, fromObject: filteredParams })
|
|
57
|
+
: new HttpParams({ fromObject: filteredParams });
|
|
58
|
+
}
|
|
59
|
+
removeDuplicateSlashes(url) {
|
|
60
|
+
return url.replace(/([^:]\/)\/+/g, '$1');
|
|
61
|
+
}
|
|
62
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: RestService, deps: [{ token: CORE_OPTIONS }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
63
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: RestService, providedIn: 'root' });
|
|
64
|
+
}
|
|
65
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: RestService, decorators: [{
|
|
66
|
+
type: Injectable,
|
|
67
|
+
args: [{
|
|
68
|
+
providedIn: 'root',
|
|
69
|
+
}]
|
|
70
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
71
|
+
type: Inject,
|
|
72
|
+
args: [CORE_OPTIONS]
|
|
73
|
+
}] }, { type: i1.HttpClient }] });
|
|
74
|
+
function isUndefinedOrEmptyString(value) {
|
|
75
|
+
return value === undefined || value === '';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class BaseService {
|
|
79
|
+
restService;
|
|
80
|
+
apiName = '';
|
|
81
|
+
moduleName = '';
|
|
82
|
+
constructor(restService) {
|
|
83
|
+
this.restService = restService;
|
|
84
|
+
}
|
|
85
|
+
get = (id) => this.restService.request({
|
|
86
|
+
method: 'GET',
|
|
87
|
+
url: `/${this.moduleName}/${this.apiName}/${id}`,
|
|
88
|
+
}, { apiName: this.apiName });
|
|
89
|
+
getList = (input, endpoint) => {
|
|
90
|
+
const params = Object.keys(input).reduce((acc, key) => {
|
|
91
|
+
acc[key] = input[key];
|
|
92
|
+
return acc;
|
|
93
|
+
}, {});
|
|
94
|
+
const url = endpoint ? endpoint : `/${this.moduleName}/${this.apiName}`;
|
|
95
|
+
return this.restService.request({
|
|
96
|
+
method: 'GET',
|
|
97
|
+
url: url,
|
|
98
|
+
params: params,
|
|
99
|
+
}, { apiName: this.apiName })
|
|
100
|
+
.pipe(map(response => response));
|
|
101
|
+
};
|
|
102
|
+
create = (input) => this.restService.request({
|
|
103
|
+
method: 'POST',
|
|
104
|
+
url: `/${this.moduleName}/${this.apiName}`,
|
|
105
|
+
body: input,
|
|
106
|
+
}, { apiName: this.apiName });
|
|
107
|
+
update = (id, input) => this.restService.request({
|
|
108
|
+
method: 'PUT',
|
|
109
|
+
url: `/${this.moduleName}/${this.apiName}/${id}`,
|
|
110
|
+
body: input,
|
|
111
|
+
}, { apiName: this.apiName });
|
|
112
|
+
delete = (id) => this.restService.request({
|
|
113
|
+
method: 'DELETE',
|
|
114
|
+
url: `/${this.moduleName}/${this.apiName}/${id}`,
|
|
115
|
+
}, { apiName: this.apiName });
|
|
116
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: BaseService, deps: [{ token: RestService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
117
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: BaseService, providedIn: 'root' });
|
|
118
|
+
}
|
|
119
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: BaseService, decorators: [{
|
|
120
|
+
type: Injectable,
|
|
121
|
+
args: [{
|
|
122
|
+
providedIn: 'root',
|
|
123
|
+
}]
|
|
124
|
+
}], ctorParameters: () => [{ type: RestService }] });
|
|
125
|
+
|
|
126
|
+
// src/app/services/generic.service.ts
|
|
127
|
+
/**
|
|
128
|
+
* GenericService<T, K>:
|
|
129
|
+
* - T = نوع الكائن (Model)
|
|
130
|
+
* - K = نوع المفتاح الأساسي (ID)، افتراضي number
|
|
131
|
+
*
|
|
132
|
+
* يحتوي على جميع دوال الـ CRUD القياسية للتوريث في الخدمات المتخصصة.
|
|
133
|
+
*/
|
|
134
|
+
class GenericService {
|
|
135
|
+
http;
|
|
136
|
+
constructor(http) {
|
|
137
|
+
this.http = http;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* جلب كل السجلات
|
|
141
|
+
*/
|
|
142
|
+
getAll() {
|
|
143
|
+
// ملاحظة: يمكن إضافة معالج أخطاء مركزي هنا أو عبر Interceptor
|
|
144
|
+
return this.http.get(this.baseUrl);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* جلب سجل واحد بناءً على المعرف
|
|
148
|
+
*/
|
|
149
|
+
getById(id) {
|
|
150
|
+
// ملاحظة: تأكد أن الـ endpoint يدعم GET برقم المعرف
|
|
151
|
+
return this.http.get(`${this.baseUrl}/${id}`);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* إنشاء سجل جديد
|
|
155
|
+
*/
|
|
156
|
+
create(item) {
|
|
157
|
+
// ملاحظة: استخدم Partial<T> للسماح ببعض الحقول الاختيارية
|
|
158
|
+
return this.http.post(this.baseUrl, item);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* تحديث سجل موجود
|
|
162
|
+
*/
|
|
163
|
+
update(id, item) {
|
|
164
|
+
// ملاحظة: هنا نُعيد Observable<void> لأن API قد لا تُرجع الجسم نفسه
|
|
165
|
+
return this.http.put(`${this.baseUrl}`, item);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* حذف سجل
|
|
169
|
+
*/
|
|
170
|
+
delete(id) {
|
|
171
|
+
// ملاحظة: يُفضّل استخدام Confirm قبل الحذف في الواجهة
|
|
172
|
+
return this.http.delete(`${this.baseUrl}/${id}`);
|
|
173
|
+
}
|
|
174
|
+
/** endpoint قابل للتخصيص — يمكن للفرع override–ها */
|
|
175
|
+
getPageUrl() {
|
|
176
|
+
return this.baseUrl;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* جلب صفحة من البيانات مع دعم الفلاتر والفرز
|
|
180
|
+
* @param pageIndex صفر-based
|
|
181
|
+
* @param pageSize عدد السجلات
|
|
182
|
+
* @param filters كائن Partial<T> أو Record<string,any>
|
|
183
|
+
* @param sort نص الفرز، مثلاً "eiNa:desc"
|
|
184
|
+
*/
|
|
185
|
+
getPage(pageIndex, pageSize, filters, sort) {
|
|
186
|
+
// debugger
|
|
187
|
+
let params = new HttpParams()
|
|
188
|
+
.set('pageIndex', pageIndex.toString())
|
|
189
|
+
.set('pageSize', pageSize.toString());
|
|
190
|
+
if (filters) {
|
|
191
|
+
Object.entries(filters).forEach(([key, val]) => {
|
|
192
|
+
if (val != null && val !== '') {
|
|
193
|
+
params = params.set(key, val.toString());
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
if (sort) {
|
|
198
|
+
params = params.set('sort', sort);
|
|
199
|
+
}
|
|
200
|
+
// return this.http
|
|
201
|
+
// .get<T[]>(this.getPageUrl(), { params, observe: 'response' })
|
|
202
|
+
// .pipe(
|
|
203
|
+
// map((resp: HttpResponse<T[]>) => ({
|
|
204
|
+
// items: resp.body || [],
|
|
205
|
+
// totalCount: Number(resp.headers.get('X-Total-Count')) || resp.body?.length || 0
|
|
206
|
+
// }))
|
|
207
|
+
// );
|
|
208
|
+
return this.http.get(this.getPageUrl(), { params });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Define the `Request` token
|
|
213
|
+
const REQUEST = new InjectionToken('REQUEST');
|
|
214
|
+
class SsrCookieService {
|
|
215
|
+
document;
|
|
216
|
+
platformId;
|
|
217
|
+
request;
|
|
218
|
+
documentIsAccessible;
|
|
219
|
+
static initialUrl = '';
|
|
220
|
+
constructor(document,
|
|
221
|
+
// Get the `PLATFORM_ID` so we can check if we're in a browser.
|
|
222
|
+
platformId, request) {
|
|
223
|
+
this.document = document;
|
|
224
|
+
this.platformId = platformId;
|
|
225
|
+
this.request = request;
|
|
226
|
+
this.documentIsAccessible = isPlatformBrowser(this.platformId);
|
|
227
|
+
SsrCookieService.initialUrl = this.documentIsAccessible ? this.document.location.href : this.request?.url;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Get cookie Regular Expression
|
|
231
|
+
*
|
|
232
|
+
* @param name Cookie name
|
|
233
|
+
* @returns property RegExp
|
|
234
|
+
*
|
|
235
|
+
* @author: Stepan Suvorov
|
|
236
|
+
* @since: 1.0.0
|
|
237
|
+
*/
|
|
238
|
+
static getCookieRegExp(name) {
|
|
239
|
+
const escapedName = name.replace(/([\[\]\{\}\(\)\|\=\;\+\?\,\.\*\^\$])/gi, '\\$1');
|
|
240
|
+
return new RegExp('(?:^' + escapedName + '|;\\s*' + escapedName + ')=(.*?)(?:;|$)', 'g');
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).
|
|
244
|
+
*
|
|
245
|
+
* @param encodedURIComponent A value representing an encoded URI component.
|
|
246
|
+
*
|
|
247
|
+
* @returns The unencoded version of an encoded component of a Uniform Resource Identifier (URI).
|
|
248
|
+
*
|
|
249
|
+
* @author: Stepan Suvorov
|
|
250
|
+
* @since: 1.0.0
|
|
251
|
+
*/
|
|
252
|
+
static safeDecodeURIComponent(encodedURIComponent) {
|
|
253
|
+
try {
|
|
254
|
+
return decodeURIComponent(encodedURIComponent);
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
// probably it is not uri encoded. return as is
|
|
258
|
+
return encodedURIComponent;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Return `true` if {@link Document} is accessible, otherwise return `false`
|
|
263
|
+
*
|
|
264
|
+
* @param name Cookie name
|
|
265
|
+
* @returns boolean - whether cookie with specified name exists
|
|
266
|
+
*
|
|
267
|
+
* @author: Stepan Suvorov
|
|
268
|
+
* @since: 1.0.0
|
|
269
|
+
*/
|
|
270
|
+
check(name) {
|
|
271
|
+
name = encodeURIComponent(name);
|
|
272
|
+
const regExp = SsrCookieService.getCookieRegExp(name);
|
|
273
|
+
return regExp.test((this.documentIsAccessible ? this.document.cookie : this.request?.headers.cookie) ?? '');
|
|
274
|
+
}
|
|
275
|
+
isDocumentIsAccessible() {
|
|
276
|
+
return this.documentIsAccessible;
|
|
277
|
+
}
|
|
278
|
+
get url() {
|
|
279
|
+
return this.documentIsAccessible ? this.document.location.href : this.request?.url;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Get cookies by name
|
|
283
|
+
*
|
|
284
|
+
* @param name Cookie name
|
|
285
|
+
* @returns property value
|
|
286
|
+
*
|
|
287
|
+
* @author: Stepan Suvorov
|
|
288
|
+
* @since: 1.0.0
|
|
289
|
+
*/
|
|
290
|
+
get(name) {
|
|
291
|
+
if (this.check(name)) {
|
|
292
|
+
name = encodeURIComponent(name);
|
|
293
|
+
const regExp = SsrCookieService.getCookieRegExp(name);
|
|
294
|
+
const result = regExp.exec((this.documentIsAccessible ? this.document.cookie : this.request?.headers.cookie) ?? '');
|
|
295
|
+
return result[1] ? SsrCookieService.safeDecodeURIComponent(result[1]) : '';
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
return '';
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get all cookies in JSON format
|
|
303
|
+
*
|
|
304
|
+
* @returns all the cookies in json
|
|
305
|
+
*
|
|
306
|
+
* @author: Stepan Suvorov
|
|
307
|
+
* @since: 1.0.0
|
|
308
|
+
*/
|
|
309
|
+
getAll() {
|
|
310
|
+
const cookies = {};
|
|
311
|
+
const cookieString = this.documentIsAccessible ? this.document?.cookie : this.request?.headers.cookie;
|
|
312
|
+
if (cookieString && cookieString !== '') {
|
|
313
|
+
cookieString.split(';').forEach((currentCookie) => {
|
|
314
|
+
const [cookieName, cookieValue] = currentCookie.split('=');
|
|
315
|
+
cookies[SsrCookieService.safeDecodeURIComponent(cookieName.replace(/^ /, ''))] = SsrCookieService.safeDecodeURIComponent(cookieValue);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return cookies;
|
|
319
|
+
}
|
|
320
|
+
set(name, value, expiresOrOptions, path, domain, secure, sameSite, partitioned) {
|
|
321
|
+
if (!this.documentIsAccessible) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (typeof expiresOrOptions === 'number' || expiresOrOptions instanceof Date || path || domain || secure || sameSite) {
|
|
325
|
+
const optionsBody = {
|
|
326
|
+
expires: expiresOrOptions,
|
|
327
|
+
path,
|
|
328
|
+
domain,
|
|
329
|
+
secure,
|
|
330
|
+
sameSite: sameSite ? sameSite : 'Lax',
|
|
331
|
+
partitioned,
|
|
332
|
+
};
|
|
333
|
+
this.set(name, value, optionsBody);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
let cookieString = encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';';
|
|
337
|
+
const options = expiresOrOptions ? expiresOrOptions : {};
|
|
338
|
+
if (options.expires) {
|
|
339
|
+
if (typeof options.expires === 'number') {
|
|
340
|
+
const dateExpires = new Date(new Date().getTime() + options.expires * 1000 * 60 * 60 * 24);
|
|
341
|
+
cookieString += 'expires=' + dateExpires.toUTCString() + ';';
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
cookieString += 'expires=' + options.expires.toUTCString() + ';';
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (options.path) {
|
|
348
|
+
cookieString += 'path=' + options.path + ';';
|
|
349
|
+
}
|
|
350
|
+
if (options.domain) {
|
|
351
|
+
cookieString += 'domain=' + options.domain + ';';
|
|
352
|
+
}
|
|
353
|
+
if (options.secure === false && options.sameSite === 'None') {
|
|
354
|
+
options.secure = true;
|
|
355
|
+
console.warn(`[ngx-cookie-service] Cookie ${name} was forced with secure flag because sameSite=None.` +
|
|
356
|
+
`More details : https://github.com/stevermeister/ngx-cookie-service/issues/86#issuecomment-597720130`);
|
|
357
|
+
}
|
|
358
|
+
if (options.secure) {
|
|
359
|
+
cookieString += 'secure;';
|
|
360
|
+
}
|
|
361
|
+
if (!options.sameSite) {
|
|
362
|
+
options.sameSite = 'Lax';
|
|
363
|
+
}
|
|
364
|
+
cookieString += 'sameSite=' + options.sameSite + ';';
|
|
365
|
+
if (options.partitioned) {
|
|
366
|
+
cookieString += 'Partitioned;';
|
|
367
|
+
}
|
|
368
|
+
this.document.cookie = cookieString;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Delete cookie by name
|
|
372
|
+
*
|
|
373
|
+
* @param name Cookie name
|
|
374
|
+
* @param path Cookie path
|
|
375
|
+
* @param domain Cookie domain
|
|
376
|
+
* @param secure Cookie secure flag
|
|
377
|
+
* @param sameSite Cookie sameSite flag - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
|
|
378
|
+
*
|
|
379
|
+
* @author: Stepan Suvorov
|
|
380
|
+
* @since: 1.0.0
|
|
381
|
+
*/
|
|
382
|
+
delete(name, path, domain, secure, sameSite = 'Lax') {
|
|
383
|
+
if (!this.documentIsAccessible) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const expiresDate = new Date('Thu, 01 Jan 1970 00:00:01 GMT');
|
|
387
|
+
this.set(name, '', { expires: expiresDate, path, domain, secure, sameSite });
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Delete all cookies
|
|
391
|
+
*
|
|
392
|
+
* @param path Cookie path
|
|
393
|
+
* @param domain Cookie domain
|
|
394
|
+
* @param secure Is the Cookie secure
|
|
395
|
+
* @param sameSite Is the cookie same site
|
|
396
|
+
*
|
|
397
|
+
* @author: Stepan Suvorov
|
|
398
|
+
* @since: 1.0.0
|
|
399
|
+
*/
|
|
400
|
+
deleteAll(path, domain, secure, sameSite = 'Lax') {
|
|
401
|
+
if (!this.documentIsAccessible) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
const cookies = this.getAll();
|
|
405
|
+
for (const cookieName in cookies) {
|
|
406
|
+
if (cookies.hasOwnProperty(cookieName)) {
|
|
407
|
+
this.delete(cookieName, path, domain, secure, sameSite);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: SsrCookieService, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: REQUEST, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
412
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: SsrCookieService, providedIn: 'root' });
|
|
413
|
+
}
|
|
414
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: SsrCookieService, decorators: [{
|
|
415
|
+
type: Injectable,
|
|
416
|
+
args: [{
|
|
417
|
+
providedIn: 'root',
|
|
418
|
+
}]
|
|
419
|
+
}], ctorParameters: () => [{ type: Document, decorators: [{
|
|
420
|
+
type: Inject,
|
|
421
|
+
args: [DOCUMENT]
|
|
422
|
+
}] }, { type: undefined, decorators: [{
|
|
423
|
+
type: Inject,
|
|
424
|
+
args: [PLATFORM_ID]
|
|
425
|
+
}] }, { type: undefined, decorators: [{
|
|
426
|
+
type: Optional
|
|
427
|
+
}, {
|
|
428
|
+
type: Inject,
|
|
429
|
+
args: [REQUEST]
|
|
430
|
+
}] }] });
|
|
431
|
+
|
|
432
|
+
// app/shared/services/swal.service.ts
|
|
433
|
+
class SwalService {
|
|
434
|
+
/** رسالة تأكيد قبل تنفيذ إجراء */
|
|
435
|
+
confirm(title = 'هل أنت متأكد؟', text = 'لن يمكنك التراجع عن هذا الإجراء', confirmButtonText = 'نعم', cancelButtonText = 'إلغاء') {
|
|
436
|
+
return Swal.fire({
|
|
437
|
+
icon: 'warning',
|
|
438
|
+
title,
|
|
439
|
+
text,
|
|
440
|
+
showCancelButton: true,
|
|
441
|
+
confirmButtonText,
|
|
442
|
+
cancelButtonText,
|
|
443
|
+
// reverseButtons: true,
|
|
444
|
+
customClass: {
|
|
445
|
+
container: 'swal2-container' // ✅ أضف هذه الفئة
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
/** رسالة نجاح */
|
|
450
|
+
success(title, text, timer = 2000) {
|
|
451
|
+
return Swal.fire({
|
|
452
|
+
icon: 'success',
|
|
453
|
+
title,
|
|
454
|
+
text,
|
|
455
|
+
timer,
|
|
456
|
+
showConfirmButton: false,
|
|
457
|
+
customClass: {
|
|
458
|
+
container: 'swal2-container' // ✅ أضف هذه الفئة
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
/** رسالة خطأ */
|
|
463
|
+
error(title, text, footer) {
|
|
464
|
+
return Swal.fire({
|
|
465
|
+
icon: 'error',
|
|
466
|
+
title,
|
|
467
|
+
text,
|
|
468
|
+
footer,
|
|
469
|
+
customClass: {
|
|
470
|
+
container: 'swal2-container' // ✅ أضف هذه الفئة
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
/** رسالة معلومات */
|
|
475
|
+
info(title, text) {
|
|
476
|
+
return Swal.fire({
|
|
477
|
+
icon: 'info',
|
|
478
|
+
title,
|
|
479
|
+
text,
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
/** عرض نافذة SweetAlert2 بأي خيارات تريد */
|
|
483
|
+
alert(options) {
|
|
484
|
+
return Swal.fire(options);
|
|
485
|
+
}
|
|
486
|
+
/** Toast بسيط قابل لإعادة الاستخدام */
|
|
487
|
+
toast(title, icon = 'info', position = 'top-end', timer = 3000) {
|
|
488
|
+
const Toast = Swal.mixin({
|
|
489
|
+
toast: true,
|
|
490
|
+
position,
|
|
491
|
+
timer,
|
|
492
|
+
showConfirmButton: false,
|
|
493
|
+
});
|
|
494
|
+
Toast.fire({ icon, title });
|
|
495
|
+
}
|
|
496
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: SwalService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
497
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: SwalService, providedIn: 'root' });
|
|
498
|
+
}
|
|
499
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: SwalService, decorators: [{
|
|
500
|
+
type: Injectable,
|
|
501
|
+
args: [{ providedIn: 'root' }]
|
|
502
|
+
}] });
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Generated bundle index. Do not edit.
|
|
506
|
+
*/
|
|
507
|
+
|
|
508
|
+
export { BaseService, GenericService, REQUEST, RestService, SsrCookieService, SwalService, isUndefinedOrEmptyString };
|
|
509
|
+
//# sourceMappingURL=elite.framework-ng.core-services.mjs.map
|