Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
Merge 0e580b6 into d43689e
Browse files Browse the repository at this point in the history
  • Loading branch information
nappozord committed Sep 8, 2020
2 parents d43689e + 0e580b6 commit f540bbb
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 126 deletions.
21 changes: 18 additions & 3 deletions __mocks__/crd_fetch.json
Original file line number Diff line number Diff line change
Expand Up @@ -741,14 +741,29 @@
"description": "Layout that will be displayed",
"type": "object"
},
"name": {
"viewName": {
"description": "The name showed in the sidebar",
"type": "string"
},
"templates": {
"crds": {
"description": "Collection of CR template views",
"type": "array",
"items": {"type":"object","properties":{"kind":{"description":"The kind of a CRD we want to put in the view","type":"string"},"name":{"description":"The name showed in the custom view for this CRD","type":"string"},"template":{"description":"The path of a type template CRD custom resource (if default use the template in the CRD)","type":"string"}}}
"items": {
"type":"object",
"properties":{
"crdName":{
"description":"The kind of a CRD we want to put in the view",
"type":"string"
},
"crdAltName":{
"description":"The name showed in the custom view for this CRD",
"type":"string"
},
"template":{
"description":"The path of a type template CRD custom resource (if default use the template in the CRD)",
"type":"string"}
}
}
}
}
}
Expand Down
21 changes: 18 additions & 3 deletions __mocks__/crd_fetch_long.json
Original file line number Diff line number Diff line change
Expand Up @@ -871,14 +871,29 @@
"description": "Layout that will be displayed",
"type": "object"
},
"name": {
"viewName": {
"description": "The name showed in the sidebar",
"type": "string"
},
"templates": {
"crds": {
"description": "Collection of CR template views",
"type": "array",
"items": {"type":"object","properties":{"kind":{"description":"The kind of a CRD we want to put in the view","type":"string"},"name":{"description":"The name showed in the custom view for this CRD","type":"string"},"template":{"description":"The path of a type template CRD custom resource (if default use the template in the CRD)","type":"string"}}}
"items": {
"type":"object",
"properties":{
"crdName":{
"description":"The kind of a CRD we want to put in the view",
"type":"string"
},
"crdAltName":{
"description":"The name showed in the custom view for this CRD",
"type":"string"
},
"template":{
"description":"The path of a type template CRD custom resource (if default use the template in the CRD)",
"type":"string"}
}
}
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions __mocks__/views.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"selfLink": "/apis/test/v1/namespaces/default/views/awesome-view"
},
"spec": {
"name": "Liqo View",
"templates": [
"viewName": "Liqo View",
"crds": [
{
"name": "Test",
"kind": "advertisements.protocol.liqo.io"
"crdAltName": "Test",
"crdName": "advertisements.protocol.liqo.io"
},
{
"kind": "tunnelendpoints.liqonet.liqo.io"
"crdName": "tunnelendpoints.liqonet.liqo.io"
}
]
}
Expand Down
12 changes: 6 additions & 6 deletions __mocks__/views_alt_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
"selfLink": "/apis/test/v1/namespaces/default/views/awesome-view"
},
"spec": {
"name": "Liqo View",
"templates": [
"viewName": "Liqo View",
"crds": [
{
"name": "Test",
"kind": "advertisements.protocol.liqo.io"
"crdAltName": "Test",
"crdName": "advertisements.protocol.liqo.io"
},
{
"kind": "tunnelendpoints.liqonet.liqo.io"
"crdName": "tunnelendpoints.liqonet.liqo.io"
},
{
"kind": "liqodashtests.dashboard.liqo.com",
"crdName": "liqodashtests.dashboard.liqo.com",
"template": "dashboard.liqo.com/v1/histocharts/histo-test"
}
]
Expand Down
4 changes: 2 additions & 2 deletions __mocks__/views_empty.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"selfLink": "/apis/test/v1/namespaces/default/views/awesome-view"
},
"spec": {
"name": "Liqo View",
"templates": []
"viewName": "Liqo View",
"crds": []
}
}
],
Expand Down
12 changes: 6 additions & 6 deletions __mocks__/views_modified.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
"selfLink": "/apis/test/v1/namespaces/default/views/awesome-view"
},
"spec": {
"name": "Liqo View",
"templates": [
"viewName": "Liqo View",
"crds": [
{
"name": "Test",
"kind": "advertisements.protocol.liqo.io"
"crdAltName": "Test",
"crdName": "advertisements.protocol.liqo.io"
},
{
"kind": "tunnelendpoints.liqonet.liqo.io"
"crdName": "tunnelendpoints.liqonet.liqo.io"
},
{
"kind": "liqodashtests.dashboard.liqo.com"
"crdName": "liqodashtests.dashboard.liqo.com"
}
]
}
Expand Down
6 changes: 3 additions & 3 deletions __mocks__/views_withLayout.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
}
]
},
"templates": [
"crds": [
{
"kind": "advertisements.protocol.liqo.io"
"crdName": "advertisements.protocol.liqo.io"
},
{
"kind": "foreignclusters.discovery.liqo.io"
"crdName": "foreignclusters.discovery.liqo.io"
}
]
}
Expand Down
10 changes: 4 additions & 6 deletions kubernetes/config/dashboard-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production
labels:
app: liqo-dashboard
name: liqo-dashboard-content
namespace: liqo
spec:
rules:
- host: liqodashboard.crown-labs.ipv6.polito.it
- host: example.liqodashboard.com
http:
paths:
- backend:
serviceName: liqo-dashboard
servicePort: 80
servicePort: 443
path: /
tls:
- hosts:
- liqodashboard.crown-labs.ipv6.polito.it
secretName: dashboard-cert
- example.liqodashboard.com
secretName: liqo-dashboard-certificate
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,34 @@ spec:
type: object
spec:
properties:
name:
description: The name showed in the sidebar
viewName:
description: The name of the view showed in the sidebar
type: string
layout:
description: Layout that will be displayed
description: Layout of the view
type: object
templates:
description: Collection of CR template views
crds:
description: Collection of CRDs to show
items:
properties:
name:
crdAltName:
description: The name showed in the custom view for this CRD
type: string
kind:
description: The kind of a CRD we want to put in the view
crdName:
description: The name of the CRD that will be in the view
type: string
template:
description: The path of a type template CRD custom resource (if default use the template in the CRD)
description: The path of a type template CRD custom resource (if empty will use the template specified in the CRD)
type: string
type: object
type: array
type: object
type: object
version: v1
version: v1alpha1
versions:
- name: v1
served: true
storage: true
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
Expand Down
36 changes: 17 additions & 19 deletions src/CRD/CRD.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import './CRD.css';
import './CRDList.css';
import {
Space,
Badge, Breadcrumb, Button, Layout, Dropdown,
notification, Tabs, Tag, Typography, Popover, Row, Tooltip,
Col, Descriptions, Switch, Pagination, Empty, Rate, message, Drawer, Card, Divider
Badge, Button, Layout, Dropdown,
notification, Tag, Typography, Tooltip,
Descriptions, Switch, Pagination, Empty, Rate, Drawer, Card, Divider
} from 'antd';
import CR from './CR';
import { Link } from 'react-router-dom';
Expand Down Expand Up @@ -195,10 +195,10 @@ class CRD extends Component {
let cv = this.state.customViews.find(item => {
return item.metadata.name === e;
});
if(cv.spec.templates){
return !!cv.spec.templates.find(item => {
if(cv.spec.crds){
return !!cv.spec.crds.find(item => {
if(item)
return item.kind === this.state.CRD.metadata.name;
return item.crdName === this.state.CRD.metadata.name;
});
}
}
Expand All @@ -211,24 +211,24 @@ class CRD extends Component {
let index = -1;

/** Search if the CRD is in the view */
if(cv.spec.templates){
index = cv.spec.templates.indexOf(
cv.spec.templates.find(item => {
if(cv.spec.crds){
index = cv.spec.crds.indexOf(
cv.spec.crds.find(item => {
if(item)
return item.kind === this.state.CRD.metadata.name;
return item.crdName === this.state.CRD.metadata.name;
}));
} else {
cv.spec.templates = [];
cv.spec.crds = [];
}

/** If the CRD is in the view, remove it
* or else, add it in the view
*/
if(index !== -1){
cv.spec.templates[index] = null;
cv.spec.crds[index] = null;
} else {
cv.spec.templates.push({
kind: this.state.CRD.metadata.name
cv.spec.crds.push({
crdName: this.state.CRD.metadata.name
});
}

Expand Down Expand Up @@ -266,10 +266,10 @@ class CRD extends Component {
items.push(
<Menu.Item key={item.metadata.name} onClick={this.handleClick_addToView}>
{
item.spec.name ? (
item.spec.viewName ? (
<span style={this.checkAlreadyInView(item.metadata.name) ? {
color: 'red'
} : null}>{ item.spec.name }</span>
} : null}>{ item.spec.viewName }</span>
) : (
<span style={this.checkAlreadyInView(item.metadata.name) ? {
color: 'red'
Expand Down Expand Up @@ -321,12 +321,10 @@ class CRD extends Component {
!this.props.onCustomView ? (
<div style={{float: "right"}}>
<Space align={'center'}>
<Tooltip title={'Add or Remove to View'} placement={'topRight'}>
<div aria-label={'dropdown-CRD'}>
<Tooltip title={'Add or Remove to View'} placement={'topLeft'}>
<Dropdown.Button overlay={menu} placement="bottomCenter"
style={{paddingTop: 6}}
trigger={['click']} icon={<LayoutOutlined />} />
</div>
</Tooltip>
<Tooltip title={'Edit design'} placement={'top'}>
<Button icon={<PictureOutlined />} type="primary"
Expand Down
4 changes: 2 additions & 2 deletions src/common/SideBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class SideBar extends Component {
}}>
<LayoutOutlined style={{ fontSize: '20px' }} />
{
item.spec.name ? (
<span>{ item.spec.name }</span>
item.spec.viewName ? (
<span>{ item.spec.viewName }</span>
) : (
<span>{ item.metadata.name }</span>
)
Expand Down
45 changes: 20 additions & 25 deletions src/services/ApiManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class ApiManager {
});
}

/** Get the CRDs for the group crd-template.liqo.com */
/** Get the CRDs for the group dashboard.liqo.com */
getTemplates() {
let templates = [];
this.CRDs.forEach(CRD => {
Expand All @@ -91,31 +91,26 @@ export default class ApiManager {

/** Load Custom Views CRs */
loadCustomViewsCRs() {
let CRD = {
spec: {
group: 'crd-template.liqo.com',
version: 'v1',
names: {
plural: 'views'
}
}
let CRD = this.getCRDfromKind('View');

if(CRD){
/** First get all the CR */
this.getCustomResourcesAllNamespaces(CRD)
.then((res) => {
this.customViews = res.body.items;

/** update CVs in the views */
this.manageCallbackCVs(this.customViews);

/** Then set up a watch to watch changes in the CR of the CRD */
this.watchSingleCRD(
CRD.spec.group,
CRD.spec.version,
CRD.spec.names.plural,
this.CVsNotifyEvent);
}
);
}
/** First get all the CR */
this.getCustomResourcesAllNamespaces(CRD)
.then((res) => {
this.customViews = res.body.items;

/** update CVs in the views */
this.manageCallbackCVs(this.customViews);

/** Then set up a watch to watch changes in the CR of the CRD */
this.watchSingleCRD(
CRD.spec.group,
CRD.spec.version,
CRD.spec.names.plural,
this.CVsNotifyEvent);
}
);
}

/**
Expand Down

0 comments on commit f540bbb

Please sign in to comment.