@molochko-dev/data 1.4.20 → 1.4.22
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/dist/event/animal-event-filter.d.ts +17 -0
- package/dist/event/animal-event-filter.js +138 -0
- package/dist/event/index.d.ts +2 -0
- package/dist/event/index.js +5 -0
- package/dist/helpers/date.d.ts +1 -0
- package/dist/helpers/date.js +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/role-permissions.js +1 -1
- package/dist/types.d.ts +23 -1
- package/package.json +3 -2
- package/src/event/animal-event-filter.ts +156 -0
- package/src/event/index.ts +3 -0
- package/src/helpers/date.ts +6 -0
- package/src/index.ts +3 -0
- package/src/role-permissions.ts +1 -1
- package/src/types.ts +31 -1
- package/settings.service.ts +0 -35
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
filter(): IAnimal[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
filter() {
|
|
120
|
+
switch (this.eventType) {
|
|
121
|
+
case enums_1.EVENT_TYPES_ENUM.abort:
|
|
122
|
+
return this.abortFilter();
|
|
123
|
+
case enums_1.EVENT_TYPES_ENUM.neosem:
|
|
124
|
+
return this.neosemFilter();
|
|
125
|
+
case enums_1.EVENT_TYPES_ENUM.osemenenie:
|
|
126
|
+
return this.osemenenieFilter();
|
|
127
|
+
case enums_1.EVENT_TYPES_ENUM.otel:
|
|
128
|
+
return this.otelFilter();
|
|
129
|
+
case enums_1.EVENT_TYPES_ENUM.recheck:
|
|
130
|
+
return this.recheckFilter();
|
|
131
|
+
case enums_1.EVENT_TYPES_ENUM.suhostoi:
|
|
132
|
+
return this.suhostoiFilter();
|
|
133
|
+
default:
|
|
134
|
+
throw new Error(`AnimalForEventFilter.filter.${this.eventType} not implemented`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.AnimalForEventFilter = 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/role-permissions.js
CHANGED
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.
|
|
3
|
+
"version": "1.4.22",
|
|
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,156 @@
|
|
|
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
|
+
filter () {
|
|
138
|
+
switch (this.eventType) {
|
|
139
|
+
case EVENT_TYPES_ENUM.abort:
|
|
140
|
+
return this.abortFilter()
|
|
141
|
+
case EVENT_TYPES_ENUM.neosem:
|
|
142
|
+
return this.neosemFilter()
|
|
143
|
+
case EVENT_TYPES_ENUM.osemenenie:
|
|
144
|
+
return this.osemenenieFilter()
|
|
145
|
+
case EVENT_TYPES_ENUM.otel:
|
|
146
|
+
return this.otelFilter()
|
|
147
|
+
case EVENT_TYPES_ENUM.recheck:
|
|
148
|
+
return this.recheckFilter()
|
|
149
|
+
case EVENT_TYPES_ENUM.suhostoi:
|
|
150
|
+
return this.suhostoiFilter()
|
|
151
|
+
default:
|
|
152
|
+
throw new Error(`AnimalForEventFilter.filter.${this.eventType} not implemented`)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
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/role-permissions.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
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/settings.service.ts
DELETED
|
@@ -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
|
-
}
|