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-04-23 10:37:39 -04:00
|
|
|
var set_healthcheck_status = function( status )
|
|
|
|
{
|
|
|
|
var hc_button = $( '.healthcheck-status' )
|
|
|
|
if ( status == 'enable' )
|
|
|
|
{
|
|
|
|
hc_button.parents( 'dd' )
|
|
|
|
.removeClass( 'ico-0' )
|
|
|
|
.addClass( 'ico-1' );
|
|
|
|
hc_button
|
|
|
|
.addClass( 'enabled' )
|
|
|
|
.html( 'disable ping' );
|
|
|
|
} else {
|
|
|
|
hc_button.parents( 'dd' )
|
|
|
|
.removeClass( 'ico-1')
|
|
|
|
.addClass( 'ico-0' );
|
|
|
|
hc_button
|
|
|
|
.removeClass( 'enabled' )
|
|
|
|
.html( 'enable ping' );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-02-23 14:23:10 -05:00
|
|
|
// #/:core
|
|
|
|
sammy.get
|
|
|
|
(
|
2013-01-05 05:57:21 -05:00
|
|
|
new RegExp( app.core_regex_base + '$' ),
|
2012-03-07 11:30:20 -05:00
|
|
|
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
|
|
|
|
2013-03-27 04:40:22 -04:00
|
|
|
if( !app.core_menu.data( 'admin-extra-loaded' ) )
|
2012-03-07 11:30:20 -05:00
|
|
|
{
|
2013-03-27 04:40:22 -04:00
|
|
|
app.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
|
|
|
|
(
|
2013-03-27 04:40:22 -04:00
|
|
|
core_basepath + '/admin/file/?file=admin-extra.menu-top.html&contentType=text/html;charset=utf-8',
|
2012-03-07 11:30:20 -05:00
|
|
|
function( menu_extra )
|
|
|
|
{
|
2013-03-27 04:40:22 -04:00
|
|
|
app.core_menu
|
2012-03-07 11:30:20 -05:00
|
|
|
.prepend( menu_extra );
|
|
|
|
}
|
|
|
|
);
|
2013-03-27 04:40:22 -04:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$.get
|
|
|
|
(
|
2013-03-27 04:40:22 -04:00
|
|
|
core_basepath + '/admin/file/?file=admin-extra.menu-bottom.html&contentType=text/html;charset=utf-8',
|
2012-03-07 11:30:20 -05:00
|
|
|
function( menu_extra )
|
|
|
|
{
|
2013-03-27 04:40:22 -04:00
|
|
|
app.core_menu
|
2012-03-07 11:30:20 -05:00
|
|
|
.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
|
|
|
|
2013-07-16 15:54:52 -04:00
|
|
|
$( '.content', this )
|
2012-03-07 11:30:20 -05:00
|
|
|
.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 = {
|
2015-04-03 16:03:34 -04:00
|
|
|
'index_num-doc' : response['index']['numDocs'],
|
2013-10-08 02:58:46 -04:00
|
|
|
'index_heap-usage-bytes' : response['index']['indexHeapUsageBytes'],
|
2012-03-07 11:30:20 -05:00
|
|
|
'index_max-doc' : response['index']['maxDoc'],
|
2015-04-03 16:03:34 -04:00
|
|
|
'index_deleted-doc' : response['index']['deletedDocs'],
|
2012-03-07 11:30:20 -05:00
|
|
|
'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 );
|
2013-04-17 17:13:20 -04:00
|
|
|
var current_type_element = $( ( is_slave ? '.slave' : '.masterSearch' ), this );
|
|
|
|
var master_data = is_slave ? data.slave.masterDetails : data;
|
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
|
|
|
|
2013-04-17 17:13:20 -04:00
|
|
|
// the currently searchable commit regardless of type
|
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
|
|
|
|
2013-04-17 17:13:20 -04:00
|
|
|
// what's replicable on the master
|
|
|
|
var master_element = $( '.master', details_element );
|
|
|
|
$( '.version div', master_element )
|
|
|
|
.html( master_data.master.replicableVersion || '-' );
|
|
|
|
$( '.generation div', master_element )
|
|
|
|
.html( master_data.master.replicableGeneration || '-' );
|
|
|
|
$( '.size div', master_element )
|
|
|
|
.html( "-" );
|
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
if( is_slave )
|
|
|
|
{
|
2013-04-17 17:13:20 -04:00
|
|
|
var master_element = $( '.masterSearch', details_element );
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.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
|
|
|
|
2013-04-17 17:13:20 -04:00
|
|
|
// warnings if slave version|gen doesn't match what's replicable
|
|
|
|
if( data.indexVersion !== master_data.master.replicableVersion )
|
2012-03-07 11:30:20 -05:00
|
|
|
{
|
|
|
|
$( '.version', details_element )
|
|
|
|
.addClass( 'diff' );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$( '.version', details_element )
|
|
|
|
.removeClass( 'diff' );
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2013-04-17 17:13:20 -04:00
|
|
|
if( data.generation !== master_data.master.replicableGeneration )
|
2012-03-07 11:30:20 -05:00
|
|
|
{
|
|
|
|
$( '.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
|
|
|
|
(
|
|
|
|
{
|
2013-07-16 15:54:52 -04:00
|
|
|
url : core_basepath + '/admin/system?wt=json',
|
2012-03-07 11:30:20 -05:00
|
|
|
dataType : 'json',
|
2013-07-16 15:54:52 -04:00
|
|
|
context : $( '#instance', dashboard_element ),
|
2012-03-07 11:30:20 -05:00
|
|
|
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' );
|
2013-07-16 15:54:52 -04:00
|
|
|
|
|
|
|
$( '.content', this )
|
|
|
|
.hide();
|
2012-03-07 11:30:20 -05:00
|
|
|
},
|
|
|
|
success : function( response, text_status, xhr )
|
|
|
|
{
|
|
|
|
$( '.message', this )
|
|
|
|
.empty()
|
|
|
|
.hide();
|
2013-07-16 15:54:52 -04:00
|
|
|
|
|
|
|
$( '.content', this )
|
|
|
|
.show();
|
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 = {
|
2013-07-16 15:54:52 -04:00
|
|
|
'dir_cwd' : response.core.directory.cwd,
|
|
|
|
'dir_instance' : response.core.directory.instance,
|
|
|
|
'dir_data' : response.core.directory.data,
|
|
|
|
'dir_index' : response.core.directory.index,
|
|
|
|
'dir_impl' : response.core.directory.dirimpl
|
2012-03-07 11:30:20 -05:00
|
|
|
};
|
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()
|
2013-07-16 15:54:52 -04:00
|
|
|
.html( '/admin/system Handler is not configured' );
|
2012-03-07 11:30:20 -05:00
|
|
|
},
|
|
|
|
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-04-23 10:37:39 -04:00
|
|
|
|
|
|
|
$.ajax
|
|
|
|
(
|
|
|
|
{
|
|
|
|
url : core_basepath + '/admin/ping?action=status&wt=json',
|
|
|
|
dataType : 'json',
|
|
|
|
context : $( '#healthcheck', dashboard_element ),
|
|
|
|
beforeSend : function( xhr, settings )
|
|
|
|
{
|
|
|
|
$( 'h2', this )
|
|
|
|
.addClass( 'loader' );
|
|
|
|
|
|
|
|
$( '.message', this )
|
|
|
|
.show()
|
|
|
|
.html( 'Loading' );
|
|
|
|
|
|
|
|
$( '.content', this )
|
|
|
|
.hide();
|
|
|
|
},
|
|
|
|
success : function( response, text_status, xhr )
|
|
|
|
{
|
|
|
|
$( '.message', this )
|
|
|
|
.empty()
|
|
|
|
.hide();
|
|
|
|
|
|
|
|
$( '.content', this )
|
|
|
|
.show();
|
|
|
|
|
|
|
|
var status_element = $( '.value.status', this );
|
|
|
|
var toggle_button = $( '.healthcheck-status', this );
|
|
|
|
var status = response['status'];
|
|
|
|
$( 'span', status_element ).html( status );
|
|
|
|
|
|
|
|
var action = ( response['status'] == 'enabled' ) ? 'enable' : 'disable';
|
|
|
|
set_healthcheck_status(action);
|
|
|
|
|
|
|
|
if( response['status'] == 'enabled' )
|
|
|
|
{
|
|
|
|
status_element
|
|
|
|
.addClass( 'ico-1' );
|
|
|
|
toggle_button
|
|
|
|
.addClass( 'enabled' );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status_element
|
|
|
|
.addClass( 'ico-0' );
|
|
|
|
}
|
|
|
|
|
|
|
|
$( '.healthcheck-status', status_element )
|
|
|
|
.die( 'click' )
|
|
|
|
.live
|
|
|
|
(
|
|
|
|
'click',
|
|
|
|
function( event )
|
|
|
|
{
|
|
|
|
var action = $(this).hasClass( 'enabled' ) ? 'disable' : 'enable';
|
|
|
|
$.ajax
|
|
|
|
(
|
|
|
|
{
|
|
|
|
url : core_basepath + '/admin/ping?action=' + action + '&wt=json',
|
|
|
|
dataType : 'json',
|
|
|
|
context : $( this ),
|
|
|
|
beforeSend : function( xhr, settings )
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.addClass( 'loader' );
|
|
|
|
},
|
|
|
|
success : function( response, text_status, xhr )
|
|
|
|
{
|
|
|
|
set_healthcheck_status(action);
|
|
|
|
},
|
|
|
|
error : function( xhr, text_status, error_thrown)
|
|
|
|
{
|
|
|
|
console.warn( 'd0h, enable broken!' );
|
|
|
|
},
|
|
|
|
complete : function( xhr, text_status )
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.removeClass( 'loader' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
error : function( xhr, text_status, error_thrown)
|
|
|
|
{
|
|
|
|
this
|
|
|
|
.addClass( 'disabled' );
|
|
|
|
|
|
|
|
$( '.message', this )
|
|
|
|
.show()
|
2012-06-11 18:05:44 -04:00
|
|
|
.html( 'Ping request handler is not configured with a healthcheck file.' );
|
2012-04-23 10:37:39 -04:00
|
|
|
},
|
|
|
|
complete : function( xhr, text_status )
|
|
|
|
{
|
|
|
|
$( 'h2', this )
|
|
|
|
.removeClass( 'loader' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2012-03-07 11:30:20 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2012-04-23 10:37:39 -04:00
|
|
|
);
|