Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
[action.scheduler] Create simple react dashboard for enterprise admin…
Browse files Browse the repository at this point in the history
… panel. Just trigger same ol' actions.
  • Loading branch information
cdujeu committed Dec 8, 2015
1 parent 8949969 commit e4e7e9a
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 37 deletions.
34 changes: 34 additions & 0 deletions core/src/plugins/action.scheduler/Gruntfile.js
@@ -0,0 +1,34 @@
module.exports = function(grunt) {
grunt.initConfig({
babel: {
options: {},

dist: {
files: [
{
expand: true,
cwd: 'react/',
src: ['**/*.js'],
dest: 'build/',
ext: '.js'
}
]
}
},
watch: {
js: {
files: [
"react/**/*"
],
tasks: ['babel'],
options: {
spawn: false
}
}
}
});
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['babel']);

};
22 changes: 18 additions & 4 deletions core/src/plugins/action.scheduler/class.AjxpScheduler.php
Expand Up @@ -306,7 +306,21 @@ public function switchAction($action, $httpVars, $postProcessData)
public function placeConfigNode(&$configTree)
{
$mess = ConfService::getMessages();
if (isSet($configTree["admin"])) {
if (isSet($configTree["parameters"])){

$configTree["parameters"]["CHILDREN"]["scheduler"] = array(
"AJXP_MIME" => "scheduler_zone",
"LABEL" => "action.scheduler.18",
"DESCRIPTION" => "action.scheduler.22",
"ICON" => "preferences_desktop.png",
"METADATA" => array(
"icon_class" => "icon-time",
"component" => "Scheduler.Board"
),
"LIST" => array($this, "listTasks")
);

}else if (isSet($configTree["admin"])) {
$configTree["admin"]["CHILDREN"]["scheduler"] = array(
"LABEL" => $mess["action.scheduler.18"],
"AJXP_MIME" => "scheduler_zone",
Expand All @@ -316,10 +330,10 @@ public function placeConfigNode(&$configTree)
}
}

public function listTasks($action, $httpVars, $postProcessData)
public function listTasks($nodeName, $baseDir)
{
$mess =ConfService::getMessages();
AJXP_XMLWriter::renderHeaderNode("/admin/scheduler", "Scheduler", false, array("icon" => "scheduler/ICON_SIZE/player_time.png"));
$mess = ConfService::getMessages();
AJXP_XMLWriter::renderHeaderNode("/$baseDir/$nodeName", "Scheduler", false, array("icon" => "scheduler/ICON_SIZE/player_time.png"));
AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchGridMode="filelist" switchDisplayMode="list" template_name="action.scheduler_list">
<column messageId="action.scheduler.12" attributeName="ajxp_label" sortType="String"/>
<column messageId="action.scheduler.2" attributeName="schedule" sortType="String"/>
Expand Down
95 changes: 62 additions & 33 deletions core/src/plugins/action.scheduler/manifest.xml
Expand Up @@ -4,9 +4,22 @@
<resources>
<i18n namespace="action.scheduler" path="plugins/action.scheduler/i18n"/>
<img_library alias="scheduler" path="plugins/action.scheduler/icons"/>
<js className="Scheduler" file="plugins/action.scheduler/build/Scheduler.js" depends="React"/>
</resources>
</client_settings>
<registry_contributions>
<client_configs>
<template element="ajxp_desktop" name="scheduler_style" position="after"><![CDATA[
<style>
.scheduler-list .mui-toolbar-group.mui-left {
width: 88% !important;
}
.dialogButtons input.dialogButton{
padding: 0 !important;
}
</style>
]]></template>
</client_configs>
<actions>
<action name="scheduler_menu">
<gui text="action.scheduler.18" iconClass="icon-time" title="action.scheduler.18d" src="scheduler/ICON_SIZE/player_time.png" hasAccessKey="false">
Expand Down Expand Up @@ -43,9 +56,9 @@
]]></dialogOnComplete>
</clientCallback>
<clientForm id="scheduler_cronExpression"><![CDATA[
<div id="scheduler_cronExpression" box_width="330">
<div id="scheduler_cronExpression" box_width="420">
<div class="dialogLegend" ajxp_message_id="action.scheduler.21">AJXP_MESSAGE[action.scheduler.21]</div>
<textarea class="dialogFocus" style="width:300px;height:80px; margin-top: 5px;" id="cron_expression"></textarea>
<textarea class="dialogFocus" style="width:400px;height:80px; margin-top: 5px;" id="cron_expression"></textarea>
</div>
]]></clientForm>
<serverCallback methodName="switchAction" developerComment="Generate a correct expression to be inserted in Crontab, in order to trigger the {runAll} action on a regular basis."/>
Expand All @@ -69,32 +82,6 @@
<serverCallback methodName="switchAction" developerComment="Run the scheduler: check if some tasks must be run now, and launch them. Generally launched from command line."/>
</processing>
</action>
<action name="scheduler_runTask">
<gui text="action.scheduler.16" title="action.scheduler.15d" iconClass="icon-play" src="scheduler/22/task_run.png" hasAccessKey="false">
<context selection="true" dir="" recycle="hidden" allowedMimes="scheduler_zone"
actionBar="true" contextMenu="true" infoPanel="true"
actionBarGroup="get"/>
<selectionContext dir="false" behaviour="hidden" file="true" recycle="false" unique="true" allowedMimes="scheduler_task"/>
</gui>
<processing>
<clientCallback prepareModal="true"><![CDATA[
var u = ajaxplorer.getUserSelection();
var taskId = getBaseName(u.getUniqueNode().getPath());
var connexion = new Connexion();
connexion.setParameters(new Hash({
get_action:'scheduler_runTask',
task_id:taskId
}));
connexion.onComplete = function(transport){
pydio.getController().parseXmlMessage(transport.responseXML);
};
connexion.sendAsync();
]]></clientCallback>
<serverCallback methodName="switchAction" developerComment="Force running a specific task">
<input_param description="The id of the task to run" name="task_id" type="string" mandatory="true"/>
</serverCallback>
</processing>
</action>
<action name="scheduler_loadTask">
<processing>
<serverCallback methodName="handleTasks" developerComment="Returns a JSON representation of the task parameters">
Expand Down Expand Up @@ -224,6 +211,37 @@
</serverCallback>
</processing>
</action>
<action name="scheduler_runTask">
<gui text="action.scheduler.16" title="action.scheduler.15d" iconClass="icon-play" src="scheduler/22/task_run.png" hasAccessKey="false">
<context selection="true" dir="" recycle="hidden" allowedMimes="scheduler_zone"
actionBar="true" contextMenu="true" infoPanel="true"
actionBarGroup="get"/>
<selectionContext dir="false" behaviour="hidden" file="true" recycle="false" unique="true" allowedMimes="scheduler_task"/>
</gui>
<processing>
<clientCallback prepareModal="true"><![CDATA[
var userSelection;
if(window.actionArguments && window.actionArguments.length){
userSelection = window.actionArguments[0];
}else{
userSelection = pydio.getUserSelection();
}
var taskId = getBaseName(userSelection.getUniqueNode().getPath());
var connexion = new Connexion();
connexion.setParameters(new Hash({
get_action:'scheduler_runTask',
task_id:taskId
}));
connexion.onComplete = function(transport){
pydio.getController().parseXmlMessage(transport.responseXML);
};
connexion.sendAsync();
]]></clientCallback>
<serverCallback methodName="switchAction" developerComment="Force running a specific task">
<input_param description="The id of the task to run" name="task_id" type="string" mandatory="true"/>
</serverCallback>
</processing>
</action>
<action name="scheduler_editTask">
<gui text="action.scheduler.10" title="action.scheduler.11" iconClass="icon-edit" src="scheduler/ICON_SIZE/task.png" hasAccessKey="false">
<context selection="true" dir="" recycle="hidden" allowedMimes="scheduler_zone"
Expand All @@ -233,8 +251,13 @@
</gui>
<processing>
<clientCallback><![CDATA[
var u = ajaxplorer.getUserSelection();
pydio.getController().fireAction('scheduler_addTask', u.getUniqueNode());
var userSelection;
if(window.actionArguments && window.actionArguments.length){
userSelection = window.actionArguments[0];
}else{
userSelection = pydio.getUserSelection();
}
pydio.getController().fireAction('scheduler_addTask', userSelection.getUniqueNode());
]]></clientCallback>
</processing>
</action>
Expand All @@ -247,9 +270,14 @@
</gui>
<processing>
<clientCallback><![CDATA[
var u = ajaxplorer.getUserSelection();
var userSelection;
if(window.actionArguments && window.actionArguments.length){
userSelection = window.actionArguments[0];
}else{
userSelection = pydio.getUserSelection();
}
var conn = new Connexion();
conn.setParameters($H({ get_action : 'scheduler_removeTask', task_id: getBaseName(u.getUniqueNode().getPath()) }));
conn.setParameters($H({ get_action : 'scheduler_removeTask', task_id: getBaseName(userSelection.getUniqueNode().getPath()) }));
conn.onComplete = function(transport){
pydio.getController().parseXmlMessage(transport.responseXML);
};
Expand All @@ -269,10 +297,11 @@
</actions>
<hooks>
<serverCallback methodName="placeConfigNode" hookName="ajxp_conf.list_config_nodes"/>
<serverCallback methodName="placeConfigNode" hookName="admin.list_config_nodes"/>
</hooks>
</registry_contributions>
<class_definition filename="plugins/action.scheduler/class.AjxpScheduler.php" classname="AjxpScheduler"/>
<dependencies>
<activePlugin pluginName="access.ajxp_conf"/>
<activePlugin pluginName="access.ajxp_conf|access.ajxp_admin"/>
</dependencies>
</ajxp_plugin>
17 changes: 17 additions & 0 deletions core/src/plugins/action.scheduler/package.json
@@ -0,0 +1,17 @@
{
"name": "action.scheduler",
"version": "6.2.0",
"description": "",
"source_path":"react",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Abstrium SAS",
"license": "AGPL",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-babel": "~5.0.3",
"grunt-contrib-watch": "~0.6.1"
}
}
73 changes: 73 additions & 0 deletions core/src/plugins/action.scheduler/react/Scheduler.js
@@ -0,0 +1,73 @@
(function(global) {

var MessagesConsumerMixin = AdminComponents.MessagesConsumerMixin;

var Board = React.createClass({

mixins:[MessagesConsumerMixin],

keys: {
'label':{label:'Label', message:'action.scheduler.12'},
'schedule':{label:'Schedule', message:'action.scheduler.2'},
'action_name':{label:'Action', message:'action.scheduler.1'},
'repository_id':{label:'Workspace', message:'action.scheduler.4s'},
'user_id':{label:'User(s)', message:'action.scheduler.17'},
'NEXT_EXECUTION':{label:'Next Execution', message:'action.scheduler.3'},
'LAST_EXECUTION':{label:'Last Execution', message:'action.scheduler.14'},
'STATUS':{label:'Status', message:'action.scheduler.13'}
},

showTaskCreator: function(){
global.pydio.Controller.fireAction("scheduler_addTask");
},

runAllTasks: function(){
global.pydio.Controller.fireAction("scheduler_runAll");
},

showCronExpression: function(){
global.pydio.Controller.fireAction("scheduler_generateCronExpression");
},

render: function(){

return (
<div className="main-layout-nav-to-stack workspaces-board">
<div className="left-nav vertical-layout" style={{width:'100%', backgroundColor:'white'}}>
<ReactMUI.Paper zDepth={0} className="vertical-layout layout-fill">
<div className="vertical-layout workspaces-list layout-fill">
<h1 className="hide-on-vertical-layout">{this.context.getMessage('18', 'action.scheduler')}</h1>
<div className="button-container">
<ReactMUI.FlatButton primary={true} label={'+ ' + this.context.getMessage('8', 'action.scheduler')} onClick={this.showTaskCreator}/>
<ReactMUI.FlatButton secondary={true} label={this.context.getMessage('15', 'action.scheduler')} onClick={this.runAllTasks} />
<ReactMUI.FlatButton secondary={true} label={this.context.getMessage('20', 'action.scheduler')} onClick={this.showCronExpression} />
</div>
<ReactPydio.SimpleList
node={this.props.currentNode}
dataModel={this.props.dataModel}
className="scheduler-list layout-fill"
actionBarGroups={['get']}
infineSliceCount={1000}
tableKeys={this.keys}
elementHeight={{
"max-width:480px":201,
"(min-width:480px) and (max-width:760px)":80,
"min-width:760px":ReactPydio.SimpleList.HEIGHT_ONE_LINE
}}
/>

</div>
</ReactMUI.Paper>
</div>
</div>
);

}

});

global.Scheduler = {
Board: Board
};

})(window);

0 comments on commit e4e7e9a

Please sign in to comment.