Skip to content

Commit

Permalink
RCP improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kwin committed Aug 11, 2020
1 parent c588590 commit a4e778b
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@
padding-right: 6em;
}

input[type=text], input[type=password] {
input[type=text], input[type=password], textarea {
width: 100%;
}

input:read-only {
color: #6d6d6d;
background-color: #f0f0f0;
}
.excludes {
width: 100%;
input[type=text] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ angular
.controller('MainCtrl', ['$scope', '$http', '$timeout', '$interval', 'NotificationsService',
function ($scope, $http, $timeout, $interval, NotificationsService) {

$scope.rcp_uris = ['/system/jackrabbit/filevault/rcp', '/libs/granite/packaging/rcp'];
$scope.rcp_uris = ['/system/jackrabbit/filevault/rcp'];

$scope.task_src = 'http://localhost:4502/crx/server/crx.default/jcr:root/content/dam/my-site';

Expand Down Expand Up @@ -55,8 +55,11 @@ function ($scope, $http, $timeout, $interval, NotificationsService) {
$scope.vltMissing = true;

$scope.taskExpandedStatuses = [];

/** false in case the scope refers to an existing task, otherwise true */
$scope.isNew = true;

/*
/**
* Loads the tasks
*/
$scope.init = function (rcpUris) {
Expand Down Expand Up @@ -99,13 +102,18 @@ function ($scope, $http, $timeout, $interval, NotificationsService) {
});
};

$scope.editCredentials = function (task) {
$scope.task_id = task.id;
$scope.task_src_username = "";
$scope.task_src_password = "";
};

/**
* Set the scope values from a task
* Used for the duplicate functionality
* @param {*} task The task to duplicate
* @param {*} task The task to edit
*/
$scope.duplicate = function (task) {
$scope.task_id = task.id + "-copy"; // unique
$scope.edit = function (task) {
$scope.task_id = task.id;
$scope.task_src = task.src;
$scope.task_dst = task.dst;
$scope.task_batchSize = task.batchsize;
Expand All @@ -115,21 +123,40 @@ function ($scope, $http, $timeout, $interval, NotificationsService) {
update: task.update,
onlyNewer: task.onlyNewer,
noOrdering: task.noOrdering,
autoRefresh: false
autoRefresh: false,
useSystemProperties: task.useSystemProperties,
allowSelfSignedCertificate: task.allowSelfSignedCertificate,
disableHostnameVerification: task.disableHostnameVerification
};

if (task.excludes) {
$scope.excludes = task.excludes.map(function(exclude){
return {value: exclude};
});
} else if (task.filter) {
$scope.filter = task.filter;
}

if (task.resumeFrom) {
$scope.task_resumeFrom = task.resumeFrom;
}
$scope.isNew = false;
};

/*

/**
* Set the scope values from a task
* Used for the duplicate functionality
* @param {*} task The task to duplicate
*/
$scope.duplicate = function (task) {
$scope.edit(task);
// different task id
$scope.task_id = task.id + "-copy"; // unique
$scope.isNew = true;
};

/**
* Start task
*/
$scope.start = function (task) {
Expand All @@ -148,7 +175,7 @@ function ($scope, $http, $timeout, $interval, NotificationsService) {
});
};

/*
/**
* Stop task
*/
$scope.stop = function (task) {
Expand All @@ -167,7 +194,7 @@ function ($scope, $http, $timeout, $interval, NotificationsService) {
});
};

/*
/**
* Remove task
*/
$scope.remove = function (task) {
Expand Down Expand Up @@ -202,6 +229,9 @@ function ($scope, $http, $timeout, $interval, NotificationsService) {
"onlyNewer": $scope.checkboxModel.onlyNewer,
"recursive": $scope.checkboxModel.recursive,
"noOrdering": $scope.checkboxModel.noOrdering,
"useSystemProperties": $scope.checkboxModel.useSystemProperties,
"allowSelfSignedCertificate": $scope.checkboxModel.allowSelfSignedCertificate,
"disableHostnameVerification": $scope.checkboxModel.disableHostnameVerification,
"throttle": $scope.task_throttle || 0
};
if ($scope.task_resumeFrom !== "") {
Expand All @@ -212,8 +242,9 @@ function ($scope, $http, $timeout, $interval, NotificationsService) {
cmd.excludes = $scope.excludes.map(function(exclude){
return exclude.value;
});
} else if ($scope.filter && $scope.filter.length > 0) {
cmd.filter = $scope.filter;
}

$http
.post($scope.app.uri, cmd)
.success(function (data, status, headers, config) {
Expand All @@ -228,10 +259,77 @@ function ($scope, $http, $timeout, $interval, NotificationsService) {
});
};

/**
* Create new task
*/
$scope.save = function () {
var i = 0,
cmd = {
"cmd": "edit",
"id": $scope.task_id,
"src": $scope.task_src,
"srcCreds": $scope.task_src_username + ":" + $scope.task_src_password,
"dst": $scope.task_dst,
"batchsize": $scope.task_batchSize || 1024,
"update": $scope.checkboxModel.update,
"onlyNewer": $scope.checkboxModel.onlyNewer,
"recursive": $scope.checkboxModel.recursive,
"noOrdering": $scope.checkboxModel.noOrdering,
"useSystemProperties": $scope.checkboxModel.useSystemProperties,
"allowSelfSignedCertificate": $scope.checkboxModel.allowSelfSignedCertificate,
"disableHostnameVerification": $scope.checkboxModel.disableHostnameVerification,
"throttle": $scope.task_throttle || 0
};
if ($scope.task_resumeFrom !== "") {
cmd.resumeFrom = $scope.task_resumeFrom;
}

if ($scope.excludes.length > 0) {
cmd.excludes = $scope.excludes.map(function(exclude){
return exclude.value;
});
} else if ($scope.filter && $scope.filter.length > 0) {
cmd.filter = $scope.filter;
}
$http
.post($scope.app.uri, cmd)
.success(function (data, status, headers, config) {
NotificationsService.add('info', 'INFO', 'Task modified.');

$scope.refresh();
angular.element('#create-new-task-modal').modal('hide');
$scope.reset();
})
.error(function (data, status, headers, config) {
NotificationsService.add('error', 'ERROR', data.message);
});
};

/**
* Set credentials task
*/
$scope.set_credentials = function () {
var cmd = {
"cmd": "set-credentials",
"id": $scope.task_id,
"srcCreds": $scope.task_src_username + ":" + $scope.task_src_password
};

$http.post($scope.app.uri, cmd).
success(function (data, status, headers, config) {
NotificationsService.add('info', 'INFO', 'Set credentials for task ' + $scope.task_id + '.');
$scope.refresh();
}).
error(function (data, status, headers, config) {
NotificationsService.add('error', 'ERROR', 'Could not set credentials for task.');
});
};

$scope.reset = function() {
$scope.task_id = '';
$scope.task_src = 'http://localhost:4502/crx/server/crx.default/jcr:root/content/dam/my-site';
$scope.task_src_username = '';
$scope.task_src_password = '';
$scope.task_dst = '/content/dam/my-site';
$scope.task_batchSize = '1024';
$scope.task_throttle = '';
Expand All @@ -240,9 +338,14 @@ function ($scope, $http, $timeout, $interval, NotificationsService) {
update: false,
onlyNewer: false,
noOrdering: false,
autoRefresh: false
autoRefresh: false,
useSystemProperties: false,
allowSelfSignedCertificate: false,
disableHostnameVerification: false
};
$scope.excludes = [];
$scope.filter = '';
$scope.isNew = true;
};

$scope.addExclude = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
pageContext.setAttribute("rcpPath",
resourceResolver.map(slingRequest, "/system/jackrabbit/filevault/rcp"));
pageContext.setAttribute("legacyRcpPath",
resourceResolver.map(slingRequest, "/libs/granite/packaging/rcp"));
%><div ng-controller="MainCtrl"
ng-init="init(['${rcpPath}', '${legacyRcpPath}']);">
ng-init="init(['${rcpPath}']);">

<!-- VLT-RCP Not installed Message -->
<div ng-show="vltMissing">
Expand All @@ -48,8 +45,8 @@
<li>
The VLT-RCP endpoint URL must be accessible and not blocked via
Dispatcher or another reverse proxy. Note: The VLT RCP servlet
endpoint changed from &quot;/system/jackrabbit/filevault/rcp&quot; to
&quot;/libs/granite/packaging/rcp&quot; in VLT-RCP 3.1.6.
endpoint changed from &quot;/libs/granite/packaging/rcp&quot; to
&quot;/system/jackrabbit/filevault/rcp&quot; in VLT-RCP 3.1.6.
</li>
</ol>
</div>
Expand All @@ -73,7 +70,9 @@

<button class="coral-Button"
data-target="#create-new-task-modal"
data-toggle="modal"><i class="icon-add"></i> Add Task</button>
data-toggle="modal"><i class="icon-add">
<i class="coral-Icon coral-Icon--add coral-Selector-icon"></i>
Add Task</button>
</div>
<!-- // Header buttons: add/refresh -->

Expand Down Expand Up @@ -118,15 +117,21 @@
<!-- Task Action buttons -->
<span class="task-actions">
<button class="coral-Button--quiet"
title="Create new duplicate task with this tasks values"
title="Edit task"
ng-click="edit(task)"
data-target="#create-new-task-modal"
data-toggle="modal">
<i class="coral-Icon coral-Icon--sizeS coral-Icon--edit"></i>
<button class="coral-Button--quiet"
title="Create new task with this task's values"
ng-click="duplicate(task)"
data-target="#create-new-task-modal"
data-toggle="modal">
<i class="coral-Icon coral-Icon--sizeS coral-Icon--duplicate"></i>
</button>
<button class="coral-Button--quiet"
title="Start task"
ng-show="task.status.state == 'NEW'"
ng-show="task.status.state != 'RUNNING' || task.status.state == 'STOPPING'"
ng-click="start(task)">
<i class="coral-Icon coral-Icon--sizeS coral-Icon--playCircle"></i>
</button>
Expand All @@ -136,6 +141,13 @@
ng-click="stop(task)">
<i class="coral-Icon coral-Icon--sizeS coral-Icon--stopCircle"></i>
</button>
<button class="coral-Button--quiet"
title="Set credentials"
ng-click="editCredentials(task)"
data-target="#set-credentials-modal"
data-toggle="modal">
<i class="coral-Icon coral-Icon--sizeS coral-Icon--userEdit"></i>
</button>
<button class="coral-Button--quiet"
title="Delete Task"
ng-click="remove(task)">
Expand Down Expand Up @@ -172,12 +184,16 @@
<li><b>No ordering:</b> {{ task.noOrdering }}</li>
<li><b>Throttle:</b> {{ task.throttle || 0}} seconds</li>
<li><b>Resume from:</b> {{ task.resumeFrom || 'Not set'}}</li>
<li><b>Use system properties:</b> {{ task.useSystemProperties || 'No'}}</li>
<li><b>Allow self-signed certificate:</b> {{ task.allowSelfSignedCertificate || 'No'}}</li>
<li><b>Disable hostname verification:</b> {{ task.disableHostnameVerification || 'No'}}</li>
<li ng-show="task.excludes.length > 0">
Excludes:
<ul>
<li ng-repeat="exclude in task.excludes track by $index">{{exclude}}</li>
</ul>
</li>
<li ng-show="task.filter && task.filter.length > 0"><b>Filter:</b> {{ task.filter || 'Not set'}}</li>
</ul>
</div>
</div>
Expand All @@ -187,6 +203,7 @@
<!-- // Tasks accordion section -->

<cq:include script="includes/create-task-modal.jsp"/>
<cq:include script="includes/set-credentials-modal.jsp"/>
</div>

</div>
Loading

0 comments on commit a4e778b

Please sign in to comment.