Skip to content

Commit

Permalink
ceph: split GUI files
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerdietmar committed Jan 24, 2014
1 parent 6ab534d commit df4417b
Show file tree
Hide file tree
Showing 9 changed files with 1,315 additions and 1,315 deletions.
8 changes: 7 additions & 1 deletion www/manager/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ JSSRC= \
panel/ConfigPanel.js \
grid/BackupView.js \
panel/LogView.js \
ceph/Pool.js \
ceph/OSD.js \
ceph/Disks.js \
ceph/Monitor.js \
ceph/Crush.js \
ceph/Status.js \
ceph/Config.js \
node/DNSEdit.js \
node/DNSView.js \
node/TimeView.js \
Expand All @@ -87,7 +94,6 @@ JSSRC= \
node/Tasks.js \
node/Subscription.js \
node/APT.js \
node/Ceph.js \
node/Config.js \
qemu/StatusView.js \
window/Migrate.js \
Expand Down
175 changes: 175 additions & 0 deletions www/manager/ceph/Config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
Ext.define('PVE.node.CephConfig', {
extend: 'Ext.panel.Panel',
alias: ['widget.pveNodeCephConfig'],

load: function() {
var me = this;

PVE.Utils.API2Request({
url: me.url,
waitMsgTarget: me,
failure: function(response, opts) {
me.update(gettext('Error') + " " + response.htmlStatus);
},
success: function(response, opts) {
var data = response.result.data;
me.update(Ext.htmlEncode(data));
}
});
},

initComponent: function() {
var me = this;

var nodename = me.pveSelNode.data.node;
if (!nodename) {
throw "no node name specified";
}

Ext.apply(me, {
url: '/nodes/' + nodename + '/ceph/config',
bodyStyle: 'white-space:pre',
bodyPadding: 5,
autoScroll: true,
listeners: {
show: function() {
me.load();
}
}
});

me.callParent();

me.load();
}
});

Ext.define('PVE.node.Ceph', {
extend: 'Ext.tab.Panel',
alias: ['widget.pveNodeCeph'],

getHState: function(itemId) {
/*jslint confusion: true */
var me = this;

if (!itemId) {
itemId = me.getActiveTab().itemId;
}

var first = me.items.get(0);
var ntab;

// Note: '' is alias for first tab.
if (itemId === first.itemId) {
ntab = 'ceph';
} else {
ntab = 'ceph-' + itemId;
}

return { value: ntab };
},

initComponent: function() {
var me = this;

var nodename = me.pveSelNode.data.node;
if (!nodename) {
throw "no node name specified";
}

if (!me.phstateid) {
throw "no parent history state specified";
}

var sp = Ext.state.Manager.getProvider();
var state = sp.get(me.phstateid);
var hsregex = /^ceph-(\S+)$/;

if (state && state.value) {
var res = hsregex.exec(state.value);
if (res && res[1]) {
me.activeTab = res[1];
}
}

Ext.apply(me, {
plain: true,
tabPosition: 'bottom',
defaults: {
border: false,
pveSelNode: me.pveSelNode
},
items: [
{
xtype: 'pveNodeCephStatus',
title: 'Status',
itemId: 'status'
},
{
xtype: 'pveNodeCephConfig',
title: 'Config',
itemId: 'config'
},
{
xtype: 'pveNodeCephMonList',
title: 'Monitor',
itemId: 'monlist'
},
{
xtype: 'pveNodeCephDiskList',
title: 'Disks',
itemId: 'disklist'
},
{
xtype: 'pveNodeCephOsdTree',
title: 'OSD',
itemId: 'osdtree'
},
{
xtype: 'pveNodeCephPoolList',
title: 'Pools',
itemId: 'pools'
},
{
title: 'Crush',
xtype: 'pveNodeCephCrushMap',
itemId: 'crushmap'
},
{
title: 'Log',
itemId: 'log',
xtype: 'pveLogView',
url: "/api2/extjs/nodes/" + nodename + "/ceph/log"
}
],
listeners: {
afterrender: function(tp) {
var first = tp.items.get(0);
if (first) {
first.fireEvent('show', first);
}
},
tabchange: function(tp, newcard, oldcard) {
var state = me.getHState(newcard.itemId);
sp.set(me.phstateid, state);
}
}
});

me.callParent();

var statechange = function(sp, key, state) {
if ((key === me.phstateid) && state) {
var first = me.items.get(0);
var atab = me.getActiveTab().itemId;
var res = hsregex.exec(state.value);
var ntab = (res && res[1]) ? res[1] : first.itemId;
if (ntab && (atab != ntab)) {
me.setActiveTab(ntab);
}
}
};

me.mon(sp, 'statechange', statechange);
}
});
45 changes: 45 additions & 0 deletions www/manager/ceph/Crush.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Ext.define('PVE.node.CephCrushMap', {
extend: 'Ext.panel.Panel',
alias: ['widget.pveNodeCephCrushMap'],

load: function() {
var me = this;

PVE.Utils.API2Request({
url: me.url,
waitMsgTarget: me,
failure: function(response, opts) {
me.update(gettext('Error') + " " + response.htmlStatus);
},
success: function(response, opts) {
var data = response.result.data;
me.update(Ext.htmlEncode(data));
}
});
},

initComponent: function() {
var me = this;

var nodename = me.pveSelNode.data.node;
if (!nodename) {
throw "no node name specified";
}

Ext.apply(me, {
url: '/nodes/' + nodename + '/ceph/crush',
bodyStyle: 'white-space:pre',
bodyPadding: 5,
autoScroll: true,
listeners: {
show: function() {
me.load();
}
}
});

me.callParent();

me.load();
}
});
Loading

0 comments on commit df4417b

Please sign in to comment.