import Alt from './skyquakeAltInstance.js';
import SkyquakeContainerSource from './skyquakeContainerSource.js';
import SkyquakeContainerActions from './skyquakeContainerActions';
+let Utils = require('utils/utils.js');
import _ from 'lodash';
//Temporary, until api server is on same port as webserver
var rw = require('utils/rw.js');
this.nav = {};
this.notifications = [];
this.socket = null;
+ this.projects = [];
+ this.user = {};
//Notification defaults
this.notificationMessage = '';
this.displayNotification = false;
})
}
+ openProjectSocketSuccess = (connection) => {
+ var self = this;
+ var ws = window.multiplexer.channel(connection);
+ if (!connection) return;
+ self.setState({
+ socket: ws.ws,
+ channelId: connection
+ });
+ ws.onmessage = function(socket) {
+ try {
+ var data = JSON.parse(socket.data);
+ Utils.checkAuthentication(data.statusCode, function() {
+ self.closeSocket();
+ });
+ if (!_.isEqual(data.project, self.projects)) {
+ self.setState({
+ projects: data.project
+ });
+ }
+ } catch(e) {
+ console.log('HIT an exception in openProjectSocketSuccess', e);
+ }
+ };
+ }
+ getUserProfileSuccess = (user) => {
+ this.alt.actions.global.hideScreenLoader.defer();
+ this.setState({user})
+ }
+ selectActiveProjectSuccess = (projectId) => {
+ let user = this.user;
+ user.projectId = projectId;
+ this.setState({user});
+ }
//Notifications
showNotification = (data) => {
let state = {
if(typeof(data) == 'string') {
} else {
- state.notificationMessage = data.msg;
- if(data.type == 'success') {
- state.notificationType = 'success';
+ if(!data) data = {};
+ state.notificationMessage = data.msg || 'Something very bad happened wrong';
+ if(data.type) {
+ state.notificationType = data.type;
}
}
this.setState(state);