@centreon/ui-context 22.10.0
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 +13 -0
- package/package.json +13 -0
- package/src/acknowledgementAtom.ts +9 -0
- package/src/aclAtom.ts +9 -0
- package/src/cloudServicesAtom.ts +5 -0
- package/src/defaults.ts +60 -0
- package/src/downtimeAtom.ts +9 -0
- package/src/index.ts +19 -0
- package/src/refreshIntervalAtom.ts +7 -0
- package/src/resourceStorageOptimizationMode.ts +9 -0
- package/src/types.ts +62 -0
- package/src/userAtom.ts +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# centreon-ui-context
|
|
2
|
+
|
|
3
|
+
A repository containing the shared context for the Centreon front-end (using the [React Context](https://reactjs.org/docs/context.html))
|
|
4
|
+
|
|
5
|
+
## Linting
|
|
6
|
+
|
|
7
|
+
To lint the code with ESlint, run:
|
|
8
|
+
|
|
9
|
+
`npm run eslint`
|
|
10
|
+
|
|
11
|
+
You can also fix fixable linter errors by running:
|
|
12
|
+
|
|
13
|
+
`npm run eslint:fix`
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@centreon/ui-context",
|
|
3
|
+
"version": "22.10.0",
|
|
4
|
+
"description": "Centreon UI shared context",
|
|
5
|
+
"main": "src",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": "centreon@centreon.com",
|
|
8
|
+
"license": "GPL-2.0",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"eslint": "eslint ./src --ext .ts",
|
|
11
|
+
"eslint:fix": "npm run eslint -- --fix"
|
|
12
|
+
}
|
|
13
|
+
}
|
package/src/aclAtom.ts
ADDED
package/src/defaults.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { User, ThemeMode } from './types';
|
|
2
|
+
|
|
3
|
+
const defaultUser: User = {
|
|
4
|
+
alias: '',
|
|
5
|
+
default_page: '/monitoring/resources',
|
|
6
|
+
isExportButtonEnabled: false,
|
|
7
|
+
locale: navigator.language,
|
|
8
|
+
name: '',
|
|
9
|
+
themeMode: ThemeMode.light,
|
|
10
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
11
|
+
use_deprecated_pages: false,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const defaultResourceStorageOptimizationMode = false;
|
|
15
|
+
|
|
16
|
+
const defaultAcl = {
|
|
17
|
+
actions: {
|
|
18
|
+
host: {
|
|
19
|
+
acknowledgement: false,
|
|
20
|
+
check: false,
|
|
21
|
+
comment: false,
|
|
22
|
+
disacknowledgement: false,
|
|
23
|
+
downtime: false,
|
|
24
|
+
submit_status: false,
|
|
25
|
+
},
|
|
26
|
+
service: {
|
|
27
|
+
acknowledgement: false,
|
|
28
|
+
check: false,
|
|
29
|
+
comment: false,
|
|
30
|
+
disacknowledgement: false,
|
|
31
|
+
downtime: false,
|
|
32
|
+
submit_status: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const defaultDowntime = {
|
|
38
|
+
duration: 3600,
|
|
39
|
+
fixed: true,
|
|
40
|
+
with_services: false,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const defaultRefreshInterval = 15;
|
|
44
|
+
|
|
45
|
+
const defaultAcknowledgement = {
|
|
46
|
+
force_active_checks: false,
|
|
47
|
+
notify: true,
|
|
48
|
+
persistent: false,
|
|
49
|
+
sticky: false,
|
|
50
|
+
with_services: true,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
defaultUser,
|
|
55
|
+
defaultAcl,
|
|
56
|
+
defaultDowntime,
|
|
57
|
+
defaultRefreshInterval,
|
|
58
|
+
defaultAcknowledgement,
|
|
59
|
+
defaultResourceStorageOptimizationMode,
|
|
60
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { default as userAtom } from './userAtom';
|
|
2
|
+
export { default as aclAtom } from './aclAtom';
|
|
3
|
+
export { default as downtimeAtom } from './downtimeAtom';
|
|
4
|
+
export { default as refreshIntervalAtom } from './refreshIntervalAtom';
|
|
5
|
+
export { default as cloudServicesAtom } from './cloudServicesAtom';
|
|
6
|
+
export { default as acknowledgementAtom } from './acknowledgementAtom';
|
|
7
|
+
export { default as resourceStorageOptimizationModeAtom } from './resourceStorageOptimizationMode';
|
|
8
|
+
export { ThemeMode } from './types';
|
|
9
|
+
|
|
10
|
+
export type {
|
|
11
|
+
User,
|
|
12
|
+
UserContext,
|
|
13
|
+
ActionAcl,
|
|
14
|
+
Actions,
|
|
15
|
+
Downtime,
|
|
16
|
+
CloudServices,
|
|
17
|
+
Acknowledgement,
|
|
18
|
+
Acl,
|
|
19
|
+
} from './types';
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface User {
|
|
4
|
+
alias: string;
|
|
5
|
+
default_page?: string | null;
|
|
6
|
+
isExportButtonEnabled: boolean;
|
|
7
|
+
locale: string;
|
|
8
|
+
name: string;
|
|
9
|
+
themeMode?: ThemeMode;
|
|
10
|
+
timezone: string;
|
|
11
|
+
use_deprecated_pages: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export enum ThemeMode {
|
|
15
|
+
dark = 'dark',
|
|
16
|
+
light = 'light',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CloudServices {
|
|
20
|
+
areCloudServicesEnabled: boolean;
|
|
21
|
+
setAreCloudServicesEnabled: React.Dispatch<React.SetStateAction<boolean>>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Acknowledgement {
|
|
25
|
+
force_active_checks: boolean;
|
|
26
|
+
notify: boolean;
|
|
27
|
+
persistent: boolean;
|
|
28
|
+
sticky: boolean;
|
|
29
|
+
with_services: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type UserContext = {
|
|
33
|
+
acknowledgement: Acknowledgement;
|
|
34
|
+
acl: Acl;
|
|
35
|
+
cloudServices: CloudServices | undefined;
|
|
36
|
+
downtime: Downtime;
|
|
37
|
+
refreshInterval: number;
|
|
38
|
+
resourceStorageOptimizationMode: boolean;
|
|
39
|
+
} & User;
|
|
40
|
+
|
|
41
|
+
export interface ActionAcl {
|
|
42
|
+
acknowledgement: boolean;
|
|
43
|
+
check: boolean;
|
|
44
|
+
comment: boolean;
|
|
45
|
+
downtime: boolean;
|
|
46
|
+
submit_status: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface Actions {
|
|
50
|
+
host: ActionAcl;
|
|
51
|
+
service: ActionAcl;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface Acl {
|
|
55
|
+
actions: Actions;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface Downtime {
|
|
59
|
+
duration: number;
|
|
60
|
+
fixed: boolean;
|
|
61
|
+
with_services: boolean;
|
|
62
|
+
}
|