finish create issue attachment UI
This commit is contained in:
@ -325,7 +325,10 @@ func runWeb(ctx *cli.Context) {
|
||||
})
|
||||
}, adminReq)
|
||||
|
||||
m.Get("/:username", ignSignIn, user.Profile)
|
||||
m.Group("", func() {
|
||||
m.Get("/:username", user.Profile)
|
||||
m.Post("/attachments", repo.UploadAttachment)
|
||||
}, ignSignIn)
|
||||
|
||||
if macaron.Env == macaron.DEV {
|
||||
m.Get("/template/*", dev.TemplatePreview)
|
||||
|
@ -854,3 +854,9 @@ months = %d months %s
|
||||
years = %d years %s
|
||||
raw_seconds = seconds
|
||||
raw_minutes = minutes
|
||||
|
||||
[dropzone]
|
||||
default_message = Drop files here or click to upload.
|
||||
invalid_input_type = You can't upload files of this type.
|
||||
file_too_big = File size({{filesize}} MB) exceeds maximum size({{maxFilesize}} MB).
|
||||
remove_file = Remove file
|
@ -95,6 +95,15 @@
|
||||
"outputPathIsOutsideProject": 0,
|
||||
"outputPathIsSetByUser": 0
|
||||
},
|
||||
"\/public\/css\/dropzone.css": {
|
||||
"fileType": 16,
|
||||
"ignore": 0,
|
||||
"ignoreWasSetByUser": 0,
|
||||
"inputAbbreviatedPath": "\/public\/css\/dropzone.css",
|
||||
"outputAbbreviatedPath": "No Output Path",
|
||||
"outputPathIsOutsideProject": 0,
|
||||
"outputPathIsSetByUser": 0
|
||||
},
|
||||
"\/public\/css\/font-awesome.min.css": {
|
||||
"fileType": 16,
|
||||
"ignore": 0,
|
||||
|
File diff suppressed because one or more lines are too long
388
public/css/dropzone.css
Normal file
388
public/css/dropzone.css
Normal file
File diff suppressed because it is too large
Load Diff
2
public/css/gogs.min.css
vendored
2
public/css/gogs.min.css
vendored
File diff suppressed because one or more lines are too long
@ -244,6 +244,35 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
// Dropzone
|
||||
if ($('#dropzone').length > 0) {
|
||||
// Disable auto discover for all elements:
|
||||
Dropzone.autoDiscover = false;
|
||||
|
||||
var filenameDict = {};
|
||||
var $dropz = $('#dropzone');
|
||||
$dropz.dropzone({
|
||||
url: $dropz.data('upload-url'),
|
||||
headers: {"X-Csrf-Token": csrf},
|
||||
maxFiles: 5,
|
||||
maxFilesize: $dropz.data('max-size'),
|
||||
acceptedFiles: $dropz.data('accepts'),
|
||||
addRemoveLinks: true,
|
||||
dictDefaultMessage: $dropz.data('default-message'),
|
||||
dictInvalidFileType: $dropz.data('invalid-input-type'),
|
||||
dictFileTooBig: $dropz.data('file-too-big'),
|
||||
dictRemoveFile: $dropz.data('remove-file'),
|
||||
init: function () {
|
||||
this.on("success", function (file, data) {
|
||||
filenameDict[file.name] = data.uuid;
|
||||
console.log(data)
|
||||
})
|
||||
this.on("removedfile", function (file) {
|
||||
console.log(filenameDict[file.name]);
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Helpers.
|
||||
$('.delete-button').click(function () {
|
||||
|
1728
public/js/libs/dropzone.js
Normal file
1728
public/js/libs/dropzone.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -147,6 +147,12 @@
|
||||
height: 200px;
|
||||
}
|
||||
}
|
||||
.dropzone {
|
||||
width: 100%;
|
||||
margin-bottom: 10px;
|
||||
border: 2px dashed #0087F7;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
.label.list {
|
||||
|
@ -178,6 +178,7 @@ func Issues(ctx *middleware.Context) {
|
||||
func NewIssue(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
|
||||
ctx.Data["PageIsIssueList"] = true
|
||||
ctx.Data["RequireDropzone"] = true
|
||||
ctx.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled
|
||||
ctx.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes
|
||||
|
||||
@ -214,8 +215,10 @@ func NewIssue(ctx *middleware.Context) {
|
||||
}
|
||||
|
||||
func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
|
||||
fmt.Println(ctx.QueryStrings("uuids"))
|
||||
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
|
||||
ctx.Data["PageIsIssueList"] = true
|
||||
ctx.Data["RequireDropzone"] = true
|
||||
ctx.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled
|
||||
ctx.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes
|
||||
|
||||
@ -344,6 +347,12 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
|
||||
}
|
||||
|
||||
func UploadAttachment(ctx *middleware.Context) {
|
||||
ctx.JSON(200, map[string]string{
|
||||
"uuid": "fuck",
|
||||
})
|
||||
}
|
||||
|
||||
func checkLabels(labels, allLabels []*models.Label) {
|
||||
for _, l := range labels {
|
||||
for _, l2 := range allLabels {
|
||||
@ -926,6 +935,7 @@ func Comment(ctx *middleware.Context) {
|
||||
func Labels(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.labels")
|
||||
ctx.Data["PageIsLabels"] = true
|
||||
ctx.Data["RequireMinicolors"] = true
|
||||
ctx.HTML(200, LABELS)
|
||||
}
|
||||
|
||||
@ -1031,6 +1041,7 @@ func Milestones(ctx *middleware.Context) {
|
||||
func NewMilestone(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.milestones.new")
|
||||
ctx.Data["PageIsMilestones"] = true
|
||||
ctx.Data["RequireDatetimepicker"] = true
|
||||
ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
|
||||
ctx.HTML(200, MILESTONE_NEW)
|
||||
}
|
||||
@ -1038,6 +1049,7 @@ func NewMilestone(ctx *middleware.Context) {
|
||||
func NewMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.milestones.new")
|
||||
ctx.Data["PageIsMilestones"] = true
|
||||
ctx.Data["RequireDatetimepicker"] = true
|
||||
ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
|
||||
|
||||
if ctx.HasError() {
|
||||
@ -1073,6 +1085,7 @@ func EditMilestone(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.milestones.edit")
|
||||
ctx.Data["PageIsMilestones"] = true
|
||||
ctx.Data["PageIsEditMilestone"] = true
|
||||
ctx.Data["RequireDatetimepicker"] = true
|
||||
ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
|
||||
|
||||
m, err := models.GetMilestoneByID(ctx.ParamsInt64(":id"))
|
||||
@ -1096,6 +1109,7 @@ func EditMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.milestones.edit")
|
||||
ctx.Data["PageIsMilestones"] = true
|
||||
ctx.Data["PageIsEditMilestone"] = true
|
||||
ctx.Data["RequireDatetimepicker"] = true
|
||||
ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
|
||||
|
||||
if ctx.HasError() {
|
||||
|
@ -31,13 +31,18 @@
|
||||
<script src="{{AppSubUrl}}/js/gogs.js?v={{AppVer}}"></script>
|
||||
|
||||
<!-- Third-party libraries -->
|
||||
{{if .PageIsLabels}}
|
||||
{{if .RequireMinicolors}}
|
||||
<link rel="stylesheet" href="{{AppSubUrl}}/css/jquery.minicolors.css?v={{AppVer}}">
|
||||
<script src="{{AppSubUrl}}/js/libs/jquery.minicolors.min.js?v={{AppVer}}"></script>
|
||||
{{else if .PageIsMilestones}}
|
||||
{{end}}
|
||||
{{if .RequireDatetimepicker}}
|
||||
<link rel="stylesheet" href="{{AppSubUrl}}/css/jquery.datetimepicker.css?v={{AppVer}}">
|
||||
<script src="{{AppSubUrl}}/js/libs/jquery.datetimepicker.js?v={{AppVer}}"></script>
|
||||
{{end}}
|
||||
{{if .RequireDropzone}}
|
||||
<link rel="stylesheet" href="{{AppSubUrl}}/css/dropzone.css?v={{AppVer}}">
|
||||
<script src="{{AppSubUrl}}/js/libs/dropzone.js?v={{AppVer}}"></script>
|
||||
{{end}}
|
||||
|
||||
<title>{{if .Title}}{{.Title}} - {{end}}{{AppName}}</title>
|
||||
</head>
|
||||
|
@ -27,6 +27,9 @@
|
||||
{{.i18n.Tr "repo.release.loading"}}
|
||||
</div>
|
||||
</div>
|
||||
{{if .IsAttachmentEnabled}}
|
||||
<div class="ui basic button dropzone" id="dropzone" data-upload-url="/attachments" data-accepts="{{.AttachmentAllowedTypes}}" data-max-size="1" data-default-message="{{.i18n.Tr "dropzone.default_message"}}" data-invalid-input-type="{{.i18n.Tr "dropzone.invalid_input_type"}}" data-file-too-big="{{.i18n.Tr "dropzone.file_too_big"}}" data-remove-file="{{.i18n.Tr "dropzone.remove_file"}}"></div>
|
||||
{{end}}
|
||||
<div class="text right">
|
||||
<button class="ui green button">
|
||||
{{.i18n.Tr "repo.issues.create"}}
|
||||
|
Reference in New Issue
Block a user