2 * Copyright 2016 RIFT.IO Inc
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 import LaunchNetworkServiceSource from '../network_service_launcher/launchNetworkServiceSource.js';
23 import LaunchNetworkServiceActions from '../network_service_launcher/launchNetworkServiceActions.js';
25 var alt = require('../../core/alt');
26 var ConfigAgentAccountSource = require('./configAgentAccountSource');
27 var ConfigAgentAccountActions = require('./configAgentAccountActions');
29 function createconfigAgentAccountStore () {
30 this.exportAsync(ConfigAgentAccountSource);
31 this.exportAsync(LaunchNetworkServiceSource);
32 this.bindAction(ConfigAgentAccountActions.CREATE_SUCCESS, this.createSuccess);
33 this.bindAction(ConfigAgentAccountActions.CREATE_LOADING, this.createLoading);
34 this.bindAction(ConfigAgentAccountActions.CREATE_FAIL, this.createFail);
35 this.bindAction(ConfigAgentAccountActions.UPDATE_SUCCESS, this.updateSuccess);
36 this.bindAction(ConfigAgentAccountActions.UPDATE_LOADING, this.updateLoading);
37 this.bindAction(ConfigAgentAccountActions.UPDATE_FAIL, this.updateFail);
38 this.bindAction(ConfigAgentAccountActions.DELETE_SUCCESS, this.deleteSuccess);
39 this.bindAction(ConfigAgentAccountActions.DELETE_FAIL, this.deleteFail);
40 this.bindAction(ConfigAgentAccountActions.GET_CONFIG_AGENT_ACCOUNT_SUCCESS, this.getConfigAgentAccountSuccess);
41 this.bindAction(ConfigAgentAccountActions.GET_CONFIG_AGENT_ACCOUNT_FAIL, this.getConfigAgentAccountFail);
42 this.bindAction(ConfigAgentAccountActions.GET_CONFIG_AGENT_ACCOUNTS_SUCCESS, this.getConfigAgentAccountsSuccess);
43 // this.bindAction(ConfigAgentAccountActions.GET_CONFIG_AGENT_ACCOUNTS_FAIL, this.getConfigAgentAccountsFail);
44 this.bindAction(ConfigAgentAccountActions.VALIDATE_ERROR, this.validateError);
45 this.bindAction(ConfigAgentAccountActions.VALIDATE_RESET, this.validateReset);
47 getCatalogSuccess: LaunchNetworkServiceActions.getCatalogSuccess
49 this.exportPublicMethods({
50 resetAccount: this.resetAccount.bind(this)
52 this.configAgentAccount = {};
53 this.configAgentAccounts = [];
55 self.validateErrorMsg = "";
56 self.validateErrorEvent = 0;
57 this.isLoading = true;
77 "account-type": "juju",
80 this.configAgentAccount = {
82 'account-type': 'juju'
87 createconfigAgentAccountStore.prototype.resetAccount = function() {
91 'account-type': 'juju'
96 createconfigAgentAccountStore.prototype.createLoading = function() {
101 createconfigAgentAccountStore.prototype.createSuccess = function() {
106 createconfigAgentAccountStore.prototype.createFail = function() {
107 var xhr = arguments[0];
110 validateErrorEvent: true,
111 validateErrorMsg: "There was an error creating your Config Agent Account. Please contact your system administrator"
114 createconfigAgentAccountStore.prototype.updateLoading = function() {
119 createconfigAgentAccountStore.prototype.updateSuccess = function() {
124 createconfigAgentAccountStore.prototype.updateFail = function() {
125 var xhr = arguments[0];
128 validateErrorEvent: true,
129 validateErrorMsg: "There was an error updating your Config Agent Account. Please contact your system administrator"
133 createconfigAgentAccountStore.prototype.deleteSuccess = function(data) {
142 createconfigAgentAccountStore.prototype.deleteFail = function(data) {
145 validateErrorEvent: true,
146 validateErrorMsg: "There was an error deleting your Config Agent Account. Please contact your system administrator"
153 createconfigAgentAccountStore.prototype.getConfigAgentAccountSuccess = function(data) {
156 configAgentAccount: data.configAgentAccount,
161 createconfigAgentAccountStore.prototype.getConfigAgentAccountFail = function(data) {
164 validateErrorEvent: true,
165 validateErrorMsg: "There was an error obtaining the data for the Config Agent Account. Please contact your system administrator"
169 createconfigAgentAccountStore.prototype.validateError = function(msg) {
171 validateErrorEvent: true,
172 validateErrorMsg: msg
175 createconfigAgentAccountStore.prototype.validateReset = function() {
177 validateErrorEvent: false
180 createconfigAgentAccountStore.prototype.getConfigAgentAccountsSuccess = function(configAgentAccounts) {
182 configAgentAccounts: configAgentAccounts || [],
186 createconfigAgentAccountStore.prototype.getCatalogSuccess = function(data) {
188 var descriptorCount = 0;
189 data.forEach(function(catalog) {
190 descriptorCount += catalog.descriptors.length;
194 descriptorCount: descriptorCount
199 module.exports = alt.createStore(createconfigAgentAccountStore);;