Skip to content

Commit

Permalink
Fix various issues with Storage on the Console. Prevent refresh on St…
Browse files Browse the repository at this point in the history
…atus view if server is unreachable.
  • Loading branch information
mofirouz committed May 1, 2019
1 parent 56c495b commit 33a0e55
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 27 deletions.
34 changes: 17 additions & 17 deletions console/a_console-packr.go

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion console/ui/src/routes/status/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Dispatch} from 'redux';
import {connect} from 'react-redux';
import {ApplicationState, ConnectedReduxProps} from '../../store';
import * as statusActions from '../../store/status/actions';
import {StatusNodes} from '../../store/status/types';
import {Node, StatusNodes} from '../../store/status/types';

import Header from '../../components/header';
import Sidebar from '../../components/sidebar';
Expand Down Expand Up @@ -71,6 +71,16 @@ class Status extends Component<Props, State> {
const now = new Date();
const t = now.valueOf();

if (data && data.nodes && data.nodes.length == 0) {
data.nodes.push({
name: "",
avg_latency_ms: NaN,
avg_rate_sec: NaN,
avg_input_kbs: NaN,
avg_output_kbs: NaN
} as Node);
}

if (
data &&
data.nodes &&
Expand Down Expand Up @@ -209,6 +219,7 @@ class Status extends Component<Props, State> {
pointRadius: 0,
fill: false,
lineTension: 0.2,
spanGaps: false,
borderWidth: 2
}))
},
Expand Down
14 changes: 10 additions & 4 deletions console/ui/src/routes/storage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ class Storage extends Component<Props, State>
{
this.props.deleteManyRequest();
(document.getElementById('user_id') as HTMLInputElement).value = '';
this.props.fetchManyRequest({});
}
}

Expand All @@ -166,9 +165,16 @@ class Storage extends Component<Props, State>
event.preventDefault();
if(confirm('Are you sure you want to delete this object?'))
{
this.props.deleteRequest(object);
(document.getElementById('user_id') as HTMLInputElement).value = '';
this.props.fetchManyRequest({});
var user_id = (document.getElementById('user_id') as HTMLInputElement).value;

var request = {
filter: user_id,
user_id: object.user_id,
collection: object.collection,
key: object.key
} as StorageObjectRequest;

this.props.deleteRequest(request);
}
}

Expand Down
4 changes: 1 addition & 3 deletions console/ui/src/store/status/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function* handleFetch()
}
catch(err)
{
console.error(err);
if(err.status === 401)
{
localStorage.clear();
Expand All @@ -33,8 +32,7 @@ function* handleFetch()
else if(err instanceof Error)
{
yield put(statusError(err.stack!));
localStorage.clear();
window.location.href = '/';
// don't punt to the login screen. Just leave be.
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion console/ui/src/store/storage/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const storageUpdateError = (message: string) => action(

export const storageDeleteRequest = (data: StorageObjectRequest) => action(
StorageActionTypes.DELETE_REQUEST,
data
data,
);
export const storageDeleteSuccess = () => action(
StorageActionTypes.DELETE_SUCCESS
Expand Down
2 changes: 2 additions & 0 deletions console/ui/src/store/storage/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function* handleDeleteMany()
else
{
yield put(storageDeleteManySuccess());
yield handleFetchMany({type: '@@storage/FETCH_MANY_REQUEST', payload: {}});
}
}
catch(err)
Expand Down Expand Up @@ -263,6 +264,7 @@ function* handleDelete({payload: data}: AnyAction)
else
{
yield put(storageDeleteSuccess());
yield handleFetchMany({type: '@@storage/FETCH_MANY_REQUEST', payload: {user_id: data.filter} });
}
}
catch(err)
Expand Down
3 changes: 2 additions & 1 deletion console/ui/src/store/storage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export interface StorageObjectRequest
{
collection?: string,
key?: string,
user_id?: string
user_id?: string,
filter?: string
}

export interface StorageObject
Expand Down

0 comments on commit 33a0e55

Please sign in to comment.