summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/apps/connectApp/src/actions
diff options
context:
space:
mode:
authorHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-02-28 15:23:42 +0100
committerHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-02-28 15:24:28 +0100
commit7446f23b3abc30d7c53f2eaa951742371c071171 (patch)
treeb76a8d2e64c7aa850c09f8e69f01e7a262ab5cd5 /sdnr/wt/odlux/apps/connectApp/src/actions
parent49b155ec687cdf58fb51fe8245a2f5f4582b68f0 (diff)
UX extensions
UX Maintenance client and further changes Change-Id: I7643661d17db5fc3d3f94b58cb42ed0be558c64f Issue-ID: SDNC-583 Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps/connectApp/src/actions')
-rw-r--r--sdnr/wt/odlux/apps/connectApp/src/actions/mountedNetworkElementsActions.ts47
-rw-r--r--sdnr/wt/odlux/apps/connectApp/src/actions/requiredNetworkElementsActions.ts4
2 files changed, 33 insertions, 18 deletions
diff --git a/sdnr/wt/odlux/apps/connectApp/src/actions/mountedNetworkElementsActions.ts b/sdnr/wt/odlux/apps/connectApp/src/actions/mountedNetworkElementsActions.ts
index e342f6314..1cf528aa7 100644
--- a/sdnr/wt/odlux/apps/connectApp/src/actions/mountedNetworkElementsActions.ts
+++ b/sdnr/wt/odlux/apps/connectApp/src/actions/mountedNetworkElementsActions.ts
@@ -21,7 +21,7 @@ export class AllMountedNetworkElementsLoadedAction extends BaseAction {
}
/** Represents an action causing the store to update all mounted network elements. */
-export class AddMountedNetworkElement extends BaseAction {
+export class AddOrUpdateMountedNetworkElement extends BaseAction {
constructor(public mountedNetworkElement: MountedNetworkElementType | null, public error?: string) {
super();
}
@@ -47,43 +47,58 @@ export class UpdateRequiredMountedNetworkElement extends BaseAction {
}
/**
- * An actioncrator for a async thunk action to add an allready mounted element to the state of this app.
- * Note: Use this action to add created object notified by the websocket.
+ * Represents an action crator for a async thunk action to add an allready mounted element to the state of this app.
+ * Note: Use this action to add created object notified by the websocket.
*/
export const addMountedNetworkElementAsyncActionCreator = (mountId: string) => async (dispatch: Dispatch) => {
- connectService.getMountedNetworkElementByMountId(mountId).then(mountedNetworkElement => {
- mountedNetworkElement && dispatch(new AddMountedNetworkElement(mountedNetworkElement));
+ return connectService.getMountedNetworkElementByMountId(mountId).then(mountedNetworkElement => {
+ mountedNetworkElement && dispatch(new AddOrUpdateMountedNetworkElement(mountedNetworkElement));
}).catch(error => {
- dispatch(new AddMountedNetworkElement(null, error));
+ dispatch(new AddOrUpdateMountedNetworkElement(null, error));
+ });
+};
+
+export const updateMountedNetworkElementAsyncActionCreator = (mountId: string) => async (dispatch: Dispatch) => {
+ return connectService.getMountedNetworkElementByMountId(mountId).then(mountedNetworkElement => {
+ if (mountedNetworkElement) {
+ dispatch(new AddOrUpdateMountedNetworkElement(mountedNetworkElement));
+ } else {
+ dispatch(new RemoveMountedNetworkElement(mountId));
+ }
+ }).catch(error => {
+ dispatch(new AddOrUpdateMountedNetworkElement(null, error));
});
};
/** Represents an async thunk action to load all mounted network elements. */
export const loadAllMountedNetworkElementsAsync = (dispatch: Dispatch) => {
dispatch(new LoadAllMountedNetworkElementsAction());
- connectService.getMountedNetworkElementsList().then(mountedNetworkElements => {
+ return connectService.getMountedNetworkElementsList().then(mountedNetworkElements => {
mountedNetworkElements && dispatch(new AllMountedNetworkElementsLoadedAction(mountedNetworkElements));
}).catch(error => {
dispatch(new AllMountedNetworkElementsLoadedAction(null, error));
});
};
-/** Represents an async thunk action to load all mounted network elements. */
-export const mountNetworkElementActionCreatorAsync = (networkElement: RequiredNetworkElementType) => (dispatch: Dispatch) => {
- connectService.mountNetworkElement(networkElement).then((success) => {
- success && dispatch(new AddSnackbarNotification({ message: `Requesting mount [${ networkElement.mountId }]`, options: { variant: 'info' } }))
- || dispatch(new AddSnackbarNotification({ message: `Failed to mount [${ networkElement.mountId }]`, options: { variant: 'warning' } }));
+/** Represents an action crator for a async thunk action to mount a network element. */
+export const mountNetworkElementAsyncActionCreator = (networkElement: RequiredNetworkElementType) => (dispatch: Dispatch) => {
+ return connectService.mountNetworkElement(networkElement).then((success) => {
+ success && (
+ dispatch(addMountedNetworkElementAsyncActionCreator(networkElement.mountId)) &&
+ dispatch(new AddSnackbarNotification({ message: `Requesting mount [${networkElement.mountId}]`, options: { variant: 'info' } }))
+ ) || dispatch(new AddSnackbarNotification({ message: `Failed to mount [${ networkElement.mountId }]`, options: { variant: 'warning' } }));
}).catch(error => {
- dispatch(new AddMountedNetworkElement(null, error));
+ dispatch(new AddOrUpdateMountedNetworkElement(null, error));
});
};
-export const unmountNetworkElementActionCreatorAsync = (mountId: string) => (dispatch: Dispatch) => {
- connectService.unmountNetworkElement(mountId).then((success) => {
+/** Represents an action crator for a async thunk action to unmount a network element. */
+export const unmountNetworkElementAsyncActionCreator = (mountId: string) => (dispatch: Dispatch) => {
+ return connectService.unmountNetworkElement(mountId).then((success) => {
success && dispatch(new AddSnackbarNotification({ message: `Requesting unmount [${ mountId }]`, options: { variant: 'info' } }))
|| dispatch(new AddSnackbarNotification({ message: `Failed to unmount [${ mountId }]`, options: { variant: 'warning' } }));
}).catch(error => {
- dispatch(new AddMountedNetworkElement(null, error));
+ dispatch(new AddOrUpdateMountedNetworkElement(null, error));
});
};
diff --git a/sdnr/wt/odlux/apps/connectApp/src/actions/requiredNetworkElementsActions.ts b/sdnr/wt/odlux/apps/connectApp/src/actions/requiredNetworkElementsActions.ts
index 979321957..387ab8f54 100644
--- a/sdnr/wt/odlux/apps/connectApp/src/actions/requiredNetworkElementsActions.ts
+++ b/sdnr/wt/odlux/apps/connectApp/src/actions/requiredNetworkElementsActions.ts
@@ -12,7 +12,7 @@ import { connectService } from '../services/connectService';
export class BaseAction extends Action { }
-/** Represents an async thunk action that will add an element to the required network elements. */
+/** Represents an async thunk action creator to add an element to the required network elements. */
export const addToRequiredNetworkElementsAsyncActionCreator = (element: RequiredNetworkElementType) => (dispatch: Dispatch) => {
connectService.insertRequiredNetworkElement(element).then(_ => {
window.setTimeout(() => {
@@ -23,7 +23,7 @@ export const addToRequiredNetworkElementsAsyncActionCreator = (element: Required
});
};
-/** Represents an async thunk action that will delete an element from the required network elements. */
+/** Represents an async thunk action creator to delete an element from the required network elements. */
export const removeFromRequiredNetworkElementsAsyncActionCreator = (element: RequiredNetworkElementType) => (dispatch: Dispatch) => {
connectService.deleteRequiredNetworkElement(element).then(_ => {
window.setTimeout(() => {