| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137 |
1
1
1
5
6
6
1
5
3
3
2
| 'use strict';
;require.register("views/main/admin/stack_upgrade/upgrade_version_column_view", function (exports, require, module) {
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var App = require('app');
App.UpgradeVersionColumnView = App.UpgradeVersionBoxView.extend({
templateName: require('templates/main/admin/stack_upgrade/upgrade_version_column'),
isVersionColumnView: true,
classNames: ['version-column', 'col-md-4'],
/**
* Indicates whether block for version type should be displayed.
* True if any of available versions is of PATCH, MAINT or SERVICE type
* @type {Boolean}
*/
displayVersionTypeBlock: false,
currentLabelClass: 'btn btn-primary',
didInsertElement: function didInsertElement() {
App.tooltip($('.out-of-sync-badge'), { title: Em.I18n.t('hosts.host.stackVersions.status.out_of_sync') });
App.tooltip($('.not-upgradable'));
if (!this.get('content.isCompatible')) {
App.tooltip(this.$(".repo-version-tooltip"), {
title: Em.I18n.t('admin.stackVersions.version.noCompatible.tooltip')
});
}
this.adjustColumnWidth();
},
adjustColumnWidth: function () {
//set the width, height of each version column dynamically
var reposCount = App.RepositoryVersion.find().filterProperty('isVisible').get('length');
var widthFactor = reposCount > 3 ? 0.18 : 0.31;
$('.version-column').width($('.versions-slides').width() * widthFactor);
var height = App.Service.find().get('length') > 10 ? (App.Service.find().get('length') - 10) * 40 + 500 : 500;
$('.version-column').height(height);
// set the lines width of the table, line up the labels
$('.border-extended-table').width(reposCount * 100 + 100 + "%");
$('.border-extended-table').css("max-width", reposCount * 100 + 100 + "%");
}.observes('parentView.repoVersions.@each.isVisible'),
services: function () {
var _this = this;
var originalServices = this.get('content.stackServices');
// sort the services in the order the same as service menu
return App.Service.find().map(function (service) {
var stackService = originalServices.findProperty('name', service.get('serviceName')),
isAvailable = _this.isStackServiceAvailable(stackService);
var notUpgradable = false,
notUpgradableTitle = '';
if (!stackService) {
console.error(stackService + ' definition does not exist in the stack.');
notUpgradable = true;
notUpgradableTitle = Em.I18n.t('admin.stackVersions.version.service.notSupported');
} else {
notUpgradable = _this.getNotUpgradable(isAvailable, stackService.get('isUpgradable'));
if (notUpgradable) {
notUpgradableTitle = Em.I18n.t('admin.stackVersions.version.service.notUpgradable');
}
}
return Em.Object.create({
displayName: service.get('displayName'),
name: service.get('serviceName'),
latestVersion: stackService ? stackService.get('latestVersion') : '',
isVersionInvisible: !stackService,
notUpgradable: notUpgradable,
notUpgradableTitle: notUpgradableTitle,
isAvailable: isAvailable
});
});
}.property(),
getNotUpgradable: function getNotUpgradable(isAvailable, isUpgradable) {
return this.get('content.isMaint') && !this.get('isUpgrading') && this.get('content.status') !== 'CURRENT' && isAvailable && !isUpgradable;
},
/**
* @param {Em.Object} stackService
* @returns {boolean}
*/
isStackServiceAvailable: function isStackServiceAvailable(stackService) {
var self = this;
if (!stackService) {
return false;
}
if (this.get('content.isCurrent')) {
var originalService = App.Service.find(stackService.get('name'));
return stackService.get('isAvailable') && originalService.get('desiredRepositoryVersionId') === this.get('content.id');
} else {
return stackService.get('isAvailable');
}
},
/**
* on click handler for "show details" link
*/
openVersionBoxPopup: function openVersionBoxPopup(event) {
var content = this.get('content');
var parentView = this.get('parentView');
return App.ModalPopup.show({
classNames: ['version-box-popup'],
bodyClass: App.UpgradeVersionBoxView.extend({
classNames: ['version-box-in-popup'],
content: content,
parentView: parentView
}),
header: Em.I18n.t('admin.stackVersions.version.column.showDetails.title'),
primary: Em.I18n.t('common.dismiss'),
secondary: null
});
}
});
}); |