repository.js 2.4 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 validator = require('utils/validator');
  20. App.Repository = DS.Model.extend({
  21. id: DS.attr('string'), // This is ${osType}-${repoId}.
  22. repoId: DS.attr('string'),
  23. osType: DS.attr('string'),
  24. baseUrl: DS.attr('string'),
  25. baseUrlInit: DS.attr('string'),
  26. defaultBaseUrl: DS.attr('string'),
  27. latestBaseUrl: DS.attr('string'),
  28. repoName: DS.attr('string'),
  29. stackName: DS.attr('string'),
  30. stackVersion: DS.attr('string'),
  31. operatingSystem: DS.belongsTo('App.OperatingSystem'),
  32. validation: DS.attr('string', {defaultValue: ''}),
  33. errorContent: DS.attr('string', {defaultValue: ''}),
  34. errorTitle: DS.attr('string', {defaultValue: ''}),
  35. isSelected: Em.computed.alias('operatingSystem.isSelected'),
  36. invalidFormatError: function() {
  37. return !validator.isValidBaseUrl(this.get('baseUrl'));
  38. }.property('baseUrl'),
  39. isEmpty: function() {
  40. return this.get('baseUrl') == '';
  41. }.property('baseUrl'),
  42. invalidError: function() {
  43. return this.get('validation') === App.Repository.validation.INVALID;
  44. }.property('validation'),
  45. /**
  46. * @type {boolean}
  47. */
  48. isUtils: function () {
  49. return this.get('repoName').contains('UTILS');
  50. }.property('repoName'),
  51. undo: Em.computed.notEqualProperties('baseUrl', 'baseUrlInit'),
  52. notEmpty: Em.computed.notEqual('baseUrl', ''),
  53. clearAll: Em.computed.alias('baseUrl'),
  54. /**
  55. * @type {string}
  56. */
  57. placeholder: Em.computed.ifThenElse('isUtils', '', Em.I18n.t('installer.step1.advancedRepo.localRepo.placeholder')),
  58. });
  59. App.Repository.validation = {
  60. PENDING: '',
  61. INVALID: 'icon-exclamation-sign',
  62. OK: 'icon-ok',
  63. INPROGRESS: 'icon-repeat'
  64. };
  65. App.Repository.FIXTURES = [];