aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/apps/connectApp/src
diff options
context:
space:
mode:
authorHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-03-12 18:00:21 +0100
committerHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-03-12 18:01:06 +0100
commit2d4424c28ac35763ef44c42ae2f01664d42b268c (patch)
tree4e6ebdc2e57c1c8f2c91d3ec094b340c89dfe5c5 /sdnr/wt/odlux/apps/connectApp/src
parentcaf781999351fc6a3e2acb5b2fe47fe04a291d2d (diff)
Security provider for UX-Client-Login
Use ODL provided oauth2/token for UX clients Change-Id: I9f9ae931fc5e74dc13076bd23551d163c0685606 Issue-ID: SDNC-648 Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps/connectApp/src')
-rw-r--r--sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts30
-rw-r--r--sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx6
2 files changed, 19 insertions, 17 deletions
diff --git a/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts b/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts
index 91891deb6..aa6512011 100644
--- a/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts
+++ b/sdnr/wt/odlux/apps/connectApp/src/services/connectService.ts
@@ -6,7 +6,7 @@ import { requestRest } from '../../../../framework/src/services/restService';
import { Result, HitEntry } from '../../../../framework/src/models/elasticSearch';
-/**
+/**
* Represents a web api accessor service for all Network Elements actions.
*/
class ConnectService {
@@ -16,7 +16,7 @@ class ConnectService {
public async getAllRequiredNetworkElements(): Promise<(RequiredNetworkElementType & { _id: string })[] | null> {
const path = 'database/mwtn/required-networkelement/_search';
const query = { "query": { "match_all": {} } };
-
+
const result = await requestRest<Result<RequiredNetworkElementType>>(path, { method: "POST", body: JSON.stringify(query) });
return result && result.hits && result.hits.hits && result.hits.hits.map(ne => ({
_id: ne._id,
@@ -30,7 +30,7 @@ class ConnectService {
public async getRequiredNetworkElementByMountId(mountId:string): Promise<(RequiredNetworkElementType & { _id: string }) | null> {
const path = `database/mwtn/required-networkelement/${mountId}`;
-
+
const result = await requestRest<HitEntry<RequiredNetworkElementType> & { found: boolean }>(path, { method: "GET" });
return result && result.found && result._source && {
_id: result._id,
@@ -104,8 +104,8 @@ class ConnectService {
/** Get all mounted network elements and fills the property required according to the database contents. */
public async getMountedNetworkElementsList(): Promise<MountedNetworkElementType[] | null> {
const path = 'restconf/operational/network-topology:network-topology/topology/topology-netconf';
-
- const topologyRequestPomise = requestRest<{ topology: Topology[] | null }>(path, { method: "GET" }, true);
+
+ const topologyRequestPomise = requestRest<{ topology: Topology[] | null }>(path, { method: "GET" });
const requiredNetworkElementsPromise = this.getAllRequiredNetworkElements();
const [netconfResponse, requiredNetworkElements] = await Promise.all([topologyRequestPomise, requiredNetworkElementsPromise]);
@@ -122,16 +122,16 @@ class ConnectService {
return mountPoints || [];
}
- /** Get one mounted network element. */
+ /** Get one mounted network element. */
public async getMountedNetworkElementByMountId(mountId: string): Promise<MountedNetworkElementType | null> {
const path = 'restconf/operational/network-topology:network-topology/topology/topology-netconf/node/' + mountId;
- const getMountedNetworkElementByMountIdPromise = requestRest<{ node: TopologyNode[] | null }>(path, { method: "GET" }, true);
+ const getMountedNetworkElementByMountIdPromise = requestRest<{ node: TopologyNode[] | null }>(path, { method: "GET" });
const getRequiredNetworkElementByMountIdPromise = this.getRequiredNetworkElementByMountId(mountId);
const [mountedNetworkElement, requiredNetworkElement] = await Promise.all([getMountedNetworkElementByMountIdPromise, getRequiredNetworkElementByMountIdPromise]);
return mountedNetworkElement && mountedNetworkElement.node && ConnectService.mapTopologyNode(mountedNetworkElement.node[0], requiredNetworkElement && requiredNetworkElement.mountId === mountedNetworkElement.node[0]["node-id"] || false) || null;
}
-
+
/** Mounts an required network element. */
public async mountNetworkElement(networkElement: RequiredNetworkElementType): Promise<boolean> {
const path = 'restconf/config/network-topology:network-topology/topology/topology-netconf/node/' + networkElement.mountId;
@@ -154,7 +154,7 @@ class ConnectService {
' <!-- keepalive-delay set to 0 turns off keepalives-->',
' <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">120</keepalive-delay>',
'</node>'].join('');
-
+
try {
const result = await requestRest<string>(path, {
method: 'PUT',
@@ -163,9 +163,9 @@ class ConnectService {
'Accept': 'application/xml'
},
body: mountXml
- }, true);
+ });
// expect an empty answer
- return result !== null;
+ return result !== null;
} catch {
return false;
}
@@ -174,7 +174,7 @@ class ConnectService {
/** Unmounts a network element by its id. */
public async unmountNetworkElement(mountId: string): Promise<boolean> {
const path = 'restconf/config/network-topology:network-topology/topology/topology-netconf/node/' + mountId;
-
+
try {
const result = await requestRest<string>(path, {
method: 'DELETE',
@@ -182,10 +182,10 @@ class ConnectService {
'Content-Type': 'application/xml',
'Accept': 'application/xml'
},
- }, true);
+ });
// expect an empty answer
- return result !== null;
-
+ return result !== null;
+
} catch {
return false;
}
diff --git a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx
index b73eb39d7..998618608 100644
--- a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx
+++ b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx
@@ -37,11 +37,12 @@ class ConnectApplicationComponent extends React.Component<ConnectApplicationComp
*/
constructor(props: ConnectApplicationComponentProps) {
super(props);
-
+
this.state = {
activePanel: null
};
}
+
private onTogglePanel = (panelId: PanelId) => {
const nextActivePanel = panelId === this.state.activePanel ? null : panelId;
this.setState({
@@ -69,7 +70,7 @@ class ConnectApplicationComponent extends React.Component<ConnectApplicationComp
render(): JSX.Element {
const { activePanel } = this.state;
-
+
return (
<>
<Panel activePanel={ activePanel } panelId={ 'RequiredNetworkElements' } onToggle={ this.onTogglePanel } title={ "Required Network Elements" }>
@@ -85,6 +86,7 @@ class ConnectApplicationComponent extends React.Component<ConnectApplicationComp
);
};
public componentDidMount() {
+ this.onTogglePanel("RequiredNetworkElements");
this.props.onLoadUnknownNetworkElements();
}
}