2022-10-31 14:36:45 +00:00
2023-03-27 16:44:49 +00:00
function extensions _apply ( _ , _ , disable _all ) {
2023-01-28 12:57:56 +00:00
var disable = [ ]
var update = [ ]
2022-10-31 14:36:45 +00:00
gradioApp ( ) . querySelectorAll ( '#extensions input[type="checkbox"]' ) . forEach ( function ( x ) {
if ( x . name . startsWith ( "enable_" ) && ! x . checked )
disable . push ( x . name . substr ( 7 ) )
if ( x . name . startsWith ( "update_" ) && x . checked )
update . push ( x . name . substr ( 7 ) )
} )
restart _reload ( )
2023-03-27 16:44:49 +00:00
return [ JSON . stringify ( disable ) , JSON . stringify ( update ) , disable _all ]
2022-10-31 14:36:45 +00:00
}
2023-03-27 16:44:49 +00:00
function extensions _check ( _ , _ ) {
2023-01-28 12:57:56 +00:00
var disable = [ ]
gradioApp ( ) . querySelectorAll ( '#extensions input[type="checkbox"]' ) . forEach ( function ( x ) {
if ( x . name . startsWith ( "enable_" ) && ! x . checked )
disable . push ( x . name . substr ( 7 ) )
} )
2022-10-31 14:36:45 +00:00
gradioApp ( ) . querySelectorAll ( '#extensions .extension_status' ) . forEach ( function ( x ) {
x . innerHTML = "Loading..."
} )
2023-01-28 12:57:56 +00:00
var id = randomId ( )
requestProgress ( id , gradioApp ( ) . getElementById ( 'extensions_installed_top' ) , null , function ( ) {
} )
return [ id , JSON . stringify ( disable ) ]
2022-11-01 06:59:00 +00:00
}
function install _extension _from _index ( button , url ) {
button . disabled = "disabled"
button . value = "Installing..."
textarea = gradioApp ( ) . querySelector ( '#extension_to_install textarea' )
textarea . value = url
2023-01-17 11:15:47 +00:00
updateInput ( textarea )
2022-11-01 06:59:00 +00:00
gradioApp ( ) . querySelector ( '#install_extension_button' ) . click ( )
}
2023-03-29 21:46:03 +00:00
function config _state _confirm _restore ( _ , config _state _name , config _restore _type ) {
if ( config _state _name == "Current" ) {
return [ false , config _state _name ] ;
}
let restored = "" ;
if ( config _restore _type == "extensions" ) {
restored = "all saved extension versions" ;
} else if ( config _restore _type == "webui" ) {
restored = "the webui version" ;
} else {
restored = "the webui version and all saved extension versions" ;
}
let confirmed = confirm ( "Are you sure you want to restore from this state?\nThis will reset " + restored + ".\n(A backup of the current state will be made.)" ) ;
return [ confirmed , config _state _name , config _restore _type ] ;
}