mirror of
https://github.com/openziti/zrok.git
synced 2024-12-22 06:40:50 +01:00
communicate time as epoch ms; better disable of durations in ui (#33)
This commit is contained in:
parent
225e00861b
commit
95b4143a85
@ -8,6 +8,7 @@ import (
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/metadata"
|
||||
"github.com/sirupsen/logrus"
|
||||
"time"
|
||||
)
|
||||
|
||||
func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
@ -29,13 +30,14 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
|
||||
logrus.Errorf("error finding services for environment '%v': %v", env.ZId, err)
|
||||
return metadata.NewOverviewInternalServerError()
|
||||
}
|
||||
logrus.Infof("updatedAt: %v", time.Since(env.UpdatedAt.UTC()))
|
||||
es := &rest_model_zrok.EnvironmentServices{
|
||||
Environment: &rest_model_zrok.Environment{
|
||||
Address: env.Address,
|
||||
CreatedAt: env.CreatedAt.String(),
|
||||
CreatedAt: env.CreatedAt.UnixMilli(),
|
||||
Description: env.Description,
|
||||
Host: env.Host,
|
||||
UpdatedAt: env.UpdatedAt.String(),
|
||||
UpdatedAt: env.UpdatedAt.UnixMilli(),
|
||||
ZID: env.ZId,
|
||||
},
|
||||
}
|
||||
@ -46,10 +48,10 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
|
||||
}
|
||||
for _, svc := range svcs {
|
||||
es.Services = append(es.Services, &rest_model_zrok.Service{
|
||||
CreatedAt: svc.CreatedAt.String(),
|
||||
CreatedAt: svc.CreatedAt.UnixMilli(),
|
||||
Frontend: svc.Frontend,
|
||||
Backend: svc.Backend,
|
||||
UpdatedAt: svc.UpdatedAt.String(),
|
||||
UpdatedAt: svc.UpdatedAt.UnixMilli(),
|
||||
ZID: svc.ZId,
|
||||
Name: svc.Name,
|
||||
Metrics: sparkData[svc.Name],
|
||||
|
@ -8,8 +8,8 @@ create table accounts (
|
||||
email varchar(1024) not null unique,
|
||||
password char(128) not null,
|
||||
token varchar(32) not null unique,
|
||||
created_at timestamp not null default(current_timestamp),
|
||||
updated_at timestamp not null default(current_timestamp),
|
||||
created_at timestamptz not null default(current_timestamp),
|
||||
updated_at timestamptz not null default(current_timestamp),
|
||||
|
||||
constraint chk_email check (email <> ''),
|
||||
constraint chk_password check (password <> ''),
|
||||
@ -24,8 +24,8 @@ create table account_requests (
|
||||
token varchar(32) not null unique,
|
||||
email varchar(1024) not null unique,
|
||||
source_address varchar(64) not null,
|
||||
created_at timestamp not null default(current_timestamp),
|
||||
updated_at timestamp not null default(current_timestamp)
|
||||
created_at timestamptz not null default(current_timestamp),
|
||||
updated_at timestamptz not null default(current_timestamp)
|
||||
);
|
||||
|
||||
--
|
||||
@ -38,8 +38,8 @@ create table environments (
|
||||
host varchar(256),
|
||||
address varchar(64),
|
||||
z_id varchar(32) not null unique,
|
||||
created_at timestamp not null default(current_timestamp),
|
||||
updated_at timestamp not null default(current_timestamp),
|
||||
created_at timestamptz not null default(current_timestamp),
|
||||
updated_at timestamptz not null default(current_timestamp),
|
||||
|
||||
constraint chk_z_id check (z_id <> '')
|
||||
);
|
||||
@ -54,8 +54,8 @@ create table services (
|
||||
name varchar(32) not null unique,
|
||||
frontend varchar(1024),
|
||||
backend varchar(1024),
|
||||
created_at timestamp not null default(current_timestamp),
|
||||
updated_at timestamp not null default(current_timestamp),
|
||||
created_at timestamptz not null default(current_timestamp),
|
||||
updated_at timestamptz not null default(current_timestamp),
|
||||
|
||||
constraint chk_z_id check (z_id <> ''),
|
||||
constraint chk_name check (name <> '')
|
||||
|
@ -24,7 +24,7 @@ type Environment struct {
|
||||
Address string `json:"address,omitempty"`
|
||||
|
||||
// created at
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
CreatedAt int64 `json:"createdAt,omitempty"`
|
||||
|
||||
// description
|
||||
Description string `json:"description,omitempty"`
|
||||
@ -33,7 +33,7 @@ type Environment struct {
|
||||
Host string `json:"host,omitempty"`
|
||||
|
||||
// updated at
|
||||
UpdatedAt string `json:"updatedAt,omitempty"`
|
||||
UpdatedAt int64 `json:"updatedAt,omitempty"`
|
||||
|
||||
// z Id
|
||||
ZID string `json:"zId,omitempty"`
|
||||
|
@ -22,7 +22,7 @@ type Service struct {
|
||||
Backend string `json:"backend,omitempty"`
|
||||
|
||||
// created at
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
CreatedAt int64 `json:"createdAt,omitempty"`
|
||||
|
||||
// frontend
|
||||
Frontend string `json:"frontend,omitempty"`
|
||||
@ -34,7 +34,7 @@ type Service struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// updated at
|
||||
UpdatedAt string `json:"updatedAt,omitempty"`
|
||||
UpdatedAt int64 `json:"updatedAt,omitempty"`
|
||||
|
||||
// z Id
|
||||
ZID string `json:"zId,omitempty"`
|
||||
|
@ -428,7 +428,7 @@ func init() {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
"type": "integer"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
@ -437,7 +437,7 @@ func init() {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
"type": "integer"
|
||||
},
|
||||
"zId": {
|
||||
"type": "string"
|
||||
@ -524,7 +524,7 @@ func init() {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
"type": "integer"
|
||||
},
|
||||
"frontend": {
|
||||
"type": "string"
|
||||
@ -536,7 +536,7 @@ func init() {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
"type": "integer"
|
||||
},
|
||||
"zId": {
|
||||
"type": "string"
|
||||
@ -1036,7 +1036,7 @@ func init() {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
"type": "integer"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
@ -1045,7 +1045,7 @@ func init() {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
"type": "integer"
|
||||
},
|
||||
"zId": {
|
||||
"type": "string"
|
||||
@ -1132,7 +1132,7 @@ func init() {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
"type": "integer"
|
||||
},
|
||||
"frontend": {
|
||||
"type": "string"
|
||||
@ -1144,7 +1144,7 @@ func init() {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
"type": "integer"
|
||||
},
|
||||
"zId": {
|
||||
"type": "string"
|
||||
|
@ -282,9 +282,9 @@ definitions:
|
||||
active:
|
||||
type: boolean
|
||||
createdAt:
|
||||
type: string
|
||||
type: integer
|
||||
updatedAt:
|
||||
type: string
|
||||
type: integer
|
||||
|
||||
environmentServicesList:
|
||||
type: array
|
||||
@ -352,9 +352,9 @@ definitions:
|
||||
metrics:
|
||||
$ref: "#/definitions/serviceMetrics"
|
||||
createdAt:
|
||||
type: string
|
||||
type: integer
|
||||
updatedAt:
|
||||
type: string
|
||||
type: integer
|
||||
|
||||
serviceMetrics:
|
||||
type: array
|
||||
|
11
ui/package-lock.json
generated
11
ui/package-lock.json
generated
@ -15,6 +15,7 @@
|
||||
"@mui/material": "^5.10.4",
|
||||
"dagre": "^0.8.5",
|
||||
"eslint-config-react-app": "^7.0.1",
|
||||
"humanize-duration": "^3.27.3",
|
||||
"react": "^18.2.0",
|
||||
"react-data-table-component": "^7.5.2",
|
||||
"react-dom": "^18.2.0",
|
||||
@ -8964,6 +8965,11 @@
|
||||
"node": ">=10.17.0"
|
||||
}
|
||||
},
|
||||
"node_modules/humanize-duration": {
|
||||
"version": "3.27.3",
|
||||
"resolved": "https://registry.npmjs.org/humanize-duration/-/humanize-duration-3.27.3.tgz",
|
||||
"integrity": "sha512-iimHkHPfIAQ8zCDQLgn08pRqSVioyWvnGfaQ8gond2wf7Jq2jJ+24ykmnRyiz3fIldcn4oUuQXpjqKLhSVR7lw=="
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
@ -23475,6 +23481,11 @@
|
||||
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz",
|
||||
"integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw=="
|
||||
},
|
||||
"humanize-duration": {
|
||||
"version": "3.27.3",
|
||||
"resolved": "https://registry.npmjs.org/humanize-duration/-/humanize-duration-3.27.3.tgz",
|
||||
"integrity": "sha512-iimHkHPfIAQ8zCDQLgn08pRqSVioyWvnGfaQ8gond2wf7Jq2jJ+24ykmnRyiz3fIldcn4oUuQXpjqKLhSVR7lw=="
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
|
@ -10,6 +10,7 @@
|
||||
"@mui/material": "^5.10.4",
|
||||
"dagre": "^0.8.5",
|
||||
"eslint-config-react-app": "^7.0.1",
|
||||
"humanize-duration": "^3.27.3",
|
||||
"react": "^18.2.0",
|
||||
"react-data-table-component": "^7.5.2",
|
||||
"react-dom": "^18.2.0",
|
||||
|
@ -2,6 +2,8 @@ import DataTable from 'react-data-table-component';
|
||||
import Services from './Services';
|
||||
|
||||
const Environments = (props) => {
|
||||
const humanizeDuration = require("humanize-duration")
|
||||
|
||||
const columns = [
|
||||
{
|
||||
name: 'Description',
|
||||
@ -24,8 +26,8 @@ const Environments = (props) => {
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'Updated',
|
||||
selector: row => row.environment.updatedAt,
|
||||
name: 'Uptime',
|
||||
selector: row => humanizeDuration(new Date().getTime() - row.environment.updatedAt),
|
||||
sortable: true,
|
||||
},
|
||||
]
|
||||
@ -33,6 +35,8 @@ const Environments = (props) => {
|
||||
const servicesComponent = ({ data }) => <Services services={data.services} />
|
||||
const servicesExpanded = row => row.services != null && row.services.length > 0
|
||||
|
||||
console.log('now', Date.now())
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Environments</h2>
|
||||
|
@ -48,8 +48,8 @@
|
||||
* @property {string} address
|
||||
* @property {string} zId
|
||||
* @property {boolean} active
|
||||
* @property {string} createdAt
|
||||
* @property {string} updatedAt
|
||||
* @property {number} createdAt
|
||||
* @property {number} updatedAt
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -101,8 +101,8 @@
|
||||
* @property {string} frontend
|
||||
* @property {string} backend
|
||||
* @property {module:types.serviceMetrics} metrics
|
||||
* @property {string} createdAt
|
||||
* @property {string} updatedAt
|
||||
* @property {number} createdAt
|
||||
* @property {number} updatedAt
|
||||
*/
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user