123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- /**
- * 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');
- var filters = require('views/common/filter_view');
- var sort = require('views/common/sort_view');
- App.MainConfigHistoryView = App.TableView.extend(App.TableServerViewMixin, {
- templateName: require('templates/main/dashboard/config_history'),
- controllerBinding: 'App.router.mainConfigHistoryController',
- /**
- * @type {boolean}
- * @default false
- */
- filteringComplete: false,
- isInitialRendering: true,
- /**
- * return filtered number of all content number information displayed on the page footer bar
- * @returns {String}
- */
- filteredContentInfo: function () {
- return this.t('tableView.filters.filteredConfigVersionInfo').format(this.get('filteredCount'), this.get('totalCount'));
- }.property('filteredCount', 'totalCount'),
- didInsertElement: function () {
- this.addObserver('startIndex', this, 'updatePagination');
- this.addObserver('displayLength', this, 'updatePagination');
- this.set('isInitialRendering', true);
- this.refresh();
- this.set('controller.isPolling', true);
- this.get('controller').doPolling();
- },
- /**
- * stop polling after leaving config history page
- */
- willDestroyElement: function () {
- this.set('controller.isPolling', false);
- clearTimeout(this.get('controller.timeoutRef'));
- },
- updateFilter: function (iColumn, value, type) {
- if (!this.get('isInitialRendering')) {
- this._super(iColumn, value, type);
- }
- },
- sortView: sort.serverWrapperView,
- versionSort: sort.fieldView.extend({
- column: 1,
- name: 'serviceVersion',
- displayName: Em.I18n.t('dashboard.configHistory.table.version.title'),
- classNames: ['first']
- }),
- configGroupSort: sort.fieldView.extend({
- column: 2,
- name: 'configGroup',
- displayName: Em.I18n.t('dashboard.configHistory.table.configGroup.title')
- }),
- modifiedSort: sort.fieldView.extend({
- column: 3,
- name: 'createTime',
- status: 'sorting_desc',
- displayName: Em.I18n.t('dashboard.configHistory.table.created.title')
- }),
- authorSort: sort.fieldView.extend({
- column: 4,
- name: 'author',
- displayName: Em.I18n.t('common.author')
- }),
- notesSort: sort.fieldView.extend({
- column: 5,
- name: 'notes',
- displayName: Em.I18n.t('common.notes')
- }),
- serviceFilterView: filters.createSelectView({
- column: 1,
- fieldType: 'filter-input-width',
- content: function () {
- return [
- {
- value: '',
- label: Em.I18n.t('common.all')
- }
- ].concat(App.Service.find().map(function (service) {
- return {
- value: service.get('serviceName'),
- label: service.get('displayName')
- }
- }));
- }.property('App.router.clusterController.isLoaded'),
- onChangeValue: function () {
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'select');
- }
- }),
- configGroupFilterView: filters.createSelectView({
- column: 2,
- fieldType: 'filter-input-width',
- content: function () {
- var groupName = App.ServiceConfigVersion.find().mapProperty('groupName').uniq();
- if (groupName.indexOf(null) > -1) {
- groupName.splice(groupName.indexOf(null), 1);
- }
- return [
- {
- value: '',
- label: Em.I18n.t('common.all')
- }
- ].concat(groupName.map(function (item) {
- return {
- value: item,
- label: item
- }
- }));
- }.property('App.router.mainConfigHistoryController.content'),
- onChangeValue: function () {
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'select');
- }
- }),
- modifiedFilterView: filters.createSelectView({
- column: 3,
- appliedEmptyValue: ["", ""],
- fieldType: 'filter-input-width,modified-filter',
- triggeredOnSameValue: [
- {
- values: ['Custom', 'Custom2'],
- displayAs: 'Custom'
- }
- ],
- emptyValue: 'Any',
- valueBinding: "controller.modifiedFilter.optionValue",
- selectedBinding: "controller.modifiedFilter.optionValue",
- contentBinding: "controller.modifiedFilter.content",
- onTimeChange: function () {
- this.get('parentView').updateFilter(this.get('column'), [this.get('controller.modifiedFilter.actualValues.startTime'), this.get('controller.modifiedFilter.actualValues.endTime')], 'range');
- }.observes('controller.modifiedFilter.actualValues')
- }),
- authorFilterView: filters.createTextView({
- column: 4,
- fieldType: 'filter-input-width',
- onChangeValue: function () {
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
- }
- }),
- notesFilterView: filters.createTextView({
- column: 5,
- fieldType: 'filter-input-width',
- onChangeValue: function () {
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
- }
- }),
- ConfigVersionView: Em.View.extend({
- tagName: 'tr',
- showLessNotes: true,
- toggleShowLessStatus: function () {
- this.toggleProperty('showLessNotes');
- },
- didInsertElement: function () {
- App.tooltip(this.$("[rel='Tooltip']"));
- }
- }),
- /**
- * refresh table content
- */
- refresh: function () {
- var self = this;
- this.set('filteringComplete', false);
- this.get('controller').load().done(this.refreshDone);
- },
- /**
- * callback executed after refresh call done
- * @method refreshDone
- */
- refreshDone: function () {
- this.set('isInitialRendering', false);
- this.set('filteringComplete', true);
- this.propertyDidChange('pageContent');
- this.set('controller.resetStartIndex', false);
- },
- /**
- * associations between host property and column index
- * @type {Array}
- */
- colPropAssoc: function () {
- return this.get('controller.colPropAssoc');
- }.property('controller.colPropAssoc')
- });
|