dataset_job.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. var date = require('utils/date');
  20. App.DataSetJob = DS.Model.extend({
  21. name: DS.attr('string'),
  22. dataset: DS.belongsTo('App.Dataset'),
  23. status: DS.attr('string'),
  24. startDate: DS.attr('number'),
  25. endDate: DS.attr('number'),
  26. statusFormatted: function () {
  27. return this.get('status').toLowerCase().capitalize();
  28. }.property('status'),
  29. isSuspended: function () {
  30. return this.get('status') === 'SUSPENDED';
  31. }.property('status'),
  32. startFormatted: function () {
  33. if (this.get('startDate')) {
  34. return $.timeago(this.get('startDate'));
  35. }
  36. return '';
  37. }.property('startDate'),
  38. endFormatted: function () {
  39. if (this.get('endDate')) {
  40. return $.timeago(this.get('endDate'));
  41. }
  42. return '';
  43. }.property('endDate'),
  44. healthClass: function () {
  45. var result = 'icon-question-sign';
  46. switch (this.get('status')) {
  47. case 'SUCCEEDED':
  48. result = 'icon-ok';
  49. break;
  50. case 'SUSPENDED':
  51. result = 'icon-cog';
  52. break;
  53. case 'WAITING':
  54. result = 'icon-time';
  55. break;
  56. case 'RUNNING':
  57. result = 'icon-play';
  58. break;
  59. case 'KILLED':
  60. result = 'icon-exclamation-sign';
  61. break;
  62. case 'FAILED':
  63. result = 'icon-warning-sign';
  64. break;
  65. case 'ERROR':
  66. result = 'icon-remove';
  67. break;
  68. }
  69. return result;
  70. }.property('status')
  71. });
  72. App.DataSetJob.FIXTURES = [];