Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
-布谷鸟-
nosqlclient
提交
057b5806
N
nosqlclient
项目概览
-布谷鸟-
/
nosqlclient
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nosqlclient
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
057b5806
编写于
5月 10, 2017
作者:
R
rsercano
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resolves #358
上级
e573e43a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
60 deletion
+25
-60
client/imports/views/layouts/top_navbar/top_navbar.html
client/imports/views/layouts/top_navbar/top_navbar.html
+1
-12
client/imports/views/layouts/top_navbar/top_navbar.js
client/imports/views/layouts/top_navbar/top_navbar.js
+2
-25
client/imports/views/query_templates/collection/find/find.js
client/imports/views/query_templates/collection/find/find.js
+1
-1
server/imports/mongodb/methods_common.js
server/imports/mongodb/methods_common.js
+0
-20
server/imports/webapp.js
server/imports/webapp.js
+21
-2
未找到文件。
client/imports/views/layouts/top_navbar/top_navbar.html
浏览文件 @
057b5806
...
...
@@ -104,7 +104,7 @@
<h4
id=
"importExportMongoclientTitle"
class=
"modal-title"
>
Import Mongoclient Data
</h4>
</div>
<div
class=
"modal-body"
>
<form
id=
"frmImportMongoclient"
class=
"form-horizontal"
style=
"display: none"
>
<form
id=
"frmImportMongoclient"
class=
"form-horizontal"
>
<div
class=
"form-group"
>
<label
class=
"col-lg-3 control-label"
>
Backup File
</label>
<div
class=
"col-lg-9"
>
...
...
@@ -114,17 +114,6 @@
</div>
</div>
</form>
<form
id=
"frmExportMongoclient"
class=
"form-horizontal"
style=
"display: none"
>
<div
class=
"form-group"
>
<label
class=
"col-lg-3 control-label"
>
Place to Export
</label>
<div
class=
"col-lg-9"
>
<input
class=
"form-control"
type=
"text"
id=
"inputExportBackupDir"
data-buttonName=
"btn-primary"
>
<span
class=
"help-block m-b-none"
>
Example:
<b>
/home/user/mongoclient/
</b></span>
</div>
</div>
</form>
</div>
<div
class=
"modal-footer"
>
<div
class=
"pull-left"
>
...
...
client/imports/views/layouts/top_navbar/top_navbar.js
浏览文件 @
057b5806
...
...
@@ -79,11 +79,9 @@ Template.topNavbar.events({
'
click #btnProceedImportExport
'
(
e
)
{
e
.
preventDefault
();
let
laddaButton
=
Ladda
.
create
(
document
.
querySelector
(
'
#btnProceedImportExport
'
));
let
isImport
=
$
(
'
#importExportMongoclientTitle
'
).
text
()
==
'
Import Mongoclient Data
'
;
let
importInput
=
$
(
'
#inputImportBackupFile
'
);
let
exportInput
=
$
(
'
#inputExportBackupDir
'
);
if
(
i
sImport
&&
i
mportInput
.
val
())
{
if
(
importInput
.
val
())
{
laddaButton
.
start
();
loadFile
(
null
,
importInput
,
function
(
val
)
{
Meteor
.
call
(
'
importMongoclient
'
,
val
,
function
(
err
)
{
...
...
@@ -98,20 +96,6 @@ Template.topNavbar.events({
});
},
true
);
}
else
if
(
!
isImport
&&
exportInput
.
val
())
{
laddaButton
.
start
();
Meteor
.
call
(
'
exportMongoclient
'
,
exportInput
.
val
(),
function
(
err
,
path
)
{
if
(
err
)
{
toastr
.
error
(
"
Couldn't export:
"
+
err
.
message
);
}
else
{
toastr
.
success
(
"
Successfully exported to
"
+
path
.
result
);
$
(
'
#importExportMongoclientModal
'
).
modal
(
'
hide
'
);
}
Ladda
.
stopAll
();
});
}
},
'
change .filestyle
'
(
e
){
...
...
@@ -132,14 +116,7 @@ Template.topNavbar.events({
'
click #btnExportMongoclient
'
(
e
)
{
e
.
preventDefault
();
let
icon
=
$
(
'
#importExportMongoclientIcon
'
);
$
(
'
#importExportMongoclientTitle
'
).
text
(
'
Export Mongoclient Data
'
);
icon
.
removeClass
(
'
fa-download
'
);
icon
.
addClass
(
'
fa-upload
'
);
$
(
'
#btnProceedImportExport
'
).
text
(
'
Export
'
);
$
(
'
#frmImportMongoclient
'
).
hide
();
$
(
'
#frmExportMongoclient
'
).
show
();
$
(
'
#importExportMongoclientModal
'
).
modal
(
'
show
'
);
window
.
open
(
'
exportMongoclient
'
);
},
'
click #btnImportMongoclient
'
(
e
)
{
...
...
client/imports/views/query_templates/collection/find/find.js
浏览文件 @
057b5806
...
...
@@ -27,7 +27,7 @@ const proceedFindQuery = function (selectedCollection, selector, cursorOptions,
};
if
(
exportFormat
)
{
window
.
open
(
'
export?format=
'
+
exportFormat
+
'
&selectedCollection=
'
+
selectedCollection
+
"
&selector=
"
+
JSON
.
stringify
(
selector
)
+
"
&cursorOptions=
"
+
JSON
.
stringify
(
cursorOptions
));
window
.
open
(
'
export?format=
'
+
exportFormat
+
'
&selectedCollection=
'
+
selectedCollection
+
"
&selector=
"
+
JSON
.
stringify
(
selector
)
+
"
&cursorOptions=
"
+
JSON
.
stringify
(
cursorOptions
)
+
"
&sessionId=
"
+
Meteor
.
default_connection
.
_lastSessionId
);
Ladda
.
stopAll
();
}
else
{
Meteor
.
call
(
"
find
"
,
selectedCollection
,
selector
,
cursorOptions
,
executeExplain
,
Meteor
.
default_connection
.
_lastSessionId
,
function
(
err
,
result
)
{
...
...
server/imports/mongodb/methods_common.js
浏览文件 @
057b5806
...
...
@@ -215,26 +215,6 @@ Meteor.methods({
}
},
exportMongoclient
(
dir
)
{
let
filePath
=
dir
+
"
/backup_
"
+
moment
().
format
(
'
DD_MM_YYYY_HH_mm_ss
'
)
+
"
.json
"
;
let
fileContent
=
{};
fileContent
.
settings
=
Settings
.
findOne
();
fileContent
.
connections
=
Connections
.
find
().
fetch
();
LOGGER
.
info
(
'
[exportMongoclient]
'
,
filePath
);
return
Async
.
runSync
(
function
(
done
)
{
try
{
fs
.
writeFile
(
filePath
,
JSON
.
stringify
(
fileContent
),
function
(
err
)
{
done
(
err
,
filePath
);
});
}
catch
(
ex
)
{
LOGGER
.
error
(
'
[exportMongoclient]
'
,
ex
);
done
(
new
Meteor
.
Error
(
ex
.
message
),
null
);
}
});
},
listCollectionNames
(
dbName
,
sessionId
)
{
LOGGER
.
info
(
'
[listCollectionNames]
'
,
dbName
,
sessionId
);
...
...
server/imports/webapp.js
浏览文件 @
057b5806
...
...
@@ -4,21 +4,40 @@
import
{
WebApp
}
from
"
meteor/webapp
"
;
import
{
Meteor
}
from
"
meteor/meteor
"
;
import
{
Papa
}
from
"
meteor/harrison:papa-parse
"
;
import
{
Settings
}
from
"
/lib/imports/collections/settings
"
;
import
{
Connections
}
from
"
/lib/imports/collections/connections
"
;
import
{
databasesBySessionId
}
from
"
/server/imports/mongodb/methods_common
"
;
import
LOGGER
from
"
/server/imports/internal/logger
"
;
const
mongodbApi
=
require
(
'
mongodb
'
);
WebApp
.
connectHandlers
.
use
(
'
/exportMongoclient
'
,
function
(
req
,
res
)
{
let
fileContent
=
{};
fileContent
.
settings
=
Settings
.
findOne
();
fileContent
.
connections
=
Connections
.
find
().
fetch
();
let
fileName
=
"
backup_
"
+
moment
().
format
(
'
DD_MM_YYYY_HH_mm_ss
'
)
+
"
.json
"
;
LOGGER
.
info
(
'
[exportMongoclient]
'
,
fileContent
,
fileName
);
const
headers
=
{
'
Content-type
'
:
'
application/octet-stream
'
,
'
Content-Disposition
'
:
'
attachment; filename=
'
+
fileName
};
res
.
writeHead
(
200
,
headers
);
res
.
end
(
JSON
.
stringify
(
fileContent
));
});
WebApp
.
connectHandlers
.
use
(
'
/export
'
,
function
(
req
,
res
)
{
const
urlParts
=
decodeURI
(
req
.
url
).
split
(
'
&
'
);
const
format
=
urlParts
[
0
].
substr
(
urlParts
[
0
].
indexOf
(
'
=
'
)
+
1
);
const
selectedCollection
=
urlParts
[
1
].
substr
(
urlParts
[
1
].
indexOf
(
'
=
'
)
+
1
);
const
selector
=
urlParts
[
2
].
substr
(
urlParts
[
2
].
indexOf
(
'
=
'
)
+
1
);
const
cursorOptions
=
urlParts
[
3
].
substr
(
urlParts
[
3
].
indexOf
(
'
=
'
)
+
1
);
const
sessionId
=
urlParts
[
4
].
substr
(
urlParts
[
4
].
indexOf
(
'
=
'
)
+
1
);
LOGGER
.
info
(
'
[export]
'
,
format
,
selectedCollection
,
selector
,
cursorOptions
);
LOGGER
.
info
(
'
[export]
'
,
format
,
selectedCollection
,
selector
,
cursorOptions
,
sessionId
);
Meteor
.
call
(
"
find
"
,
selectedCollection
,
JSON
.
parse
(
selector
),
JSON
.
parse
(
cursorOptions
),
false
,
Meteor
.
default_connection
.
_lastS
essionId
,
function
(
err
,
result
)
{
Meteor
.
call
(
"
find
"
,
selectedCollection
,
JSON
.
parse
(
selector
),
JSON
.
parse
(
cursorOptions
),
false
,
s
essionId
,
function
(
err
,
result
)
{
if
(
err
||
result
.
error
)
{
LOGGER
.
error
(
'
[export]
'
,
err
,
result
.
error
);
res
.
writeHead
(
400
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录