@orchestrator-ui/orchestrator-ui-components 0.0.1-alpha.5 → 0.0.1-alpha.7

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/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
2
2
  import { css } from '@emotion/react';
3
3
  import { useState, createContext, useContext, useRef } from 'react';
4
- import { useEuiTheme, tint, EuiBadge, EuiText, EuiHeader, EuiHeaderSection, EuiHeaderSectionItem, EuiHeaderLogo, EuiBadgeGroup, EuiButtonIcon, EuiToolTip, EuiSideNav, EuiPageTemplate, EuiDataGrid } from '@elastic/eui';
4
+ import { useEuiTheme, tint, EuiBadge, EuiText, EuiHeader, EuiHeaderSection, EuiHeaderSectionItem, EuiHeaderLogo, EuiBadgeGroup, EuiButtonIcon, EuiToolTip, EuiSideNav, EuiButton, EuiSpacer, EuiPageTemplate, EuiDataGrid, EuiFlexGroup, EuiFlexItem, EuiIcon, EuiTextColor, EuiPanel, EuiHorizontalRule, EuiFieldSearch, EuiAvatar } from '@elastic/eui';
5
5
  import { useQuery } from 'react-query';
6
- import 'regenerator-runtime/runtime';
7
6
  import { GraphQLClient } from 'graphql-request';
7
+ import moment from 'moment';
8
+ import Link from 'next/link';
8
9
 
9
10
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10
11
 
@@ -2990,6 +2991,7 @@ const useOrchestratorConfig = initialOrchestratorConfig => {
2990
2991
  };
2991
2992
 
2992
2993
  const OrchestratorConfigContext = /*#__PURE__*/createContext({
2994
+ orchestratorApiBaseUrl: '',
2993
2995
  engineStatusEndpoint: '',
2994
2996
  processStatusCountsEndpoint: '',
2995
2997
  environmentName: '',
@@ -3048,10 +3050,9 @@ const useProcessStatusCountsQuery = () => {
3048
3050
  };
3049
3051
 
3050
3052
  const getTaskCountsSummary = processStatusCounts => {
3051
- var _a, _b, _c;
3052
- const failed = (_a = processStatusCounts === null || processStatusCounts === void 0 ? void 0 : processStatusCounts.task_counts.failed) !== null && _a !== void 0 ? _a : 0;
3053
- const inconsistentData = (_b = processStatusCounts === null || processStatusCounts === void 0 ? void 0 : processStatusCounts.task_counts.inconsistent_data) !== null && _b !== void 0 ? _b : 0;
3054
- const apiUnavailable = (_c = processStatusCounts === null || processStatusCounts === void 0 ? void 0 : processStatusCounts.task_counts.api_unavailable) !== null && _c !== void 0 ? _c : 0;
3053
+ const failed = 0;
3054
+ const inconsistentData = 0;
3055
+ const apiUnavailable = 0;
3055
3056
  return {
3056
3057
  failed,
3057
3058
  inconsistentData,
@@ -3152,10 +3153,8 @@ const FailedTasksBadge = () => {
3152
3153
  const {
3153
3154
  theme
3154
3155
  } = useOrchestratorTheme();
3155
- const {
3156
- data: processStatusCounts
3157
- } = useProcessStatusCountsQuery();
3158
- const taskCountsSummary = getTaskCountsSummary(processStatusCounts);
3156
+ useProcessStatusCountsQuery();
3157
+ const taskCountsSummary = getTaskCountsSummary();
3159
3158
  return jsx(EuiToolTip, Object.assign({
3160
3159
  position: "bottom",
3161
3160
  content: jsxs(Fragment, {
@@ -3186,10 +3185,24 @@ const OrchestratorSidebar = ({
3186
3185
  mobileTitle: "Nav Items",
3187
3186
  isOpenOnMobile: false,
3188
3187
  items: [{
3188
+ renderItem: () => jsxs(Fragment, {
3189
+ children: [jsx(EuiButton, Object.assign({
3190
+ onClick: e => {
3191
+ e.preventDefault();
3192
+ routeTo('/new-process');
3193
+ },
3194
+ iconType: "plus",
3195
+ fullWidth: true
3196
+ }, {
3197
+ children: "New Process"
3198
+ })), jsx(EuiSpacer, {
3199
+ size: "m"
3200
+ })]
3201
+ }),
3189
3202
  name: 'Menu',
3190
3203
  id: 1,
3191
3204
  items: [{
3192
- name: 'Home',
3205
+ name: 'Start',
3193
3206
  id: 2,
3194
3207
  onClick: e => {
3195
3208
  e.preventDefault();
@@ -3957,4 +3970,347 @@ const getStatusBadgeColor = status => {
3957
3970
  statusColors[status] : 'primary';
3958
3971
  };
3959
3972
 
3960
- export { Badge, CheckmarkCircleFill, CustomButton, Environment, LogoutIcon, MinusCircleOutline, OrchestratorConfigContext, OrchestratorConfigProvider, OrchestratorPageTemplate, PlusCircleFill, ProcessStatus, SortDirection, StatusDotIcon, SubscriptionStatusBadge, Table, XCircleFill, columnSortToEuiDataGridSorting, defaultOrchestratorTheme, getInitialColumnOrder, getStatusBadgeColor, getTypedFieldFromObject, useEngineStatusQuery, useOrchestratorConfig, useOrchestratorTheme, useProcessStatusCountsQuery, useQueryWithGraphql };
3973
+ const ListItemStartPage = ({
3974
+ item,
3975
+ type
3976
+ }) => {
3977
+ const [hoverState, setHoverState] = useState(false);
3978
+ const renderItem = (item, type) => {
3979
+ if (type === 'subscription') {
3980
+ item = item;
3981
+ return jsxs(EuiFlexItem, {
3982
+ children: [jsx(EuiTextColor, Object.assign({
3983
+ color: hoverState ? '#397dc2' : 'black',
3984
+ style: {
3985
+ fontWeight: 500,
3986
+ transition: '0.2s'
3987
+ }
3988
+ }, {
3989
+ children: item.product.name
3990
+ })), jsx(EuiTextColor, Object.assign({
3991
+ style: {
3992
+ fontWeight: 400
3993
+ }
3994
+ }, {
3995
+ children: item.subscription_id.slice(0, 8)
3996
+ }))]
3997
+ });
3998
+ } else if (type === 'process') {
3999
+ item = item;
4000
+ const date = new Date(item.last_modified_at * 1000);
4001
+ const formattedDate = moment(date).format('DD-MM-YYYY, HH:mm');
4002
+ return jsxs(EuiFlexItem, {
4003
+ children: [jsx(EuiTextColor, Object.assign({
4004
+ color: hoverState ? '#397dc2' : 'black',
4005
+ style: {
4006
+ fontWeight: 500,
4007
+ transition: '0.2s'
4008
+ }
4009
+ }, {
4010
+ children: item.workflow
4011
+ })), jsxs(EuiTextColor, Object.assign({
4012
+ style: {
4013
+ fontWeight: 400
4014
+ }
4015
+ }, {
4016
+ children: [formattedDate, " for", ' ', jsx("span", Object.assign({
4017
+ style: {
4018
+ color: '#397dc2'
4019
+ }
4020
+ }, {
4021
+ children: "KLM"
4022
+ }))]
4023
+ }))]
4024
+ });
4025
+ }
4026
+ };
4027
+ return jsx(Link, Object.assign({
4028
+ href: `/subscriptions/${'subscription_id' in item ? item.subscription_id : ''}`
4029
+ }, {
4030
+ children: jsxs(EuiFlexGroup, Object.assign({
4031
+ style: {
4032
+ cursor: 'pointer',
4033
+ paddingBlock: 10
4034
+ },
4035
+ onMouseOver: () => setHoverState(true),
4036
+ onMouseLeave: () => setHoverState(false)
4037
+ }, {
4038
+ children: [renderItem(item, type), jsx(EuiFlexItem, Object.assign({
4039
+ grow: false,
4040
+ style: {
4041
+ display: hoverState ? 'block' : 'none'
4042
+ }
4043
+ }, {
4044
+ children: jsx(EuiIcon, {
4045
+ type: "sortRight",
4046
+ color: "primary"
4047
+ })
4048
+ }))]
4049
+ }))
4050
+ }));
4051
+ };
4052
+
4053
+ function ListStartPage({
4054
+ list
4055
+ }) {
4056
+ return list && jsx(EuiFlexItem, Object.assign({
4057
+ style: {
4058
+ minWidth: 300
4059
+ }
4060
+ }, {
4061
+ children: jsxs(EuiPanel, Object.assign({
4062
+ hasShadow: false,
4063
+ hasBorder: true,
4064
+ paddingSize: "l"
4065
+ }, {
4066
+ children: [jsx("p", Object.assign({
4067
+ style: {
4068
+ fontWeight: 600
4069
+ }
4070
+ }, {
4071
+ children: list.title
4072
+ })), jsx(EuiSpacer, {
4073
+ size: "m"
4074
+ }), list.items.map((item, index) => jsxs(Fragment, {
4075
+ children: [jsx(ListItemStartPage, {
4076
+ item: item,
4077
+ type: list.type
4078
+ }), index === list.items.length - 1 ? null : jsx(EuiHorizontalRule, {
4079
+ margin: "none"
4080
+ })]
4081
+ })), jsx(EuiSpacer, {
4082
+ size: "m"
4083
+ }), jsx(EuiButton, Object.assign({
4084
+ fullWidth: true
4085
+ }, {
4086
+ children: list.buttonName
4087
+ }))]
4088
+ }))
4089
+ }));
4090
+ }
4091
+
4092
+ function getFavouriteSubscriptions(apiUrl) {
4093
+ return __awaiter(this, void 0, void 0, function* () {
4094
+ console.log('api url', apiUrl);
4095
+ const response = yield fetch(apiUrl + '/subscriptions/?range=10%2C15');
4096
+ return yield response.json();
4097
+ });
4098
+ }
4099
+ function getProcessesNeedingAttention(apiUrl) {
4100
+ return __awaiter(this, void 0, void 0, function* () {
4101
+ const response = yield fetch(apiUrl + '/processes/?range=100%2C105');
4102
+ return yield response.json();
4103
+ });
4104
+ }
4105
+ function getRecentProcesses(apiUrl) {
4106
+ return __awaiter(this, void 0, void 0, function* () {
4107
+ const response = yield fetch(apiUrl + '/processes/?range=106%2C111');
4108
+ return yield response.json();
4109
+ });
4110
+ }
4111
+ const useFavouriteSubscriptions = () => {
4112
+ const {
4113
+ orchestratorApiBaseUrl
4114
+ } = useContext(OrchestratorConfigContext);
4115
+ const {
4116
+ data,
4117
+ isLoading
4118
+ } = useQuery(['favouriteSubscriptions'], () => getFavouriteSubscriptions(orchestratorApiBaseUrl));
4119
+ const initialData = {
4120
+ buttonName: 'Show all favourites',
4121
+ items: [],
4122
+ title: 'Favourite Subscriptions',
4123
+ type: 'subscription'
4124
+ };
4125
+ return isLoading ? initialData : Object.assign(Object.assign({}, initialData), {
4126
+ items: data
4127
+ });
4128
+ };
4129
+ const useProcessesAttention = () => {
4130
+ const {
4131
+ orchestratorApiBaseUrl
4132
+ } = useContext(OrchestratorConfigContext);
4133
+ const {
4134
+ data,
4135
+ isLoading
4136
+ } = useQuery(['processesAttention'], () => getProcessesNeedingAttention(orchestratorApiBaseUrl));
4137
+ const initialData = {
4138
+ type: 'process',
4139
+ title: 'Processes that need attention',
4140
+ items: [],
4141
+ buttonName: 'Show all active processes'
4142
+ };
4143
+ return isLoading ? initialData : Object.assign(Object.assign({}, initialData), {
4144
+ items: data
4145
+ });
4146
+ };
4147
+ const useRecentProcesses = () => {
4148
+ const {
4149
+ orchestratorApiBaseUrl
4150
+ } = useContext(OrchestratorConfigContext);
4151
+ const {
4152
+ data,
4153
+ isLoading
4154
+ } = useQuery(['recentProcesses'], () => getRecentProcesses(orchestratorApiBaseUrl));
4155
+ const initialData = {
4156
+ type: 'process',
4157
+ title: 'Recently completed processes',
4158
+ items: [],
4159
+ buttonName: 'Show all completed processes'
4160
+ };
4161
+ return isLoading ? initialData : Object.assign(Object.assign({}, initialData), {
4162
+ items: data
4163
+ });
4164
+ };
4165
+
4166
+ const MultiListSection = () => {
4167
+ const favouriteSubscriptionsList = useFavouriteSubscriptions();
4168
+ const processesAttentionList = useProcessesAttention();
4169
+ const completedProcessesList = useRecentProcesses();
4170
+ return jsxs(EuiFlexGroup, Object.assign({
4171
+ wrap: true
4172
+ }, {
4173
+ children: [jsx(ListStartPage, {
4174
+ list: favouriteSubscriptionsList
4175
+ }), jsx(ListStartPage, {
4176
+ list: processesAttentionList
4177
+ }), jsx(ListStartPage, {
4178
+ list: completedProcessesList
4179
+ })]
4180
+ }));
4181
+ };
4182
+
4183
+ const FrequentlyUsed = ({
4184
+ values
4185
+ }) => {
4186
+ return jsx(EuiFlexGroup, Object.assign({
4187
+ wrap: true,
4188
+ gutterSize: "m"
4189
+ }, {
4190
+ children: values.map((value, index) => jsx(EuiFlexItem, Object.assign({
4191
+ grow: false
4192
+ }, {
4193
+ children: jsx(EuiButton, Object.assign({
4194
+ size: "xs",
4195
+ style: {
4196
+ minWidth: 0
4197
+ }
4198
+ }, {
4199
+ children: value
4200
+ }))
4201
+ }), index))
4202
+ }));
4203
+ };
4204
+
4205
+ const NewProcessPanel = () => {
4206
+ const [value, setValue] = useState('');
4207
+ const onChange = e => {
4208
+ setValue(e.target.value);
4209
+ };
4210
+ const frequentlyUsedValues = ['IP Prefix', 'SN8 LightPath', 'NL8 MSC', 'NL8 Service Port 100G', 'SN8 AGGSP'];
4211
+ return jsxs(EuiPanel, Object.assign({
4212
+ hasShadow: false,
4213
+ color: "subdued",
4214
+ paddingSize: "l"
4215
+ }, {
4216
+ children: [jsx(EuiText, {
4217
+ children: jsx("b", {
4218
+ children: "Start a new process"
4219
+ })
4220
+ }), jsx(EuiSpacer, {
4221
+ size: "m"
4222
+ }), jsx(EuiFieldSearch, {
4223
+ fullWidth: true,
4224
+ placeholder: "Search and select process",
4225
+ value: value,
4226
+ onChange: e => onChange(e),
4227
+ "aria-label": "Search and select process"
4228
+ }), jsx(EuiSpacer, {
4229
+ size: "m"
4230
+ }), jsx(EuiTextColor, Object.assign({
4231
+ color: "subdued"
4232
+ }, {
4233
+ children: "Frequently used:"
4234
+ })), jsx(EuiSpacer, {
4235
+ size: "s"
4236
+ }), jsx(FrequentlyUsed, {
4237
+ values: frequentlyUsedValues
4238
+ })]
4239
+ }));
4240
+ };
4241
+
4242
+ const totalStats = [{
4243
+ icon: 'kubernetesPod',
4244
+ name: 'subscriptions',
4245
+ value: 24864,
4246
+ color: 'primary'
4247
+ }, {
4248
+ icon: 'error',
4249
+ name: 'processes failed',
4250
+ value: 462252,
4251
+ color: 'danger'
4252
+ }, {
4253
+ icon: 'checkInCircleFilled',
4254
+ name: 'processes completed',
4255
+ value: 1353632,
4256
+ color: 'success'
4257
+ }];
4258
+ const StatCards = () => {
4259
+ const [stats] = useState(totalStats);
4260
+ const {
4261
+ theme
4262
+ } = useOrchestratorTheme();
4263
+ return jsx(EuiFlexGroup, Object.assign({
4264
+ wrap: true
4265
+ }, {
4266
+ children: stats.map((stat, index) => jsx(EuiFlexItem, {
4267
+ children: jsx(EuiPanel, Object.assign({
4268
+ hasShadow: false,
4269
+ color: "subdued",
4270
+ paddingSize: "l"
4271
+ }, {
4272
+ children: jsxs(EuiFlexGroup, {
4273
+ children: [jsx(EuiFlexItem, Object.assign({
4274
+ grow: false
4275
+ }, {
4276
+ children: jsx(EuiAvatar, {
4277
+ iconSize: "l",
4278
+ size: "xl",
4279
+ type: "space",
4280
+ name: stat.name,
4281
+ style: {
4282
+ maxHeight: 55,
4283
+ maxWidth: 55
4284
+ },
4285
+ iconType: stat.icon,
4286
+ iconColor: theme.colors.ghost,
4287
+ color: theme.colors[stat.color]
4288
+ })
4289
+ })), jsxs(EuiFlexItem, {
4290
+ children: [jsx(EuiText, Object.assign({
4291
+ color: "subdued"
4292
+ }, {
4293
+ children: jsxs("h4", Object.assign({
4294
+ style: {
4295
+ fontWeight: 300
4296
+ }
4297
+ }, {
4298
+ children: ["Total ", stat.name]
4299
+ }))
4300
+ })), jsx(EuiText, {
4301
+ children: jsx("h2", Object.assign({
4302
+ style: {
4303
+ fontWeight: 500
4304
+ }
4305
+ }, {
4306
+ children: stat.value.toLocaleString('de-DE')
4307
+ }))
4308
+ })]
4309
+ })]
4310
+ })
4311
+ }))
4312
+ }, index))
4313
+ }));
4314
+ };
4315
+
4316
+ export { Badge, CheckmarkCircleFill, CustomButton, Environment, ListItemStartPage, LogoutIcon, MinusCircleOutline, MultiListSection, NewProcessPanel, OrchestratorConfigContext, OrchestratorConfigProvider, OrchestratorPageTemplate, PlusCircleFill, ProcessStatus, SortDirection, StatCards, StatusDotIcon, SubscriptionStatusBadge, Table, XCircleFill, columnSortToEuiDataGridSorting, defaultOrchestratorTheme, getInitialColumnOrder, getStatusBadgeColor, getTypedFieldFromObject, useEngineStatusQuery, useOrchestratorConfig, useOrchestratorTheme, useProcessStatusCountsQuery, useQueryWithGraphql };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orchestrator-ui/orchestrator-ui-components",
3
- "version": "0.0.1-alpha.5",
3
+ "version": "0.0.1-alpha.7",
4
4
  "main": "./index.js",
5
5
  "module": "./index.js",
6
6
  "type": "module",
@@ -10,7 +10,8 @@
10
10
  "@elastic/eui": "77.1.0",
11
11
  "react": "18.2.0",
12
12
  "@emotion/react": "11.10.6",
13
- "regenerator-runtime": "0.13.7",
13
+ "moment": "2.29.4",
14
+ "next": "13.1.1",
14
15
  "react-query": "3.39.3",
15
16
  "graphql-request": "5.2.0",
16
17
  "@graphql-typed-document-node/core": "3.1.2"
package/src/index.d.ts CHANGED
@@ -9,4 +9,10 @@ export * from './lib/theme/defaultOrchestratorTheme';
9
9
  export * from './lib/utils/getTypedFieldFromObject';
10
10
  export * from './lib/utils/getStatusBadgeColor';
11
11
  export * from './lib/contexts/OrchestratorConfigContext';
12
+ export * from './lib/components/StartPage/ListItemStartPage';
13
+ export * from './lib/components/StartPage/ListStartPage';
14
+ export * from './lib/components/StartPage/MultiListSection';
15
+ export * from './lib/components/StartPage/NewProcessPanel';
16
+ export * from './lib/components/StartPage/StatCards';
17
+ export * from './lib/types';
12
18
  export * from './lib/hooks';
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ export interface FrequentlyUsedProps {
3
+ values: string[];
4
+ }
5
+ export declare const FrequentlyUsed: FC<FrequentlyUsedProps>;
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ import { Process, Subscription } from '../../types';
3
+ export interface ListItemStartPageProps {
4
+ item: Subscription | Process;
5
+ type: string;
6
+ }
7
+ export declare const ListItemStartPage: FC<ListItemStartPageProps>;
@@ -0,0 +1,7 @@
1
+ import { ReactElement } from 'react';
2
+ import { ItemsList } from '../../types';
3
+ interface ListStartPage {
4
+ list: ItemsList;
5
+ }
6
+ export default function ListStartPage({ list }: ListStartPage): ReactElement;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const MultiListSection: FC;
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const NewProcessPanel: FC;
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const StatCards: FC;
@@ -1,4 +1,3 @@
1
- import 'regenerator-runtime/runtime';
2
1
  import { ControlColumn, DataSorting, TableColumns } from './columns';
3
2
  import { EuiDataGridPaginationProps } from '@elastic/eui/src/components/datagrid/data_grid_types';
4
3
  export declare type Pagination = EuiDataGridPaginationProps & {
@@ -0,0 +1,18 @@
1
+ export declare const useFavouriteSubscriptions: () => {
2
+ items: any;
3
+ type: string;
4
+ title: string;
5
+ buttonName: string;
6
+ };
7
+ export declare const useProcessesAttention: () => {
8
+ items: any;
9
+ type: string;
10
+ title: string;
11
+ buttonName: string;
12
+ };
13
+ export declare const useRecentProcesses: () => {
14
+ items: any;
15
+ type: string;
16
+ title: string;
17
+ buttonName: string;
18
+ };
@@ -4,6 +4,7 @@ export declare enum Environment {
4
4
  }
5
5
  export declare type OrchestratorConfig = {
6
6
  environmentName: Environment | string;
7
+ orchestratorApiBaseUrl: string;
7
8
  engineStatusEndpoint: string;
8
9
  processStatusCountsEndpoint: string;
9
10
  graphqlEndpoint: string;
@@ -0,0 +1,55 @@
1
+ import { _EuiThemeColorsMode } from '@elastic/eui/src/global_styling/variables/colors';
2
+ export interface ItemsList {
3
+ type: string;
4
+ title: string;
5
+ items: Subscription[] | Process[];
6
+ buttonName: string;
7
+ }
8
+ export interface TotalStat {
9
+ icon: string;
10
+ name: string;
11
+ value: number;
12
+ color: keyof _EuiThemeColorsMode;
13
+ }
14
+ export interface Subscription {
15
+ name: string;
16
+ subscription_id: string;
17
+ description: string;
18
+ product: Product;
19
+ product_id: string;
20
+ status: string;
21
+ insync: boolean;
22
+ customer_id: string;
23
+ start_date: number;
24
+ end_date: number;
25
+ note: string;
26
+ }
27
+ export interface Process {
28
+ pid: string;
29
+ workflow: string;
30
+ assignee: string;
31
+ last_status: string;
32
+ failed_reason: string;
33
+ traceback: string;
34
+ step: string;
35
+ created_by: string;
36
+ started_at: number;
37
+ last_modified_at: number;
38
+ is_task: boolean;
39
+ }
40
+ export interface Product {
41
+ name: string;
42
+ tag: string;
43
+ description: string;
44
+ product_id: string;
45
+ created_at: number;
46
+ product_type: string;
47
+ end_date: number;
48
+ status: string;
49
+ fixed_inputs: [];
50
+ workflows: [];
51
+ product_blocks: [];
52
+ create_subscription_workflow_key: string;
53
+ modify_subscription_workflow_key: string;
54
+ terminate_subscription_workflow_key: string;
55
+ }