experimental.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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', 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. onPrimary: function () {
  59. var router = App.router;
  60. App.db.cleanUp();
  61. router.clearAllSteps();
  62. App.cache.clear();
  63. App.clusterStatus.setClusterStatus({});
  64. this.hide();
  65. router.transitionTo('root.index');
  66. }
  67. });
  68. }
  69. });