2016-10-21 15:53:12 +02:00
< html >
< head >
< title > Cloudron Setup < / title >
<!-- Latest compiled and minified CSS -->
< link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity = "sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin = "anonymous" >
<!-- Optional theme -->
< link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity = "sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin = "anonymous" >
<!-- jQuery 3 minified -->
< script src = "https://code.jquery.com/jquery-3.1.1.min.js" integrity = "sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin = "anonymous" > < / script >
<!-- Latest compiled and minified JavaScript -->
< script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity = "sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin = "anonymous" > < / script >
2016-10-23 22:58:56 +02:00
<!-- fontawesome -->
< link href = "https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel = "stylesheet" integrity = "sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin = "anonymous" >
2016-10-21 15:53:12 +02:00
< / head >
< body >
< div class = "container" >
< div class = "row" >
< div class = "col-md-offset-2 col-md-8" >
< h1 > Cloudron Setup< / h1 >
2016-10-23 22:58:56 +02:00
< div id = "setupForm" >
< form >
< div class = "form-group" >
< label for = "inputDomain" > Domain< / label >
< input type = "text" class = "form-control" id = "inputDomain" name = "fqdn" placeholder = "example.com" required >
< / div >
< a data-toggle = "collapse" href = "#collapseExample" > Advanced< / a > < br / >
< div class = "collapse" id = "collapseExample" >
< div class = "form-group" >
< label for = "inputVersionsUrl" > Versions URL (optional)< / label >
< input type = "text" class = "form-control" id = "inputVersionsUrl" name = "boxVersionsUrl" placeholder = "" >
< / div >
< / div >
< button type = "submit" class = "btn btn-default pull-right" > Next< / button >
< / form >
< / div >
< div id = "waitForDNS" style = "display: none;" >
< center >
< br / >
< h4 > Now setup a wildcard or at least a < b > my.< span id = "fqdn_placeholder" > < / span > < / b > DNS record, pointing to < b > < span id = "ip_placeholder" > < / span > < / b > < / h4 >
< br / >
< i class = "fa fa-circle-o-notch fa-spin fa-3x fa-fw" > < / i > < br / >
< br / >
< i > Waiting for DNS to be setup< / i >
< br / > < br / >
< button type = "button" class = "btn btn-default" id = "backButton" > Back< / button >
< / center >
< / div >
2016-10-21 15:53:12 +02:00
< / div >
< / div >
< / div >
< script >
$ ( function ( ) {
2016-10-23 22:58:56 +02:00
'use strict' ;
2016-10-21 15:53:12 +02:00
2016-10-23 22:58:56 +02:00
$ ( '#backButton' ) . on ( 'click' , function ( ) {
showForm ( ) ;
} ) ;
function hideForm ( ) {
$ ( '#setupForm' ) . hide ( ) ;
$ ( '#waitForDNS' ) . show ( ) ;
}
2016-10-21 15:53:12 +02:00
2016-10-23 22:58:56 +02:00
function showForm ( ) {
$ ( '#waitForDNS' ) . hide ( ) ;
$ ( '#setupForm' ) . show ( ) ;
}
function setup ( ) {
2016-10-21 15:53:12 +02:00
var data = {
fqdn : $ ( '#inputDomain' ) . val ( ) ,
boxVersionsUrl : $ ( '#inputVersionsUrl' ) . val ( )
} ;
$ . ajax ( {
type : 'POST' ,
url : '/api/v1/setup' ,
data : JSON . stringify ( data ) ,
success : function ( data ) { console . log ( 'data: ' + data ) ; } ,
contentType : 'application/json'
} ) ;
2016-10-23 22:58:56 +02:00
}
function waitForDNS ( fqdn , ip ) {
$ ( '#fqdn_placeholder' ) . text ( fqdn ) ;
$ ( '#ip_placeholder' ) . text ( ip ) ;
hideForm ( ) ;
var data = {
fqdn : fqdn ,
ip : ip
} ;
$ . ajax ( {
type : 'POST' ,
url : '/api/v1/dns' ,
data : JSON . stringify ( data ) ,
2016-10-23 23:10:49 +02:00
contentType : 'application/json' ,
success : function ( data , status ) { console . log ( 'data: ' , status , data ) ; } ,
error : function ( ) {
setTimeout ( waitForDNS . bind ( null , fqdn , ip ) , 5000 ) ;
} ,
2016-10-23 22:58:56 +02:00
} ) ;
}
$ ( '#setupForm' ) . submit ( function ( event ) {
event . preventDefault ( ) ;
waitForDNS ( $ ( '#inputDomain' ) . val ( ) , location . hostname ) ;
2016-10-21 15:53:12 +02:00
} ) ;
} ) ;
< / script >
< / body >
< / html >