progress_bar_view.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.ProgressBarView = Em.View.extend({
  20. template: Ember.Handlebars.compile('<div class="bar" {{bindAttr style="view.progressWidth"}}></div>'),
  21. classNameBindings: ['generalClass', 'barClass'],
  22. /**
  23. * @type {number}
  24. * @default null
  25. */
  26. progress: null,
  27. /**
  28. * @type {string}
  29. * @default null
  30. */
  31. status: null,
  32. /**
  33. * @type {string}
  34. */
  35. generalClass: 'progress',
  36. /**
  37. * string format: width:<number>%;
  38. * @type {string}
  39. */
  40. progressWidth: function () {
  41. return "width:" + this.get('progress') + "%;";
  42. }.property('progress'),
  43. /**
  44. * @type {string}
  45. */
  46. barClass: function () {
  47. switch (this.get('status')) {
  48. case 'FAILED':
  49. return 'progress-danger';
  50. case 'ABORTED':
  51. case 'TIMED_OUT':
  52. return 'progress-warning';
  53. case 'COMPLETED':
  54. return 'progress-success';
  55. case 'QUEUED':
  56. case 'PENDING':
  57. case 'IN_PROGRESS':
  58. return 'progress-info active progress-striped';
  59. default:
  60. return 'progress-info'
  61. }
  62. }.property('status')
  63. });