step1.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.InstallerStep1Controller = Em.Controller.extend({
  20. name: 'installerStep1Controller',
  21. content: [],
  22. clusterName: '',
  23. validClusterName: true,
  24. clusterNameError: '',
  25. evaluateStep1: function () {
  26. //TODO: Done
  27. //task1 = checks on valid cluster name
  28. //task2 (prereq(task1 says it's a valid cluster name)) = storing cluster name in localstorage
  29. var result;
  30. console.log('TRACE: Entering controller:InstallerStep1:evaluateStep1 function');
  31. if (this.get('clusterName') == '') {
  32. this.set('clusterNameError', App.messages.step1_clusterName_error_required);
  33. this.set('validClusterName', false);
  34. result = false;
  35. } else if (/\s/.test(this.get('clusterName'))) {
  36. console.log('White spaces not allowed for cluster name');
  37. this.set('clusterNameError', App.messages.step1_clusterName_error_whitespaces);
  38. this.set('validClusterName', false);
  39. result = false;
  40. } else if (/[^\w\s]/gi.test(this.get('clusterName'))) {
  41. console.log('Special characters are not allowed for the cluster name');
  42. this.set('clusterNameError', App.messages.step1_clusterName_error_specialChar);
  43. this.set('validClusterName', false);
  44. result = false;
  45. } else {
  46. console.log('value of clusterNmae is: ' + this.get('clusterName'));
  47. this.set('clusterNameError', '');
  48. this.set('validClusterName', true);
  49. result = true;
  50. }
  51. if (result === true) {
  52. App.db.setClusterName(this.get('clusterName'));
  53. }
  54. console.log('Exiting the evaluatestep1 function');
  55. return result;
  56. }.observes('clusterName')
  57. })