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

Commit b983ee8

Browse files
committed
Fix #819 (missing log refresh button) and fix #820 (restore old "Copy as Text" button)
1 parent 16d3e3f commit b983ee8

File tree

4 files changed

+82
-44
lines changed

4 files changed

+82
-44
lines changed

core/src/plugins/access.ajxp_conf/ajxp_confActions.xml

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -518,47 +518,6 @@
518518
</serverCallback>
519519
</processing>
520520
</action>
521-
<action name="copyAsText">
522-
<gui text="302" title="303" iconClass="icon-copy" src="editcopy.png" accessKey="" hasAccessKey="false">
523-
<context selection="true" dir="" recycle="false"
524-
actionBar="true" contextMenu="true" infoPanel="false"
525-
actionBarGroup="change" inZip="false">
526-
</context>
527-
<selectionContext dir="false" file="true" recycle="false" unique="false" allowedMimes="log,testResult" image="false" editable="false"/></gui>
528-
<rightsContext noUser="true" userLogged="only" read="true" write="true" adminOnly=""/>
529-
<processing>
530-
<clientCallback prepareModal="true"><![CDATA[
531-
var onLoad = function(oForm){
532-
var userSelection = ajaxplorer.getUserSelection();
533-
var nodes = userSelection.getSelectedNodes();
534-
var firstNode = userSelection.getUniqueNode();
535-
var copyDiv = $(oForm).select('textarea[id="text_copy"]')[0];
536-
var attributes = ['date','ip','level','user','action','params'];
537-
var message = attributes.join("\t") + "\n\n";
538-
nodes.each(function(node){
539-
var meta = node.getMetadata();
540-
for(var i=0;i<attributes.length;i++){
541-
var attName = attributes[i];
542-
if(attName == "ajxp_label") attName = "text";
543-
message += meta.get(attName) + '\t';
544-
}
545-
message += '\n';
546-
});
547-
copyDiv.setValue(message);
548-
copyDiv.select();
549-
};
550-
modal.showDialogForm('Delete', 'copy_as_text', onLoad, function(){
551-
hideLightBox(true);
552-
return false;
553-
},null,true);
554-
]]></clientCallback>
555-
<clientForm id="copy_as_text"><![CDATA[
556-
<div id="copy_as_text" action="copy" box_width="650">
557-
<textarea id="text_copy" style="width:630px; height: 350px;"></textarea>
558-
</div>
559-
]]></clientForm>
560-
</processing>
561-
</action>
562521
<action name="user_update_right">
563522
<processing>
564523
<serverCallback methodName="switchAction" restParams="/repository_id/user_id/right" checkParams="true" developerComment="Update a user access right on a given workspace.">

core/src/plugins/editor.ajxp_datagrid/ajxp_datagrid.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#ajxp_datagridbox{
22
overflow: auto;
3+
position: relative;
4+
}
5+
6+
#ajxp_datagridbox div.action_bar.editor_action_bar{
7+
top:1px;
38
}
49

510
#ajxp_datagridbox .tabrow{

core/src/plugins/editor.ajxp_datagrid/class.AjxpDataGridEditor.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,75 @@ Class.create("AjxpDataGridEditor", AbstractEditor, {
4040
this._lists = $A();
4141
},
4242

43+
addAction: function(aName){
44+
if(aName == 'refresh' && this.fRP){
45+
if(!this.htmlElement.down("#refreshButton")){
46+
this.htmlElement.down(".editor_action_bar").insert('' +
47+
'<a id="refreshButton" class="icon-refresh" title="Refresh">' +
48+
' <span message_id="235" class="actionbar_button_label">Refresh</span>' +
49+
'</a>');
50+
this.htmlElement.down("#refreshButton").observe("click", function(){
51+
this.fRP.reloadDataModel();
52+
}.bind(this));
53+
}
54+
}else if(aName == 'copy_as_text'){
55+
if(!this.htmlElement.down("#copyAsTextButton")){
56+
this.htmlElement.down(".editor_action_bar").insert('' +
57+
'<a id="copyAsTextButton" class="icon-copy" title="Copy">' +
58+
' <span message_id="235" class="actionbar_button_label">Copy Selection</span>' +
59+
'</a>');
60+
this.htmlElement.down("#copyAsTextButton").observe("click", function(){
61+
var nodes = this.fRP.getDataModel().getSelectedNodes();
62+
if(nodes){
63+
this.showCopyAsTextWindow(nodes);
64+
}
65+
}.bind(this));
66+
}
67+
68+
}
69+
},
70+
71+
showCopyAsTextWindow: function(nodes){
72+
if(!nodes.first()) {
73+
alert('Please select at least one line');
74+
return;
75+
}
76+
if(!$('copy_as_text')){
77+
$('all_forms').insert('<div id="copy_as_text" action="copy" box_width="80%">' +
78+
' <textarea id="text_copy" style="width:100%; height: 450px;"></textarea>' +
79+
'</div>');
80+
}
81+
var onLoad = function(oForm){
82+
var copyDiv = $(oForm).select('textarea[id="text_copy"]')[0];
83+
var exclude = ['icon','ajxp_mime','is_file','filename', 'ajxp_modiftime'];
84+
var message = '';
85+
var first = nodes.first();
86+
var meta = first.getMetadata();
87+
meta.each(function(pair){
88+
if(exclude.indexOf(pair.key) == -1) {
89+
message += pair.key + '\t';
90+
}
91+
});
92+
message += '\n\n';
93+
nodes.each(function(node){
94+
var meta = node.getMetadata();
95+
meta.each(function(pair){
96+
if(exclude.indexOf(pair.key) == -1) {
97+
message += pair.value + '\t';
98+
}
99+
});
100+
message += '\n';
101+
});
102+
copyDiv.setValue(message);
103+
copyDiv.select();
104+
};
105+
modal.prepareHeader('Export as text','', 'icon-copy');
106+
modal.showDialogForm('Copy', 'copy_as_text', onLoad, function(){
107+
hideLightBox(true);
108+
return false;
109+
},null,false);
110+
},
111+
43112
open : function($super, node){
44113
$super(node);
45114
this.node = node;
@@ -63,6 +132,10 @@ Class.create("AjxpDataGridEditor", AbstractEditor, {
63132
this.fRP._dataLoaded = false;
64133
this.fRP.showElement(true);
65134
this._lists.push(this.fRP);
135+
var actions = this.node.getMetadata().get("grid_actions") || "";
136+
$A(actions.split(",")).each(function(a){
137+
this.addAction(a);
138+
}.bind(this));
66139
}else{
67140
var i = 1;
68141
while(this.node.getMetadata().get("grid_datasource_" + i)){

core/src/plugins/log.sql/class.sqlLogDriver.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,10 @@ public function xmlListLogFiles($nodeName="file", $year=null, $month=null, $root
309309
$metadata = array(
310310
"icon" => "toggle_log.png",
311311
"date"=> $date,
312-
"ajxp_mime" => "datagrid",
313-
"grid_datasource" => "get_action=ls&dir=".urlencode($path),
314-
"grid_header_title" => "Application Logs for $date"
312+
"ajxp_mime" => "datagrid",
313+
"grid_datasource" => "get_action=ls&dir=".urlencode($path),
314+
"grid_header_title" => "Application Logs for $date",
315+
"grid_actions" => "refresh,copy_as_text"
315316
);
316317
$xml_strings[$date] = AJXP_XMLWriter::renderNode($path, $date, true, $metadata, true, false);
317318
}

0 commit comments

Comments
 (0)