mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-24 03:35:59 +08:00
移回来,因为 harp 不支持在 mount 多次
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
child_process = require 'child_process'
|
||||
path = require 'path'
|
||||
harp = require 'harp'
|
||||
|
||||
service = require './service'
|
||||
configure = require './configure'
|
||||
@@ -11,8 +9,6 @@ mAccount = require '../../core/model/account'
|
||||
|
||||
module.exports = exports = express.Router()
|
||||
|
||||
exports.use harp.mount(path.join(__dirname, 'static'))
|
||||
|
||||
sample =
|
||||
_id: '53c96734c2dad7d6208a0fbe'
|
||||
is_enable: true
|
||||
|
||||
@@ -11,7 +11,3 @@ module.exports =
|
||||
panel_widgets: [
|
||||
service.widget
|
||||
]
|
||||
|
||||
panel_script: [
|
||||
'/script/panel.js'
|
||||
]
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
$ ->
|
||||
syncToJSON = ->
|
||||
username = $('.nav.navbar-nav.navbar-right li:first a').text()
|
||||
|
||||
try
|
||||
config = JSON.parse($('#nginx-type-json textarea').val())
|
||||
catch e
|
||||
config = {}
|
||||
|
||||
config['listen'] ?= 80
|
||||
|
||||
config['is_enable'] = $('.option-is-enable input').prop('checked')
|
||||
config['server_name'] = $('.option-server-name input').val().split ' '
|
||||
|
||||
switch $('.option-type :radio:checked').val()
|
||||
when 'fastcgi'
|
||||
config['root'] = $('.option-root input').val() or $('.option-root input').prop('placeholder')
|
||||
config['location'] ?= {}
|
||||
config['location']['/'] =
|
||||
try_files: ['$uri', '$uri/', '/index.php?$args']
|
||||
config['location']['~ \\.php$'] =
|
||||
fastcgi_pass: "unix:///home/#{username}/phpfpm.sock"
|
||||
include: 'fastcgi_params'
|
||||
|
||||
when 'proxy'
|
||||
config['location'] ?= {}
|
||||
config['location']['/'] =
|
||||
proxy_pass: $('.option-proxy input').val() or $('.option-proxy input').prop('placeholder')
|
||||
proxy_set_header:
|
||||
Host: '$host'
|
||||
|
||||
when 'uwsgi'
|
||||
config['location'] ?= {}
|
||||
config['location']['/'] =
|
||||
uwsgi_pass: $('.option-uwsgi input').val() or $('.option-uwsgi input').prop('placeholder')
|
||||
include: 'uwsgi_params'
|
||||
|
||||
when 'static'
|
||||
config['root'] = $('.option-root input').val() or $('.option-root input').prop('placeholder')
|
||||
|
||||
json = JSON.stringify(config, null, ' ')
|
||||
$('#nginx-type-json textarea').val json
|
||||
return json
|
||||
|
||||
$('#nginx-type-json textarea').on 'change keyup paste', ->
|
||||
try
|
||||
JSON.parse($('#nginx-type-json textarea').val())
|
||||
$('.json-error').parent().addClass 'hide'
|
||||
catch err
|
||||
console.log err
|
||||
$('.json-error').text err.toString()
|
||||
$('.json-error').parent().removeClass 'hide'
|
||||
|
||||
$('#nginx-modal ul li a').click ->
|
||||
switch $(@).prop('href').match(/.*#nginx-type-(.*)/)[1]
|
||||
when 'json'
|
||||
syncToJSON()
|
||||
when 'guide'
|
||||
$('.json-error').parent().addClass 'hide'
|
||||
|
||||
try
|
||||
config = JSON.parse($('#nginx-type-json textarea').val())
|
||||
catch e
|
||||
return
|
||||
|
||||
$('.option-is-enable input').prop 'checked', config['is_enable']
|
||||
$('.option-server-name input').val config['server_name']?.join ' '
|
||||
$('.option-root input').val config['root']
|
||||
|
||||
type = do ->
|
||||
unless config['location']['/']
|
||||
return 'static'
|
||||
|
||||
if config['location']['/']['proxy_pass']
|
||||
return 'proxy'
|
||||
|
||||
if config['location']['/']['uwsgi_pass']
|
||||
return 'uwsgi'
|
||||
|
||||
if config['location']['/']?['try_files']
|
||||
for item in config['location']['/']['try_files']
|
||||
if item.match(/\.php/)
|
||||
return 'factcgi'
|
||||
|
||||
return 'static'
|
||||
|
||||
$("#nginx-modal :radio[value=#{type}]").click()
|
||||
|
||||
switch type
|
||||
when 'proxy'
|
||||
$('.option-proxy input').val config['location']['/']['proxy_pass']
|
||||
when 'uwsgi'
|
||||
$('.option-uwsgi input').val config['location']['/']['uwsgi_pass']
|
||||
when 'static', 'fastcgi'
|
||||
$('.option-root input').val config['root']
|
||||
|
||||
$('#nginx-modal .radio input').click ->
|
||||
options = ['root', 'proxy', 'uwsgi']
|
||||
|
||||
mapping_table =
|
||||
fastcgi: ['root']
|
||||
proxy: ['proxy']
|
||||
uwsgi: ['uwsgi']
|
||||
static: ['root']
|
||||
|
||||
options_to_show = mapping_table[$(@).val()]
|
||||
|
||||
for item in options
|
||||
if item in options_to_show
|
||||
$("#nginx-modal .option-#{item}").removeClass 'hide'
|
||||
else
|
||||
$("#nginx-modal .option-#{item}").addClass 'hide'
|
||||
|
||||
$('#nginx-modal .modal-footer button.btn-success').click ->
|
||||
type = $('#nginx-modal ul.config-type').find('.active a').prop('href').match(/.*#nginx-type-(.*)/)[1]
|
||||
|
||||
if type == 'guide'
|
||||
config = syncToJSON()
|
||||
|
||||
else if type == 'json'
|
||||
try
|
||||
config = JSON.parse($('#nginx-type-json textarea').val())
|
||||
catch e
|
||||
return alert 'Invalid JSON'
|
||||
|
||||
else
|
||||
return alert 'Coming Soon'
|
||||
|
||||
$.post '/plugin/nginx/update_site/', JSON.stringify
|
||||
action: if config.id then 'update' else 'create'
|
||||
id: config.id
|
||||
type: 'json'
|
||||
config: config
|
||||
.fail (jqXHR) ->
|
||||
alert jqXHR.responseJSON.error
|
||||
.done ->
|
||||
location.reload()
|
||||
Reference in New Issue
Block a user