[pve-devel] [PATCH manager v2 15/22] use ServiceView from widget toolkit

Dominik Csapak d.csapak at proxmox.com
Mon Jan 15 15:18:03 CET 2018


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile            |   1 -
 www/manager6/node/Config.js      |   9 ++-
 www/manager6/node/ServiceView.js | 164 ---------------------------------------
 3 files changed, 8 insertions(+), 166 deletions(-)
 delete mode 100644 www/manager6/node/ServiceView.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 4db0616c..65ff58e9 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -117,7 +117,6 @@ JSSRC= 				                 	\
 	node/DNSView.js					\
 	node/StatusView.js				\
 	node/Summary.js					\
-	node/ServiceView.js				\
 	node/Subscription.js				\
 	node/Config.js					\
 	window/Migrate.js				\
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index 77744e03..21d85941 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -158,7 +158,14 @@ Ext.define('PVE.node.Config', {
 		    iconCls: 'fa fa-cogs',
 		    itemId: 'services',
 		    expandedOnInit: true,
-		    xtype: 'pveNodeServiceView'
+		    startOnlyServices: {
+			'pveproxy': true,
+			'pvedaemon': true,
+			'pve-cluster': true
+		    },
+		    nodename: nodename,
+		    onlineHelp: 'pve_service_daemons',
+		    xtype: 'proxmoxNodeServiceView'
 		},
 		{
 		    title: gettext('Network'),
diff --git a/www/manager6/node/ServiceView.js b/www/manager6/node/ServiceView.js
deleted file mode 100644
index b78d1766..00000000
--- a/www/manager6/node/ServiceView.js
+++ /dev/null
@@ -1,164 +0,0 @@
-Ext.define('PVE.node.ServiceView', {
-    extend: 'Ext.grid.GridPanel',
-
-    alias: ['widget.pveNodeServiceView'],
-
-    onlineHelp: 'pve_service_daemons',
-
-    initComponent : function() {
-	var me = this;
-
-	var nodename = me.pveSelNode.data.node;
-	if (!nodename) {
-	    throw "no node name specified";
-	}
-
-	var rstore = Ext.create('Proxmox.data.UpdateStore', {
-	    interval: 1000,
-	    storeid: 'pve-services' + nodename,
-	    model: 'pve-services',
-	    proxy: {
-                type: 'pve',
-                url: "/api2/json/nodes/" + nodename + "/services"
-	    }
-	});
-
-	var store = Ext.create('PVE.data.DiffStore', {
-	    rstore: rstore,
-	    sortAfterUpdate: true,
-	    sorters: [
-		{
-		    property : 'name',
-		    direction: 'ASC'
-		}
-	    ]
-	});
-
-	var service_cmd = function(cmd) {
-	    var sm = me.getSelectionModel();
-	    var rec = sm.getSelection()[0];
-	    PVE.Utils.API2Request({
-		url: "/nodes/" + nodename + "/services/" + rec.data.service + "/" + cmd,
-		method: 'POST',
-		failure: function(response, opts) {
-		    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
-		    me.loading = true;
-		},
-		success: function(response, opts) {
-		    rstore.startUpdate();
-		    var upid = response.result.data;
-
-		    var win = Ext.create('PVE.window.TaskProgress', { 
-			upid: upid
-		    });
-		    win.show();
-		}
-	    });
-	};
-
-	var start_btn = new Ext.Button({
-	    text: gettext('Start'),
-	    disabled: true,
-	    handler: function(){
-		service_cmd("start");
-	    }
-	});
-
-	var stop_btn = new Ext.Button({
-	    text: gettext('Stop'),
-	    disabled: true,
-	    handler: function(){
-		service_cmd("stop");
-	    }
-	});
-
-	var restart_btn = new Ext.Button({
-	    text: gettext('Restart'),
-	    disabled: true,
-	    handler: function(){
-		service_cmd("restart");
-	    }
-	});
-
-	var set_button_status = function() {
-	    var sm = me.getSelectionModel();
-	    var rec = sm.getSelection()[0];
-
-	    if (!rec) {
-		start_btn.disable();
-		stop_btn.disable();
-		restart_btn.disable();
-		return;
-	    }
-	    var service = rec.data.service;
-	    var state = rec.data.state;
-	    if (service == 'pveproxy' ||
-		service == 'pvecluster' ||
-		service == 'pvedaemon') {
-		if (state == 'running') {
-		    start_btn.disable();
-		    restart_btn.enable();
-		} else {
-		    start_btn.enable();
-		    restart_btn.disable();
-		}
-		stop_btn.disable();
-	    } else {
-		if (state == 'running') {
-		    start_btn.disable();
-		    restart_btn.enable();
-		    stop_btn.enable();
-		} else {
-		    start_btn.enable();
-		    restart_btn.disable();
-		    stop_btn.disable();
-		}
-	    }
-	};
-
-	me.mon(store, 'refresh', set_button_status);
-
-	PVE.Utils.monStoreErrors(me, rstore);
-
-	Ext.apply(me, {
-	    store: store,
-	    stateful: false,
-	    tbar: [ start_btn, stop_btn, restart_btn ],
-	    columns: [
-		{
-		    header: gettext('Name'),
-		    width: 100,
-		    sortable: true,
-		    dataIndex: 'name'
-		},
-		{
-		    header: gettext('Status'),
-		    width: 100,
-		    sortable: true,
-		    dataIndex: 'state'
-		},
-		{
-		    header: gettext('Description'),
-		    renderer: Ext.String.htmlEncode,
-		    dataIndex: 'desc',
-		    flex: 1
-		}
-	    ],
-	    listeners: {
-		selectionchange: set_button_status,
-		activate: rstore.startUpdate,
-		destroy: rstore.stopUpdate
-	    }
-	});
-
-	me.callParent();
-    }
-}, function() {
-
-    Ext.define('pve-services', {
-	extend: 'Ext.data.Model',
-	fields: [ 'service', 'name', 'desc', 'state' ],
-	idProperty: 'service'
-    });
-
-});
-- 
2.11.0





More information about the pve-devel mailing list