Skip to content

Commit

Permalink
Merge remote branch 'vova/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ssOleg committed Oct 15, 2013
2 parents 0dba218 + 46d25fc commit 036e672
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ZenPacks/zenoss/MySqlMonitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ZenPack(ZenPackBase):
"""

packZProperties = [
('zMySQLConnectionString', 'root::3306;', 'string'),
('zMySQLConnectionString', 'root::3306;', 'miltilinecredentials'),
]

def install(self, app):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def process(self, device, results, log):
log.error(server.getErrorMessage())
continue

# Connection error: sending event
# Connection error: send event in errback
if not server:
return

Expand Down Expand Up @@ -164,7 +164,6 @@ def _failure(self, error, log, device):
@type error: Twisted error instance
@parameter log: log object
@type log: object
@return: dict with error message for event
"""

log.error(error.getErrorMessage())
Expand Down
138 changes: 138 additions & 0 deletions ZenPacks/zenoss/MySqlMonitor/resources/js/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,142 @@ var ZC = Ext.ns('Zenoss.component');
ZC.registerName('MySQLServer', _t('MySQL Server'), _t('MySQL Server'));
ZC.registerName('MySQLDatabase', _t('Database'), _t('Databases'));

/* zMySQLConnectionString property */
Zenoss.zproperties.registerZPropertyType('miltilinecredentials', {xtype: 'miltilinecredentials'});

Ext.define("Zenoss.form.MultilineCredentials", {
alias:['widget.miltilinecredentials'],
extend:'Ext.form.Display',

constructor: function(config) {
// submitHandler: this.setValue,
Zenoss.form.MultilineCredentials.superclass.constructor.apply(this, arguments);
},

initComponent: function() {
this.grid = this.childComponent = Ext.create('Ext.grid.Panel', {
hideHeaders: true,
columns: [{
dataIndex: 'value',
flex: 1,
renderer: function(value) {
var bits = value.split(":");
if (bits.length == 3)
return bits[0]+ ":***:" + bits[2]
else
return "ERROR: Invalid connection string!";
}
}],

store: {
fields: ['value'],
data: []
},

height: this.height || 150,
width: this.width || 150,

tbar: [{
itemId: 'user',
xtype:"textfield",
scope: this,
width: 50,
value: "root",
},{
itemId: 'password',
xtype:"password",
scope: this,
width: 50,
value: "",
},{
itemId: 'port',
xtype:"textfield",
scope: this,
width: 50,
value: "3306",
},{
text: 'Add',
scope: this,
handler: function() {
var user = this.grid.down('#user');
var password = this.grid.down('#password');
var port = this.grid.down('#port');

var value = user.value+":"+password.value+":"+port.value+";";
if (user.value !== "") {
this.grid.getStore().add({value: value});
}

user.setValue("");
password.setValue("");
port.setValue("");
}
},{
text: "Remove",
itemId: 'removeButton',
disabled: true, // initial state
scope: this,
handler: function() {
var grid = this.grid,
selModel = grid.getSelectionModel(),
store = grid.getStore();
store.remove(selModel.getSelection());
}
}],

listeners: {
scope: this,
selectionchange: function(selModel, selection) {
var removeButton = this.grid.down('#removeButton');
removeButton.setDisabled(Ext.isEmpty(selection));
}
}
});

this.callParent(arguments);
},

// --- Rendering ---
// Generates the child component markup
getSubTplMarkup: function() {
// generateMarkup will append to the passed empty array and return it
var buffer = Ext.DomHelper.generateMarkup(this.childComponent.getRenderTree(), []);
// but we want to return a single string
return buffer.join('');
},

// Regular containers implements this method to call finishRender for each of their
// child, and we need to do the same for the component to display smoothly
finishRenderChildren: function() {
this.callParent(arguments);
this.childComponent.finishRender();
},

// --- Resizing ---
onResize: function(w, h) {
this.callParent(arguments);
this.childComponent.setSize(w - this.getLabelWidth(), h);
},

// --- Value handling ---
setValue: function(values) {
var data = [];
if (values) {
Ext.each(values, function(value) {
data.push({value: value});
});
}
this.grid.getStore().loadData(data);
},

getValue: function() {
var data = [];
this.grid.getStore().each(function(record) {
data.push(record.get('value'));
});
return data;
},
});


}());

0 comments on commit 036e672

Please sign in to comment.