Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
admpub committed Oct 13, 2019
1 parent 420f372 commit d31dafc
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 16 deletions.
23 changes: 17 additions & 6 deletions application/handler/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ import (
"path/filepath"
"strings"

"github.com/webx-top/com"
"github.com/webx-top/echo"
mw "github.com/webx-top/echo/middleware"

"github.com/admpub/godownloader/service"
"github.com/admpub/nging/application/handler"
"github.com/admpub/nging/application/handler/caddy"
"github.com/admpub/nging/application/library/config"
"github.com/admpub/nging/application/library/dbmanager/driver/mysql"
"github.com/admpub/nging/application/library/filemanager"
"github.com/admpub/nging/application/library/notice"
"github.com/webx-top/com"
"github.com/webx-top/echo"
mw "github.com/webx-top/echo/middleware"
)

var downloadDir = func() string {
Expand Down Expand Up @@ -103,9 +104,19 @@ func File(ctx echo.Context) error {
}
return ctx.JSON(data)
case `delete`:
err = mgr.Remove(absPath)
if err != nil {
handler.SendFail(ctx, err.Error())
paths := ctx.FormValues(`path`)
for _, filePath := range paths {
filePath = strings.TrimSpace(filePath)
if len(filePath) == 0 {
continue
}
filePath = filepath.Clean(filePath)
absPath = filepath.Join(root, filePath)
err = mgr.Remove(absPath)
if err != nil {
handler.SendFail(ctx, err.Error())
return ctx.Redirect(ctx.Referer())
}
}
return ctx.Redirect(ctx.Referer())
case `upload`:
Expand Down
7 changes: 4 additions & 3 deletions public/assets/backend/js/behaviour/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ var App = function () {
var cachedLang = null;
return {
clientID: {},
i18n: { SYS_INFO: 'System Information', UPLOAD_ERR: 'Upload Error', PLEASE_SELECT_FOR_REMOVE: 'Please select the item you want to delete', CONFIRM_REMOVE: 'Are you sure you want to delete them?' },
i18n: { SYS_INFO: 'System Information', UPLOAD_ERR: 'Upload Error', PLEASE_SELECT_FOR_REMOVE: 'Please select the item you want to delete', CONFIRM_REMOVE: 'Are you sure you want to delete them?', SELECTED_ITEMS: 'You have selected %d items' },
lang: 'en',
sprintf: sprintfWrapper.init,
t: function (key) {
Expand Down Expand Up @@ -1296,13 +1296,14 @@ var App = function () {
if (postField == null) postField = 'id';
var data = [];
$(elem).each(function () {
if($(this).is(':checked')) data.push({ name: postField, value: $(this).val() });
if( $(this).is(':checked') && !$(this).prop('disabled') ) data.push({ name: postField, value: $(this).val() });
});
if (data.length < 1) {
App.message({ title: App.i18n.SYS_INFO, text: App.i18n.PLEASE_SELECT_FOR_REMOVE, type: 'warning' });
return false;
}
if (!confirm(App.i18n.CONFIRM_REMOVE)) return false;
var answer = App.i18n.CONFIRM_REMOVE+"\n"+App.sprintf(App.i18n.SELECTED_ITEMS,data.length);
if (!confirm(answer)) return false;
App.loading('show');
$.get(removeURL, data, function (r) {
App.loading('hide');
Expand Down
2 changes: 1 addition & 1 deletion public/assets/backend/js/behaviour/general.min.js

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions public/assets/backend/js/behaviour/page/file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
var dropzone,dropzoneZIP,editor;
function resetCheckedbox() {
$('#checkedAll:checked').prop('checked', false);
$('#tbody-content input[type=checkbox][name="path[]"]:checked').prop('checked', false);
}
function refreshList() {
if($('#tbody-content').length<1){
window.location.reload();
Expand All @@ -11,6 +15,7 @@ function refreshList() {
App.float('#tbody-content img.previewable');
App.loading('hide');
$('#tbody-content').trigger('refresh');
resetCheckedbox();
},'html');
}
function initCodeMirrorEditor() {
Expand Down Expand Up @@ -220,10 +225,15 @@ $(function(){
var q=$(this).val();
if(q==''){
$('#tbody-content').children('tr:not(:visible)').show();
var disabledBoxies=$('#tbody-content input[type=checkbox][name="path[]"]:disabled');
if(disabledBoxies.length>0)$('#checkedAll').prop('checked',false);
disabledBoxies.prop('disabled',false);
return;
}
$('#tbody-content').children('tr:not([item*="'+q+'"])').hide();
$('#tbody-content').children('tr[item*="'+q+'"]:not(:visible)').show();
$('#tbody-content').children('tr:not([item*="'+q+'"])').hide().find('input[type=checkbox][name="path[]"]').prop('disabled',true);
$('#tbody-content').children('tr[item*="'+q+'"]:not(:visible)').show().find('input[type=checkbox][name="path[]"]:disabled').prop('disabled',false);
$('#tbody-content input[type=checkbox][name="path[]"]:disabled:checked').prop('checked',false);
$('#checkedAll').prop('checked',$('#tbody-content tr[item]:visible input[type=checkbox][name="path[]"]:checked').length==$('#tbody-content tr[item]:visible input[type=checkbox][name="path[]"]'));
if(event.keyCode==13){
var tr=$('#tbody-content').children('tr:visible');
if(tr.length==1){
Expand All @@ -238,4 +248,6 @@ $(function(){
$('#query-current-path').trigger('keyup');
});
App.float('#tbody-content img.previewable');
resetCheckedbox();
App.attachCheckedAll('#checkedAll','#tbody-content input[type=checkbox][name="path[]"]');
});
2 changes: 1 addition & 1 deletion public/assets/backend/js/behaviour/page/file.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions template/backend/caddy/file.script.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
App.i18n.MODIFY_FILENAME='{{"修改文件名"|T}}';
App.i18n.EDIT_FILE='{{"编辑文件"|T}}';
App.i18n.PLAY='{{"播放"|T}}';
App.i18n.SELECTED_ITEMS='{{"您已经选择了%d条数据"|T}}';
</script>
{{/Strip}}
Loading

0 comments on commit d31dafc

Please sign in to comment.