compass_ae_console 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/controllers/compass_ae_console/erp_app/desktop/base_controller.rb +76 -66
- data/lib/compass_ae_console.rb +0 -1
- data/lib/compass_ae_console/engine.rb +1 -1
- data/lib/compass_ae_console/version.rb +5 -1
- data/public/javascripts/erp_app/desktop/applications/compass_ae_console/module.js +21 -159
- data/public/javascripts/erp_app/shared/console_panel.js +145 -0
- metadata +25 -99
- data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +0 -12
- data/spec/dummy/db/data_migrations/20110608185830_create_default_dynamic_models_and_forms.erp_forms.rb +0 -33
- data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +0 -19
- data/spec/dummy/db/data_migrations/20110728201729_erp_app_setup.erp_app.rb +0 -298
- data/spec/dummy/db/data_migrations/20110728201730_update_preferences.erp_app.rb +0 -53
- data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +0 -16
- data/spec/dummy/db/data_migrations/20110816161238_create_desktop_app_audit_log_viewer.erp_app.rb +0 -21
- data/spec/dummy/db/data_migrations/20110817160743_add_file_manager_application.erp_app.rb +0 -32
- data/spec/dummy/db/data_migrations/20110824020426_create_desktop_app_console.compass_ae_console.rb +0 -20
- data/spec/dummy/db/data_migrations/20110828190913_create_desktop_app_dynamic_forms.erp_forms.rb +0 -19
- data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +0 -12
- data/spec/dummy/db/data_migrations/20111108183739_add_default_capabilities.erp_app.rb +0 -30
- data/spec/dummy/db/data_migrations/20111108183740_add_new_contact_widgets.erp_app.rb +0 -51
- data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +0 -22
- data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb +0 -14
- data/spec/dummy/db/data_migrations/20120229160222_add_userinfo_widget.erp_app.rb +0 -31
- data/spec/dummy/db/data_migrations/20120405193721_create_party_and_role_type_for_communication_events.erp_app.rb +0 -11
- data/spec/dummy/db/data_migrations/20120411180756_create_user_management_mobile_application.erp_app.rb +0 -19
- data/spec/dummy/db/data_migrations/20120418164215_create_configuration_management_desktop_application.erp_app.rb +0 -23
- data/spec/dummy/db/data_migrations/20120824013449_create_ticket_form.erp_forms.rb +0 -67
- data/spec/dummy/db/data_migrations/20121026013449_update_ticket_form.erp_forms.rb +0 -65
- data/spec/dummy/db/data_migrations/20121026191738_update_contact_form.erp_forms.rb +0 -27
- data/spec/dummy/db/migrate/20121207195349_base_erp_services.erp_base_erp_svcs.rb +0 -461
- data/spec/dummy/db/migrate/20121207195350_base_tech_services.erp_tech_svcs.rb +0 -255
- data/spec/dummy/db/migrate/20121207195351_create_has_attribute_tables.erp_tech_svcs.rb +0 -39
- data/spec/dummy/db/migrate/20121207195352_base_app_framework.erp_app.rb +0 -276
- data/spec/dummy/db/migrate/20121207195353_dynamic_forms.erp_forms.rb +0 -95
- data/spec/dummy/db/migrate/20121207195354_create_tickets.erp_forms.rb +0 -19
- data/spec/dummy/db/migrate/20121207195355_upgrade_dynamic_forms_table.erp_forms.rb +0 -32
- data/spec/dummy/db/schema.rb +0 -879
- data/spec/dummy/db/spec.sqlite3 +0 -0
- data/spec/dummy/log/spec.log +0 -3827
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fcfb01271f7ba1c6474ee78c6c2440ffd85e2fb8
|
4
|
+
data.tar.gz: 59cee03a3a8e0fb847b0fbdd67b9f0189fa7d35f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 24b0b9a9eb3bd3bb57e041eb0bb40c2bfd5375ac0ec7ac49110650e87712d185d8ba38bf82eb299a17fddc71658fa626ebeedbd4bb996a14fa574c56b4a07249
|
7
|
+
data.tar.gz: e66eb2b633e7a04ef1c621ed281fe31ed571dcecab7cc12ba22c385ec75f9c5952b35ad778c0b4a6d5785842a898a9ed29922ebfa540570028c634bcf4362980
|
@@ -3,9 +3,8 @@ module CompassAeConsole
|
|
3
3
|
module Desktop
|
4
4
|
class BaseController < ::ErpApp::Desktop::BaseController
|
5
5
|
def command
|
6
|
-
logger.debug("command received:#{params}")
|
7
6
|
begin
|
8
|
-
result=""
|
7
|
+
result = ""
|
9
8
|
|
10
9
|
# NOTE- the console uses a shared binding. this is due to the fact
|
11
10
|
# that binding instances are not serializable and cant be stored
|
@@ -15,127 +14,138 @@ module CompassAeConsole
|
|
15
14
|
|
16
15
|
# the shared binding is needed to allow for variable scope visibility
|
17
16
|
# across multiple requests
|
18
|
-
if($session_binding==nil)
|
17
|
+
if ($session_binding==nil)
|
19
18
|
$session_binding=binding
|
20
19
|
end
|
21
20
|
|
22
21
|
command_message=params[:command_message]
|
23
|
-
logger.debug("console session context:#{$session_binding}")
|
24
|
-
logger.debug("command:#{command_message}")
|
25
22
|
|
26
23
|
# here we handle any desktop console-specific command
|
27
24
|
# these can include non-eval related funtions
|
28
25
|
# or provide shortcuts to common eval expressions
|
29
|
-
result = case command_message
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
26
|
+
result = case command_message
|
27
|
+
when /^-help/
|
28
|
+
help_message
|
29
|
+
when /^-clear/
|
30
|
+
#this is handled in the console desktop application
|
31
|
+
when /^-time/
|
32
|
+
evaluate_command("Time.now")
|
33
|
+
when /^-whoami/
|
34
|
+
evaluate_command("current_user.username")
|
35
|
+
else
|
36
|
+
evaluate_command(command_message)
|
37
|
+
end
|
42
38
|
|
43
|
-
|
44
|
-
|
45
|
-
result_message =result.to_s.gsub("\n", "<br />\n")
|
46
|
-
render :json=> {:success=>"#{result_message}<hr><br>"}
|
39
|
+
result_message = result.to_s.gsub("\n", "<br />\n")
|
40
|
+
render :json => {:success => "#{result_message}<hr><br>"}
|
47
41
|
end
|
48
42
|
end
|
43
|
+
|
49
44
|
private
|
45
|
+
|
50
46
|
#****************************************************************************
|
51
47
|
def help_message()
|
52
|
-
message = "<
|
48
|
+
message = "<span color='lightgray'><b>Compass Desktop Console Help<b><hr>"
|
53
49
|
message<< "<ul>"
|
54
|
-
message<< "<li>-clear :
|
55
|
-
message<< "<li>-help :
|
56
|
-
message<< "<li>-time :
|
57
|
-
message<< "<li>-whoami :
|
58
|
-
message<< "</ul> </
|
50
|
+
message<< "<li>-clear : Clear screen contents.</li>"
|
51
|
+
message<< "<li>-help : This help list.</li>"
|
52
|
+
message<< "<li>-time : Current time.</li>"
|
53
|
+
message<< "<li>-whoami : Logged in as.</li>"
|
54
|
+
message<< "</ul> </span>"
|
59
55
|
end
|
56
|
+
|
60
57
|
#****************************************************************************
|
61
58
|
def highlight_class(klass)
|
62
|
-
|
63
|
-
|
59
|
+
"".tap do |buffer|
|
60
|
+
klass.columns.each do |column|
|
61
|
+
buffer << "<div>#{column.name}<span style='color:gray'>:</span><span style='color:gold'>#{column.type}</span></div>"
|
62
|
+
end
|
64
63
|
end
|
65
64
|
end
|
66
|
-
|
65
|
+
|
67
66
|
def hightlight_instance(instance)
|
68
67
|
"".tap do |buffer|
|
69
68
|
instance.attributes.keys.sort.each do |model_attribute_key|
|
70
|
-
|
71
|
-
buffer << "<font color='yellow'>#{model_attribute_key}</font> <font color='lightgray'>=</font><font color='gold'>#{instance.attributes[model_attribute_key]}</font> <font color='lightgray'>, </font>"
|
69
|
+
buffer << "<div>#{model_attribute_key} <span style='color:lightgray'>=</span><span style='color:gold'>#{instance.attributes[model_attribute_key]}</span></div>"
|
72
70
|
end
|
73
71
|
end
|
74
72
|
end
|
73
|
+
|
75
74
|
#****************************************************************************
|
76
75
|
|
77
76
|
def evaluate_command(command_message)
|
78
|
-
Rails.logger.debug("evaluate_command(#{command_message}")
|
79
77
|
begin
|
80
78
|
result_eval = $session_binding.eval(command_message)
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
79
|
+
|
80
|
+
result = if result_eval.respond_to?("columns") # If it responds to columns, this is an ActiveRecord model
|
81
|
+
|
82
|
+
render_active_record_model(result_eval)
|
83
|
+
elsif result_eval.respond_to?("class") && result_eval.class.ancestors.include?(ActiveRecord::Base)
|
84
|
+
|
85
|
+
render_model(result_eval)
|
86
|
+
elsif result_eval.is_a? Array
|
87
|
+
|
88
|
+
render_array(result_eval)
|
89
|
+
elsif result_eval.is_a? Hash
|
90
|
+
|
91
|
+
render_hash(result_eval)
|
92
|
+
else
|
93
|
+
|
94
|
+
"#{result_eval.inspect}"
|
95
|
+
end
|
96
|
+
rescue => ex
|
97
|
+
result = "<span style='color:red'>#{ex.to_s}</span>"
|
94
98
|
end
|
95
99
|
|
96
100
|
result
|
97
101
|
end
|
102
|
+
|
98
103
|
#****************************************************************************
|
99
104
|
def render_active_record_model(result_eval)
|
100
|
-
|
101
|
-
"<font color='YellowGreen'>#{result_eval.class} </font><br>#{highlight_class(result_eval)} "
|
105
|
+
"<div>#{highlight_class(result_eval)}<div>"
|
102
106
|
end
|
107
|
+
|
108
|
+
#****************************************************************************
|
109
|
+
def render_model(result_eval)
|
110
|
+
"<div style='color:YellowGreen'>#{result_eval.class}</div><div>#{hightlight_instance(result_eval)}<div>"
|
111
|
+
end
|
112
|
+
|
103
113
|
#****************************************************************************
|
104
114
|
def render_array(result_eval)
|
105
|
-
result="#{result_eval.class.to_s}
|
106
|
-
|
107
|
-
|
115
|
+
result = "#{result_eval.class.to_s}"
|
116
|
+
count = 0
|
117
|
+
|
108
118
|
result_eval.each do |array_element|
|
109
|
-
if
|
110
|
-
result << "<
|
119
|
+
if array_element.is_a? ActiveRecord::Base
|
120
|
+
result << "<span style='color:YellowGreen'>#{array_element.class}[<span color='white'>#{count}</span>] </span>#{hightlight_instance(array_element)} <br>"
|
111
121
|
else
|
112
|
-
result << "<
|
122
|
+
result << "<span style='color:YellowGreen'>#{array_element.class}[<span color='white'>#{count}</span>] </span>#{array_element} <br>"
|
113
123
|
end
|
114
124
|
count=count+1
|
115
125
|
end
|
116
126
|
result
|
117
127
|
end
|
128
|
+
|
118
129
|
#****************************************************************************
|
119
130
|
def render_hash(result_eval)
|
120
|
-
|
121
|
-
|
122
|
-
|
131
|
+
result = "#{result_eval.class.to_s}<br>"
|
132
|
+
count = 0
|
133
|
+
|
123
134
|
result_eval.keys.each do |hash_key|
|
124
135
|
symbol_modifier=''
|
125
|
-
if
|
136
|
+
if hash_key.is_a? Symbol
|
126
137
|
symbol_modifier=':'
|
127
138
|
end
|
128
|
-
if
|
129
|
-
|
130
|
-
result<< "<font color='YellowGreen'>#{result_eval.class}<font color='yellow'>[</font><font color='white'>#{symbol_modifier}#{hash_key}</font><font color='yellow'>] => </font> </font>#{highlight(result_eval[hash_key])} <br>"
|
139
|
+
if hash_key.is_a? ActiveRecord::Base
|
140
|
+
result<< "<span style='color:YellowGreen'>#{result_eval.class}[<span style='color:white'>#{symbol_modifier}#{hash_key}</span>] => </span>#{highlight(result_eval[hash_key])} <br>"
|
131
141
|
else
|
132
|
-
result<<"<
|
142
|
+
result<<"<span style='color:YellowGreen'>#{result_eval.class}</span>[<span style='color:white'>#{symbol_modifier}#{hash_key}</span>] => #{result_eval[hash_key]} <br>"
|
133
143
|
end
|
134
144
|
count=count+1
|
135
145
|
end
|
136
146
|
result
|
137
147
|
end
|
138
148
|
end
|
139
|
-
end#end BaseController
|
140
|
-
end#end ErpApp
|
141
|
-
end#end Console
|
149
|
+
end #end BaseController
|
150
|
+
end #end ErpApp
|
151
|
+
end #end Console
|
data/lib/compass_ae_console.rb
CHANGED
@@ -3,7 +3,7 @@ module CompassAeConsole
|
|
3
3
|
isolate_namespace CompassAeConsole
|
4
4
|
|
5
5
|
initializer "compass_console.merge_public" do |app|
|
6
|
-
app.middleware.insert_before Rack::
|
6
|
+
app.middleware.insert_before Rack::Runtime, ::ActionDispatch::Static, "#{root}/public"
|
7
7
|
end
|
8
8
|
|
9
9
|
ErpBaseErpSvcs.register_as_compass_ae_engine(config, self)
|
@@ -1,176 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
var desktop_console_history_index=0;
|
6
|
-
//----------------------------------
|
7
|
-
// add startsWith method to string
|
8
|
-
String.prototype.startsWith = function (str){
|
9
|
-
return this.indexOf(str) == 0;
|
10
|
-
};
|
11
|
-
//---------------------------------
|
12
|
-
var startup_heading="<font color='goldenrod'><b>Compass Console Version 0.01</b> (<font color='white'>-help</font> for Help)</font><br>"
|
13
|
-
//---------------------------------
|
14
|
-
function sendCommand(destination,command){
|
15
|
-
update_history_panel("<font color='white'>"+command+"</font>")
|
16
|
-
|
17
|
-
if(command.startsWith("-clear")){
|
18
|
-
clear_history_panel(startup_heading+"<br><hr>");
|
19
|
-
}else{
|
20
|
-
|
21
|
-
Ext.Ajax.request({
|
22
|
-
url: '/compass_ae_console/erp_app/desktop/command',
|
23
|
-
params: {
|
24
|
-
|
25
|
-
command_message: command
|
26
|
-
},
|
27
|
-
success: function(response){
|
28
|
-
var text = response.responseText;
|
29
|
-
var result =Ext.JSON.decode(text)
|
30
|
-
update_history_panel("<font color='yellow'>"+result.success+"</font>")
|
31
|
-
}
|
32
|
-
});
|
33
|
-
}
|
34
|
-
}
|
35
|
-
//---------------------------------
|
36
|
-
function clear_history_panel(text){
|
37
|
-
var panel=Ext.getCmp('console_history_panel');
|
38
|
-
|
39
|
-
panel.update(""+text+"<br>");
|
40
|
-
|
41
|
-
var d = panel.body.dom;
|
42
|
-
d.scrollTop = d.scrollHeight - d.offsetHeight+10;
|
43
|
-
panel.doLayout();
|
44
|
-
}
|
45
|
-
//---------------------------------
|
46
|
-
function update_history_panel(text){
|
47
|
-
var panel=Ext.getCmp('console_history_panel');
|
48
|
-
var old = panel.body.dom.innerHTML;
|
49
|
-
panel.update(old+""+text+"<br>");
|
50
|
-
|
51
|
-
var d = panel.body.dom;
|
52
|
-
d.scrollTop = d.scrollHeight - d.offsetHeight+10;
|
53
|
-
panel.doLayout();
|
54
|
-
}
|
55
|
-
|
56
|
-
//---------------------------------
|
57
|
-
var console_history_panel ={
|
58
|
-
xtype: 'panel',
|
59
|
-
id : 'console_history_panel',
|
60
|
-
region: 'center',
|
61
|
-
bodyStyle: "background-color:#000;",
|
62
|
-
autoScroll:true,
|
63
|
-
html : startup_heading
|
64
|
-
}
|
65
|
-
|
66
|
-
//---------------------------------
|
67
|
-
|
68
|
-
var console_text_area ={
|
69
|
-
xtype: 'textarea',
|
70
|
-
region : 'south',
|
71
|
-
autoscroll: true,
|
72
|
-
id: "console_text_area",
|
73
|
-
enableKeyEvents: true,
|
74
|
-
listeners: {
|
75
|
-
afterrender: function(field) {
|
76
|
-
field.focus();
|
77
|
-
},
|
78
|
-
// use key-up for textarea since ENTER does not affect focus traversal
|
79
|
-
keyup: function(field, e){
|
80
|
-
//console.log("textarea keyup:"+e);
|
81
|
-
if (e.getKey() == e.ENTER){
|
82
|
-
|
83
|
-
sendCommand('console_text_area',field.getValue());
|
84
|
-
// add to history
|
85
|
-
desktop_console_history[desktop_console_history.length]=field.getValue().substring(0,field.getValue().length-1);
|
86
|
-
//update index
|
87
|
-
desktop_console_history_index=desktop_console_history.length
|
88
|
-
field.setValue("");
|
89
|
-
}else if (e.getKey() == e.UP){
|
90
|
-
|
91
|
-
if(desktop_console_history.length==0){
|
92
|
-
// no history to display
|
93
|
-
}else{
|
94
|
-
desktop_console_history_index--;
|
95
|
-
if(desktop_console_history_index >=0){
|
96
|
-
|
97
|
-
}
|
98
|
-
else{
|
99
|
-
desktop_console_history_index=desktop_console_history.length-1
|
100
|
-
}
|
101
|
-
field.setValue(desktop_console_history[desktop_console_history_index]);
|
102
|
-
}
|
103
|
-
|
104
|
-
}else if (e.getKey() == e.DOWN){
|
105
|
-
|
106
|
-
if(desktop_console_history.length==0){
|
107
|
-
// no history to display
|
108
|
-
}else{
|
109
|
-
desktop_console_history_index++;
|
110
|
-
if(desktop_console_history_index >=(desktop_console_history.length)){
|
111
|
-
desktop_console_history_index=0
|
112
|
-
}
|
113
|
-
else{
|
114
|
-
//desktop_console_history_index=desktop_console_history.length-1
|
115
|
-
}
|
116
|
-
field.setValue(desktop_console_history[desktop_console_history_index]);
|
117
|
-
}
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
|
-
}
|
122
|
-
}
|
123
|
-
//---------------------------------
|
124
|
-
var console_panel={
|
125
|
-
xtype: 'panel',
|
126
|
-
layout: 'border',
|
127
|
-
items :[ console_history_panel,console_text_area]
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
//---------------------------------
|
132
|
-
|
133
|
-
Ext.define("Compass.ErpApp.Desktop.Applications.CompassAeConsole",{
|
134
|
-
extend:"Ext.ux.desktop.Module",
|
135
|
-
id:'compass_console-win',
|
136
|
-
init : function(){
|
1
|
+
Ext.define("Compass.ErpApp.Desktop.Applications.CompassAeConsole", {
|
2
|
+
extend: "Ext.ux.desktop.Module",
|
3
|
+
id: 'compass_console-win',
|
4
|
+
init: function () {
|
137
5
|
this.launcher = {
|
138
6
|
text: 'Compass Console',
|
139
|
-
iconCls:'icon-console',
|
7
|
+
iconCls: 'icon-console',
|
140
8
|
handler: this.createWindow,
|
141
9
|
scope: this
|
142
|
-
}
|
10
|
+
};
|
143
11
|
},
|
144
12
|
|
145
|
-
createWindow
|
13
|
+
createWindow: function () {
|
146
14
|
var desktop = this.app.getDesktop();
|
147
15
|
var win = desktop.getWindow('console');
|
148
|
-
if(!win){
|
16
|
+
if (!win) {
|
149
17
|
win = desktop.createWindow({
|
150
18
|
id: 'console',
|
151
|
-
title:'Compass Console',
|
152
|
-
width:
|
153
|
-
height:
|
154
|
-
iconCls: '
|
155
|
-
shim:false,
|
156
|
-
animCollapse:false,
|
157
|
-
resizable
|
158
|
-
constrainHeader:true,
|
19
|
+
title: 'Compass Console',
|
20
|
+
width: 800,
|
21
|
+
height: 600,
|
22
|
+
iconCls: 'icon-console',
|
23
|
+
shim: false,
|
24
|
+
animCollapse: false,
|
25
|
+
resizable: true,
|
26
|
+
constrainHeader: true,
|
159
27
|
layout: 'fit',
|
160
|
-
items:[
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
type:'help',
|
165
|
-
tooltip: 'about',
|
166
|
-
handler: function(event, toolEl, panel){
|
167
|
-
Ext.Msg.alert("About","<center><b>Compass Console</b><br><i>Version 0.01</i>")
|
28
|
+
items: [
|
29
|
+
{
|
30
|
+
xtype: 'compass_ae_console_panel',
|
31
|
+
header: false
|
168
32
|
}
|
169
|
-
|
170
|
-
|
33
|
+
]
|
171
34
|
});
|
172
35
|
}
|
173
36
|
win.show();
|
174
|
-
sendCommand('console_text_area',"Rails.version ");
|
175
37
|
}
|
176
38
|
});
|