ProviderStore.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. Copyright (C) 2017 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import alt from '../alt'
  15. import ProviderActions from '../actions/ProviderActions'
  16. class ProviderStore {
  17. constructor() {
  18. this.connectionInfoSchema = []
  19. this.connectionSchemaLoading = false
  20. this.providers = null
  21. this.providersLoading = false
  22. this.optionsSchema = []
  23. this.optionsSchemaLoading = false
  24. this.bindListeners({
  25. handleGetConnectionInfoSchema: ProviderActions.GET_CONNECTION_INFO_SCHEMA,
  26. handleGetConnectionInfoSchemaSuccess: ProviderActions.GET_CONNECTION_INFO_SCHEMA_SUCCESS,
  27. handleGetConnectionInfoSchemaFailed: ProviderActions.GET_CONNECTION_INFO_SCHEMA_FAILED,
  28. handleLoadProviders: ProviderActions.LOAD_PROVIDERS,
  29. handleLoadProvidersSuccess: ProviderActions.LOAD_PROVIDERS_SUCCESS,
  30. handleLoadOptionsSchema: ProviderActions.LOAD_OPTIONS_SCHEMA,
  31. handleLoadOptionsSchemaSuccess: ProviderActions.LOAD_OPTIONS_SCHEMA_SUCCESS,
  32. handleLoadOptionsSchemaFailed: ProviderActions.LOAD_OPTIONS_SCHEMA_FAILED,
  33. })
  34. }
  35. handleGetConnectionInfoSchema() {
  36. this.connectionSchemaLoading = true
  37. }
  38. handleGetConnectionInfoSchemaSuccess(schema) {
  39. this.connectionSchemaLoading = false
  40. this.connectionInfoSchema = schema
  41. }
  42. handleGetConnectionInfoSchemaFailed() {
  43. this.connectionSchemaLoading = false
  44. }
  45. handleLoadProviders() {
  46. this.providers = null
  47. this.providersLoading = true
  48. }
  49. handleLoadProvidersSuccess(providers) {
  50. this.providers = providers
  51. this.providersLoading = false
  52. }
  53. handleLoadOptionsSchema() {
  54. this.optionsSchemaLoading = true
  55. }
  56. handleLoadOptionsSchemaSuccess(schema) {
  57. this.optionsSchemaLoading = false
  58. this.optionsSchema = schema
  59. }
  60. handleLoadOptionsSchemaFailed() {
  61. this.optionsSchemaLoading = false
  62. }
  63. }
  64. export default alt.createStore(ProviderStore)