2 * Copyright 2010-2013 Ben Birch
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this software except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 (function( $, app, i18n ){
18 var ui = app.ns("ui");
19 var data = app.ns("data");
21 ui.Browser = ui.Page.extend({
23 cluster: null // (required) instanceof app.services.Cluster
27 this.cluster = this.config.cluster;
28 this.query = new app.data.Query( { cluster: this.cluster } );
29 this._refreshButton = new ui.Button({
30 label: i18n.text("General.RefreshResults"),
31 onclick: function( btn ) {
35 this.el = $(this._main_template());
36 new data.MetaDataFactory({
37 cluster: this.cluster,
38 onReady: function(metadata) {
39 this.metadata = metadata;
40 this.store = new data.QueryDataSourceInterface( { metadata: metadata, query: this.query } );
41 this.queryFilter = new ui.QueryFilter({ metadata: metadata, query: this.query });
42 this.queryFilter.attach(this.el.find("> .uiBrowser-filter") );
43 this.resultTable = new ui.ResultTable( {
44 onHeaderClick: this._changeSort_handler,
47 this.resultTable.attach( this.el.find("> .uiBrowser-table") );
52 updateResults: function() {
55 _changeSort_handler: function(table, wEv) {
56 this.query.setSort(wEv.column, wEv.dir === "desc");
57 this.query.setPage(1);
60 _main_template: function() {
61 return { tag: "DIV", cls: "uiBrowser", children: [
63 label: i18n.text("Browser.Title"),
65 right: [ this._refreshButton ]
67 { tag: "DIV", cls: "uiBrowser-filter" },
68 { tag: "DIV", cls: "uiBrowser-table" }
73 })( this.jQuery, this.app, this.i18n );