Skip to content

Commit

Permalink
feat: added guard content app
Browse files Browse the repository at this point in the history
  • Loading branch information
aochmann committed Feb 18, 2021
1 parent 627e271 commit 5d7a4a8
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(function () {
"use strict";

angular.module("umbraco")
.controller("Cogworks.Guard.Controller",
function ($scope, editorState, contentGuardService) {
var vm = this;

vm.buttonState = "init";
vm.clickCommand = clickCommand;
vm.notification = "";

function clickCommand() {
vm.buttonState = "busy";
var pageId = editorState.current.id;

contentGuardService.unlockPage(pageId)
.then(function () {
vm.buttonState = "success";
vm.notification = "Page successfully unlocked. You will be redirected to root page in a moment.";

setTimeout(function () {
window.location.href = "/umbraco#/content";
}, 2500);
}, function (error) {
vm.buttonState = "error";
vm.notification = "There was a problem unlocking this page. Please try again.";

console.log("Unlocking page failed", error);
});
}
});
})();
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
var contentGuardService = $injector.get("contentGuardService");

userService.getCurrentUser().then(function (user) {
console.log(user);

contentGuardService.isPageLocked(pageId, user.name)
.then(function (data) {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div ng-controller="Cogworks.Guard.Controller as vm">
<umb-box>
<umb-box-header title="Contend Guard"></umb-box-header>
<umb-box-content>
<div>
<p>Have you finished editing this page? Would you like to unlock this page to allow other editors access.</p>
</div>

<umb-button action="vm.clickCommand()"
type="button"
button-style="action"
state="vm.buttonState"
label="Unlock"
disabled="vm.buttonState === 'busy'">
</umb-button>

<hr />
<div ng-if="vm.notification">
<p>{{vm.notification}}</p>
</div>
</umb-box-content>
</umb-box>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
{
"contentApps": [
{
"name": "Content Guard",
"alias": "contentGuard",
"weidht": "1",
"icon": "icon-shield",
"view": "~/App_Plugins/Cogworks.ContentGuard/guard-button.html",
"show": [
"+content/*",
"-media/*",
"-member/*",
"-contentType/*"
]
}
],
"javascript": [
"~/App_Plugins/Cogworks.ContentGuard/contentguard.resources.js",
"~/App_Plugins/Cogworks.ContentGuard/contentguard.interceptor.js"
"~/App_Plugins/Cogworks.ContentGuard/contentguard.interceptor.js",
"~/App_Plugins/Cogworks.ContentGuard/contentguard.controller.js"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="App_Plugins\Cogworks.ContentGuard\contentguard.controller.js" />
<Content Include="App_Plugins\Cogworks.ContentGuard\editor-manager.html" />
<Content Include="App_Plugins\Cogworks.ContentGuard\contentguard.interceptor.js" />
<Content Include="App_Plugins\Cogworks.ContentGuard\contentguard.resources.js" />
<Content Include="App_Plugins\Cogworks.ContentGuard\guard-button.html" />
<Content Include="App_Plugins\Cogworks.ContentGuard\lang\en-US.xml" />
<Content Include="config\grid.editors.config.js" />
<Content Include="config\Lang\cs-CZ.user.xml" />
Expand Down

0 comments on commit 5d7a4a8

Please sign in to comment.