@molochko-dev/data 1.4.21 → 1.4.23

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.
@@ -0,0 +1,18 @@
1
+ import { IAnimal } from '../types';
2
+ import { ANIMAL_GENDER_ENUM, ANIMAL_STATUS_ENUM, EVENT_TYPES_ENUM } from '../enums';
3
+ export declare class AnimalForEventFilter {
4
+ animals: IAnimal[];
5
+ eventType: EVENT_TYPES_ENUM;
6
+ constructor(animals: IAnimal[], eventType: EVENT_TYPES_ENUM);
7
+ genderFilter(animal: IAnimal, availableGender: ANIMAL_GENDER_ENUM): Boolean;
8
+ ageFilter(animal: IAnimal, availableMinAge: number): Boolean;
9
+ statusFilter(animal: IAnimal, availableStatuses: ANIMAL_STATUS_ENUM[]): Boolean;
10
+ abortFilter(): IAnimal[];
11
+ neosemFilter(): IAnimal[];
12
+ osemenenieFilter(): IAnimal[];
13
+ otelFilter(): IAnimal[];
14
+ recheckFilter(): IAnimal[];
15
+ suhostoiFilter(): IAnimal[];
16
+ pozSuhostoiFilter(): IAnimal[];
17
+ filter(): IAnimal[];
18
+ }
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnimalForEventFilter = void 0;
4
+ const enums_1 = require("../enums");
5
+ const date_1 = require("../helpers/date");
6
+ const status = enums_1.ANIMAL_STATUS_ENUM;
7
+ const defaultCowAge = 12;
8
+ class AnimalForEventFilter {
9
+ constructor(animals, eventType) {
10
+ this.animals = animals;
11
+ this.eventType = eventType;
12
+ }
13
+ genderFilter(animal, availableGender) {
14
+ if (animal.gender === availableGender) {
15
+ return true;
16
+ }
17
+ return false;
18
+ }
19
+ ageFilter(animal, availableMinAge /*month*/) {
20
+ const months = (0, date_1.getMonthFromDate)(animal.dob.toISOString());
21
+ if (months > availableMinAge) {
22
+ return true;
23
+ }
24
+ return false;
25
+ }
26
+ statusFilter(animal, availableStatuses) {
27
+ if (availableStatuses.includes(animal.status)) {
28
+ return true;
29
+ }
30
+ return false;
31
+ }
32
+ abortFilter() {
33
+ const result = [];
34
+ this.animals.forEach(animal => {
35
+ if (this.genderFilter(animal, enums_1.ANIMAL_GENDER_ENUM.cow)) {
36
+ result.push(animal);
37
+ }
38
+ });
39
+ return result;
40
+ }
41
+ neosemFilter() {
42
+ return this.abortFilter();
43
+ }
44
+ osemenenieFilter() {
45
+ const result = [];
46
+ this.animals.forEach(animal => {
47
+ let genderOk = false;
48
+ let statusOk = false;
49
+ let ageOk = false;
50
+ if (this.genderFilter(animal, enums_1.ANIMAL_GENDER_ENUM.cow)) {
51
+ genderOk = true;
52
+ }
53
+ if (this.statusFilter(animal, [status.heifer, status.bred, status.open, status.fresh])) {
54
+ statusOk = true;
55
+ }
56
+ if (this.ageFilter(animal, defaultCowAge)) {
57
+ ageOk = true;
58
+ }
59
+ if (genderOk && statusOk && ageOk) {
60
+ result.push(animal);
61
+ }
62
+ });
63
+ return result;
64
+ }
65
+ otelFilter() {
66
+ const result = [];
67
+ this.animals.forEach(animal => {
68
+ let genderOk = false;
69
+ let statusOk = false;
70
+ let ageOk = false;
71
+ if (this.genderFilter(animal, enums_1.ANIMAL_GENDER_ENUM.cow)) {
72
+ genderOk = true;
73
+ }
74
+ if (this.statusFilter(animal, [status.dry, status.pregnant])) {
75
+ statusOk = true;
76
+ }
77
+ if (this.ageFilter(animal, defaultCowAge)) {
78
+ ageOk = true;
79
+ }
80
+ if (genderOk && statusOk && ageOk) {
81
+ result.push(animal);
82
+ }
83
+ });
84
+ return result;
85
+ }
86
+ recheckFilter() {
87
+ const result = [];
88
+ this.animals.forEach(animal => {
89
+ let genderOk = false;
90
+ let statusOk = false;
91
+ let ageOk = false;
92
+ if (this.genderFilter(animal, enums_1.ANIMAL_GENDER_ENUM.cow)) {
93
+ genderOk = true;
94
+ }
95
+ if (this.ageFilter(animal, defaultCowAge)) {
96
+ ageOk = true;
97
+ }
98
+ let availableStatus = [status.bred, status.pregnant, status.dry];
99
+ if (animal.animalEventRelation) {
100
+ const previousRechecks = animal.animalEventRelation.filter((row) => {
101
+ return row.eventDetail.type === enums_1.EVENT_TYPES_ENUM.recheck;
102
+ });
103
+ if (previousRechecks.length == 0) {
104
+ availableStatus = [status.bred];
105
+ }
106
+ }
107
+ if (this.statusFilter(animal, availableStatus)) {
108
+ statusOk = true;
109
+ }
110
+ if (genderOk && statusOk && ageOk) {
111
+ result.push(animal);
112
+ }
113
+ });
114
+ return result;
115
+ }
116
+ suhostoiFilter() {
117
+ return this.abortFilter();
118
+ }
119
+ pozSuhostoiFilter() {
120
+ return this.abortFilter();
121
+ }
122
+ filter() {
123
+ switch (this.eventType) {
124
+ case enums_1.EVENT_TYPES_ENUM.abort:
125
+ return this.abortFilter();
126
+ case enums_1.EVENT_TYPES_ENUM.neosem:
127
+ return this.neosemFilter();
128
+ case enums_1.EVENT_TYPES_ENUM.osemenenie:
129
+ return this.osemenenieFilter();
130
+ case enums_1.EVENT_TYPES_ENUM.otel:
131
+ return this.otelFilter();
132
+ case enums_1.EVENT_TYPES_ENUM.recheck:
133
+ return this.recheckFilter();
134
+ case enums_1.EVENT_TYPES_ENUM.suhostoi:
135
+ return this.suhostoiFilter();
136
+ case enums_1.EVENT_TYPES_ENUM.pozSuhostoi:
137
+ return this.pozSuhostoiFilter();
138
+ default:
139
+ throw new Error(`AnimalForEventFilter.filter.${this.eventType} not implemented`);
140
+ }
141
+ }
142
+ }
143
+ exports.AnimalForEventFilter = AnimalForEventFilter;
@@ -0,0 +1,2 @@
1
+ import { AnimalForEventFilter as _AnimalForEventFilter } from './animal-event-filter';
2
+ export { _AnimalForEventFilter as AnimalForEventFilter };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnimalForEventFilter = void 0;
4
+ const animal_event_filter_1 = require("./animal-event-filter");
5
+ Object.defineProperty(exports, "AnimalForEventFilter", { enumerable: true, get: function () { return animal_event_filter_1.AnimalForEventFilter; } });
@@ -0,0 +1 @@
1
+ export declare const getMonthFromDate: (dateString: string) => number;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getMonthFromDate = void 0;
7
+ const moment_1 = __importDefault(require("moment"));
8
+ const getMonthFromDate = (dateString) => {
9
+ const result = (0, moment_1.default)().diff(dateString, 'months');
10
+ return result;
11
+ };
12
+ exports.getMonthFromDate = getMonthFromDate;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as dataEnums from "./enums";
2
2
  import * as typeDefinitions from "./types";
3
3
  import * as _rolePermissions from './role-permissions';
4
+ import * as _animalForEventFilters from './event';
4
5
  export declare const enums: {
5
6
  BREED: typeDefinitions.EnumItem[];
6
7
  BREED_AS_OBJECT: typeDefinitions.EnumArrayAsObject;
@@ -68,3 +69,4 @@ export declare const enums: {
68
69
  };
69
70
  export declare const rolePermissions: typeof _rolePermissions;
70
71
  export declare const types: typeof typeDefinitions;
72
+ export declare const animalForEventFilters: typeof _animalForEventFilters;
package/dist/index.js CHANGED
@@ -23,11 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.types = exports.rolePermissions = exports.enums = void 0;
26
+ exports.animalForEventFilters = exports.types = exports.rolePermissions = exports.enums = void 0;
27
27
  const dataEnums = __importStar(require("./enums"));
28
28
  const breed_1 = require("./breed");
29
29
  const typeDefinitions = __importStar(require("./types"));
30
30
  const _rolePermissions = __importStar(require("./role-permissions"));
31
+ const _animalForEventFilters = __importStar(require("./event"));
31
32
  exports.enums = Object.assign(Object.assign({}, dataEnums), { BREED: breed_1.BREED, BREED_AS_OBJECT: breed_1.BREED_AS_OBJECT });
32
33
  exports.rolePermissions = _rolePermissions;
33
34
  exports.types = typeDefinitions;
35
+ exports.animalForEventFilters = _animalForEventFilters;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { USER_PERMISSION_ENUM, USER_PERMISSION_METHOD_ENUM } from './enums';
1
+ import { USER_PERMISSION_ENUM, USER_PERMISSION_METHOD_ENUM, EVENT_TYPES_ENUM, ANIMAL_GENDER_ENUM, ANIMAL_STATUS_ENUM } from './enums';
2
2
  export interface EnumItem {
3
3
  readonly id: string;
4
4
  readonly label: string;
@@ -21,3 +21,25 @@ export interface IRolePermissionItem {
21
21
  };
22
22
  backend?: IBackendRolePermissionItem[];
23
23
  }
24
+ export interface IAnimal {
25
+ id: string;
26
+ orgId: string;
27
+ name: string;
28
+ animalId: string;
29
+ isoId: string;
30
+ regId: string;
31
+ activometrId: string;
32
+ status: ANIMAL_STATUS_ENUM;
33
+ gender: ANIMAL_GENDER_ENUM;
34
+ dob: Date;
35
+ breed?: string;
36
+ tags?: number[];
37
+ searchTag?: string;
38
+ animalEventRelation?: IAnimalEventRelation[];
39
+ }
40
+ export interface IAnimalEventRelation {
41
+ eventDetail: IEventDetail;
42
+ }
43
+ export interface IEventDetail {
44
+ type: EVENT_TYPES_ENUM;
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molochko-dev/data",
3
- "version": "1.4.21",
3
+ "version": "1.4.23",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "typings/index.d.ts",
@@ -26,6 +26,7 @@
26
26
  "typescript": "~4.8.2"
27
27
  },
28
28
  "dependencies": {
29
- "@types/jest": "^29.5.2"
29
+ "@types/jest": "^29.5.2",
30
+ "moment": "^2.30.1"
30
31
  }
31
32
  }
@@ -0,0 +1,162 @@
1
+ import { IAnimal } from '../types';
2
+ import { ANIMAL_GENDER_ENUM, ANIMAL_STATUS_ENUM, EVENT_TYPES_ENUM } from '../enums';
3
+ import { getMonthFromDate } from '../helpers/date';
4
+
5
+ const status = ANIMAL_STATUS_ENUM
6
+
7
+ const defaultCowAge = 12
8
+
9
+ export class AnimalForEventFilter {
10
+ animals: IAnimal[]
11
+ eventType: EVENT_TYPES_ENUM
12
+
13
+ constructor (animals: IAnimal[], eventType: EVENT_TYPES_ENUM) {
14
+ this.animals = animals
15
+ this.eventType = eventType
16
+ }
17
+
18
+ genderFilter (animal: IAnimal, availableGender: ANIMAL_GENDER_ENUM): Boolean {
19
+ if (animal.gender === availableGender) {
20
+ return true
21
+ }
22
+ return false
23
+ }
24
+
25
+ ageFilter (animal: IAnimal, availableMinAge: number /*month*/): Boolean {
26
+ const months = getMonthFromDate(animal.dob.toISOString())
27
+ if ( months > availableMinAge) {
28
+ return true
29
+ }
30
+ return false
31
+ }
32
+
33
+ statusFilter (animal: IAnimal, availableStatuses: ANIMAL_STATUS_ENUM[]): Boolean {
34
+ if (availableStatuses.includes(animal.status)) {
35
+ return true
36
+ }
37
+ return false
38
+ }
39
+
40
+ abortFilter () {
41
+ const result: IAnimal[] = []
42
+ this.animals.forEach(animal => {
43
+ if (this.genderFilter(animal, ANIMAL_GENDER_ENUM.cow)) {
44
+ result.push(animal)
45
+ }
46
+ })
47
+ return result
48
+ }
49
+
50
+ neosemFilter () {
51
+ return this.abortFilter()
52
+ }
53
+
54
+ osemenenieFilter() {
55
+ const result: IAnimal[] = []
56
+ this.animals.forEach(animal => {
57
+ let genderOk = false
58
+ let statusOk = false
59
+ let ageOk = false
60
+
61
+ if (this.genderFilter(animal, ANIMAL_GENDER_ENUM.cow)) {
62
+ genderOk = true
63
+ }
64
+ if (this.statusFilter(animal, [status.heifer, status.bred, status.open, status.fresh])) {
65
+ statusOk = true
66
+ }
67
+ if (this.ageFilter(animal, defaultCowAge)) {
68
+ ageOk = true
69
+ }
70
+ if (genderOk && statusOk && ageOk) {
71
+ result.push(animal)
72
+ }
73
+ })
74
+ return result
75
+ }
76
+
77
+ otelFilter () {
78
+ const result: IAnimal[] = []
79
+ this.animals.forEach(animal => {
80
+ let genderOk = false
81
+ let statusOk = false
82
+ let ageOk = false
83
+
84
+ if (this.genderFilter(animal, ANIMAL_GENDER_ENUM.cow)) {
85
+ genderOk = true
86
+ }
87
+ if (this.statusFilter(animal, [status.dry, status.pregnant])) {
88
+ statusOk = true
89
+ }
90
+ if (this.ageFilter(animal, defaultCowAge)) {
91
+ ageOk = true
92
+ }
93
+ if (genderOk && statusOk && ageOk) {
94
+ result.push(animal)
95
+ }
96
+ })
97
+ return result
98
+ }
99
+
100
+ recheckFilter () {
101
+ const result: IAnimal[] = []
102
+ this.animals.forEach(animal => {
103
+ let genderOk = false
104
+ let statusOk = false
105
+ let ageOk = false
106
+
107
+ if (this.genderFilter(animal, ANIMAL_GENDER_ENUM.cow)) {
108
+ genderOk = true
109
+ }
110
+ if (this.ageFilter(animal, defaultCowAge)) {
111
+ ageOk = true
112
+ }
113
+
114
+ let availableStatus = [status.bred, status.pregnant, status.dry]
115
+ if (animal.animalEventRelation) {
116
+ const previousRechecks = animal.animalEventRelation.filter((row) => {
117
+ return row.eventDetail.type === EVENT_TYPES_ENUM.recheck
118
+ })
119
+ if (previousRechecks.length == 0) {
120
+ availableStatus = [status.bred]
121
+ }
122
+ }
123
+ if (this.statusFilter(animal, availableStatus)) {
124
+ statusOk = true
125
+ }
126
+ if (genderOk && statusOk && ageOk) {
127
+ result.push(animal)
128
+ }
129
+ })
130
+ return result
131
+ }
132
+
133
+ suhostoiFilter () {
134
+ return this.abortFilter()
135
+ }
136
+
137
+ pozSuhostoiFilter () {
138
+ return this.abortFilter()
139
+ }
140
+
141
+ filter () {
142
+ switch (this.eventType) {
143
+ case EVENT_TYPES_ENUM.abort:
144
+ return this.abortFilter()
145
+ case EVENT_TYPES_ENUM.neosem:
146
+ return this.neosemFilter()
147
+ case EVENT_TYPES_ENUM.osemenenie:
148
+ return this.osemenenieFilter()
149
+ case EVENT_TYPES_ENUM.otel:
150
+ return this.otelFilter()
151
+ case EVENT_TYPES_ENUM.recheck:
152
+ return this.recheckFilter()
153
+ case EVENT_TYPES_ENUM.suhostoi:
154
+ return this.suhostoiFilter()
155
+ case EVENT_TYPES_ENUM.pozSuhostoi:
156
+ return this.pozSuhostoiFilter()
157
+ default:
158
+ throw new Error(`AnimalForEventFilter.filter.${this.eventType} not implemented`)
159
+ }
160
+ }
161
+ }
162
+
@@ -0,0 +1,3 @@
1
+ import { AnimalForEventFilter as _AnimalForEventFilter } from './animal-event-filter'
2
+
3
+ export { _AnimalForEventFilter as AnimalForEventFilter }
@@ -0,0 +1,6 @@
1
+ import moment from 'moment'
2
+
3
+ export const getMonthFromDate = (dateString: string) => {
4
+ const result = moment().diff(dateString, 'months')
5
+ return result
6
+ }
package/src/index.ts CHANGED
@@ -2,7 +2,10 @@ import * as dataEnums from "./enums";
2
2
  import { BREED, BREED_AS_OBJECT } from "./breed";
3
3
  import * as typeDefinitions from "./types";
4
4
  import * as _rolePermissions from './role-permissions'
5
+ import * as _animalForEventFilters from './event'
5
6
 
6
7
  export const enums = { ...dataEnums, BREED, BREED_AS_OBJECT };
7
8
  export const rolePermissions = _rolePermissions
8
9
  export const types = typeDefinitions;
10
+
11
+ export const animalForEventFilters = _animalForEventFilters
package/src/types.ts CHANGED
@@ -1,4 +1,9 @@
1
- import { USER_PERMISSION_ENUM, USER_PERMISSION_METHOD_ENUM } from './enums'
1
+ import {
2
+ USER_PERMISSION_ENUM,
3
+ USER_PERMISSION_METHOD_ENUM,
4
+ EVENT_TYPES_ENUM,
5
+ ANIMAL_GENDER_ENUM,
6
+ ANIMAL_STATUS_ENUM } from './enums'
2
7
 
3
8
  export interface EnumItem {
4
9
  readonly id: string;
@@ -24,3 +29,28 @@ export interface IRolePermissionItem {
24
29
  backend?: IBackendRolePermissionItem[]
25
30
  }
26
31
 
32
+ export interface IAnimal {
33
+ id: string;
34
+ orgId: string;
35
+ name: string;
36
+ animalId: string;
37
+ isoId: string;
38
+ regId: string;
39
+ activometrId: string;
40
+ status: ANIMAL_STATUS_ENUM;
41
+ gender: ANIMAL_GENDER_ENUM;
42
+ dob: Date;
43
+ breed?: string;
44
+ tags?: number[];
45
+ searchTag?: string;
46
+ animalEventRelation?: IAnimalEventRelation[]
47
+ }
48
+
49
+ export interface IAnimalEventRelation {
50
+ eventDetail: IEventDetail
51
+ }
52
+
53
+ export interface IEventDetail {
54
+ type: EVENT_TYPES_ENUM
55
+ }
56
+
package/perms.json DELETED
@@ -1,293 +0,0 @@
1
- {
2
- "data":[
3
- {
4
- "name": "org",
5
- "backend": [
6
- {
7
- "paths": [
8
- "/api/org"
9
- ],
10
- "active": true,
11
- "method": "POST",
12
- "permission": "create"
13
- },
14
- {
15
- "paths": [
16
- "/api/org/list",
17
- "/api/org/:id"
18
- ],
19
- "active": true,
20
- "method": "GET",
21
- "permission": "view"
22
- },
23
- {
24
- "paths": [
25
- "/api/org/:id"
26
- ],
27
- "active": true,
28
- "method": "PUT",
29
- "permission": "update"
30
- },
31
- {
32
- "paths": [
33
- "/api/org/:id"
34
- ],
35
- "active": true,
36
- "method": "DELETE",
37
- "permission": "delete"
38
- }
39
- ],
40
- "frontend": {
41
- "path": "/main/company",
42
- "active": false
43
- }
44
- },
45
- {
46
- "name": "employees",
47
- "backend": [
48
- {
49
- "paths": [
50
- "/api/users/list"
51
- ],
52
- "active": true,
53
- "method": "GET",
54
- "permission": "view"
55
- },
56
- {
57
- "paths": [
58
- "/api/users/by-admin"
59
- ],
60
- "active": true,
61
- "method": "POST",
62
- "permission": "create"
63
- },
64
- {
65
- "paths": [
66
- "/api/users/by-admin/:id"
67
- ],
68
- "active": true,
69
- "method": "PUT",
70
- "permission": "update"
71
- },
72
- {
73
- "paths": [
74
- "/api/users/by-admin/:id"
75
- ],
76
- "active": true,
77
- "method": "DELETE",
78
- "permission": "delete"
79
- },
80
- {
81
- "paths": [
82
- "/api/users/remove"
83
- ],
84
- "active": true,
85
- "method": "PUT",
86
- "permission": "deleteAll"
87
- }
88
- ],
89
- "frontend": {
90
- "path": "/main/employees"
91
- }
92
- },
93
- {
94
- "name": "seed-bank",
95
- "backend": [
96
- {
97
- "paths": [
98
- "/api/seed-bank/list"
99
- ],
100
- "active": true,
101
- "method": "GET",
102
- "permission": "view"
103
- },
104
- {
105
- "paths": [
106
- "/api/seed-bank/:naab"
107
- ],
108
- "active": true,
109
- "method": "GET",
110
- "permission": "view"
111
- },
112
- {
113
- "paths": [
114
- "/api/seed-bank"
115
- ],
116
- "active": true,
117
- "method": "POST",
118
- "permission": "create"
119
- },
120
- {
121
- "paths": [
122
- "/api/seed-bank/:id"
123
- ],
124
- "active": true,
125
- "method": "PUT",
126
- "permission": "update"
127
- },
128
- {
129
- "paths": [
130
- "/api/seed-bank/:id"
131
- ],
132
- "active": true,
133
- "method": "DELETE",
134
- "permission": "delete"
135
- }
136
- ],
137
- "frontend": {
138
- "path": "/main/seed-bank"
139
- }
140
- },
141
- {
142
- "name": "tags",
143
- "backend": [
144
- {
145
- "paths": [
146
- "/api/animal-tag"
147
- ],
148
- "active": true,
149
- "method": "POST",
150
- "permission": "create"
151
- },
152
- {
153
- "paths": [
154
- "/api/animal-tag/:id"
155
- ],
156
- "active": true,
157
- "method": "PUT",
158
- "permission": "update"
159
- },
160
- {
161
- "paths": [
162
- "/api/animal-tag/:id"
163
- ],
164
- "active": true,
165
- "method": "DELETE",
166
- "permission": "delete"
167
- },
168
- {
169
- "paths": [
170
- "/api/animal-tag/list"
171
- ],
172
- "active": true,
173
- "method": "GET",
174
- "permission": "view"
175
- }
176
- ],
177
- "frontend": {
178
- "path": "/main/tags"
179
- }
180
- },
181
- {
182
- "name": "animal",
183
- "backend": [
184
- {
185
- "paths": [
186
- "/api/animal"
187
- ],
188
- "active": true,
189
- "method": "POST",
190
- "permission": "create"
191
- },
192
- {
193
- "paths": [
194
- "/api/animal/:id"
195
- ],
196
- "active": true,
197
- "method": "PUT",
198
- "permission": "update"
199
- },
200
- {
201
- "paths": [
202
- "/api/animal/:id"
203
- ],
204
- "active": true,
205
- "method": "DELETE",
206
- "permission": "delete"
207
- },
208
- {
209
- "paths": [
210
- "/api/animal/list"
211
- ],
212
- "active": false,
213
- "method": "GET",
214
- "permission": "view"
215
- },
216
- {
217
- "paths": [
218
- "/api/animal/to-tag"
219
- ],
220
- "active": true,
221
- "method": "PUT",
222
- "permission": "attach"
223
- },
224
- {
225
- "paths": [
226
- "/api/animal/from-tag/:animalId"
227
- ],
228
- "active": true,
229
- "method": "DELETE",
230
- "permission": "detach"
231
- },
232
- {
233
- "paths": [
234
- "/api/animals/remove"
235
- ],
236
- "active": true,
237
- "method": "PUT",
238
- "permission": "deleteAll"
239
- }
240
- ],
241
- "frontend": {
242
- "path": "/main/animals"
243
- }
244
- },
245
- {
246
- "name": "eventForAnimals",
247
- "backend": [
248
- {
249
- "paths": [
250
- "/api/event"
251
- ],
252
- "active": true,
253
- "method": "POST",
254
- "permission": "create"
255
- },
256
- {
257
- "paths": [
258
- "/api/event/remove"
259
- ],
260
- "active": true,
261
- "method": "PUT",
262
- "permission": "deleteAll"
263
- }
264
- ],
265
- "frontend": {
266
- "path": "/main/animals"
267
- }
268
- },
269
- {
270
- "name": "event",
271
- "backend": [
272
- {
273
- "paths": [
274
- "/api/event/list"
275
- ],
276
- "active": true,
277
- "method": "GET",
278
- "permission": "view"
279
- },
280
- {
281
- "paths": [
282
- "/api/event/:id"
283
- ],
284
- "active": true,
285
- "method": "GET",
286
- "permission": "view"
287
- }
288
- ],
289
- "frontend": {
290
- "path": "/main/events-history"
291
- }
292
- }
293
- ]}
@@ -1,35 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { NavigationEnd, Router } from '@angular/router';
3
- import { LocalStorageService } from './local-storage.service';
4
-
5
- @Injectable({
6
- providedIn: 'root',
7
- })
8
- export class SettingsService {
9
- isLoading = false;
10
-
11
- constructor(private router: Router, private storage: LocalStorageService) {}
12
-
13
- init(): void {
14
- this.lastUrl();
15
- this.urlHandler();
16
- }
17
-
18
- private urlHandler(): void {
19
- this.router.events.subscribe((data) => {
20
- if (data instanceof NavigationEnd) {
21
- if (data.url.includes('page-not-found')) {
22
- this.storage.remove('url');
23
- }
24
- this.storage.set('url', data.url);
25
- }
26
- });
27
- }
28
-
29
- private lastUrl(): void {
30
- const url = this.storage.get<string>('url');
31
- if (url && url.length) {
32
- this.router.navigateByUrl(url).then();
33
- }
34
- }
35
- }