2012-03-07 11:30:20 -05:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2012-02-23 14:23:10 -05:00
|
|
|
// #/:core
|
|
|
|
sammy.get
|
|
|
|
(
|
2012-03-07 11:30:20 -05:00
|
|
|
/^#\/([\w\d-]+)$/,
|
|
|
|
function( context )
|
|
|
|
{
|
|
|
|
var core_basepath = this.active_core.attr( 'data-basepath' );
|
|
|
|
var content_element = $( '#content' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
content_element
|
|
|
|
.removeClass( 'single' );
|
2012-03-21 05:36:59 -04:00
|
|
|
|
|
|
|
var core_menu = this.active_core.closest( 'ul' );
|
2012-03-07 11:30:20 -05:00
|
|
|
if( !core_menu.data( 'admin-extra-loaded' ) )
|
|
|
|
{
|
|
|
|
core_menu.data( 'admin-extra-loaded', new Date() );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$.get
|
|
|
|
(
|
|
|
|
core_basepath + '/admin/file/?file=admin-extra.menu-top.html',
|
|
|
|
function( menu_extra )
|
|
|
|
{
|
|
|
|
core_menu
|
|
|
|
.prepend( menu_extra );
|
|
|
|
}
|
|
|
|
);
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$.get
|
|
|
|
(
|
|
|
|
core_basepath + '/admin/file/?file=admin-extra.menu-bottom.html',
|
|
|
|
function( menu_extra )
|
|
|
|
{
|
|
|
|
core_menu
|
|
|
|
.append( menu_extra );
|
2012-02-23 14:23:10 -05:00
|
|
|
}
|
2012-03-07 11:30:20 -05:00
|
|
|
);
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$.get
|
|
|
|
(
|
|
|
|
'tpl/dashboard.html',
|
|
|
|
function( template )
|
|
|
|
{
|
|
|
|
content_element
|
|
|
|
.html( template );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var dashboard_element = $( '#dashboard' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$.ajax
|
|
|
|
(
|
|
|
|
{
|
|
|
|
url : core_basepath + '/admin/luke?wt=json&show=index&numTerms=0',
|
|
|
|
dataType : 'json',
|
|
|
|
context : $( '#statistics', dashboard_element ),
|
|
|
|
beforeSend : function( xhr, settings )
|
|
|
|
{
|
|
|
|
$( 'h2', this )
|
|
|
|
.addClass( 'loader' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.message', this )
|
|
|
|
.show()
|
|
|
|
.html( 'Loading ...' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.content' )
|
|
|
|
.hide();
|
|
|
|
},
|
|
|
|
success : function( response, text_status, xhr )
|
|
|
|
{
|
|
|
|
$( '.message', this )
|
|
|
|
.empty()
|
|
|
|
.hide();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.content', this )
|
|
|
|
.show();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var data = {
|
|
|
|
'index_num-docs' : response['index']['numDocs'],
|
|
|
|
'index_max-doc' : response['index']['maxDoc'],
|
|
|
|
'index_version' : response['index']['version'],
|
|
|
|
'index_segmentCount' : response['index']['segmentCount'],
|
|
|
|
'index_last-modified' : response['index']['lastModified']
|
|
|
|
};
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
for( var key in data )
|
|
|
|
{
|
|
|
|
$( '.' + key, this )
|
|
|
|
.show();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.value.' + key, this )
|
|
|
|
.html( data[key] );
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var optimized_element = $( '.value.index_optimized', this );
|
|
|
|
if( !response['index']['hasDeletions'] )
|
|
|
|
{
|
|
|
|
optimized_element
|
|
|
|
.addClass( 'ico-1' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( 'span', optimized_element )
|
|
|
|
.html( 'yes' );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
optimized_element
|
|
|
|
.addClass( 'ico-0' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( 'span', optimized_element )
|
|
|
|
.html( 'no' );
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var current_element = $( '.value.index_current', this );
|
|
|
|
if( response['index']['current'] )
|
|
|
|
{
|
|
|
|
current_element
|
|
|
|
.addClass( 'ico-1' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( 'span', current_element )
|
|
|
|
.html( 'yes' );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
current_element
|
|
|
|
.addClass( 'ico-0' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( 'span', current_element )
|
|
|
|
.html( 'no' );
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( 'a', optimized_element )
|
|
|
|
.die( 'click' )
|
|
|
|
.live
|
|
|
|
(
|
|
|
|
'click',
|
|
|
|
function( event )
|
|
|
|
{
|
|
|
|
$.ajax
|
|
|
|
(
|
|
|
|
{
|
|
|
|
url : core_basepath + '/update?optimize=true&waitFlush=true&wt=json',
|
|
|
|
dataType : 'json',
|
|
|
|
context : $( this ),
|
|
|
|
beforeSend : function( xhr, settings )
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.addClass( 'loader' );
|
|
|
|
},
|
|
|
|
success : function( response, text_status, xhr )
|
|
|
|
{
|
|
|
|
this.parents( 'dd' )
|
|
|
|
.removeClass( 'ico-0' )
|
|
|
|
.addClass( 'ico-1' );
|
|
|
|
},
|
|
|
|
error : function( xhr, text_status, error_thrown)
|
|
|
|
{
|
|
|
|
console.warn( 'd0h, optimize broken!' );
|
|
|
|
},
|
|
|
|
complete : function( xhr, text_status )
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.removeClass( 'loader' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.timeago', this )
|
2012-02-23 14:23:10 -05:00
|
|
|
.timeago();
|
2012-03-07 11:30:20 -05:00
|
|
|
},
|
|
|
|
error : function( xhr, text_status, error_thrown )
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.addClass( 'disabled' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.message', this )
|
|
|
|
.show()
|
|
|
|
.html( 'Luke is not configured' );
|
|
|
|
},
|
|
|
|
complete : function( xhr, text_status )
|
|
|
|
{
|
|
|
|
$( 'h2', this )
|
|
|
|
.removeClass( 'loader' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$.ajax
|
|
|
|
(
|
|
|
|
{
|
|
|
|
url : core_basepath + '/replication?command=details&wt=json',
|
|
|
|
dataType : 'json',
|
|
|
|
context : $( '#replication', dashboard_element ),
|
|
|
|
beforeSend : function( xhr, settings )
|
|
|
|
{
|
|
|
|
$( 'h2', this )
|
|
|
|
.addClass( 'loader' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.message', this )
|
|
|
|
.show()
|
|
|
|
.html( 'Loading' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.content', this )
|
|
|
|
.hide();
|
|
|
|
},
|
|
|
|
success : function( response, text_status, xhr )
|
|
|
|
{
|
|
|
|
$( '.message', this )
|
|
|
|
.empty()
|
|
|
|
.hide();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.content', this )
|
|
|
|
.show();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.replication', context.active_core )
|
|
|
|
.show();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var data = response.details;
|
|
|
|
var is_slave = 'undefined' !== typeof( data.slave );
|
|
|
|
var headline = $( 'h2 span', this );
|
|
|
|
var details_element = $( '#details', this );
|
|
|
|
var current_type_element = $( ( is_slave ? '.slave' : '.master' ), this );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
if( is_slave )
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.addClass( 'slave' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
headline
|
|
|
|
.html( headline.html() + ' (Slave)' );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.addClass( 'master' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
headline
|
|
|
|
.html( headline.html() + ' (Master)' );
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.version div', current_type_element )
|
|
|
|
.html( data.indexVersion );
|
|
|
|
$( '.generation div', current_type_element )
|
|
|
|
.html( data.generation );
|
|
|
|
$( '.size div', current_type_element )
|
|
|
|
.html( data.indexSize );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
if( is_slave )
|
|
|
|
{
|
|
|
|
var master_element = $( '.master', details_element );
|
|
|
|
$( '.version div', master_element )
|
|
|
|
.html( data.slave.masterDetails.indexVersion );
|
|
|
|
$( '.generation div', master_element )
|
|
|
|
.html( data.slave.masterDetails.generation );
|
|
|
|
$( '.size div', master_element )
|
|
|
|
.html( data.slave.masterDetails.indexSize );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
if( data.indexVersion !== data.slave.masterDetails.indexVersion )
|
|
|
|
{
|
|
|
|
$( '.version', details_element )
|
|
|
|
.addClass( 'diff' );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$( '.version', details_element )
|
|
|
|
.removeClass( 'diff' );
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
if( data.generation !== data.slave.masterDetails.generation )
|
|
|
|
{
|
|
|
|
$( '.generation', details_element )
|
|
|
|
.addClass( 'diff' );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$( '.generation', details_element )
|
|
|
|
.removeClass( 'diff' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error : function( xhr, text_status, error_thrown)
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.addClass( 'disabled' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.message', this )
|
|
|
|
.show()
|
|
|
|
.html( 'Replication is not configured' );
|
|
|
|
},
|
|
|
|
complete : function( xhr, text_status )
|
|
|
|
{
|
|
|
|
$( 'h2', this )
|
|
|
|
.removeClass( 'loader' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$.ajax
|
|
|
|
(
|
|
|
|
{
|
|
|
|
url : core_basepath + '/dataimport?command=details&wt=json',
|
|
|
|
dataType : 'json',
|
|
|
|
context : $( '#dataimport', dashboard_element ),
|
|
|
|
beforeSend : function( xhr, settings )
|
|
|
|
{
|
|
|
|
$( 'h2', this )
|
|
|
|
.addClass( 'loader' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.message', this )
|
|
|
|
.show()
|
|
|
|
.html( 'Loading' );
|
|
|
|
},
|
|
|
|
success : function( response, text_status, xhr )
|
|
|
|
{
|
|
|
|
$( '.message', this )
|
|
|
|
.empty()
|
|
|
|
.hide();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( 'dl', this )
|
|
|
|
.show();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var data = {
|
|
|
|
'status' : response['status'],
|
|
|
|
'info' : response['statusMessages']['']
|
|
|
|
};
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
for( var key in data )
|
|
|
|
{
|
|
|
|
$( '.' + key, this )
|
|
|
|
.show();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.value.' + key, this )
|
|
|
|
.html( data[key] );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error : function( xhr, text_status, error_thrown)
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.addClass( 'disabled' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.message', this )
|
|
|
|
.show()
|
|
|
|
.html( 'Dataimport is not configured' );
|
|
|
|
},
|
|
|
|
complete : function( xhr, text_status )
|
|
|
|
{
|
|
|
|
$( 'h2', this )
|
|
|
|
.removeClass( 'loader' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$.ajax
|
|
|
|
(
|
|
|
|
{
|
|
|
|
url : core_basepath + '/admin/file/?file=admin-extra.html',
|
|
|
|
dataType : 'html',
|
|
|
|
context : $( '#admin-extra', dashboard_element ),
|
|
|
|
beforeSend : function( xhr, settings )
|
|
|
|
{
|
|
|
|
$( 'h2', this )
|
|
|
|
.addClass( 'loader' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.message', this )
|
|
|
|
.show()
|
|
|
|
.html( 'Loading' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.content', this )
|
|
|
|
.hide();
|
|
|
|
},
|
|
|
|
success : function( response, text_status, xhr )
|
|
|
|
{
|
|
|
|
$( '.message', this )
|
|
|
|
.hide()
|
|
|
|
.empty();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.content', this )
|
|
|
|
.show()
|
|
|
|
.html( response );
|
|
|
|
},
|
|
|
|
error : function( xhr, text_status, error_thrown)
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.addClass( 'disabled' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.message', this )
|
|
|
|
.show()
|
|
|
|
.html( 'We found no "admin-extra.html" file.' );
|
|
|
|
},
|
|
|
|
complete : function( xhr, text_status )
|
|
|
|
{
|
|
|
|
$( 'h2', this )
|
|
|
|
.removeClass( 'loader' );
|
2012-02-23 14:23:10 -05:00
|
|
|
}
|
2012-03-07 11:30:20 -05:00
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
);
|
2012-03-07 11:30:20 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
);
|