import AccountActions from './accountActions.js';
import AccountSource from './accountSource.js';
-
+var Utils = require('utils/utils.js');
var rw = require('utils/rw.js');
var altImage = rw.getSearchParams(window.location).alt_image;
+var _ = require('lodash');
let Params = {
//Config Agent
}
-
let AccountMeta = {
+ 'resource-orchestrator': {
+ defaultType: 'openmano',
+ types: [
+ {
+ name: "OpenMANO",
+ 'ro-account-type': 'openmano'
+ }],
+ params: {
+ 'openmano' : [{
+ label: "Host",
+ ref: 'host'
+ }, {
+ label: "Port",
+ ref: 'port'
+ }, {
+ label: "Tenant ID",
+ ref: 'tenant-id'
+ }]
+ }
+ },
'config-agent': {
defaultType: 'juju',
}, {
label: "URL",
ref: 'url'
- }]
+ }],
+
+ "openstack": [{
+ label: "Key",
+ ref: 'key'
+ },{
+ label: "Secret",
+ ref: 'secret'
+ },{
+ label: "Authentication URL",
+ ref: 'auth_url'
+ },{
+ label: "Tenant",
+ ref: 'tenant'
+ },{
+ label: "User domain",
+ ref: 'user-domain',
+ optional: true
+ },{
+ label: "Project domain",
+ ref: 'project-domain',
+ optional: true
+ },{
+ label: "Region",
+ ref: 'region',
+ optional: true
+ }
+ // ,{
+ // label: "admin",
+ // ref: 'admin',
+ // default: false,
+ // optional: true
+ // }
+ // ,{
+ // label: "Management Network",
+ // ref: 'mgmt-network'
+ // }
+ // ,{
+ // label: "Plugin Name",
+ // ref: 'plugin-name',
+ // optional: true
+ // },{
+ // label: "Security Groups",
+ // ref: 'security-groups',
+ // type: 'list',
+ // optional: true
+ // },{
+ // label: "Dynamic Flavor Support ",
+ // ref: 'dynamic-flavor-support',
+ // type: 'boolean',
+ // optional: true
+ // }
+ //, {
+ // label: "Floating IP Pool",
+ // ref: 'floating-ip-pool',
+ // optional: true
+ // }
+ // ,{
+ // label: "Certificate Validation",
+ // ref: 'cert-validate',
+ // type: 'boolean',
+ // optional: true
+ // }
+ ]
+
},
types: [{
"name": "ODL",
"account-type": "odl",
+ },{
+ "name": "OpenStack",
+ "account-type": "openstack",
}]
},
'cloud': {
label: "Tenant",
ref: 'tenant'
}, {
- label: 'Management Network',
- ref: 'mgmt-network'
+ label: 'Default Management Network',
+ ref: 'mgmt-network',
+ optional: true
}, {
- label: 'Floating IP Pool',
+ label: 'Default Floating IP Pool Network Name',
ref: 'floating-ip-pool',
optional: true
+ }, {
+ label: "User Domain",
+ ref: 'user-domain',
+ optional: true
+ }, {
+ label: "Project Domain",
+ ref: 'project-domain',
+ optional: true
+ }, {
+ label: "Region",
+ ref: 'region',
+ optional: true
}],
"openvim": [{
label: "Host",
label: "Port",
ref: 'port',
optional: true
- }]
+ }],
+ "prop_cloud1": [{
+ label: "Host",
+ ref: "host"
+ }, {
+ label: "Username",
+ ref: "username"
+ }, {
+ label: "Password",
+ ref: "password"
+ }, {
+ label: "Management Network",
+ ref: "mgmt-network"
+ }, {
+ label: "Public IP pool",
+ ref: "public-ip-pool"
+ }, {
+ label: "WAN Interface",
+ ref: "wan-interface"
+ }, {
+ label: "Firewall",
+ ref: "firewall",
+ optional: true
+ }]
},
nestedParams: {
"openvim": {
}, {
"name": "Open VIM",
"account-type": "openvim"
- }]
+ }, {
+ "name": "Brocade",
+ "account-type": "prop_cloud1"
+ }]
},
resources: {
},
"openstack": require("../../images/openstack.png"),
"cloudsim_proxy": require("../../images/riftio.png"),
"odl": require("../../images/OpenDaylight_logo.png"),
- "juju": require("../../images/juju.svg")
+ "juju": require("../../images/juju.svg"),
+ "prop_cloud1": require("../../images/brocade.png"),
+ "openmano": require("../../images/openmano.png")
},
labelByType: {
"aws": "AWS",
"openvim": "Open VIM",
"openstack": "OpenStack",
- "cloudsim_proxy": "Cloudsim"
+ "cloudsim_proxy": "Cloudsim",
+ "prop_cloud1": "Brocade",
+ "openmano": "OpenStack"
}
}
export default class AccountStore {
constructor() {
+ // const savedData = JSON.parse(window.sessionStorage.getItem('account'));
+ const savedData = null;
+ this.saveAccountToSessionStorage(null, true)
this.cloud = [];
this['config-agent'] = [];
+ this['resource-orchestrator'] = [];
this.sdn = [];
+ this.savedData = savedData;
this.account = null;
- this.types = [];
+ // this.account = savedData.account;
+ // this.accountType = savedData.accountType;
+ this.types = this.accountType ? AccountMeta[this.accountType].types : [];
this.refreshingAll = false;
this.sdnOptions = [];
this.AccountMeta = AccountMeta;
this.showVIM = true;
+ this.vduInstanceTimeout = '';
this.bindActions(AccountActions(this.alt));
this.registerAsync(AccountSource);
this.exportPublicMethods({
updateAccount: this.updateAccount,
viewAccount: this.viewAccount,
handleNestedParamChange: this.handleNestedParamChange,
- getImage: this.getImage
+ getImage: this.getImage,
+ saveAccountToSessionStorage: this.saveAccountToSessionStorage,
+ updateVduTimeout: this.updateVduTimeout,
+ getTransientAccountForUser: this.getTransientAccountForUser
})
}
refreshAllAccountsSuccess = () => {
}
refreshCloudAccountSuccess = () => {
- }
- getResourceOrchestratorSuccess = (data) => {
- this.alt.actions.global.hideScreenLoader.defer();
- if(data['account-type'] == 'openmano') {
- this.setState({
- showVIM: false
- })
- }
}
deleteAccountSuccess = (response) => {
+ this.saveAccountToSessionStorage(null, true);
this.setState({
currentAccount: false,
account: {}
openAccountSocketSuccess = (connection) => {
let self = this;
let ws = window.multiplexer.channel(connection);
-
if (!connection) return;
this.setState({
socket: ws.ws,
ws.onmessage = (socket) => {
try {
var data = JSON.parse(socket.data);
+ Utils.checkAuthentication(data.statusCode, function() {
+ self.closeSocket();
+ });
let SdnOptions = [{
label: 'Select an SDN Account',
value: false
cloud: data.cloud.data,
'config-agent': data['config-agent'].data,
sdn: data.sdn.data,
+ 'resource-orchestrator': data['resource-orchestrator'].data,
sdnOptions: SdnOptions
};
//If account is selected, updated connection status only
- if(self.currentAccount) {
+ if(self.currentAccount && (self.account || self.savedData)) {
let Account = self.getAccountFromStream(data[self.currentAccount.type].data, self.currentAccount.name);
- newState.account = self.account;
- newState.account['connection-status'] = Account['connection-status']
+ newState.account = self.changedData ? self.account : self.savedData || self.account;
+
+ newState.account['connection-status'] = Account && Account['connection-status'];
+ newState.savedData = null;
}
- self.setState(newState)
+ self.setState(newState);
} catch(error) {
console.log('Hit at exception in openAccountSocketSuccess', error)
}
socket: null
})
}
- setAccountTemplate = (AccountType, type) => {
+ setAccountTemplate = (AccountType, type, savedData) => {
+ console.log('Setting Account Template')
let account = {
name: '',
'account-type': type || AccountMeta[AccountType].defaultType,
account[type || AccountMeta[AccountType].defaultType] = {}
this.setState({
- account: account,
+ account: savedData || account,
accountType: AccountType,
types: AccountMeta[AccountType].types,
- currentAccount: null
+ currentAccount: null,
+ changedData: true,
+ savedData: null
})
}
getAccountFromStream(data, name) {
let result = null;
- data.map(function(a) {
+ data && _.isArray(data) && data.map(function(a) {
if(a.name == name) {
result = a;
}
});
return result;
}
- viewAccount = ({type, name}) => {
+ viewAccount = ({type, name}, savedData) => {
+ console.log('Viewing account')
var data = null;
var accounts = null;
- if(this && this[type].length) {
+ let vduInstanceTimeout = '';
+ if(this && this[type] && this[type].length) {
accounts = this[type];
data = this.getAccountFromStream(accounts, name);
+ const isRo = data.hasOwnProperty('ro-account-type');
if(data) {
let accountParams = {
- params: AccountMeta[type].params[data['account-type']]
+ params: AccountMeta[type].params[
+ isRo ? data['ro-account-type'] : data['account-type']
+ ]
};
let accountNestedParams = {
- nestedParams: AccountMeta[type].nestedParams?AccountMeta[type].nestedParams[data['account-type']]:null
+ nestedParams: AccountMeta[type].nestedParams?AccountMeta[type].nestedParams[
+ isRo ? data['ro-account-type'] : data['account-type']
+ ]:null
};
-
+ if (data.hasOwnProperty('vdu-instance-timeout')) {
+ vduInstanceTimeout = data['vdu-instance-timeout'];
+ }
this.setState({
currentAccount: {type, name},
- account: Object.assign(data, accountParams, accountNestedParams),
- accountType: type
+ account: (savedData ? savedData : Object.assign(data, accountParams, accountNestedParams)) || null,
+ accountType: type,
+ types: AccountMeta[type].types,
+ vduInstanceTimeout: vduInstanceTimeout,
+ savedData: null
})
}
+ } else {
+ this.setState({
+ currentAccount: {type, name},
+ account: null,
+ accountType: type,
+ types: AccountMeta[type].types,
+ })
}
}
generateOptionsByName(data) {
let results = [];
- if (data && data.constructor.name == "Array") {
+ if (data && _.isArray(data)) {
data.map(function(d) {
results.push({
label: d.name,
return results;
}
updateAccount = (account) => {
- this.setState({account:account})
+ this.saveAccountToSessionStorage(account);
+ this.setState({account:account,
+ changedData: true})
}
handleNameChange = (event) => {
var account = this.account;
account.name = event.target.value;
+ this.saveAccountToSessionStorage(account)
+ this.setState(
+ {
+ account:account,
+ changedData: true
+ }
+ );
+ }
+ updateVduTimeout = (event) => {
+ var vduInstanceTimeout = event.target.value;
this.setState(
{
- account:account
+ vduInstanceTimeout:vduInstanceTimeout
}
);
}
- handleAccountTypeChange = (node, event) => {
+ handleAccountTypeChange = (node, isRo, event) => {
var temp = {};
temp.name = this.account.name;
- temp['account-type'] = event.target.value;
+ if (isRo) {
+ temp['ro-account-type'] = event.target.value;
+ } else {
+ temp['account-type'] = event.target.value;
+ }
temp.params= AccountMeta[this.accountType].params[event.target.value];
- temp.nestedParams = AccountMeta[this.accountType]?AccountMeta[this.accountType].nestedParams[event.target.value]:null;
+ temp.nestedParams = (AccountMeta[this.accountType] && AccountMeta[this.accountType].nestedParams )?AccountMeta[this.accountType].nestedParams[event.target.value]:null;
temp[event.target.value] = {};
+ this.saveAccountToSessionStorage(temp)
this.setState({
- account: temp
+ account: temp,
+ changedData: true
});
}
- handleParamChange(node, event) {
+ handleParamChange(node, isRo, event) {
return function(event) {
var account = this.state.account;
- account[account['account-type']][node.ref] = event.target.value;
+ if (isRo) {
+ account[account['ro-account-type']][node.ref] = event.target.value;
+
+ } else {
+ account[account['account-type']][node.ref] = event.target.value;
+
+ }
account.params[node.ref] = event.target.value;
this.updateAccount(account);
}.bind(this);
getImage = (type) => {
return AccountMeta.image[type];
}
-}
-
-
-/**
- *Cloud
- *
- * {"name":"eng2","account-type":"openstack","openstack":{"key":"lmaultsb","secret":"mypasswd","auth_url":"http://engstack.eng.riftio.com:5000/v3/","tenant":"lmaultsb","mgmt-network":"private"}}
-Name
-Path
-
+ createAccountSuccess = () => {
+ this.setState({account: {}})
+ this.saveAccountToSessionStorage(null, true)
+ }
+ handleCancelAccount = () => {
+ this.setState({account: {}, currentAccount: null, savedData: null, accountType: null, types: []})
+ this.saveAccountToSessionStorage(null, true)
+ }
+ saveAccountToSessionStorage = (account, clear) => {
+ const userProfile = this.userProfile;
+ if(userProfile) {
+ if(clear) {
-SDN
+ window.sessionStorage.removeItem(userProfile.userId + '@' + userProfile.domain + ':account');
+ // this.setState({
+ // account:null,
+ // accountType: null
+ // })
+ } else {
+ const state = account || this.account;
+ window.sessionStorage.setItem(userProfile.userId + '@' + userProfile.domain + ':account', JSON.stringify(state));
+ }
+ }
+ }
+ getTransientAccountForUser = (userProfile) => {
+ let userProfileTransientAccount = window.sessionStorage.getItem(userProfile.userId + '@' + userProfile.domain + ':account') || null;
+ var transientAccount = null;
+ if (userProfileTransientAccount) {
+ transientAccount = JSON.parse(userProfileTransientAccount);
+ };
+ this.saveAccountToSessionStorage(null, true);
+ if(!this.userProfile) {
+ this.setState({
+ savedData: transientAccount,
+ userProfile: userProfile
+ })
+ }
+ }
+}
- *
- *
- */