experimental.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with this
  4. * work for additional information regarding copyright ownership. The ASF
  5. * licenses this file to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. var App = require('app');
  18. App.ExperimentalController = Em.Controller.extend(App.UserPref, {
  19. name: 'experimentalController',
  20. supports: function () {
  21. return Em.keys(App.get('supports')).map(function (sup) {
  22. return Ember.Object.create({
  23. name: sup,
  24. selected: App.get('supports')[sup]
  25. });
  26. });
  27. }.property('App.supports'),
  28. loadSupports: function () {
  29. return this.getUserPref('user-pref-' + App.router.get('loginName') + '-supports');
  30. },
  31. getUserPrefSuccessCallback: function (response, request, data) {
  32. if (response) {
  33. App.set('supports', $.extend(App.get('supports'), response));
  34. }
  35. },
  36. doSave: function () {
  37. var supports = this.get('supports');
  38. supports.forEach(function(s){
  39. var propName = 'App.supports.' + s.get('name');
  40. var propValue = s.get('selected');
  41. Ember.set(propName, propValue);
  42. });
  43. this.postUserPref('user-pref-' + App.router.get('loginName') + '-supports', App.get('supports')).complete(function(){
  44. App.router.transitionTo('root.index');
  45. });
  46. },
  47. doCancel: function () {
  48. App.router.transitionTo('root.index');
  49. },
  50. doResetUIStates: function () {
  51. var self = this;
  52. return App.ModalPopup.show({
  53. header: Em.I18n.t('reset.ui.states'),
  54. bodyClass: Ember.View.extend({
  55. template: Ember.Handlebars.compile(Em.I18n.t('reset.ui.states.body'))
  56. }),
  57. primary: Em.I18n.t('yes'),
  58. context: self,
  59. onPrimary: function () {
  60. var router = App.router;
  61. App.db.cleanUp();
  62. router.clearAllSteps();
  63. App.cache.clear();
  64. App.clusterStatus.setClusterStatus({});
  65. this.context.postUserPref('wizard-data', {});
  66. this.hide();
  67. router.transitionTo('root.index');
  68. }
  69. });
  70. }
  71. });