mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-01-12 22:27:09 +08:00
fix some frontend
This commit is contained in:
@@ -6,7 +6,7 @@ node_js:
|
||||
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y quota quotatool
|
||||
- sudo apt-get install -y quota quotatool supervisor
|
||||
|
||||
script: npm run test-full
|
||||
|
||||
|
||||
@@ -48,8 +48,6 @@ exports.hooks =
|
||||
widgets: []
|
||||
# path
|
||||
styles: []
|
||||
# name
|
||||
switch_buttons: []
|
||||
|
||||
pay:
|
||||
# type, filter: function(req, deposit_log, callback(l_details))
|
||||
|
||||
@@ -30,17 +30,8 @@ block main
|
||||
else
|
||||
button.action-join-plan.btn.btn-success.btn-sm= t('plan.join')
|
||||
|
||||
if selectHook('view.panel.switch_buttons').length
|
||||
#service-switch.row
|
||||
header= t('view.panel.service_switch')
|
||||
for hook in selectHook('view.panel.switch_buttons')
|
||||
if account.attribute.plugin[hook.name].is_enable
|
||||
button(data-name=hook.name).btn.btn-danger #{t('common.disable')} #{t('plugins.' + hook.name + '.name')}
|
||||
else
|
||||
button(data-name=hook.name).btn.btn-success #{t('common.enable')} #{t('plugins.' + hook.name + '.name')}
|
||||
|
||||
for widget_html in widgets_html
|
||||
.row!= widget_html
|
||||
!= widget_html
|
||||
|
||||
prepend sidebar
|
||||
.row
|
||||
|
||||
2
migration/database/v0.8.0.coffee
Normal file
2
migration/database/v0.8.0.coffee
Normal file
@@ -0,0 +1,2 @@
|
||||
module.exports = (db, callback) ->
|
||||
callback()
|
||||
@@ -9,22 +9,23 @@ mixin displayProgressBar(now, limit, unit)
|
||||
aria-valuemin='0', aria-valuemax='100', style='width: #{per}%;')
|
||||
span #{now} / #{limit} #{unit}
|
||||
|
||||
header= t('')
|
||||
table.table.table-hover.linux-widget-table
|
||||
tbody
|
||||
tr
|
||||
td= t('widget.hour_cpu')
|
||||
td
|
||||
mixin displayProgressBar(usage.cpu, limit.cpu, 's')
|
||||
tr
|
||||
td= t('widget.hour_memory')
|
||||
td
|
||||
mixin displayProgressBar(usage.memory, limit.memory, 'M')
|
||||
tr
|
||||
td= t('widget.storage')
|
||||
td
|
||||
mixin displayProgressBar(usage.storage, limit.storage, 'M')
|
||||
tr
|
||||
td= t('widget.month_transfer')
|
||||
td
|
||||
mixin displayProgressBar(0, limit.transfer, 'G')
|
||||
.row
|
||||
header= t('')
|
||||
table.table.table-hover.linux-widget-table
|
||||
tbody
|
||||
tr
|
||||
td= t('widget.hour_cpu')
|
||||
td
|
||||
mixin displayProgressBar(usage.cpu, limit.cpu, 's')
|
||||
tr
|
||||
td= t('widget.hour_memory')
|
||||
td
|
||||
mixin displayProgressBar(usage.memory, limit.memory, 'M')
|
||||
tr
|
||||
td= t('widget.storage')
|
||||
td
|
||||
mixin displayProgressBar(usage.storage, limit.storage, 'M')
|
||||
tr
|
||||
td= t('widget.month_transfer')
|
||||
td
|
||||
mixin displayProgressBar(0, limit.transfer, 'G')
|
||||
|
||||
@@ -9,7 +9,7 @@ exports = module.exports = class LinuxPlugin extends pluggable.Plugin
|
||||
linux = require '../linux/linux'
|
||||
|
||||
exports.registerHook 'view.panel.scripts',
|
||||
path: '/plugin/ssh/style/panel.js'
|
||||
path: '/plugin/ssh/script/panel.js'
|
||||
|
||||
exports.registerHook 'view.panel.widgets',
|
||||
generator: (req, callback) ->
|
||||
|
||||
@@ -1,23 +1,13 @@
|
||||
$ ->
|
||||
$('#widget-ssh .btn-kill').click ->
|
||||
$('.widget-ssh .action-kill').click ->
|
||||
if window.confirm 'Are you sure?'
|
||||
$.post '/plugin/ssh/kill/', JSON.stringify
|
||||
request '/plugin/ssh/kill',
|
||||
pid: $(@).parents('tr').data 'id'
|
||||
.fail (jqXHR) ->
|
||||
if jqXHR.responseJSON?.error
|
||||
alert jqXHR.responseJSON.error
|
||||
else
|
||||
alert jqXHR.statusText
|
||||
.success ->
|
||||
, ->
|
||||
location.reload()
|
||||
|
||||
$('#widget-ssh .update-password button').click ->
|
||||
$.post '/plugin/ssh/update_password/', JSON.stringify
|
||||
password: $('#widget-ssh .update-password input').val()
|
||||
.fail (jqXHR) ->
|
||||
if jqXHR.responseJSON?.error
|
||||
alert jqXHR.responseJSON.error
|
||||
else
|
||||
alert jqXHR.statusText
|
||||
.success ->
|
||||
$('.widget-ssh .action-update-password').click ->
|
||||
request '/plugin/ssh/update_password',
|
||||
password: $('.widget-ssh .input-password').val()
|
||||
, ->
|
||||
location.reload()
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
header= t('')
|
||||
.col-md-6
|
||||
.panel.panel-warning
|
||||
.panel-heading
|
||||
h3.panel-title= t('view.update_password')
|
||||
.panel-body
|
||||
.input-group.update-password
|
||||
input.form-control(type='password')
|
||||
span.input-group-btn
|
||||
button.btn.btn-default(type='button')= t('common.submit')
|
||||
.row.widget-ssh
|
||||
header= t('')
|
||||
.col-md-6
|
||||
.panel.panel-warning
|
||||
.panel-heading
|
||||
h3.panel-title= t('view.update_password')
|
||||
.panel-body
|
||||
.input-group
|
||||
input.input-password.form-control(type='password')
|
||||
span.input-group-btn
|
||||
button.btn.btn-default.action-update-password(type='button')= t('common.submit')
|
||||
|
||||
.col-md-6
|
||||
table(style= 'table-layout: fixed;').table.table-hover
|
||||
thead
|
||||
tr
|
||||
td(style= 'width: 250px;')= t('process')
|
||||
td= t('memory')
|
||||
td= t('cpu')
|
||||
td= t('common.actions')
|
||||
tbody
|
||||
for process in process_list
|
||||
tr(data-id= '#{process.pid}')
|
||||
td(style= 'white-space: nowrap; overflow: hidden;', title= process.command)= process.command
|
||||
td #{(process.rss / 1024).toFixed(1)}M
|
||||
td #{process.cpu_per}%
|
||||
td
|
||||
button.btn-kill.btn.btn-danger.btn-xs= t('kill')
|
||||
.col-md-6
|
||||
table(style= 'table-layout: fixed;').table.table-hover
|
||||
thead
|
||||
tr
|
||||
td(style= 'width: 250px;')= t('process')
|
||||
td= t('memory')
|
||||
td= t('cpu')
|
||||
td= t('common.actions')
|
||||
tbody
|
||||
for process in process_list
|
||||
tr(data-id= '#{process.pid}')
|
||||
td(style= 'white-space: nowrap; overflow: hidden;', title= process.command)= process.command
|
||||
td #{(process.rss / 1024).toFixed(1)}M
|
||||
td #{process.cpu_per}%
|
||||
td
|
||||
button.action-kill.btn.btn-danger.btn-xs= t('kill')
|
||||
|
||||
@@ -8,7 +8,10 @@ exports = module.exports = class SupervisorPlugin extends pluggable.Plugin
|
||||
supervisor = require './supervisor'
|
||||
|
||||
exports.registerHook 'view.panel.scripts',
|
||||
path: '/plugin/linux/script/panel.js'
|
||||
path: '/plugin/supervisor/script/panel.js'
|
||||
|
||||
exports.registerHook 'view.panel.styles',
|
||||
path: '/plugin/supervisor/style/panel.css'
|
||||
|
||||
exports.registerHook 'view.panel.widgets',
|
||||
generator: (req, callback) ->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{express, ObjectId} = app.libs
|
||||
{express, ObjectId, _} = app.libs
|
||||
{Account} = app.models
|
||||
{requireInService} = app.middleware
|
||||
|
||||
@@ -58,8 +58,8 @@ exports.param 'id', (req, res, next, id) ->
|
||||
|
||||
exports.post '/create_program', restrictProgramFields, (req, res) ->
|
||||
program = _.pick req.body, _.keys(program_sample)
|
||||
program._id = ObjectId()
|
||||
program.program_name = "@#{account.username}-#{program.name}"
|
||||
program._id = new ObjectId()
|
||||
program.program_name = "@#{req.account.username}-#{program.name}"
|
||||
|
||||
for field in require_fields
|
||||
unless field in _.keys req.body
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
$ ->
|
||||
diglog = $('#supervisor-dialog')
|
||||
|
||||
$('.widget-supervisor .action-control').click ->
|
||||
request "/plugin/supervisor/program_control/#{$(@).parents('tr').data('id')}",
|
||||
action: $(@).data 'action'
|
||||
, ->
|
||||
location.reload()
|
||||
|
||||
$('.widget-supervisor .action-create').click ->
|
||||
diglog.find('.label-program-id').val ''
|
||||
diglog.find('.input-name').val ''
|
||||
diglog.find('.input-command').val ''
|
||||
diglog.find('.input-directory').val ''
|
||||
diglog.find('.input-autostart').prop 'checked', true
|
||||
diglog.find(".input-autorestart :radio[value=unexpected]").click()
|
||||
|
||||
diglog.find('.action-submit').click ->
|
||||
if diglog.find('.label-program-id').text()
|
||||
url = "/plugin/supervisor/update_program/#{$(@).parents('tr').data('id')}"
|
||||
else
|
||||
url= '/plugin/supervisor/create_program'
|
||||
|
||||
request url,
|
||||
name: diglog.find('.input-name').val()
|
||||
command: diglog.find('.input-command').val()
|
||||
directory: diglog.find('.input-directory').val()
|
||||
autostart: diglog.find('.input-autostart').prop('checked')
|
||||
autorestart: diglog.find('.input-autorestart :radio:checked').val()
|
||||
, ->
|
||||
location.reload()
|
||||
|
||||
$('.widget-supervisor .action-edit').click ->
|
||||
request "/plugin/supervisor/program_config/#{$(@).parents('tr').data('id')}", {}, (program) ->
|
||||
diglog.find('.label-program-id').val program.id
|
||||
diglog.find('.input-name').val program.name
|
||||
diglog.find('.input-command').val program.command
|
||||
diglog.find('.input-directory').val program.directory
|
||||
diglog.find('.input-autostart').prop 'checked', program.autostart
|
||||
diglog.find(".input-autorestart :radio[value=#{program.autorestart}]").click()
|
||||
|
||||
$('#nginx-modal').modal 'show'
|
||||
|
||||
$('.widget-supervisor .action-remove').click ->
|
||||
if window.confirm 'Are you sure?'
|
||||
request "/plugin/supervisor/remove_program/#{$(@).parents('tr').data('id')}", {}, ->
|
||||
location.reload()
|
||||
|
||||
5
plugin/supervisor/static/style/panel.less
Normal file
5
plugin/supervisor/static/style/panel.less
Normal file
@@ -0,0 +1,5 @@
|
||||
@media (min-width: 768px) {
|
||||
#supervisor-creator .modal-dialog {
|
||||
margin: 80px auto;
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,10 @@ exports.removePrograms = (account, callback) ->
|
||||
callback()
|
||||
|
||||
exports.programSummary = (program) ->
|
||||
summary = "autostart:#{program.autostart};autorestart:#{program.autorestart}"
|
||||
summary = "autostart:#{program.autostart}; autorestart:#{program.autorestart}"
|
||||
|
||||
if program.directory
|
||||
summary += ";directory:#{program.directory}"
|
||||
summary += "; directory:#{program.directory}"
|
||||
|
||||
return summary
|
||||
|
||||
@@ -50,7 +50,7 @@ exports.programControl = (account, program, action, callback) ->
|
||||
callback()
|
||||
|
||||
exports.programsStatus = (callback) ->
|
||||
child_process.exec 'sudo supervisor status', (err, stdout) ->
|
||||
child_process.exec 'sudo supervisorctl status', (err, stdout) ->
|
||||
callback _.map stdout.split('\n'), (line) ->
|
||||
[name, status] = line.split '\s'
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@ user = <%= account.username %>
|
||||
redirect_stderr = true
|
||||
stdout_logfile = /home/<%= account.username %>/supervisor-<%= program.name %>.log
|
||||
<% if(program.directory) { %>
|
||||
directory = <%= program.directory %>
|
||||
directory = <%= program.directory %>
|
||||
<% } %>
|
||||
|
||||
@@ -1,78 +1,80 @@
|
||||
header= t('')
|
||||
table.table.table-hover
|
||||
thead
|
||||
tr
|
||||
th= t('common.name')
|
||||
th= t('common.command')
|
||||
th= t('common.options')
|
||||
th= t('common.status')
|
||||
th
|
||||
button.btn.btn-success.btn-xs(data-toggle='modal', data-target='#supervisor-creator')
|
||||
span.glyphicon.glyphicon-plus-sign
|
||||
.row.widget-supervisor
|
||||
header= t('')
|
||||
table.table.table-hover
|
||||
thead
|
||||
tr
|
||||
th= t('common.name')
|
||||
th= t('common.command')
|
||||
th= t('common.options')
|
||||
th= t('common.status')
|
||||
th
|
||||
button.btn.btn-success.btn-xs.action-create(data-toggle='modal', data-target='#supervisor-dialog')
|
||||
span.glyphicon.glyphicon-plus-sign
|
||||
|
||||
tbody
|
||||
for program in account.pluggable.supervisor.programs
|
||||
tr(data-id='#{program._id}')
|
||||
td= program.name
|
||||
td= program.command
|
||||
td= programSummary(program)
|
||||
td= program.status
|
||||
td
|
||||
button.btn.btn-warning.btn-xs.action-restart
|
||||
span.glyphicon.glyphicon-repeat
|
||||
if program.status != 'running'
|
||||
button.btn.btn-success.btn-xs.action-start
|
||||
span.glyphicon.glyphicon-play
|
||||
if program.status == 'running'
|
||||
button.btn.btn-danger.btn-xs.action-stop
|
||||
span.glyphicon.glyphicon-stop
|
||||
button.btn.btn-info.btn-xs.action-edit
|
||||
span.glyphicon.glyphicon-edit
|
||||
button.btn.btn-danger.btn-xs.action-remove
|
||||
span.glyphicon.glyphicon-trash
|
||||
tbody
|
||||
for program in account.pluggable.supervisor.programs
|
||||
tr(data-id=program._id)
|
||||
td= program.name
|
||||
td= program.command
|
||||
td= programSummary(program)
|
||||
td= program.status
|
||||
td
|
||||
button.btn.btn-warning.btn-xs.action-control(type='button', data-action='restart')
|
||||
span.glyphicon.glyphicon-repeat
|
||||
if program.status != 'running'
|
||||
button.btn.btn-success.btn-xs.action-control(type='button', data-action='start')
|
||||
span.glyphicon.glyphicon-play
|
||||
if program.status == 'running'
|
||||
button.btn.btn-danger.btn-xs.action-control(type='button', data-action='stop')
|
||||
span.glyphicon.glyphicon-stop
|
||||
button.btn.btn-info.btn-xs.action-edit(type='button')
|
||||
span.glyphicon.glyphicon-edit
|
||||
button.btn.btn-danger.btn-xs.action-remove(type='button')
|
||||
span.glyphicon.glyphicon-trash
|
||||
|
||||
#supervisor-creator.modal.fade(tabindex='-1', role='dialog', aria-hidden='true')
|
||||
#supervisor-dialog.modal.fade(tabindex='-1', role='dialog', aria-hidden='true')
|
||||
.modal-dialog
|
||||
.modal-content
|
||||
.modal-header
|
||||
button.close(type='button', data-dismiss='modal', aria-hidden='true') ×
|
||||
h3.modal-title
|
||||
| #{t('')}
|
||||
span.small.label-site-id
|
||||
span.small.label-program-id
|
||||
.modal-body
|
||||
.form-group
|
||||
label.col-sm-2.control-label= t('common.name')
|
||||
.col-sm-10
|
||||
input.form-control.input-name(type='text', placeholder='myapp')
|
||||
.form-group
|
||||
label.col-sm-2.control-label= t('common.command')
|
||||
.col-sm-10
|
||||
input.form-control.input-command(type='text', placeholder='node /home/jysperm/app.js')
|
||||
.form-group
|
||||
label.col-sm-2.control-label= t('common.directory')
|
||||
.col-sm-10
|
||||
input.form-control.input-directory(type='text', placeholder='/home/jysperm')
|
||||
.form-group
|
||||
label.col-sm-2.control-label »
|
||||
form.form-horizontal(role='form')
|
||||
.form-group
|
||||
label.col-sm-2.control-label= t('common.name')
|
||||
.col-sm-10
|
||||
input.form-control.input-name(type='text', name='name', placeholder='myapp')
|
||||
.form-group
|
||||
label.col-sm-2.control-label= t('common.command')
|
||||
.col-sm-10
|
||||
input.form-control.input-command(type='text', name='command', placeholder='node /home/jysperm/app.js')
|
||||
.form-group
|
||||
label.col-sm-2.control-label= t('common.directory')
|
||||
.col-sm-10
|
||||
input.form-control.input-directory(type='text', name='directory', placeholder='/home/jysperm')
|
||||
.form-group
|
||||
label.col-sm-2.control-label »
|
||||
.checkbox.col-sm-10
|
||||
label
|
||||
input.input-autostart(type='checkbox', checked)
|
||||
input.input-autostart(type='checkbox', name='autostart', checked)
|
||||
| #{t('common.autostart')}
|
||||
.form-group
|
||||
label.col-sm-2.control-label »
|
||||
.controls.col-sm-10.input-autorestart
|
||||
.radio
|
||||
label
|
||||
input(type='radio', name='autorestart', value='unexpected', checked)
|
||||
| #{t('autorestart.unexpected')}
|
||||
.radio
|
||||
label
|
||||
input(type='radio', name='autorestart', value='true')
|
||||
| #{t('autorestart.true')}
|
||||
.radio
|
||||
label
|
||||
input(type='radio', name='autorestart', value='false')
|
||||
| #{t('autorestart.false')}
|
||||
.form-group
|
||||
label.col-sm-2.control-label »
|
||||
.controls.col-sm-10.input-autorestart
|
||||
.radio
|
||||
label
|
||||
input(type='radio', name='autorestart', value='unexpected', checked)
|
||||
| #{t('autorestart.unexpected')}
|
||||
.radio
|
||||
label
|
||||
input(type='radio', name='autorestart', value='true')
|
||||
| #{t('autorestart.true')}
|
||||
.radio
|
||||
label
|
||||
input(type='radio', name='autorestart', value='false')
|
||||
| #{t('autorestart.false')}
|
||||
|
||||
.modal-footer
|
||||
button.btn.btn-success.action-submit(type='button')= t('common.save')
|
||||
|
||||
Reference in New Issue
Block a user