diff --git a/core/plan.coffee b/core/plan.coffee index 46907f3..846f7e3 100644 --- a/core/plan.coffee +++ b/core/plan.coffee @@ -38,7 +38,10 @@ exports.leavePlan = (account, plan, callback) -> modifier['$unset']["attribute.plugin.#{plan}"] = '' - mAccount.update _id: account._id, modifier, -> + console.log modifier + + mAccount.update _id: account._id, modifier, (err) -> + throw err if err (plugin.get serviceName).service.delete account, -> callback() diff --git a/core/static/script/panel.coffee b/core/static/script/panel.coffee index 926a4c2..3aa7bef 100644 --- a/core/static/script/panel.coffee +++ b/core/static/script/panel.coffee @@ -197,37 +197,27 @@ $ -> $('#nginx-modal .site-id').text data.id $('#nginx-modal').modal 'show' - # refactored above - - service = $ '#service' - service.find 'button' - .on 'click', (e) -> - e.preventDefault() - button = $ @ - prehead = if button.hasClass 'btn-success' then '' else 'un' - $.post "/plan/#{prehead}subscribe/", JSON.stringify { - plan: button.parents('tr').data 'type' - } + $('.plan-list .btn-danger').click -> + if window.confirm 'Are you sure?' + $.post "/plan/unsubscribe/", JSON.stringify + plan: $(@).parents('tr').data 'name' .success -> location.reload() - ssh = $ '#ssh-input' - ssh.find 'button' - .on 'click', (e) -> - e.preventDefault() - $.post '/plugin/ssh/update_password/', JSON.stringify { - password: ssh.find('input').val() - } - .success -> - ErrorHandle.flushInfo 'success', '修改成功', -> - location.reload() + $('.plan-list .btn-success').click -> + $.post "/plan/subscribe/", JSON.stringify + plan: $(@).parents('tr').data 'name' + .success -> + location.reload() - mysql = $ '#mysql-input' - mysql.find 'button' - .on 'click', (e) -> - e.preventDefault() - $.post '/plugin/mysql/update_password/', JSON.stringify { - password: (mysql.find 'input').val() - } - .success -> - location.reload() + $('#widget-ssh .update-password button').click -> + $.post '/plugin/ssh/update_password/', JSON.stringify + password: $('#widget-ssh .update-password input').val() + .success -> + location.reload() + + $('#widget-mysql .update-password button').click -> + $.post '/plugin/mysql/update_password/', JSON.stringify + password: $('#widget-mysql .update-password input').val() + .success -> + location.reload() diff --git a/core/view/panel.jade b/core/view/panel.jade index 0d58003..b56ef72 100644 --- a/core/view/panel.jade +++ b/core/view/panel.jade @@ -21,9 +21,6 @@ block content | #{t('ticket.')} .col-md-9 - #page-alert.alert.alert-danger - #page-success.alert.alert-success - .row header= t('panel.overview') p @@ -35,10 +32,10 @@ block content .row header= t('plan.') - table.table.table-hover - tbody#service + table.table.table-hover.plan-list + tbody for plan in plans - tr(data-type='#{plan.name}') + tr(data-name='#{plan.name}') td= plan.t_name td= plan.t_service td= plan.t_resources diff --git a/plugin/mysql/view/widget.jade b/plugin/mysql/view/widget.jade index 194028f..6c56978 100644 --- a/plugin/mysql/view/widget.jade +++ b/plugin/mysql/view/widget.jade @@ -4,7 +4,7 @@ header MySQL .panel-heading h3.panel-title 设置 MySQL 密码 .panel-body - .input-group#mysql-input + .input-group.update-password input.form-control(type='password') span.input-group-btn button.btn.btn-default(type='button') 提交 diff --git a/plugin/ssh/view/widget.jade b/plugin/ssh/view/widget.jade index 27348dd..d76265a 100644 --- a/plugin/ssh/view/widget.jade +++ b/plugin/ssh/view/widget.jade @@ -4,7 +4,7 @@ header SSH .panel-heading h3.panel-title 设置 SSH 密码 .panel-body - .input-group#ssh-input + .input-group.update-password input.form-control(type='password') span.input-group-btn button.btn.btn-default(type='button') 提交