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.
19 * STANDARD_RIFT_IO_COPYRIGHT
21 import Alt from '../alt';
22 import LaunchNetworkServiceSource from '../network_service_launcher/launchNetworkServiceSource';
23 import LaunchNetworkServiceActions from '../network_service_launcher/launchNetworkServiceActions';
24 var ConfigAgentAccountSource = require('./configAgentAccountSource');
25 var ConfigAgentAccountActions = require('./configAgentAccountActions');
27 function createconfigAgentAccountStore () {
28 this.exportAsync(ConfigAgentAccountSource);
29 this.exportAsync(LaunchNetworkServiceSource);
30 this.bindAction(ConfigAgentAccountActions.createConfigAccountSuccess, this.createConfigAccountSuccess);
31 this.bindAction(ConfigAgentAccountActions.createConfigAccountLoading, this.createConfigAccountLoading);
32 this.bindAction(ConfigAgentAccountActions.createConfigAccountFailed, this.createConfigAccountFailed);
33 this.bindAction(ConfigAgentAccountActions.UPDATE_SUCCESS, this.updateSuccess);
34 this.bindAction(ConfigAgentAccountActions.UPDATE_LOADING, this.updateLoading);
35 this.bindAction(ConfigAgentAccountActions.UPDATE_FAIL, this.updateFail);
36 this.bindAction(ConfigAgentAccountActions.DELETE_SUCCESS, this.deleteSuccess);
37 this.bindAction(ConfigAgentAccountActions.DELETE_FAIL, this.deleteFail);
38 this.bindAction(ConfigAgentAccountActions.GET_CONFIG_AGENT_ACCOUNT_SUCCESS, this.getConfigAgentAccountSuccess);
39 this.bindAction(ConfigAgentAccountActions.GET_CONFIG_AGENT_ACCOUNT_FAIL, this.getConfigAgentAccountFail);
40 this.bindAction(ConfigAgentAccountActions.GET_CONFIG_AGENT_ACCOUNTS_SUCCESS, this.getConfigAgentAccountsSuccess);
41 // this.bindAction(ConfigAgentAccountActions.GET_CONFIG_AGENT_ACCOUNTS_FAIL, this.getConfigAgentAccountsFail);
42 this.bindAction(ConfigAgentAccountActions.VALIDATE_ERROR, this.validateError);
43 this.bindAction(ConfigAgentAccountActions.VALIDATE_RESET, this.validateReset);
45 getCatalogSuccess: LaunchNetworkServiceActions.getCatalogSuccess
47 this.exportPublicMethods({
48 resetAccount: this.resetAccount.bind(this),
49 validateReset: this.validateReset.bind(this),
50 createConfigAccountFailed: this.createConfigAccountFailed.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'
84 this.validateErrorEvent = 0;
85 this.validateErrorMsg = '';
89 createconfigAgentAccountStore.prototype.resetAccount = function() {
93 'account-type': 'juju'
97 createconfigAgentAccountStore.prototype.validateReset = function() {
99 validateErrorEvent: false
102 createconfigAgentAccountStore.prototype.createConfigAccountLoading = function() {
107 createconfigAgentAccountStore.prototype.createConfigAccountSuccess = function() {
112 createconfigAgentAccountStore.prototype.createConfigAccountFailed = function(msg) {
113 console.log('failed')
114 var xhr = arguments[0];
117 validateErrorEvent: true,
118 validateErrorMsg: "There was an error creating your Config Agent Account. Please contact your system administrator"
121 createconfigAgentAccountStore.prototype.updateLoading = function() {
126 createconfigAgentAccountStore.prototype.updateSuccess = function() {
131 createconfigAgentAccountStore.prototype.updateFail = function() {
132 var xhr = arguments[0];
135 validateErrorEvent: true,
136 validateErrorMsg: "There was an error updating your Config Agent Account. Please contact your system administrator"
140 createconfigAgentAccountStore.prototype.deleteSuccess = function(data) {
149 createconfigAgentAccountStore.prototype.deleteFail = function(data) {
152 validateErrorEvent: true,
153 validateErrorMsg: "There was an error deleting your Config Agent Account. Please contact your system administrator"
160 createconfigAgentAccountStore.prototype.getConfigAgentAccountSuccess = function(data) {
163 configAgentAccount: data.configAgentAccount,
168 createconfigAgentAccountStore.prototype.getConfigAgentAccountFail = function(data) {
171 validateErrorEvent: true,
172 validateErrorMsg: "There was an error obtaining the data for the Config Agent Account. Please contact your system administrator"
176 createconfigAgentAccountStore.prototype.validateError = function(msg) {
178 validateErrorEvent: true,
179 validateErrorMsg: msg
182 createconfigAgentAccountStore.prototype.validateReset = function() {
184 validateErrorEvent: false
187 createconfigAgentAccountStore.prototype.getConfigAgentAccountsSuccess = function(configAgentAccounts) {
189 configAgentAccounts: configAgentAccounts || [],
193 createconfigAgentAccountStore.prototype.getCatalogSuccess = function(data) {
195 var descriptorCount = 0;
196 data.forEach(function(catalog) {
197 descriptorCount += catalog.descriptors.length;
201 descriptorCount: descriptorCount
206 module.exports = Alt.createStore(createconfigAgentAccountStore);;