Edit User client logic + Delete User UI
This commit is contained in:
1 parent
0809946914
commit
ec6f32d29c
10 files changed
+124
-27
No files matched your search
+1
-1
@@ -1 +1 @@
|
||||
@charset "UTF-8";a,hr{padding:0}a,button,input,select,textarea{margin:0}article,aside,details,figure,footer,header,hr,main,nav,section,summary{display:block}.container,sub,sup{position:relative}abbr,address,article,aside,audio,b,blockquote,body,body div,caption,cite,code,dd,del,details,dfn,dl,dt,em,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,p,pre,q,samp,section,small,span,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,ul,var,video{margin:0;padding:0;border:0;font-size:100%;font-weight:400;vertical-align:baseline;background:0 0}input[type=checkbox],th{vertical-align:bottom}embed,img,object{max-width:100%}ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:'';content:none}a{font-size:100%;vertical-align:baseline;background:0 0;color:#3949ab;text-decoration:none}del{text-decoration:line-through}abbr[title],dfn[title]{border-bottom:1px dotted #000;cursor:help}#alerts>ul>li,.button,.clickable,button,input[type=button],input[type=file],input[type=submit],label{cursor:pointer}th{font-weight:700}td{font-weight:400;vertical-align:top}hr{height:1px;border:0;border-top:1px solid #ccc;margin:1em 0}input,select{vertical-align:middle}pre{white-space:pre;white-space:pre-wrap;white-space:pre-line;word-wrap:break-word}input[type=radio]{vertical-align:text-bottom}.ie7 input[type=checkbox]{vertical-align:baseline}.ie6 input{vertical-align:text-bottom}input,select,textarea{font:99% sans-serif}table{border-collapse:separate;border-spacing:0;font:100%}small{font-size:85%}strong{font-weight:700}td,td img{vertical-align:top}sub,sup{font-size:75%;line-height:0}sup{top:-.5em}sub{bottom:-.25em}code,kbd,pre,samp{font-family:monospace,sans-serif}button,input[type=button]{width:auto;overflow:visible}.ie7 img{-ms-interpolation-mode:bicubic}.clearfix:after{content:" ";display:block;clear:both}@font-face{font-family:core-icons;src:url(/fonts/core-icons.ttf?e6rn1i) format("truetype"),url(/fonts/core-icons.woff?e6rn1i) format("woff"),url(/fonts/core-icons.svg?e6rn1i#core-icons) format("svg");font-weight:400;font-style:normal}[class*=" icon-"],[class^=icon-]{font-family:core-icons!important;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.button,html{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"}.icon-minus2:before{content:""}.icon-font:before{content:""}.icon-bold:before{content:""}.icon-italic:before{content:""}.icon-align-left2:before{content:""}.icon-align-center2:before{content:""}.icon-align-right2:before{content:""}.icon-align-justify2:before{content:""}.icon-list:before{content:""}.icon-video-camera2:before{content:""}.icon-image3:before,.icon-photo:before,.icon-picture-o:before{content:""}.icon-twitter-square:before{content:""}.icon-facebook-square:before{content:""}.icon-linkedin-square:before{content:""}.icon-github-square:before{content:""}.icon-twitter:before{content:""}.icon-facebook-f:before,.icon-facebook:before{content:""}.icon-github:before{content:""}.icon-chain:before,.icon-link3:before{content:""}.icon-bars:before,.icon-navicon:before,.icon-reorder:before{content:""}.icon-list-ul:before{content:""}.icon-list-ol:before{content:""}.icon-strikethrough:before{content:""}.icon-underline:before{content:""}.icon-table:before{content:""}.icon-linkedin:before{content:""}.icon-file-text-o:before{content:""}.icon-quote-left:before{content:""}.icon-terminal:before{content:""}.icon-code:before{content:""}.icon-youtube-play:before{content:""}.icon-dropbox:before{content:""}.icon-stack-overflow:before{content:""}.icon-bitbucket:before{content:""}.icon-apple:before{content:""}.icon-windows2:before{content:""}.icon-android:before{content:""}.icon-linux:before{content:""}.icon-vimeo-square:before{content:""}.icon-slack:before{content:""}.icon-google:before{content:""}.icon-git-square:before{content:""}.icon-git:before{content:""}.icon-header:before{content:""}.icon-safari:before{content:""}.icon-chrome:before{content:""}.icon-firefox:before{content:""}.icon-opera:before{content:""}.icon-internet-explorer:before{content:""}.icon-vimeo:before{content:""}.icon-edge:before{content:""}.icon-gitlab:before{content:""}.icon-th-small:before{content:""}.icon-th-menu:before{content:""}.icon-th-list:before{content:""}.icon-th-large:before{content:""}.icon-home:before{content:""}.icon-location:before{content:""}.icon-link:before{content:""}.icon-starburst:before{content:""}.icon-starburst-outline:before{content:""}.icon-star:before{content:""}.icon-flow-children:before{content:""}.icon-export:before{content:"Line truncated
|
||||
@charset "UTF-8";a,hr{padding:0}a,button,input,select,textarea{margin:0}article,aside,details,figure,footer,header,hr,main,nav,section,summary{display:block}.container,sub,sup{position:relative}abbr,address,article,aside,audio,b,blockquote,body,body div,caption,cite,code,dd,del,details,dfn,dl,dt,em,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,p,pre,q,samp,section,small,span,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,ul,var,video{margin:0;padding:0;border:0;font-size:100%;font-weight:400;vertical-align:baseline;background:0 0}input[type=checkbox],th{vertical-align:bottom}embed,img,object{max-width:100%}ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:'';content:none}a{font-size:100%;vertical-align:baseline;background:0 0;color:#3949ab;text-decoration:none}del{text-decoration:line-through}abbr[title],dfn[title]{border-bottom:1px dotted #000;cursor:help}#alerts>ul>li,.button,.clickable,button,input[type=button],input[type=file],input[type=submit],label{cursor:pointer}th{font-weight:700}td{font-weight:400;vertical-align:top}hr{height:1px;border:0;border-top:1px solid #ccc;margin:1em 0}input,select{vertical-align:middle}pre{white-space:pre;white-space:pre-wrap;white-space:pre-line;word-wrap:break-word}input[type=radio]{vertical-align:text-bottom}.ie7 input[type=checkbox]{vertical-align:baseline}.ie6 input{vertical-align:text-bottom}input,select,textarea{font:99% sans-serif}table{border-collapse:separate;border-spacing:0;font:100%}small{font-size:85%}strong{font-weight:700}td,td img{vertical-align:top}sub,sup{font-size:75%;line-height:0}sup{top:-.5em}sub{bottom:-.25em}code,kbd,pre,samp{font-family:monospace,sans-serif}button,input[type=button]{width:auto;overflow:visible}.ie7 img{-ms-interpolation-mode:bicubic}.clearfix:after{content:" ";display:block;clear:both}@font-face{font-family:core-icons;src:url(/fonts/core-icons.ttf?e6rn1i) format("truetype"),url(/fonts/core-icons.woff?e6rn1i) format("woff"),url(/fonts/core-icons.svg?e6rn1i#core-icons) format("svg");font-weight:400;font-style:normal}[class*=" icon-"],[class^=icon-]{font-family:core-icons!important;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.button,html{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"}.icon-minus2:before{content:""}.icon-font:before{content:""}.icon-bold:before{content:""}.icon-italic:before{content:""}.icon-align-left2:before{content:""}.icon-align-center2:before{content:""}.icon-align-right2:before{content:""}.icon-align-justify2:before{content:""}.icon-list:before{content:""}.icon-video-camera2:before{content:""}.icon-image3:before,.icon-photo:before,.icon-picture-o:before{content:""}.icon-twitter-square:before{content:""}.icon-facebook-square:before{content:""}.icon-linkedin-square:before{content:""}.icon-github-square:before{content:""}.icon-twitter:before{content:""}.icon-facebook-f:before,.icon-facebook:before{content:""}.icon-github:before{content:""}.icon-chain:before,.icon-link3:before{content:""}.icon-bars:before,.icon-navicon:before,.icon-reorder:before{content:""}.icon-list-ul:before{content:""}.icon-list-ol:before{content:""}.icon-strikethrough:before{content:""}.icon-underline:before{content:""}.icon-table:before{content:""}.icon-linkedin:before{content:""}.icon-file-text-o:before{content:""}.icon-quote-left:before{content:""}.icon-terminal:before{content:""}.icon-code:before{content:""}.icon-youtube-play:before{content:""}.icon-dropbox:before{content:""}.icon-stack-overflow:before{content:""}.icon-bitbucket:before{content:""}.icon-apple:before{content:""}.icon-windows2:before{content:""}.icon-android:before{content:""}.icon-linux:before{content:""}.icon-vimeo-square:before{content:""}.icon-slack:before{content:""}.icon-google:before{content:""}.icon-git-square:before{content:""}.icon-git:before{content:""}.icon-header:before{content:""}.icon-safari:before{content:""}.icon-chrome:before{content:""}.icon-firefox:before{content:""}.icon-opera:before{content:""}.icon-internet-explorer:before{content:""}.icon-vimeo:before{content:""}.icon-edge:before{content:""}.icon-gitlab:before{content:""}.icon-th-small:before{content:""}.icon-th-menu:before{content:""}.icon-th-list:before{content:""}.icon-th-large:before{content:""}.icon-home:before{content:""}.icon-location:before{content:""}.icon-link:before{content:""}.icon-starburst:before{content:""}.icon-starburst-outline:before{content:""}.icon-star:before{content:""}.icon-flow-children:before{content:""}.icon-export:before{content:"Line truncated
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
"use strict";function _classCallCheck(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}function setInputSelection(e,o,t){if(e.focus(),"undefined"!=typeof e.selectionStart)e.selectionStart=o,e.selectionEnd=t;else if(document.selection&&document.selection.createRange){e.select();var n=document.selection.createRange();n.collapse(!0),n.moveEnd("character",t),n.moveStart("character",o),n.select()}}function makeSafePath(e){var o=_.split(_.trim(e),"/");return o=_.map(o,function(e){return _.kebabCase(_.deburr(_.trim(e)))}),_.join(_.filter(o,function(e){return!_.isEmpty(e)}),"/")}var _createClass=function(){function e(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(o,t,n){return t&&e(o.prototype,t),n&&e(o,n),o}}();jQuery(document).ready(function(e){var o=this;e("a").smoothScroll({speed:400,offset:-70});new Sticky(".stickyscroll");e(window).bind("beforeunload",function(){e("#notifload").addClass("active")}),e(document).ajaxSend(function(){e("#notifload").addClass("active")}).ajaxComplete(function(){e("#notifload").removeClass("active")});var t=new Alerts;alertsData&&_.forEach(alertsData,function(e){t.push(e)});var n=io(window.location.origin);if(e("#search-input").length){e("#search-input").focus(),e(".searchresults").css("display","block");var i=new Vue({el:"#header-container",data:{searchq:"",searchres:[],searchsuggest:[],searchload:0,searchactive:!1,searchmoveidx:0,searchmovekey:"",searchmovearr:[]},watch:{searchq:function(e,o){i.searchmoveidx=0,e.length>=3?(i.searchactive=!0,i.searchload++,n.emit("search",{terms:e},function(e){i.searchres=e.match,i.searchsuggest=e.suggest,i.searchmovearr=_.concat([],i.searchres,i.searchsuggest),i.searchload>0&&i.searchload--})):(i.searchactive=!1,i.searchres=[],i.searchsuggest=[],i.searchmovearr=[],i.searchload=0)},searchmoveidx:function(e,o){e>0?i.searchmovekey=i.searchmovearr[e-1]?"res."+i.searchmovearr[e-1]._id:"sug."+i.searchmovearr[e-1]:i.searchmovekey=""}},methods:{useSuggestion:function(e){i.searchq=e},closeSearch:function(){i.searchq=""},moveSelectSearch:function(){if(!(i.searchmoveidx<1)){var e=i.searchmoveidx-1;i.searchmovearr[e]?window.location.assign("/"+i.searchmovearr[e]._id):i.searchq=i.searchmovearr[e]}},moveDownSearch:function(){i.searchmoveidx<i.searchmovearr.length&&i.searchmoveidx++},moveUpSearch:function(){i.searchmoveidx>0&&i.searchmoveidx--}}});e("main").on("click",i.closeSearch)}if(e("#page-type-view").length&&!function(){var o="home"!==e("#page-type-view").data("entrypath")?e("#page-type-view").data("entrypath"):"",n=o+"/new-page";e(".btn-create-prompt").on("click",function(t){e("#txt-create-prompt").val(n),e("#modal-create-prompt").toggleClass("is-active"),setInputSelection(e("#txt-create-prompt").get(0),o.length+1,n.length),e("#txt-create-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-create-prompt").on("keypress",function(o){13===o.which&&e(".btn-create-go").trigger("click")}),e(".btn-create-go").on("click",function(o){var t=makeSafePath(e("#txt-create-prompt").val());_.isEmpty(t)?e("#txt-create-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-create-prompt").parent().addClass("is-loading"),window.location.assign("/create/"+t))}),""!==o&&e(".btn-move-prompt").removeClass("is-hidden");var i=_.lastIndexOf(o,"/")+1;e(".btn-move-prompt").on("click",function(t){e("#txt-move-prompt").val(o),e("#modal-move-prompt").toggleClass("is-active"),setInputSelection(e("#txt-move-prompt").get(0),i,o.length),e("#txt-move-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-move-prompt").on("keypress",function(o){13===o.which&&e(".btn-move-go").trigger("click")}),e(".btn-move-go").on("click",function(n){var i=makeSafePath(e("#txt-move-prompt").val());_.isEmpty(i)||i===o||"home"===i?e("#txt-move-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-move-prompt").parent().addClass("is-loading"),e.ajax(window.location.href,{data:{move:i},dataType:"json",method:"PUT"}).then(function(e,o,n){e.ok?window.location.assign("/"+i):t.pushError("Something went wrong",e.error)},function(e,o,n){t.pushError("Something went wrong","Save operation failed.")}))})}(),e("#page-type-create").length){var a;!function(){var i=e("#page-type-create").data("entrypath");e(".btn-create-discard").on("click",function(o){e("#modal-create-discard").toggleClass("is-active")}),1===e("#mk-editor").length&&!function(){var r=!1;Vue.filter("filesize",function(e){return _.toUpper(filesize(e))});var l=new Vue({el:"#modal-editor-image",data:{isLoading:!1,isLoadingText:"",newFolderName:"",newFolderShow:!1,newFolderError:!1,fetchFromUrlURL:"",fetchFromUrlShow:!1,folders:[],currentFolder:"",currentImage:"",currentAlign:"left",images:[],uploadSucceeded:!1,postUploadChecks:0,renameImageShow:!1,renameImageId:"",renameImageFilename:"",deleteImageShow:!1,deleteImageId:"",deleteImaLine truncated
|
||||
t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){d.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){var o=_.map(d.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){var n=_.toString(e(t.$trigger).data("uid")),i=_.nth(d.folders,o);d.moveFile(n,i)}}});e.contextMenu("destroy",".editor-modal-file-choices > figure"),e.contextMenu({selector:".editor-modal-file-choices > figure",appendTo:".editor-modal-file-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");var i=e(o.$trigger).position(),a={w:e(o.$trigger).width()/5,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){d.renameFileId=_.toString(o.$trigger[0].dataset.uid),d.renameFile()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){d.deleteFileId=_.toString(o.$trigger[0].dataset.uid),d.deleteFileWarn(!0)}}}})}}});e("#btn-editor-file-upload input").on("change",function(n){var i=d.files.length;e(n.currentTarget).simpleUpload("/uploads/file",{name:"binfile",data:{folder:d.currentFolder},limit:20,expect:"json",maxFileSize:0,init:function(e){d.uploadSucceeded=!1,d.isLoadingText="Preparing to upload...",d.isLoading=!0},progress:function(e){d.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){var o=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length<e.results.length&&(t.push({title:"Some uploads succeeded",message:"Files that are not mentionned in the errors above were uploaded successfully."}),d.uploadSucceeded=!0)):d.uploadSucceeded=!0}else t.pushError("Upload error",e.msg)},error:function(e){t.pushError(e.message,o.upload.file.name)},finish:function(){d.uploadSucceeded?d.waitChangeComplete(i,!0):d.isLoading=!1}})});var c={youtube:new RegExp(/(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/,"i"),vimeo:new RegExp(/vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|)(\d+)(?:$|\/|\?)/,"i"),dailymotion:new RegExp(/(?:dailymotion\.com(?:\/embed)?(?:\/video|\/hub)|dai\.ly)\/([0-9a-z]+)(?:[\-_0-9a-zA-Z]+(?:#video=)?([a-z0-9]+)?)?/,"i")},s=new Vue({el:"#modal-editor-video",data:{link:""},methods:{open:function(o){e("#modal-editor-video").addClass("is-active"),e("#modal-editor-video input").focus()},cancel:function(o){r=!1,e("#modal-editor-video").removeClass("is-active"),s.link=""},insertVideo:function(e){a.codemirror.doc.somethingSelected()&&a.codemirror.execCommand("singleSelection");var o=_.findKey(c,function(e){return e.test(s.link)});_.isNil(o)&&(o="video");var t="[video]("+s.link+"){."+o+"}\n";a.codemirror.doc.replaceSelection(t),s.cancel()}}}),m=ace.require("ace/ext/modelist"),u=null,g=[],f=function(o){return e.ajax({url:"/js/ace/mode-"+o+".js",dataType:"script",cache:!0,beforeSend:function(){if(_.includes(g,o))return!1},success:function(){g.push(o)}})},h=new Vue({el:"#modal-editor-codeblock",data:{modes:m.modesByName,modeSelected:"text",initContent:""},watch:{modeSelected:function(e,o){f(e).done(function(){ace.require("ace/mode/"+e),u.getSession().setMode("ace/mode/"+e)})}},methods:{open:function(o){e("#modal-editor-codeblock").addClass("is-active"),_.delay(function(){u=ace.edit("codeblock-editor"),u.setTheme("ace/theme/tomorrow_night"),u.getSession().setMode("ace/mode/"+h.modeSelected),u.setOption("fontSize","14px"),u.setOption("hScrollBarAlwaysVisible",!1),u.setOption("wrap",!0),u.setValue(h.initContent),u.focus(),u.renderer.updateFull()},300)},cancel:function(o){r=!1,e("#modal-editor-codeblock").removeClass("is-active"),h.initContent=""},insertCode:function(e){a.codemirror.doc.somethingSelected()&&a.codemirror.execCommand("singleSelection");var o="\n```"+h.modeSelected+"\n"+u.getValue()+"\n```\n";a.codemirror.doc.replaceSelection(o),h.cancel()}}});a=new SimpleMDE({autofocus:!0,autoDownloadFontAwesome:!1,element:e("#mk-editor").get(0),placeholder:"Enter Markdown formatted content here...",spellChecker:!1,status:!1,toolbar:[{name:"bold",action:SimpleMDE.toggleBold,className:"icon-bold",title:"Bold"},{name:"italic",action:SimpleMDE.toggleItalic,className:"icon-italic",title:"Italic"},{name:"strikethrough",action:SimpleMDE.toggleStrikethrough,className:"icon-strikethrough",title:"Strikethrough"},"|",{name:"heading-1",action:SimpleMDE.toggleHeading1,className:"icon-header fa-header-x fa-header-1",title:"Big Heading"},{name:"heading-2",action:SimpleMDE.toggleHeading2,className:"icon-header fa-header-x fa-header-2",title:"Medium Heading"},{name:"heading-3",action:SimpleMDE.toggleHeading3,className:"icon-header fa-header-x fa-header-3",title:"Small Heading"},{name:"quote",action:SimpleMDE.toggleBlockquote,className:"icon-quote-left",title:"Quote"},"|",{name:"unorderedLine truncated
|
||||
t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){d.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){var o=_.map(d.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){var n=_.toString(e(t.$trigger).data("uid")),i=_.nth(d.folders,o);d.moveFile(n,i)}}});e.contextMenu("destroy",".editor-modal-file-choices > figure"),e.contextMenu({selector:".editor-modal-file-choices > figure",appendTo:".editor-modal-file-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");var i=e(o.$trigger).position(),a={w:e(o.$trigger).width()/5,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){d.renameFileId=_.toString(o.$trigger[0].dataset.uid),d.renameFile()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){d.deleteFileId=_.toString(o.$trigger[0].dataset.uid),d.deleteFileWarn(!0)}}}})}}});e("#btn-editor-file-upload input").on("change",function(n){var i=d.files.length;e(n.currentTarget).simpleUpload("/uploads/file",{name:"binfile",data:{folder:d.currentFolder},limit:20,expect:"json",maxFileSize:0,init:function(e){d.uploadSucceeded=!1,d.isLoadingText="Preparing to upload...",d.isLoading=!0},progress:function(e){d.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){var o=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length<e.results.length&&(t.push({title:"Some uploads succeeded",message:"Files that are not mentionned in the errors above were uploaded successfully."}),d.uploadSucceeded=!0)):d.uploadSucceeded=!0}else t.pushError("Upload error",e.msg)},error:function(e){t.pushError(e.message,o.upload.file.name)},finish:function(){d.uploadSucceeded?d.waitChangeComplete(i,!0):d.isLoading=!1}})});var c={youtube:new RegExp(/(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/,"i"),vimeo:new RegExp(/vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|)(\d+)(?:$|\/|\?)/,"i"),dailymotion:new RegExp(/(?:dailymotion\.com(?:\/embed)?(?:\/video|\/hub)|dai\.ly)\/([0-9a-z]+)(?:[\-_0-9a-zA-Z]+(?:#video=)?([a-z0-9]+)?)?/,"i")},s=new Vue({el:"#modal-editor-video",data:{link:""},methods:{open:function(o){e("#modal-editor-video").addClass("is-active"),e("#modal-editor-video input").focus()},cancel:function(o){r=!1,e("#modal-editor-video").removeClass("is-active"),s.link=""},insertVideo:function(e){a.codemirror.doc.somethingSelected()&&a.codemirror.execCommand("singleSelection");var o=_.findKey(c,function(e){return e.test(s.link)});_.isNil(o)&&(o="video");var t="[video]("+s.link+"){."+o+"}\n";a.codemirror.doc.replaceSelection(t),s.cancel()}}}),m=ace.require("ace/ext/modelist"),u=null,g=[],f=function(o){return e.ajax({url:"/js/ace/mode-"+o+".js",dataType:"script",cache:!0,beforeSend:function(){if(_.includes(g,o))return!1},success:function(){g.push(o)}})},h=new Vue({el:"#modal-editor-codeblock",data:{modes:m.modesByName,modeSelected:"text",initContent:""},watch:{modeSelected:function(e,o){f(e).done(function(){ace.require("ace/mode/"+e),u.getSession().setMode("ace/mode/"+e)})}},methods:{open:function(o){e("#modal-editor-codeblock").addClass("is-active"),_.delay(function(){u=ace.edit("codeblock-editor"),u.setTheme("ace/theme/tomorrow_night"),u.getSession().setMode("ace/mode/"+h.modeSelected),u.setOption("fontSize","14px"),u.setOption("hScrollBarAlwaysVisible",!1),u.setOption("wrap",!0),u.setValue(h.initContent),u.focus(),u.renderer.updateFull()},300)},cancel:function(o){r=!1,e("#modal-editor-codeblock").removeClass("is-active"),h.initContent=""},insertCode:function(e){a.codemirror.doc.somethingSelected()&&a.codemirror.execCommand("singleSelection");var o="\n```"+h.modeSelected+"\n"+u.getValue()+"\n```\n";a.codemirror.doc.replaceSelection(o),h.cancel()}}});a=new SimpleMDE({autofocus:!0,autoDownloadFontAwesome:!1,element:e("#mk-editor").get(0),placeholder:"Enter Markdown formatted content here...",spellChecker:!1,status:!1,toolbar:[{name:"bold",action:SimpleMDE.toggleBold,className:"icon-bold",title:"Bold"},{name:"italic",action:SimpleMDE.toggleItalic,className:"icon-italic",title:"Italic"},{name:"strikethrough",action:SimpleMDE.toggleStrikethrough,className:"icon-strikethrough",title:"Strikethrough"},"|",{name:"heading-1",action:SimpleMDE.toggleHeading1,className:"icon-header fa-header-x fa-header-1",title:"Big Heading"},{name:"heading-2",action:SimpleMDE.toggleHeading2,className:"icon-header fa-header-x fa-header-2",title:"Medium Heading"},{name:"heading-3",action:SimpleMDE.toggleHeading3,className:"icon-header fa-header-x fa-header-3",title:"Small Heading"},{name:"quote",action:SimpleMDE.toggleBlockquote,className:"icon-quote-left",title:"Quote"},"|",{name:"unorderedLine truncated
|
||||
@@ -2,7 +2,7 @@
|
||||
// Vue Create User instance
|
||||
|
||||
let vueCreateUser = new Vue({
|
||||
el: '#modal-admin-createuser',
|
||||
el: '#modal-admin-users-create',
|
||||
data: {
|
||||
email: '',
|
||||
provider: 'local',
|
||||
@@ -11,11 +11,11 @@ let vueCreateUser = new Vue({
|
||||
},
|
||||
methods: {
|
||||
open: (ev) => {
|
||||
$('#modal-admin-createuser').addClass('is-active');
|
||||
$('#modal-admin-createuser input').first().focus();
|
||||
$('#modal-admin-users-create').addClass('is-active');
|
||||
$('#modal-admin-users-create input').first().focus();
|
||||
},
|
||||
cancel: (ev) => {
|
||||
$('#modal-admin-createuser').removeClass('is-active');
|
||||
$('#modal-admin-users-create').removeClass('is-active');
|
||||
vueCreateUser.email = '';
|
||||
vueCreateUser.provider = 'local';
|
||||
},
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
// Vue Delete User instance
|
||||
|
||||
let vueDeleteUser = new Vue({
|
||||
el: '#modal-admin-users-delete',
|
||||
data: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
open: (ev) => {
|
||||
$('#modal-admin-users-delete').addClass('is-active');
|
||||
},
|
||||
cancel: (ev) => {
|
||||
$('#modal-admin-users-delete').removeClass('is-active');
|
||||
},
|
||||
deleteUser: (ev) => {
|
||||
vueDeleteUser.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('.btn-deluser-prompt').on('click', vueDeleteUser.open);
|
||||
@@ -1,6 +1,50 @@
|
||||
|
||||
if($('#page-type-admin').length) {
|
||||
if($('#page-type-admin-users').length) {
|
||||
|
||||
//=include ../modals/admin-createuser.js
|
||||
//=include ../modals/admin-users-create.js
|
||||
|
||||
} else if($('#page-type-admin-users-edit').length) {
|
||||
|
||||
let vueEditUser = new Vue({
|
||||
el: '#page-type-admin-users-edit',
|
||||
data: {
|
||||
id: '',
|
||||
email: '',
|
||||
password: '********',
|
||||
name: '',
|
||||
rights: [],
|
||||
roleoverride: 'none'
|
||||
},
|
||||
methods: {
|
||||
addRightsRow: (ev) => {
|
||||
vueEditUser.rights.push({});
|
||||
},
|
||||
removeRightsRow: (ev) => {
|
||||
|
||||
},
|
||||
saveUser: (ev) => {
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
|
||||
this.id = usrData._id;
|
||||
this.email = usrData.email;
|
||||
this.name = usrData.name;
|
||||
|
||||
console.log(_.find(usrData.rights, { role: 'admin' }));
|
||||
|
||||
if(_.find(usrData.rights, { role: 'admin' })) {
|
||||
this.rights = _.reject(usrData.rights, ['role', 'admin']);
|
||||
this.roleoverride = 'admin';
|
||||
} else {
|
||||
this.rights = usrData.rights;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//=include ../modals/admin-users-delete.js
|
||||
|
||||
}
|
||||
+11
-2
@@ -69,9 +69,18 @@ router.get('/users/:id', (req, res) => {
|
||||
}
|
||||
|
||||
db.User.findById(req.params.id)
|
||||
.select('-password')
|
||||
.select('-password -providerId')
|
||||
.exec().then((usr) => {
|
||||
res.render('pages/admin/users-edit', { adminTab: 'users', usr });
|
||||
|
||||
let usrOpts = {
|
||||
canChangeEmail: (usr.email !== 'guest' && usr.provider === 'local' && usr.email !== req.app.locals.appconfig.admin),
|
||||
canChangeName: (usr.email !== 'guest'),
|
||||
canChangePassword: (usr.email !== 'guest' && usr.provider === 'local'),
|
||||
canChangeRole: (usr.email !== 'guest' && !(usr.provider === 'local' && usr.email === req.app.locals.appconfig.admin)),
|
||||
canBeDeleted: (usr.email !== 'guest' && !(usr.provider === 'local' && usr.email === req.app.locals.appconfig.admin))
|
||||
};
|
||||
|
||||
res.render('pages/admin/users-edit', { adminTab: 'users', usr, usrOpts });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
.modal#modal-admin-createuser
|
||||
.modal#modal-admin-users-create
|
||||
.modal-background
|
||||
.modal-container
|
||||
.modal-content
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
.modal#modal-admin-users-delete
|
||||
.modal-background
|
||||
.modal-container
|
||||
.modal-content
|
||||
header.is-red Delete User Account?
|
||||
section
|
||||
span Are you sure you want to delete this user account? This action cannot be undone!
|
||||
footer
|
||||
a.button.is-grey.is-outlined(v-on:click="cancel") Abort
|
||||
a.button.is-red(v-on:click="deleteUser") Delete
|
||||
@@ -8,7 +8,7 @@ block rootNavRight
|
||||
span Return to Users
|
||||
|
||||
block adminContent
|
||||
#page-type-admin
|
||||
#page-type-admin-users-edit
|
||||
.hero
|
||||
h1.title#title Edit User
|
||||
h2.subtitle= usr.email
|
||||
@@ -16,14 +16,12 @@ block adminContent
|
||||
thead
|
||||
tr
|
||||
th Unique ID
|
||||
th Email
|
||||
th Provider
|
||||
th Created On
|
||||
th Updated On
|
||||
tbody
|
||||
tr
|
||||
td.is-centered= usr._id
|
||||
td.is-centered= usr.email
|
||||
td.is-centered.has-icons
|
||||
case usr.provider
|
||||
when 'local'
|
||||
@@ -42,15 +40,19 @@ block adminContent
|
||||
td.is-centered= userMoment(usr.createdAt).format('lll')
|
||||
td.is-centered= userMoment(usr.updatedAt).format('lll')
|
||||
.form-sections
|
||||
section
|
||||
label.label Email Address
|
||||
p.control.is-fullwidth
|
||||
input.input(type='text', placeholder='john.smith@example.com', v-model='email', disabled=!usrOpts.canChangeEmail)
|
||||
section
|
||||
label.label Display Name
|
||||
p.control.is-fullwidth
|
||||
input.input(type='text', placeholder='John Smith', value=usr.name)
|
||||
if usr.provider == 'local'
|
||||
input.input(type='text', placeholder='John Smith', v-model='name', disabled=!usrOpts.canChangeName)
|
||||
if usrOpts.canChangePassword
|
||||
section
|
||||
label.label Password
|
||||
p.control.is-fullwidth
|
||||
input.input(type='password', placeholder='Password', value='********')
|
||||
input.input(type='password', placeholder='Password', v-model='password', value='********')
|
||||
section
|
||||
label.label Access Rights
|
||||
table.table
|
||||
@@ -62,7 +64,7 @@ block adminContent
|
||||
th(style={width: '150px'}) Access
|
||||
th(style={width: '50px'})
|
||||
tbody
|
||||
tr(v-for='right in rights')
|
||||
tr(v-for='right in rights', v-cloak)
|
||||
td.is-icon
|
||||
i.icon-marquee-plus.is-green(v-if='!right.deny')
|
||||
i.icon-marquee-minus.is-red(v-if='right.deny')
|
||||
@@ -87,28 +89,38 @@ block adminContent
|
||||
option(value='false') Allow
|
||||
option(value='true') Deny
|
||||
td.is-centered.has-action-icons
|
||||
i.icon-delete.is-red
|
||||
i.icon-delete.is-red(v-on:click='removeRightsRow(right._id)')
|
||||
tr(v-if='rights.length < 1', v-cloak)
|
||||
td.is-icon
|
||||
td.is-centered(colspan='3'): em No additional access rights
|
||||
td.is-centered.has-action-icons
|
||||
.table-actions
|
||||
button.button.is-blue
|
||||
button.button.is-blue(v-on:click='addRightsRow')
|
||||
i.icon-plus
|
||||
span Add New Row
|
||||
section
|
||||
label.label Role Override
|
||||
p.control.is-fullwidth
|
||||
select(v-model='roleoverride')
|
||||
select(v-model='roleoverride', disabled=!usrOpts.canChangeRole)
|
||||
option(value='none') None
|
||||
option(value='admin') Global Administrator
|
||||
.columns.is-gapless
|
||||
.column
|
||||
section
|
||||
button.button.is-green
|
||||
button.button.is-green(v-on:click='saveUser')
|
||||
i.icon-check
|
||||
span Save Changes
|
||||
button.button.is-grey.is-outlined
|
||||
a.button.button.is-grey.is-outlined(href='/admin/users')
|
||||
i.icon-cancel
|
||||
span Discard
|
||||
.column.is-narrow
|
||||
section
|
||||
button.button.is-red
|
||||
i.icon-trash2
|
||||
span Delete Account
|
||||
if usrOpts.canBeDeleted
|
||||
button.button.is-red.btn-deluser-prompt
|
||||
i.icon-trash2
|
||||
span Delete Account
|
||||
|
||||
include ../../modals/admin-deleteuser.pug
|
||||
|
||||
script(type='text/javascript').
|
||||
var usrData = !{JSON.stringify(usr)};
|
||||
@@ -8,7 +8,7 @@ block rootNavRight
|
||||
span Create / Authorize User
|
||||
|
||||
block adminContent
|
||||
#page-type-admin
|
||||
#page-type-admin-users
|
||||
.hero
|
||||
h1.title#title Users
|
||||
h2.subtitle Manage users and access rights
|
||||
|
||||
Reference in new issue
Block a user