mindoc/views/book/setting.tpl

523 lines
26 KiB
Smarty
Raw Normal View History

2017-04-20 18:19:32 +08:00
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>设置 - {{.Model.BookName}} - Powered by MinDoc</title>
2017-04-20 18:19:32 +08:00
<!-- Bootstrap -->
2017-05-12 14:21:29 +08:00
<link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/font-awesome/css/font-awesome.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/webuploader/webuploader.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/cropper/2.3.4/cropper.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/bootstrap/plugins/tagsinput/bootstrap-tagsinput.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/bootstrap/plugins/bootstrap-switch/css/bootstrap3//bootstrap-switch.min.css"}}" rel="stylesheet">
2018-11-20 20:36:14 +08:00
<link href="{{cdncss "/static/select2/4.0.5/css/select2.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/css/main.css" "version"}}" rel="stylesheet">
2018-11-06 18:38:18 +08:00
2017-04-20 18:19:32 +08:00
</head>
<body>
<div class="manual-reader">
{{template "widgets/header.tpl" .}}
<div class="container manual-body">
<div class="row">
<div class="page-left">
<ul class="menu">
2017-04-22 17:24:17 +08:00
<li><a href="{{urlfor "BookController.Dashboard" ":key" .Model.Identify}}" class="item"><i class="fa fa-dashboard" aria-hidden="true"></i> 概要</a> </li>
2018-11-06 18:38:18 +08:00
<li><a href="{{urlfor "BookController.Users" ":key" .Model.Identify}}" class="item"><i class="fa fa-user" aria-hidden="true"></i> 成员</a> </li>
2018-11-14 15:57:55 +08:00
<li><a href="{{urlfor "BookController.Team" ":key" .Model.Identify}}" class="item"><i class="fa fa-group" aria-hidden="true"></i> 团队</a> </li>
2017-04-22 17:24:17 +08:00
<li class="active"><a href="{{urlfor "BookController.Setting" ":key" .Model.Identify}}" class="item"><i class="fa fa-gear" aria-hidden="true"></i> 设置</a> </li>
2017-04-20 18:19:32 +08:00
</ul>
</div>
<div class="page-right">
<div class="m-box">
<div class="box-head">
<strong class="box-title"> 项目设置</strong>
2017-04-22 17:24:17 +08:00
{{if eq .Model.RoleId 0}}
2017-04-25 20:05:59 +08:00
<button type="button" class="btn btn-success btn-sm pull-right" data-toggle="modal" data-target="#transferBookModal">转让项目</button>
2017-04-22 17:24:17 +08:00
{{if eq .Model.PrivatelyOwned 1}}
2017-04-25 20:05:59 +08:00
<button type="button" class="btn btn-success btn-sm pull-right" data-toggle="modal" data-target="#changePrivatelyOwnedModal" style="margin-right: 5px;">转为公有</button>
2017-04-22 17:24:17 +08:00
{{else}}
2017-04-25 20:05:59 +08:00
<button type="button" class="btn btn-danger btn-sm pull-right" data-toggle="modal" data-target="#changePrivatelyOwnedModal" style="margin-right: 5px;">转为私有</button>
2017-04-22 17:24:17 +08:00
{{end}}
2017-04-25 20:05:59 +08:00
<button type="button" class="btn btn-danger btn-sm pull-right" style="margin-right: 5px;" data-toggle="modal" data-target="#deleteBookModal">删除项目</button>
{{end}}
2017-04-20 18:19:32 +08:00
</div>
</div>
<div class="box-body" style="padding-right: 200px;">
<div class="form-left">
2017-04-25 20:05:59 +08:00
<form method="post" id="bookEditForm" action="{{urlfor "BookController.SaveBook"}}">
<input type="hidden" name="identify" value="{{.Model.Identify}}">
2017-04-20 18:19:32 +08:00
<div class="form-group">
<label>标题</label>
2017-04-25 20:05:59 +08:00
<input type="text" class="form-control" name="book_name" id="bookName" placeholder="项目名称" value="{{.Model.BookName}}">
2017-04-22 17:24:17 +08:00
</div>
<div class="form-group">
<label>标识</label>
2018-03-13 14:14:56 +08:00
<input type="text" class="form-control" value="{{urlfor "DocumentController.Index" ":key" .Model.Identify}}" placeholder="项目唯一标识" disabled>
<p class="text">项目标识用来标记项目的唯一性,不可修改。</p>
2017-04-22 17:24:17 +08:00
</div>
2018-11-20 20:36:14 +08:00
<div class="form-group">
2018-11-21 11:03:16 +08:00
<label>项目空间</label>
2018-11-20 20:36:14 +08:00
<select class="js-data-example-ajax form-control" multiple="multiple" name="itemId">
<option value="{{.Model.ItemId}}" selected="selected">{{.Model.ItemName}}</option>
</select>
</div>
<div class="form-group">
<label>历史记录数量</label>
<input type="text" class="form-control" name="history_count" value="{{.Model.HistoryCount}}" placeholder="历史记录数量">
<p class="text">当开启文档历史时,该值会限制每个文档保存的历史数量</p>
</div>
<div class="form-group">
<label>公司标识</label>
2018-01-30 13:48:07 +08:00
<input type="text" class="form-control" name="publisher" value="{{.Model.Publisher}}" placeholder="公司名称">
<p class="text">导出文档PDF文档时显示的页脚</p>
</div>
2017-04-22 17:24:17 +08:00
<div class="form-group">
<label>描述</label>
<textarea rows="3" class="form-control" name="description" style="height: 90px" placeholder="项目描述">{{.Model.Description}}</textarea>
<p class="text">描述信息不超过500个字符,支持Markdown语法</p>
2017-04-22 17:24:17 +08:00
</div>
2017-04-26 18:17:38 +08:00
<div class="form-group">
<label>编辑器</label>
<div class="radio">
<label class="radio-inline">
<input type="radio"{{if eq .Model.Editor "markdown"}} checked{{end}} name="editor" value="markdown"> Markdown编辑器
</label>
<label class="radio-inline">
<input type="radio"{{if eq .Model.Editor "html"}} checked{{end}} name="editor" value="html"> Html编辑器
</label>
</div>
</div>
2017-05-10 15:42:37 +08:00
{{if eq .Model.PrivatelyOwned 1}}
2018-11-14 15:57:55 +08:00
<div class="form-group">
<label>访问密码</label>
<input type="text" name="bPassword" id="bPassword" class="form-control" placeholder="访问密码" value="{{.Model.BookPassword}}">
<p class="text">没有访问权限访问项目时需要提供的密码</p>
</div>
2017-05-10 15:42:37 +08:00
{{end}}
2018-03-13 19:20:50 +08:00
<div class="form-group">
<label for="autoRelease">自动发布</label>
<div class="controls">
<div class="switch switch-small" data-on="primary" data-off="info">
<input type="checkbox" id="autoRelease" name="auto_release"{{if .Model.AutoRelease }} checked{{end}} data-size="small">
</div>
<p class="text">开启后,每次保存会自动发布到最新版本</p>
</div>
</div>
<div class="form-group">
<label for="autoRelease">开启导出</label>
<div class="controls">
<div class="switch switch-small" data-on="primary" data-off="info">
<input type="checkbox" id="isDownload" name="is_download"{{if .Model.IsDownload }} checked{{end}} data-size="small" placeholder="开启导出">
</div>
<p class="text">开启导出前请先配置导出程序,并在配置文件中同时开启导出功能</p>
</div>
</div>
2018-03-13 19:20:50 +08:00
<div class="form-group">
<label for="autoRelease">开启分享</label>
<div class="controls">
<div class="switch switch-small" data-on="primary" data-off="info">
<input type="checkbox" id="enableShare" name="enable_share"{{if .Model.IsEnableShare }} checked{{end}} data-size="small" placeholder="开启分享">
</div>
<p class="text">分享只对公开项目生效,私有项目不支持分享</p>
</div>
</div>
<div class="form-group">
<label for="autoRelease">设置第一篇文档为默认首页</label>
<div class="controls">
<div class="switch switch-small" data-on="primary" data-off="info">
<input type="checkbox" id="isUseFirstDocument" name="is_use_first_document"{{if .Model.IsUseFirstDocument }} checked{{end}} data-size="small" placeholder="设置第一篇文档为默认首页">
</div>
</div>
</div>
<div class="form-group">
<label for="autoRelease">自动保存</label>
<div class="controls">
<div class="switch switch-small" data-on="primary" data-off="info">
<input type="checkbox" id="autoSave" name="auto_save"{{if .Model.AutoSave }} checked{{end}} data-size="small" placeholder="自动保存">
2018-03-13 19:20:50 +08:00
</div>
<p class="text">开启后每隔30秒会自动保存</p>
2018-03-13 19:20:50 +08:00
</div>
</div>
2017-05-10 15:42:37 +08:00
<div class="form-group">
<button type="submit" id="btnSaveBookInfo" class="btn btn-success" data-loading-text="保存中...">保存修改</button>
<span id="form-error-message" class="error-message"></span>
</div>
</form>
2017-04-20 18:19:32 +08:00
</div>
2017-05-10 15:42:37 +08:00
<div class="form-right">
<label>
<a href="javascript:;" data-toggle="modal" data-target="#upload-logo-panel">
<img src="{{cdnimg .Model.Cover}}" onerror="this.src='{{cdnimg "/static/images/book.png"}}'" alt="封面" style="max-width: 120px;border: 1px solid #999" id="headimgurl">
2017-05-10 15:42:37 +08:00
</a>
</label>
<p class="text">点击图片可修改项目封面</p>
2017-05-10 15:42:37 +08:00
</div>
<div class="clearfix"></div>
2017-04-20 18:19:32 +08:00
</div>
</div>
2017-05-10 15:42:37 +08:00
</div>
</div>
{{template "widgets/footer.tpl" .}}
2017-04-20 18:19:32 +08:00
</div>
2017-04-25 20:05:59 +08:00
<!-- Modal -->
<div class="modal fade" id="changePrivatelyOwnedModal" tabindex="-1" role="dialog" aria-labelledby="changePrivatelyOwnedModalLabel">
<div class="modal-dialog" role="document">
<form method="post" action="{{urlfor "BookController.PrivatelyOwned" }}" id="changePrivatelyOwnedForm">
<input type="hidden" name="identify" value="{{.Model.Identify}}">
<input type="hidden" name="status" value="{{if eq .Model.PrivatelyOwned 0}}close{{else}}open{{end}}">
2017-05-10 15:42:37 +08:00
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">
{{if eq .Model.PrivatelyOwned 0}}
转为私有
{{else}}
转为共有
{{end}}
</h4>
</div>
<div class="modal-body">
{{if eq .Model.PrivatelyOwned 0}}
<span style="font-size: 14px;font-weight: 400;">确定将项目转为私有吗?</span>
<p></p>
<p class="text error-message">转为私有后需要通过阅读令牌才能访问该项目。</p>
2017-04-25 20:05:59 +08:00
{{else}}
2017-05-10 15:42:37 +08:00
<span style="font-size: 14px;font-weight: 400;"> 确定将项目转为公有吗?</span>
<p></p>
<p class="text error-message">转为公有后所有人都可以访问该项目。</p>
2017-04-25 20:05:59 +08:00
{{end}}
2017-05-10 15:42:37 +08:00
</div>
<div class="modal-footer">
<span class="error-message" id="form-error-message1"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-primary" data-loading-text="变更中..." id="btnChangePrivatelyOwned">确定</button>
</div>
2017-04-25 20:05:59 +08:00
</div>
</form>
</div>
</div>
<!-- Start Modal -->
<div class="modal fade" id="upload-logo-panel" tabindex="-1" role="dialog" aria-labelledby="修改封面" aria-hidden="true">
2017-04-25 20:05:59 +08:00
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">修改封面</h4>
2017-04-25 20:05:59 +08:00
</div>
<div class="modal-body">
<div class="wraper">
<div id="image-wraper">
</div>
</div>
<div class="watch-crop-list">
<div class="preview-title">预览</div>
<ul>
<li>
<div class="img-preview preview-lg"></div>
</li>
<li>
<div class="img-preview preview-sm"></div>
</li>
</ul>
</div>
<div style="clear: both"></div>
</div>
<div class="modal-footer">
<span id="error-message"></span>
<div id="filePicker" class="btn">选择</div>
<button type="button" id="saveImage" class="btn btn-success" style="height: 40px;width: 77px;" data-loading-text="上传中...">上传</button>
</div>
</div>
</div>
</div>
<!--END Modal-->
<!-- Delete Book Modal -->
<div class="modal fade" id="deleteBookModal" tabindex="-1" role="dialog" aria-labelledby="deleteBookModalLabel">
<div class="modal-dialog" role="document">
<form method="post" id="deleteBookForm" action="{{urlfor "BookController.Delete"}}">
<input type="hidden" name="identify" value="{{.Model.Identify}}">
2017-05-10 15:42:37 +08:00
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">删除项目</h4>
</div>
<div class="modal-body">
<span style="font-size: 14px;font-weight: 400;">确定删除项目吗?</span>
<p></p>
<p class="text error-message">删除项目后将无法找回。</p>
</div>
<div class="modal-footer">
<span id="form-error-message2" class="error-message"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" id="btnDeleteBook" class="btn btn-primary" data-loading-text="删除中...">确定删除</button>
</div>
2017-04-25 20:05:59 +08:00
</div>
</form>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="transferBookModal" tabindex="-1" role="dialog" aria-labelledby="transferBookModalLabel">
<div class="modal-dialog" role="document">
<form action="{{urlfor "BookController.Transfer"}}" method="post" id="transferBookForm">
<input type="hidden" name="identify" value="{{.Model.Identify}}">
2017-05-10 15:42:37 +08:00
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">项目转让</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="col-sm-2 control-label">接收账号</label>
<div class="col-sm-10">
<input type="text" name="account" class="form-control" placeholder="接收者账号" id="receiveAccount" maxlength="50">
</div>
2017-04-25 20:05:59 +08:00
</div>
2017-05-10 15:42:37 +08:00
<div class="clearfix"></div>
</div>
<div class="modal-footer">
<span id="form-error-message3" class="error-message"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" id="btnTransferBook" class="btn btn-primary">确定转让</button>
2017-04-25 20:05:59 +08:00
</div>
</div>
</form>
</div>
</div>
2017-05-12 14:21:29 +08:00
<script src="{{cdnjs "/static/jquery/1.12.4/jquery.min.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/webuploader/webuploader.min.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/cropper/2.3.4/cropper.min.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/js/jquery.form.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/bootstrap/plugins/tagsinput/bootstrap-tagsinput.min.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/bootstrap/plugins/bootstrap-switch/js/bootstrap-switch.min.js"}}" type="text/javascript"></script>
2018-11-20 20:36:14 +08:00
<script src="{{cdnjs "/static/select2/4.0.5/js/select2.full.min.js"}}"></script>
<script src="{{cdnjs "/static/select2/4.0.5/js/i18n/zh-CN.js"}}"></script>
2018-02-05 13:41:24 +08:00
<script src="{{cdnjs "/static/js/main.js"}}" type="text/javascript"></script>
2017-04-25 20:05:59 +08:00
<script type="text/javascript">
$(function () {
$("#upload-logo-panel").on("hidden.bs.modal",function () {
$("#upload-logo-panel").find(".modal-body").html(window.modalHtml);
}).on("show.bs.modal",function () {
window.modalHtml = $("#upload-logo-panel").find(".modal-body").html();
});
$("#autoRelease,#enableShare,#isDownload,#isUseFirstDocument,#autoSave").bootstrapSwitch();
2017-04-25 20:05:59 +08:00
$('input[name="label"]').tagsinput({
confirmKeys: [13,44],
maxTags: 10,
trimValue: true,
cancelConfirmKeysOnEmpty : false
});
2017-05-10 15:42:37 +08:00
$("#changePrivatelyOwnedForm").ajaxForm({
beforeSubmit :function () {
$("#btnChangePrivatelyOwned").button("loading");
},
2017-04-25 20:05:59 +08:00
success :function (res) {
if(res.errcode === 0){
window.location = window.location.href;
2017-05-10 15:42:37 +08:00
return;
2017-04-25 20:05:59 +08:00
}else{
showError(res.message,"#form-error-message1");
}
2017-05-10 15:42:37 +08:00
$("#btnChangePrivatelyOwned").button("reset");
},
error :function () {
showError("服务器异常","#form-error-message1");
$("#btnChangePrivatelyOwned").button("reset");
2017-04-25 20:05:59 +08:00
}
2017-05-10 15:42:37 +08:00
});
$("#createToken,#deleteToken").on("click",function () {
var btn = $(this).button("loading");
var action = $(this).attr("data-action");
$.ajax({
url : "{{urlfor "BookController.CreateToken"}}",
type :"post",
data : { "identify" : {{.Model.Identify}} , "action" : action },
dataType : "json",
success : function (res) {
if(res.errcode === 0){
$("#token").val(res.data);
}else{
alert(res.message);
}
btn.button("reset");
},
error : function () {
btn.button("reset");
alert("服务器错误");
}
}) ;
});
$("#token").on("focus",function () {
$(this).select();
});
$("#bookEditForm").ajaxForm({
beforeSubmit : function () {
var bookName = $.trim($("#bookName").val());
if (bookName === "") {
return showError("项目名称不能为空");
}
2017-04-25 20:05:59 +08:00
$("#btnSaveBookInfo").button("loading");
2017-05-10 15:42:37 +08:00
},
success : function (res) {
2017-04-25 20:05:59 +08:00
if(res.errcode === 0){
showSuccess("保存成功")
}else{
showError("保存失败")
}
2017-05-10 15:42:37 +08:00
$("#btnSaveBookInfo").button("reset");
},
error : function () {
showError("服务错误");
$("#btnSaveBookInfo").button("reset");
}
});
$("#deleteBookForm").ajaxForm({
beforeSubmit : function () {
$("#btnDeleteBook").button("loading");
},
success : function (res) {
if(res.errcode === 0){
window.location = "{{urlfor "BookController.Index"}}";
}else{
showError(res.message,"#form-error-message2");
}
$("#btnDeleteBook").button("reset");
},
error : function () {
showError("服务器异常","#form-error-message2");
$("#btnDeleteBook").button("reset");
}
});
$("#transferBookForm").ajaxForm({
beforeSubmit : function () {
2017-04-25 20:05:59 +08:00
var account = $.trim($("#receiveAccount").val());
if (account === ""){
2017-05-10 15:42:37 +08:00
return showError("接受者账号不能为空","#form-error-message3")
2017-04-25 20:05:59 +08:00
}
$("#btnTransferBook").button("loading");
2017-05-10 15:42:37 +08:00
},
success : function (res) {
2017-04-25 20:05:59 +08:00
if(res.errcode === 0){
window.location = window.location.href;
}else{
2017-05-10 15:42:37 +08:00
showError(res.message,"#form-error-message3");
2017-04-25 20:05:59 +08:00
}
2017-05-10 15:42:37 +08:00
$("#btnTransferBook").button("reset");
},
error : function () {
$("#btnTransferBook").button("reset");
}
});
2018-11-20 20:36:14 +08:00
$('.js-data-example-ajax').select2({
language: "zh-CN",
minimumInputLength : 1,
minimumResultsForSearch: Infinity,
maximumSelectionLength:1,
width : "100%",
ajax: {
url: '{{urlfor "BookController.ItemsetsSearch"}}',
dataType: 'json',
data: function (params) {
return {
q: params.term, // search term
page: params.page
};
},
processResults: function (data, params) {
return {
results : data.data.results
}
}
}
});
2017-04-25 20:05:59 +08:00
try {
var uploader = WebUploader.create({
auto: false,
2018-03-13 14:14:56 +08:00
swf: '{{.BaseUrl}}/static/webuploader/Uploader.swf',
2017-04-25 20:05:59 +08:00
server: '{{urlfor "BookController.UploadCover"}}',
formData : { "identify" : {{.Model.Identify}} },
pick: "#filePicker",
fileVal : "image-file",
fileNumLimit : 1,
compress : false,
accept: {
title: 'Images',
extensions: 'jpg,jpeg,png',
mimeTypes: 'image/jpg,image/jpeg,image/png'
}
}).on("beforeFileQueued",function (file) {
uploader.reset();
}).on( 'fileQueued', function( file ) {
uploader.makeThumb( file, function( error, src ) {
$img = '<img src="' + src +'" style="max-width: 360px;max-height: 360px;">';
if ( error ) {
$img.replaceWith('<span>不能预览</span>');
return;
}
$("#image-wraper").html($img);
window.ImageCropper = $('#image-wraper>img').cropper({
aspectRatio: 175 / 230,
dragMode : 'move',
viewMode : 1,
preview : ".img-preview"
});
}, 1, 1 );
}).on("uploadError",function (file,reason) {
console.log(reason);
$("#error-message").text("上传失败:" + reason);
}).on("uploadSuccess",function (file, res) {
if(res.errcode === 0){
console.log(res);
$("#upload-logo-panel").modal('hide');
$("#headimgurl").attr('src',res.data);
}else{
$("#error-message").text(res.message);
}
}).on("beforeFileQueued",function (file) {
if(file.size > 1024*1024*2){
uploader.removeFile(file);
uploader.reset();
alert("文件必须小于2MB");
return false;
}
}).on("uploadComplete",function () {
$("#saveImage").button('reset');
});
$("#saveImage").on("click",function () {
var files = uploader.getFiles();
if(files.length > 0) {
$("#saveImage").button('loading');
var cropper = window.ImageCropper.cropper("getData");
uploader.option("formData", cropper);
2017-04-20 18:19:32 +08:00
2017-04-25 20:05:59 +08:00
uploader.upload();
}else{
alert("请选择图片");
}
});
}catch(e){
console.log(e);
}
});
</script>
2017-04-20 18:19:32 +08:00
</body>
</html>