complexqa_frontend_core 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "complexqa_frontend_core",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "core of web ",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,4 +1,4 @@
1
- import { clone_object, echo, is_array } from "../utils/utils";
1
+ import { clone_object, echo, is_array, is_object } from "../utils/utils";
2
2
  import axios from "axios";
3
3
  import * as qs from "query-string";
4
4
  import { ApiException } from "../exceptions/ApiException";
@@ -379,15 +379,19 @@ export class ApiAbstractElementClass
379
379
 
380
380
  if (( api_code >= 200 ) && ( api_code <= 299 ))
381
381
  {
382
- if (is_array(api_response?.data) && this.element_class_instance)
382
+ if (is_array(api_response?.data?.api_result) && this.element_class_instance)
383
383
  {
384
- let result = api_response?.data.map((row) =>
384
+ let result = api_response?.data.api_result.map((row) =>
385
385
  {
386
386
  return new this.element_class_instance(row);
387
387
  });
388
388
 
389
389
  return result;
390
390
  }
391
+ else if (is_object(api_response?.data?.api_result))
392
+ {
393
+ return api_response?.data?.api_result;
394
+ }
391
395
  else
392
396
  {
393
397
  return api_response?.data;
@@ -0,0 +1,33 @@
1
+ /**
2
+ *
3
+ * @version v.0.1 (19/08/2025)
4
+ */
5
+ export class abstractAppConfiguration
6
+ {
7
+ static init_options = false;
8
+
9
+ static config = {};
10
+
11
+ static state = {
12
+ loaded: false
13
+ }
14
+
15
+
16
+ /**
17
+ *
18
+ * @version v.0.1 (19/08/2025)
19
+ * @param init_options - надо ли?
20
+ */
21
+ constructor(init_options = false)
22
+ {}
23
+
24
+ /**
25
+ *
26
+ * @version v.0.1 (19/08/2025)
27
+ * @param element_type
28
+ * @param section
29
+ * @param lang ???
30
+ */
31
+ static get_config(element_type = false, section = false, lang = false)
32
+ {}
33
+ }
@@ -0,0 +1,119 @@
1
+ import { abstractAppConfiguration } from "./abstract_app_configuration.js";
2
+ import { typeMenuElement } from "../types/family_service/typeMenuElement.js";
3
+ import { UserService } from "../services/UserService.js";
4
+
5
+ /**
6
+ * Основное меню (верхнее)
7
+ *
8
+ * @version v.0.1 (19/08/2025)
9
+ */
10
+ export class MenuConfigurationMain extends abstractAppConfiguration
11
+ {
12
+ static config = {};
13
+
14
+ static state = {
15
+ loaded: false
16
+ }
17
+
18
+
19
+ /**
20
+ *
21
+ * @param init_options
22
+ */
23
+ constructor(init_options = false)
24
+ {
25
+ super();
26
+ if (this.constructor._instance)
27
+ {
28
+ return this.constructor._instance;
29
+ }
30
+
31
+ this.init_options = init_options;
32
+
33
+ this.constructor._instance = this;
34
+
35
+ MenuConfigurationMain.bootstrap();
36
+ }
37
+
38
+
39
+ /**
40
+ * Не понятно пока как лучше организовать
41
+ * @version v.0.1 (17/08/2025)
42
+ */
43
+ static bootstrap()
44
+ {
45
+ if (this.state.loaded)
46
+ {
47
+ return;
48
+ }
49
+
50
+ this.bootstrap_menu();
51
+
52
+ this.state.loaded = true;
53
+ }
54
+
55
+ static bootstrap_menu()
56
+ {
57
+ this.config.menu_elements = this.bootstrap_menu_elements();
58
+ }
59
+
60
+
61
+ /**
62
+ *
63
+ * @returns {boolean|*}
64
+ */
65
+ static get_config()
66
+ {
67
+ if (!this.state.loaded)
68
+ {
69
+ this.bootstrap();
70
+ }
71
+
72
+ return this.config;
73
+ }
74
+
75
+
76
+ /**
77
+ *
78
+ * @version v.0.1 (19/08/2025)
79
+ * @returns {[typeMenuElement]}
80
+ */
81
+ static bootstrap_menu_elements()
82
+ {
83
+ let locale = UserService.get_current_language();
84
+
85
+ // @todo - use serviceTranslate
86
+
87
+ let response = [];
88
+
89
+ response.push(new typeMenuElement({
90
+ link : `/web/${ locale }/project/listing`,
91
+ text : 'Projects',
92
+ icon : '?',
93
+ sort_order: 1,
94
+ }));
95
+
96
+ response.push(new typeMenuElement({
97
+ link : `/web/${ locale }/test_case/listing`,
98
+ text : 'Test Cases',
99
+ icon : '?',
100
+ sort_order: 2,
101
+ }));
102
+
103
+ response.push(new typeMenuElement({
104
+ link : `/web/${ locale }/test_run/listing`,
105
+ text : 'Test Runs',
106
+ icon : '?',
107
+ sort_order: 3,
108
+ }));
109
+
110
+ /*response.push(new typeMenuElement({
111
+ link : `/web/${ locale }/task/listing`,
112
+ text : 'To Do',
113
+ icon : '?',
114
+ sort_order: 4,
115
+ }));*/
116
+
117
+ return response;
118
+ }
119
+ }
@@ -0,0 +1,140 @@
1
+ import { abstractAppConfiguration } from "./abstract_app_configuration.js";
2
+ import { UserService } from "../services/UserService.js";
3
+ import { typeMenuElement } from "../types/family_service/typeMenuElement.js";
4
+
5
+ /**
6
+ * Дополнительное меню (нижнее)
7
+ *
8
+ * @version v.0.1 (19/08/2025)
9
+ */
10
+ export class MenuConfigurationSecondary extends abstractAppConfiguration
11
+ {
12
+ static config = {};
13
+
14
+ static state = {
15
+ loaded: false
16
+ }
17
+
18
+
19
+
20
+ /**
21
+ *
22
+ * @param init_options
23
+ */
24
+ constructor(init_options = false)
25
+ {
26
+ super();
27
+ if (this.constructor._instance)
28
+ {
29
+ return this.constructor._instance;
30
+ }
31
+
32
+ this.init_options = init_options;
33
+
34
+ this.constructor._instance = this;
35
+
36
+ MenuConfigurationSecondary.bootstrap();
37
+ }
38
+
39
+
40
+
41
+
42
+ /**
43
+ * Не понятно пока как лучше организовать
44
+ * @version v.0.1 (17/08/2025)
45
+ */
46
+ static bootstrap()
47
+ {
48
+ if (this.state.loaded)
49
+ {
50
+ return;
51
+ }
52
+
53
+ this.bootstrap_menu();
54
+
55
+ this.state.loaded = true;
56
+ }
57
+
58
+ static bootstrap_menu()
59
+ {
60
+ this.config.menu_elements = this.bootstrap_menu_elements();
61
+ }
62
+
63
+
64
+ /**
65
+ *
66
+ * @returns {boolean|*}
67
+ */
68
+ static get_config()
69
+ {
70
+ if (!this.state.loaded)
71
+ {
72
+ this.bootstrap();
73
+ }
74
+
75
+ return this.config;
76
+ }
77
+
78
+
79
+ /**
80
+ *
81
+ * @version v.0.1 (19/08/2025)
82
+ * @returns {[typeMenuElement]}
83
+ */
84
+ static bootstrap_menu_elements()
85
+ {
86
+ let locale = UserService.get_current_language();
87
+
88
+ // @todo - use serviceTranslate
89
+
90
+ let response = [];
91
+
92
+ response.push(new typeMenuElement({
93
+ link : `/web/${ locale }/user_profile`,
94
+ text : 'User Settings',
95
+ icon : '?',
96
+ sort_order: 1,
97
+ }));
98
+
99
+ let lang_sub_menu = [];
100
+
101
+ lang_sub_menu.push(new typeMenuElement({
102
+ link : `/web/en`, // @todo - get current routing and replace $lang
103
+ text : `EN`,
104
+ icon : '?',
105
+ sort_order: 1,
106
+ reload: true,
107
+ }));
108
+
109
+ lang_sub_menu.push(new typeMenuElement({
110
+ link : `/web/ru`, // @todo - get current routing and replace $lang
111
+ text : `RU`,
112
+ icon : '?',
113
+ sort_order: 2,
114
+ reload: true,
115
+ }));
116
+
117
+ response.push(new typeMenuElement({
118
+ link : false,
119
+ text : `Language ${ locale }`,
120
+ icon : '?',
121
+ sort_order: 2,
122
+ sub_menu : lang_sub_menu
123
+ }));
124
+
125
+ response.push(new typeMenuElement({
126
+ link : `/web/${ locale }/team_management/team/listing`,
127
+ text : 'Teams',
128
+ icon : '?',
129
+ sort_order: 3,
130
+ }));
131
+
132
+ /*
133
+ feedback
134
+ docs
135
+ admins
136
+ */
137
+
138
+ return response;
139
+ }
140
+ }
@@ -1,15 +1,13 @@
1
1
  import { typeTableConfiguration } from "../types/family_service/typeTableConfiguration.js";
2
2
  import { typeTableColumn } from "../types/family_service/typeTableColumn.js";
3
+ import { abstractAppConfiguration } from "./abstract_app_configuration.js";
3
4
 
4
5
  /**
5
6
  *
6
7
  * @version v.0.1 (17/08/2025)
7
8
  */
8
- export class TableConfiguration
9
+ export class TableConfiguration extends abstractAppConfiguration
9
10
  {
10
-
11
- static init_options = false;
12
-
13
11
  static config = {};
14
12
 
15
13
  static state = {
@@ -22,6 +20,7 @@ export class TableConfiguration
22
20
  */
23
21
  constructor(init_options = false)
24
22
  {
23
+ super();
25
24
  if (this.constructor._instance)
26
25
  {
27
26
  return this.constructor._instance;
@@ -31,7 +30,7 @@ export class TableConfiguration
31
30
 
32
31
  this.constructor._instance = this;
33
32
 
34
- this.#bootstrap();
33
+ TableConfiguration.bootstrap();
35
34
  }
36
35
 
37
36
 
@@ -48,7 +47,7 @@ export class TableConfiguration
48
47
  {
49
48
  if (!this.state.loaded)
50
49
  {
51
- this.#bootstrap();
50
+ this.bootstrap();
52
51
  }
53
52
 
54
53
  if (this.config?.[ element_type ]?.[ section ])
@@ -72,14 +71,14 @@ export class TableConfiguration
72
71
  * Не понятно пока как лучше организовать
73
72
  * @version v.0.1 (17/08/2025)
74
73
  */
75
- static #bootstrap()
74
+ static bootstrap()
76
75
  {
77
76
  if (this.state.loaded)
78
77
  {
79
78
  return;
80
79
  }
81
80
 
82
- this.#bootstrap_test_case();
81
+ this.bootstrap_test_case();
83
82
 
84
83
  this.state.loaded = true;
85
84
  }
@@ -89,11 +88,11 @@ export class TableConfiguration
89
88
  *
90
89
  * @version v.0.1 (17/08/2025)
91
90
  */
92
- static #bootstrap_test_case()
91
+ static bootstrap_test_case()
93
92
  {
94
93
  let payload_listing = {};
95
94
 
96
- let columns = this.#bootstrap_test_case_columns();
95
+ let columns = this.bootstrap_test_case_columns();
97
96
 
98
97
  payload_listing.config = new typeTableConfiguration({
99
98
  columns: columns
@@ -109,7 +108,7 @@ export class TableConfiguration
109
108
  *
110
109
  * @version v.0.1 (17/08/2025)
111
110
  */
112
- static #bootstrap_test_case_columns()
111
+ static bootstrap_test_case_columns()
113
112
  {
114
113
  let response = [];
115
114
 
@@ -1,6 +1,7 @@
1
1
  import { abstractService } from "./abstractService";
2
2
  import i18next from 'i18next';
3
3
  import { Api } from "../api";
4
+ import { echo, in_array } from "../utils/utils.js";
4
5
 
5
6
  /**
6
7
  *
@@ -0,0 +1,32 @@
1
+ import { familyService } from "./familyService.js";
2
+
3
+ /**
4
+ *
5
+ * @version v.0.1 (19/08/2025)
6
+ */
7
+ export class typeMenuElement extends familyService
8
+ {
9
+ link = false; // при FALSE - нет <a>
10
+ text;
11
+ icon = false;
12
+ sort_order = 0;
13
+ sub_menu = false;
14
+ reload = false; // при TRUE - надо полностью перезагрузить
15
+
16
+ constructor(data = false)
17
+ {
18
+ super();
19
+ if (data && typeof data === 'object')
20
+ {
21
+ _.mapObject(data, (value, key) =>
22
+ {
23
+ if (this.hasOwnProperty(key))
24
+ {
25
+ this [ key ] = value;
26
+ }
27
+ });
28
+ }
29
+
30
+ return this;
31
+ }
32
+ }