angular-generate 2.2.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 +149 -0
- package/explication_conception.md +119 -0
- package/package.json +28 -0
- package/src/api/index.d.ts +2 -0
- package/src/api/index.js +18 -0
- package/src/api/index.js.map +1 -0
- package/src/api/index_spec.d.ts +1 -0
- package/src/api/index_spec.js +23 -0
- package/src/api/index_spec.js.map +1 -0
- package/src/api/schema.json +17 -0
- package/src/collection.json +88 -0
- package/src/component/add/index.d.ts +2 -0
- package/src/component/add/index.js +64 -0
- package/src/component/add/index.js.map +1 -0
- package/src/component/add/index_spec.d.ts +1 -0
- package/src/component/add/index_spec.js +23 -0
- package/src/component/add/index_spec.js.map +1 -0
- package/src/component/deconnexion/index.d.ts +2 -0
- package/src/component/deconnexion/index.js +88 -0
- package/src/component/deconnexion/index.js.map +1 -0
- package/src/component/deconnexion/index_spec.d.ts +1 -0
- package/src/component/deconnexion/index_spec.js +23 -0
- package/src/component/deconnexion/index_spec.js.map +1 -0
- package/src/component/details/index.d.ts +2 -0
- package/src/component/details/index.js +12 -0
- package/src/component/details/index.js.map +1 -0
- package/src/component/details/index_spec.d.ts +1 -0
- package/src/component/details/index_spec.js +23 -0
- package/src/component/details/index_spec.js.map +1 -0
- package/src/component/edit/index.d.ts +2 -0
- package/src/component/edit/index.js +63 -0
- package/src/component/edit/index.js.map +1 -0
- package/src/component/edit/index_spec.d.ts +1 -0
- package/src/component/edit/index_spec.js +23 -0
- package/src/component/edit/index_spec.js.map +1 -0
- package/src/component/header/index.d.ts +2 -0
- package/src/component/header/index.js +311 -0
- package/src/component/header/index.js.map +1 -0
- package/src/component/list/index.d.ts +2 -0
- package/src/component/list/index.js +64 -0
- package/src/component/list/index.js.map +1 -0
- package/src/component/list/index_spec.d.ts +1 -0
- package/src/component/list/index_spec.js +23 -0
- package/src/component/list/index_spec.js.map +1 -0
- package/src/component/login/index.d.ts +2 -0
- package/src/component/login/index.js +314 -0
- package/src/component/login/index.js.map +1 -0
- package/src/component/login/index_spec.d.ts +1 -0
- package/src/component/login/index_spec.js +23 -0
- package/src/component/login/index_spec.js.map +1 -0
- package/src/component/not-found/index.d.ts +2 -0
- package/src/component/not-found/index.js +68 -0
- package/src/component/not-found/index.js.map +1 -0
- package/src/component/not-found/index_spec.d.ts +1 -0
- package/src/component/not-found/index_spec.js +23 -0
- package/src/component/not-found/index_spec.js.map +1 -0
- package/src/component/sidebar/index.d.ts +2 -0
- package/src/component/sidebar/index.js +247 -0
- package/src/component/sidebar/index.js.map +1 -0
- package/src/component/test/index.d.ts +2 -0
- package/src/component/test/index.js +20 -0
- package/src/component/test/index.js.map +1 -0
- package/src/component/test/index_spec.d.ts +1 -0
- package/src/component/test/index_spec.js +23 -0
- package/src/component/test/index_spec.js.map +1 -0
- package/src/component/type/index.d.ts +2 -0
- package/src/component/type/index.js +45 -0
- package/src/component/type/index.js.map +1 -0
- package/src/component/type/index_spec.d.ts +1 -0
- package/src/component/type/index_spec.js +23 -0
- package/src/component/type/index_spec.js.map +1 -0
- package/src/component/wrapper/index.d.ts +2 -0
- package/src/component/wrapper/index.js +175 -0
- package/src/component/wrapper/index.js.map +1 -0
- package/src/component/wrapper/index_spec.d.ts +1 -0
- package/src/component/wrapper/index_spec.js +23 -0
- package/src/component/wrapper/index_spec.js.map +1 -0
- package/src/config/index.d.ts +2 -0
- package/src/config/index.js +166 -0
- package/src/config/index.js.map +1 -0
- package/src/config/index_spec.d.ts +1 -0
- package/src/config/index_spec.js +23 -0
- package/src/config/index_spec.js.map +1 -0
- package/src/config/schema.json +31 -0
- package/src/guard/auth/index.d.ts +2 -0
- package/src/guard/auth/index.js +60 -0
- package/src/guard/auth/index.js.map +1 -0
- package/src/guard/auth/index_spec.d.ts +1 -0
- package/src/guard/auth/index_spec.js +23 -0
- package/src/guard/auth/index_spec.js.map +1 -0
- package/src/guard/permissions/index.d.ts +2 -0
- package/src/guard/permissions/index.js +51 -0
- package/src/guard/permissions/index.js.map +1 -0
- package/src/guard/permissions/index_spec.d.ts +1 -0
- package/src/guard/permissions/index_spec.js +23 -0
- package/src/guard/permissions/index_spec.js.map +1 -0
- package/src/module/index.d.ts +2 -0
- package/src/module/index.js +94 -0
- package/src/module/index.js.map +1 -0
- package/src/module/index_spec.d.ts +1 -0
- package/src/module/index_spec.js +23 -0
- package/src/module/index_spec.js.map +1 -0
- package/src/module/schema.json +17 -0
- package/src/other/taf-add-import-to-module/index.d.ts +2 -0
- package/src/other/taf-add-import-to-module/index.js +20 -0
- package/src/other/taf-add-import-to-module/index.js.map +1 -0
- package/src/other/taf-add-import-to-module/index_spec.d.ts +1 -0
- package/src/other/taf-add-import-to-module/index_spec.js +23 -0
- package/src/other/taf-add-import-to-module/index_spec.js.map +1 -0
- package/src/service/api/index.d.ts +2 -0
- package/src/service/api/index.js +508 -0
- package/src/service/api/index.js.map +1 -0
- package/src/service/api/index_spec.d.ts +1 -0
- package/src/service/api/index_spec.js +23 -0
- package/src/service/api/index_spec.js.map +1 -0
- package/src/templates/add/add.html.d.ts +1 -0
- package/src/templates/add/add.html.js +124 -0
- package/src/templates/add/add.html.js.map +1 -0
- package/src/templates/add/add.ts.d.ts +1 -0
- package/src/templates/add/add.ts.js +112 -0
- package/src/templates/add/add.ts.js.map +1 -0
- package/src/templates/edit/edit.html.d.ts +1 -0
- package/src/templates/edit/edit.html.js +121 -0
- package/src/templates/edit/edit.html.js.map +1 -0
- package/src/templates/edit/edit.ts.d.ts +1 -0
- package/src/templates/edit/edit.ts.js +117 -0
- package/src/templates/edit/edit.ts.js.map +1 -0
- package/src/templates/list/list.html.d.ts +1 -0
- package/src/templates/list/list.html.js +98 -0
- package/src/templates/list/list.html.js.map +1 -0
- package/src/templates/list/list.ts.d.ts +2 -0
- package/src/templates/list/list.ts.js +144 -0
- package/src/templates/list/list.ts.js.map +1 -0
- package/src/templates/test/test.ts.d.ts +4 -0
- package/src/templates/test/test.ts.js +145 -0
- package/src/templates/test/test.ts.js.map +1 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const collectionPath = path.join(__dirname, '../collection.json');
|
|
16
|
+
describe('config-add-import-to-module', () => {
|
|
17
|
+
it('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
19
|
+
const tree = yield runner.runSchematic('config-add-import-to-module', {}, schematics_1.Tree.empty());
|
|
20
|
+
expect(tree.files).toEqual([]);
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index_spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAkD;AAClD,gEAAyE;AACzE,6BAA6B;AAE7B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAElE,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,EAAE,CAAC,OAAO,EAAE,GAAS,EAAE;QACrB,MAAM,MAAM,GAAG,IAAI,6BAAmB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACrE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,6BAA6B,EAAE,EAAE,EAAE,iBAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAExF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.api = void 0;
|
|
4
|
+
const strings_1 = require("@angular-devkit/core/src/utils/strings");
|
|
5
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
+
// You don't have to export the function as default. You can also have more than one rule factory
|
|
7
|
+
// per file.
|
|
8
|
+
function api(_options) {
|
|
9
|
+
let { projectName, Config } = _options;
|
|
10
|
+
let serviceName = "api";
|
|
11
|
+
return (tree) => {
|
|
12
|
+
// Le composant existe dèja
|
|
13
|
+
let c_path = `/src/app/service/${serviceName}/${serviceName}.service.ts`;
|
|
14
|
+
let c_path_idb = `/src/app/service/idb/idb.service.ts`;
|
|
15
|
+
if (tree.exists(c_path) && tree.exists(c_path_idb)) {
|
|
16
|
+
console.warn(`Le service ${serviceName} && IdbService existe dèja : ${c_path}`);
|
|
17
|
+
return tree;
|
|
18
|
+
}
|
|
19
|
+
// le composant n'existe pas encore
|
|
20
|
+
return (0, schematics_1.chain)([
|
|
21
|
+
// création du service
|
|
22
|
+
(0, schematics_1.externalSchematic)("@schematics/angular", "service", { project: projectName, name: `service/${serviceName}/${serviceName}` }),
|
|
23
|
+
// modification des fichiers
|
|
24
|
+
(tree) => {
|
|
25
|
+
// modifier le fichier TS
|
|
26
|
+
tree.overwrite(`src/app/service/${serviceName}/${serviceName}.service.ts`, // service/api/api.service.ts
|
|
27
|
+
get_ts_content(projectName, Config));
|
|
28
|
+
},
|
|
29
|
+
// création du service
|
|
30
|
+
(0, schematics_1.externalSchematic)("@schematics/angular", "service", { project: projectName, name: `service/idb/idb` }),
|
|
31
|
+
// modification des fichiers
|
|
32
|
+
(tree) => {
|
|
33
|
+
// modifier le fichier TS
|
|
34
|
+
tree.overwrite(`src/app/service/idb/idb.service.ts`, // service/api/api.service.ts
|
|
35
|
+
get_ts_content_idb(projectName));
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.api = api;
|
|
41
|
+
function get_ts_content(projectName, Config) {
|
|
42
|
+
let module = "home";
|
|
43
|
+
let les_tables = Config.les_modules.find((un_module) => un_module.module == module).les_tables;
|
|
44
|
+
let items = les_tables.map((une_table) => {
|
|
45
|
+
return `
|
|
46
|
+
{
|
|
47
|
+
text: "${(0, strings_1.classify)(une_table.table)}",
|
|
48
|
+
path: "/${module}/${une_table.table}",
|
|
49
|
+
icon: "bi bi-speedometer",
|
|
50
|
+
privileges: [],
|
|
51
|
+
items: [],
|
|
52
|
+
show_on_sidebar: true,
|
|
53
|
+
les_actions: [
|
|
54
|
+
{ id: "add_${une_table.table}", description: "Ajouter un ${une_table.table}" },
|
|
55
|
+
{ id: "edit_${une_table.table}", description: "Modifier un ${une_table.table}" },
|
|
56
|
+
{ id: "delete_${une_table.table}", description: "Supprimer un ${une_table.table}" },
|
|
57
|
+
{ id: "liste_${une_table.table}", description: "Lister les ${une_table.table}" },
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
}).join(",");
|
|
62
|
+
let api_base_url = Config.config_base_url;
|
|
63
|
+
return `import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
64
|
+
import { Injectable } from '@angular/core';
|
|
65
|
+
import { Router } from '@angular/router';
|
|
66
|
+
import { JwtHelperService } from '@auth0/angular-jwt';
|
|
67
|
+
import { IdbService } from '../idb/idb.service';
|
|
68
|
+
import Swal from 'sweetalert2';
|
|
69
|
+
import { Location } from '@angular/common';
|
|
70
|
+
import moment from 'moment';
|
|
71
|
+
import { lastValueFrom } from 'rxjs';
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@Injectable({
|
|
75
|
+
providedIn: 'root'
|
|
76
|
+
})
|
|
77
|
+
export class ApiService {
|
|
78
|
+
local_storage_prefixe = "${projectName}";
|
|
79
|
+
api_base_url = "${api_base_url}";
|
|
80
|
+
menu: any = [];
|
|
81
|
+
network: any = {
|
|
82
|
+
token: undefined,
|
|
83
|
+
status: true,
|
|
84
|
+
message: "Aucun probléme détecté",
|
|
85
|
+
}
|
|
86
|
+
token: any = {
|
|
87
|
+
token: null,
|
|
88
|
+
// token_decoded: null,
|
|
89
|
+
user_connected: null,
|
|
90
|
+
// is_expired: null,
|
|
91
|
+
// date_expiration: null
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
current_entreprise: any =JSON.parse(localStorage.getItem("current_entreprise")?? '{}');
|
|
95
|
+
id_current_entreprise: any = localStorage.getItem("id_current_entreprise") ?? '{}';
|
|
96
|
+
id_current_privilege: any = localStorage.getItem("id_current_privilege") ?? '{}';
|
|
97
|
+
user_permissions: any = localStorage.getItem("user_permissions") ?? '[]';
|
|
98
|
+
loading_current_entreprise = false;
|
|
99
|
+
|
|
100
|
+
constructor(private http: HttpClient, private route: Router, private idb: IdbService,public _location: Location) { }
|
|
101
|
+
// sauvegardes
|
|
102
|
+
async get_from_local_storage(key: string): Promise<any> {
|
|
103
|
+
try {
|
|
104
|
+
let res: any = await this.idb.get_from_indexedDB(key)
|
|
105
|
+
return res
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error("erreur de recuperation", error)
|
|
108
|
+
return null
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async save_on_local_storage(key: string, value: any): Promise<void> {
|
|
112
|
+
await this.idb.save_on_indexedDB(key, value);
|
|
113
|
+
}
|
|
114
|
+
async delete_from_local_storage(key: string) {
|
|
115
|
+
await this.idb.delete_from_indexedDB(key);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
async get_token() {
|
|
120
|
+
// //le token n'est pas encore chargé
|
|
121
|
+
// if (this.network.token == undefined) {
|
|
122
|
+
// this.network.token = await this.get_from_local_storage("token").token
|
|
123
|
+
// if (this.network.token != undefined && this.network.token != null) {// token existant
|
|
124
|
+
// this.update_data_from_token()// mise a jour du token
|
|
125
|
+
// }
|
|
126
|
+
// } else {// token dèja chargé
|
|
127
|
+
// this.update_data_from_token()// mise a jour du token
|
|
128
|
+
// }
|
|
129
|
+
// console.warn((await this.get_from_local_storage("token")).token)
|
|
130
|
+
if (this.token.token == null) {
|
|
131
|
+
this.update_data_from_token();
|
|
132
|
+
}
|
|
133
|
+
return (await this.get_from_local_storage("token"))?.token
|
|
134
|
+
}
|
|
135
|
+
async get_token_profil() {
|
|
136
|
+
return (await this.get_from_local_storage("token"))?.data
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Les routes HTTP
|
|
140
|
+
async api_post(path: string, data_to_send: any): Promise<any> {
|
|
141
|
+
let api_url = this.api_base_url + path;
|
|
142
|
+
const httpOptions = {
|
|
143
|
+
headers: new HttpHeaders({
|
|
144
|
+
Authorization: "Bearer " + await this.get_token(),
|
|
145
|
+
})
|
|
146
|
+
};
|
|
147
|
+
try {
|
|
148
|
+
return await lastValueFrom(this.http.post(api_url, data_to_send, httpOptions));
|
|
149
|
+
} catch (error: any) {
|
|
150
|
+
this.on_api_post_error(error);
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
on_api_get_error(error: any) {
|
|
156
|
+
this.network.status = false;
|
|
157
|
+
this.network.message = error;
|
|
158
|
+
this.Swal_info("Merci de vérifier votre connexion");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async api_get(path: string): Promise<any> {
|
|
162
|
+
let api_url = this.api_base_url + path;
|
|
163
|
+
const httpOptions = {
|
|
164
|
+
headers: new HttpHeaders({
|
|
165
|
+
Authorization: "Bearer " + await this.get_token(),
|
|
166
|
+
})
|
|
167
|
+
};
|
|
168
|
+
try {
|
|
169
|
+
return await lastValueFrom(this.http.get(api_url, httpOptions));
|
|
170
|
+
} catch (error: any) {
|
|
171
|
+
this.on_api_get_error(error);
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async api_delete(path: string): Promise<any> {
|
|
177
|
+
let api_url = this.api_base_url + path;
|
|
178
|
+
const httpOptions = {
|
|
179
|
+
headers: new HttpHeaders({
|
|
180
|
+
Authorization: "Bearer " + await this.get_token(),
|
|
181
|
+
})
|
|
182
|
+
};
|
|
183
|
+
try {
|
|
184
|
+
return await lastValueFrom(this.http.delete(api_url, httpOptions));
|
|
185
|
+
} catch (error: any) {
|
|
186
|
+
this.on_api_get_error(error);
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async api_put(path: string, data_to_send: any): Promise<any> {
|
|
192
|
+
let api_url = this.api_base_url + path;
|
|
193
|
+
const httpOptions = {
|
|
194
|
+
headers: new HttpHeaders({
|
|
195
|
+
Authorization: "Bearer " + await this.get_token(),
|
|
196
|
+
})
|
|
197
|
+
};
|
|
198
|
+
try {
|
|
199
|
+
return await lastValueFrom(this.http.put(api_url, data_to_send, httpOptions));
|
|
200
|
+
} catch (error: any) {
|
|
201
|
+
this.on_api_post_error(error);
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async api_post_login(path: string, data_to_send: any): Promise<any> {
|
|
207
|
+
let api_url = this.api_base_url + path;
|
|
208
|
+
try {
|
|
209
|
+
return await lastValueFrom(this.http.post(api_url, data_to_send));
|
|
210
|
+
} catch (error: any) {
|
|
211
|
+
this.on_api_post_error(error);
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
on_api_post_error(error: any) {
|
|
217
|
+
this.network.status = false;
|
|
218
|
+
this.network.message = error;
|
|
219
|
+
this.Swal_info("Merci de vérifier votre connexion");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
async update_data_from_token() {
|
|
224
|
+
let token_key = (await this.get_from_local_storage("token"))
|
|
225
|
+
// const helper = new JwtHelperService();
|
|
226
|
+
// const decodedToken = helper.decodeToken(token_key);
|
|
227
|
+
// const expirationDate = helper.getTokenExpirationDate(token_key);
|
|
228
|
+
// const isExpired = helper.isTokenExpired(token_key);
|
|
229
|
+
|
|
230
|
+
this.token = {
|
|
231
|
+
token: token_key?.token,
|
|
232
|
+
// token_decoded: decodedToken,
|
|
233
|
+
user_connected: token_key?.data,
|
|
234
|
+
// is_expired: isExpired,
|
|
235
|
+
// date_expiration: expirationDate
|
|
236
|
+
}
|
|
237
|
+
if (this.token?.is_expired) {
|
|
238
|
+
this.on_token_expire()
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
on_token_expire() {
|
|
242
|
+
this.Swal_info("Votre session s'est expiré! Veuillez vous connecter à nouveau")
|
|
243
|
+
this.delete_from_local_storage("token")
|
|
244
|
+
this.route.navigate(['/public/login'])
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
Swal_success(title: any) {
|
|
248
|
+
let succes = Swal.fire({
|
|
249
|
+
position: 'top-end',
|
|
250
|
+
icon: 'success',
|
|
251
|
+
title: title,
|
|
252
|
+
showConfirmButton: false,
|
|
253
|
+
timer: 1000,
|
|
254
|
+
toast: true,
|
|
255
|
+
timerProgressBar: true,
|
|
256
|
+
});
|
|
257
|
+
return succes
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
Swal_error(title: any) {
|
|
261
|
+
let succes = Swal.fire({
|
|
262
|
+
position: 'top-end',
|
|
263
|
+
icon: 'error',
|
|
264
|
+
title: title,
|
|
265
|
+
showConfirmButton: false,
|
|
266
|
+
timer: 1500,
|
|
267
|
+
toast: true,
|
|
268
|
+
timerProgressBar: true,
|
|
269
|
+
});
|
|
270
|
+
return succes
|
|
271
|
+
}
|
|
272
|
+
Swal_info(title: any) {
|
|
273
|
+
let succes = Swal.fire({
|
|
274
|
+
position: 'top-end',
|
|
275
|
+
icon: 'info',
|
|
276
|
+
title: title,
|
|
277
|
+
showConfirmButton: false,
|
|
278
|
+
timer: 1500,
|
|
279
|
+
toast: true,
|
|
280
|
+
timerProgressBar: true,
|
|
281
|
+
});
|
|
282
|
+
return succes
|
|
283
|
+
}
|
|
284
|
+
Swal_blue(title: any) {
|
|
285
|
+
let succes = Swal.fire({
|
|
286
|
+
position: 'top-end',
|
|
287
|
+
icon: 'info',
|
|
288
|
+
title: title,
|
|
289
|
+
showConfirmButton: false,
|
|
290
|
+
timer: 1500,
|
|
291
|
+
toast: true,
|
|
292
|
+
timerProgressBar: true,
|
|
293
|
+
});
|
|
294
|
+
return succes
|
|
295
|
+
}
|
|
296
|
+
is_already_selected(id: any, form: any, condition: string) {//la fonction désactive les options déja sélectionné dans le select
|
|
297
|
+
let is_in=form.filter((one_detail: any) => one_detail[condition] == id)[0]?.[condition];
|
|
298
|
+
return is_in;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
format_date(date_string: string) {
|
|
302
|
+
return {
|
|
303
|
+
full: moment(date_string).locale("fr").format("dddd Do MMMM YYYY"),// 27 février 2023
|
|
304
|
+
jma: moment(date_string).locale("fr").format("Do MMMM YYYY"),// jeudi ...
|
|
305
|
+
jma2: moment(date_string).locale("fr").format("DD-MM-YYYY"),// 01-11-2023
|
|
306
|
+
jma3: moment(date_string).locale("fr").format("YYYY-MM-DD"),// 2023-10-21
|
|
307
|
+
jma3_hour: moment(date_string).locale("fr").format("YYYY-MM-DD HH:mm"),// 2023-10-21 14:50
|
|
308
|
+
full_datetime: moment(date_string).locale("fr").format("dddd Do MMMM YYYY à HH:mm"),// 27 février 2023
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
format_current_date() {
|
|
312
|
+
return {
|
|
313
|
+
full: moment().locale("fr").format("dddd Do MMMM YYYY"),// 27 février 2023
|
|
314
|
+
jma: moment().locale("fr").format("Do MMMM YYYY"),// jeudi ...
|
|
315
|
+
jma2: moment().locale("fr").format("DD-MM-YYYY"),// 01-11-2023
|
|
316
|
+
jma3: moment().locale("fr").format("YYYY-MM-DD"),// 2023-10-21
|
|
317
|
+
jma3_hour: moment().locale("fr").format("YYYY-MM-DD HH:mm"),// 2023-10-21 14:50
|
|
318
|
+
full_datetime: moment().locale("fr").format("dddd Do MMMM YYYY à HH:mm"),// 27 février 2023
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
les_droits: any = {
|
|
323
|
+
// Gestion de la parti commerciale
|
|
324
|
+
"produit.add": [1, 5, 6, 8],
|
|
325
|
+
"produit.edit": [1, 5, 6, 8],
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
full_menu: any[] = [
|
|
329
|
+
{
|
|
330
|
+
menu_header: "Projet",
|
|
331
|
+
items: [${items}]
|
|
332
|
+
},];
|
|
333
|
+
|
|
334
|
+
can(action: string) {
|
|
335
|
+
// Vérifie d’abord qu’on a bien les permissions chargées
|
|
336
|
+
if (!this.user_permissions || !Array.isArray(this.user_permissions)) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// On vérifie si l’action existe dans le tableau des permissions
|
|
341
|
+
return this.user_permissions.some((perm: any) => perm.id === action);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
custom_menu() {
|
|
345
|
+
if (!this.user_permissions || !Array.isArray(this.user_permissions)) {
|
|
346
|
+
this.user_permissions = JSON.parse(localStorage.getItem("user_permissions") ?? '[]');
|
|
347
|
+
}
|
|
348
|
+
// Liste des IDs d’actions autorisées (ex: ["add_Vente", "edit_produit"])
|
|
349
|
+
const permission_ids = this.user_permissions.map((p: any) => p.id);
|
|
350
|
+
|
|
351
|
+
this.menu = this.full_menu
|
|
352
|
+
.map((section: any) => {
|
|
353
|
+
const new_section = { ...section };
|
|
354
|
+
|
|
355
|
+
// Ne garde que les items avec au moins une action autorisée
|
|
356
|
+
new_section.items = section.items.filter((item: any) => {
|
|
357
|
+
if (!item.les_actions || item.les_actions.length === 0) return false;
|
|
358
|
+
|
|
359
|
+
// Vérifie si au moins une action de l’item est dans les permissions
|
|
360
|
+
return item.les_actions.some((act: any) =>
|
|
361
|
+
permission_ids.includes(act.id)
|
|
362
|
+
);
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
return new_section;
|
|
366
|
+
})
|
|
367
|
+
// Supprime les sections vides
|
|
368
|
+
.filter((section: any) => section.items.length > 0);
|
|
369
|
+
|
|
370
|
+
console.log('MENU Adapté aux privileges:', this.menu);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
retour() {
|
|
374
|
+
this._location.back()
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
formatNumber(value: any): string {
|
|
378
|
+
if (!value || isNaN(Number(value))) {
|
|
379
|
+
return value; // Retourne la valeur telle quelle si elle est null, vide ou non numérique
|
|
380
|
+
}
|
|
381
|
+
return Number(value).toLocaleString('fr-FR'); // Utilise Number.toLocaleString pour formater le nombre
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
}`;
|
|
385
|
+
}
|
|
386
|
+
function get_ts_content_idb(projectName) {
|
|
387
|
+
return `import { Injectable } from '@angular/core';
|
|
388
|
+
|
|
389
|
+
@Injectable({
|
|
390
|
+
providedIn: 'root'
|
|
391
|
+
})
|
|
392
|
+
export class IdbService {
|
|
393
|
+
private dbName = '${projectName}';
|
|
394
|
+
private storeName = 'db';
|
|
395
|
+
private local_storage_prefixe = 'jt_';
|
|
396
|
+
|
|
397
|
+
constructor() {
|
|
398
|
+
this.initDB();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Initialiser IndexedDB
|
|
402
|
+
private initDB(): void {
|
|
403
|
+
const request = indexedDB.open(this.dbName, 1);
|
|
404
|
+
|
|
405
|
+
request.onupgradeneeded = (event: any) => {
|
|
406
|
+
const db = event.target.result;
|
|
407
|
+
|
|
408
|
+
// Crée une object store s'il n'existe pas déjà
|
|
409
|
+
if (!db.objectStoreNames.contains(this.storeName)) {
|
|
410
|
+
db.createObjectStore(this.storeName, { keyPath: 'key' });
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
request.onerror = (event) => {
|
|
415
|
+
console.error('Erreur lors de l’ouverture d’IndexedDB :', event);
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
request.onsuccess = (event) => {
|
|
419
|
+
console.log('IndexedDB initialisé avec succès');
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Récupérer une valeur par clé
|
|
424
|
+
async get_from_indexedDB(key: string): Promise<any> {
|
|
425
|
+
return new Promise((resolve, reject) => {
|
|
426
|
+
const prefixedKey = this.local_storage_prefixe + key;
|
|
427
|
+
const request = indexedDB.open(this.dbName);
|
|
428
|
+
|
|
429
|
+
request.onsuccess = (event: any) => {
|
|
430
|
+
const db = event.target.result;
|
|
431
|
+
const transaction = db.transaction(this.storeName, 'readonly');
|
|
432
|
+
const store = transaction.objectStore(this.storeName);
|
|
433
|
+
|
|
434
|
+
const getRequest = store.get(prefixedKey);
|
|
435
|
+
getRequest.onsuccess = () => {
|
|
436
|
+
resolve(getRequest.result ? getRequest.result.value : null);
|
|
437
|
+
};
|
|
438
|
+
getRequest.onerror = () => {
|
|
439
|
+
console.error('Erreur de récupération depuis IndexedDB');
|
|
440
|
+
reject(getRequest.error);
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
request.onerror = () => {
|
|
445
|
+
console.error('Erreur d’accès à IndexedDB');
|
|
446
|
+
reject(request.error);
|
|
447
|
+
};
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// Sauvegarder une valeur
|
|
452
|
+
async save_on_indexedDB(key: string, value: any): Promise<void> {
|
|
453
|
+
return new Promise((resolve, reject) => {
|
|
454
|
+
const prefixedKey = this.local_storage_prefixe + key;
|
|
455
|
+
const request = indexedDB.open(this.dbName);
|
|
456
|
+
|
|
457
|
+
request.onsuccess = (event: any) => {
|
|
458
|
+
const db = event.target.result;
|
|
459
|
+
const transaction = db.transaction(this.storeName, 'readwrite');
|
|
460
|
+
const store = transaction.objectStore(this.storeName);
|
|
461
|
+
|
|
462
|
+
const putRequest = store.put({ key: prefixedKey, value });
|
|
463
|
+
putRequest.onsuccess = () => {
|
|
464
|
+
resolve();
|
|
465
|
+
};
|
|
466
|
+
putRequest.onerror = () => {
|
|
467
|
+
console.error('Erreur lors de la sauvegarde dans IndexedDB');
|
|
468
|
+
reject(putRequest.error);
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
request.onerror = () => {
|
|
473
|
+
console.error('Erreur d’accès à IndexedDB');
|
|
474
|
+
reject(request.error);
|
|
475
|
+
};
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Supprimer une valeur par clé
|
|
480
|
+
async delete_from_indexedDB(key: string): Promise<void> {
|
|
481
|
+
return new Promise((resolve, reject) => {
|
|
482
|
+
const prefixedKey = this.local_storage_prefixe + key;
|
|
483
|
+
const request = indexedDB.open(this.dbName);
|
|
484
|
+
|
|
485
|
+
request.onsuccess = (event: any) => {
|
|
486
|
+
const db = event.target.result;
|
|
487
|
+
const transaction = db.transaction(this.storeName, 'readwrite');
|
|
488
|
+
const store = transaction.objectStore(this.storeName);
|
|
489
|
+
|
|
490
|
+
const deleteRequest = store.delete(prefixedKey);
|
|
491
|
+
deleteRequest.onsuccess = () => {
|
|
492
|
+
resolve();
|
|
493
|
+
};
|
|
494
|
+
deleteRequest.onerror = () => {
|
|
495
|
+
console.error('Erreur lors de la suppression dans IndexedDB');
|
|
496
|
+
reject(deleteRequest.error);
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
request.onerror = () => {
|
|
501
|
+
console.error('Erreur d’accès à IndexedDB');
|
|
502
|
+
reject(request.error);
|
|
503
|
+
};
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
}`;
|
|
507
|
+
}
|
|
508
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const collectionPath = path.join(__dirname, '../collection.json');
|
|
16
|
+
describe('service/api', () => {
|
|
17
|
+
it('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
19
|
+
const tree = yield runner.runSchematic('service/api', {}, schematics_1.Tree.empty());
|
|
20
|
+
expect(tree.files).toEqual([]);
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index_spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAkD;AAClD,gEAAyE;AACzE,6BAA6B;AAE7B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAElE,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,OAAO,EAAE,GAAS,EAAE;QACrB,MAAM,MAAM,GAAG,IAAI,6BAAmB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACrE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,EAAE,iBAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAExE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function get_html_content(table: any): string;
|