Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

widget tags

  • Loading branch information...
commit 4e5b960bca07a55c2d77af7a4f7cefd1dae80532 1 parent 045a40e
@Eyjafjallajokull authored
View
2  config.yml
@@ -32,7 +32,7 @@ widgets:
config:
title: Aboco git history
command: git log -n 3 --shortstat
- classes: doubleWidth doubleHeight
+ tags: [ doubleWidth, doubleHeight ]
- {id: HostInfoWidget }
View
6 core/widget.py
@@ -8,16 +8,20 @@ class BaseWidget(object):
'''
config = {}
+ tags = []
@property
def name(self):
return self.__class__.__name__
def __init__(self, config={}):
- self.config = config
+ self.setConfig(config)
def setConfig(self, config):
self.config = config
+
+ def setTags(self, tags):
+ self.tags = tags
def collectData(self):
'''
View
5 core/widgetmanager.py
@@ -58,6 +58,9 @@ def initWidgets(self):
self._installed[hash] = self._widgets[widgetId](widgetConfig['config'])
except KeyError:
self._installed[hash] = self._widgets[widgetId]()
+ try:
+ self._installed[hash].setTags(widgetConfig['tags'])
+ except KeyError: pass
if not found:
raise Exception('Unknown widget found in config: '+widgetConfig['id'])
@@ -84,5 +87,5 @@ def collectData(self):
def getConfig(self):
config = {}
for (id, widget) in self._installed.items():
- config[id] = { 'id': widget.name, 'config': widget.config }
+ config[id] = { 'id': widget.name, 'config': widget.config, 'tags': widget.tags }
return config
View
1  public/index.html
@@ -32,5 +32,6 @@
<li>Linux pawel-pc 3.2.0-35-generic</li>
</ul>
<div id="widgetsWrap"></div>
+ <div id="widgetsCustom"></div>
</body>
</html>
View
33 public/main.css
@@ -161,14 +161,31 @@ b { font-weight: bold; }
margin: 3px;
}
-.doubleWidth { width: 412px; }
-.tripleWidth { width: 624px; }
-
-.autoHeight { height: auto; }
-.doubleHeight { height: 412px; }
-.doubleHeight .widget { height: 376px; /*412-16-10-10*/ }
-.tripleHeight { height: 624px; }
-.tripleHeight .widget { height: 588px; /*624-16-10-10*/ }
+.tag-doubleWidth { width: 412px; }
+.tag-tripleWidth { width: 624px; }
+
+.tag-autoHeight { height: auto; }
+.tag-doubleHeight { height: 412px; }
+.tag-doubleHeight .widget { height: 376px; /*412-16-10-10*/ }
+.tag-tripleHeight { height: 624px; }
+.tag-tripleHeight .widget { height: 588px; /*624-16-10-10*/ }
+
+.tag-system {
+ border: 1px solid #b0bfd9;
+}
+.tag-system h3 {
+ background-image: -webkit-gradient(
+ linear,
+ left bottom,
+ left top,
+ color-stop(0.72, #dadfe6),
+ color-stop(0.3, #cad0d9)
+ );
+ background-image: -moz-linear-gradient(
+ center bottom, #d3dce8, #c1ccdb
+ );
+ border-bottom: 1px solid #b0bfd9;
+}
/* OPTIONS BAR */
View
23 public/main.js
@@ -58,12 +58,15 @@ var WidgetManager = {
install: function(widget) {
var widgetConfigs = Config.getNamespace('widgets');
for (var id in widgetConfigs){
- if (widgetConfigs.hasOwnProperty(id) && widgetConfigs[id].id == widget.id) {
- var widget = WidgetManager.registeredWidgets[widgetConfigs[id].id];
+ var widgetConfig = widgetConfigs[id];
+ if (widgetConfigs.hasOwnProperty(id) && widgetConfig.id == widget.id) {
+ var widget = WidgetManager.registeredWidgets[widgetConfig.id];
if (!widget) continue;
var widgetInstance = jQuery.extend(true, {}, widget);
- widgetInstance._init(widgetConfigs[id].config, id);
+ widgetInstance.setConfig(widgetConfig.config);
+ widgetInstance.setTags(widgetConfig.tags);
+ widgetInstance._init(id);
this.installedWidgets[id] = widgetInstance;
}
}
@@ -174,20 +177,26 @@ var Widget = {
instanceId: null,
title: "Base",
mainTpl: '',
+ config: {},
+ tags: [],
_$element: null,
baseTemplate: function() {
+ var tags = this.tags.map(function(i){return 'tag-'+i;});
return '<div id="widget'+this.instanceId+'" class="'+
- this.id+'Wrap widgetWrap'+(this.classes?' '+this.classes:'')+'">'+
+ this.id+'Wrap widgetWrap '+tags.join(' ')+'">'+
'<h3>'+this.title+'</h3>'+
'<div class="'+this.id+' widget"></div></div>';
},
config: {},
- _init: function(config, instanceId) {
- this.config = config;
+ setConfig: function(config){ this.config = config; },
+ setTags: function(tags){ this.tags = tags; },
+ _init: function(instanceId) {
this.instanceId = instanceId;
var newItem = $(this.baseTemplate());
- $('#widgetsWrap').isotope( 'insert', newItem );
+ if (this.tags.indexOf('customWidget')===-1) {
+ $('#widgetsWrap').isotope( 'insert', newItem );
+ }
if (typeof this.mainTpl == 'string')
this.$('.widget').html(this.mainTpl);
View
3  widgets/commander/main.js
@@ -8,9 +8,6 @@
this.$('h3').text(this.config.title)
else
this.$('h3').text(this.config.command)
-
- if (this.config.classes)
- this.$().addClass(this.config.classes);
};
w.render = function(data) {
View
2  widgets/disks/main.js
@@ -1,8 +1,6 @@
(function(){
var w = $.extend({}, Widget);
- w.classes = 'doubleWidth';
-
w.tableTpl = '<table><tr><th>disk</th><th>size</th><th>used</th><th>mount&nbsp;point</th>$1</tr></table>';
w.tableRowTpl = '<tr><td>$1</td><td class="tar">$2</td><td class="tar">$5</td><td>$6</td></tr>';
View
1  widgets/disks/main.py
@@ -1,5 +1,6 @@
from core.widget import BaseWidget
class DisksWidget(BaseWidget):
+ tags = [ 'system', 'doubleWidth' ]
def collectData(self):
return self.runSystemCommand('df -hP | egrep --color=never "^/"')
View
2  widgets/hostinfo/main.js
@@ -6,7 +6,7 @@
}
w.render = function(data) {
- this.$().remove();
+ //this.$().remove();
var html = '';
html += '<li>'+data['uname']+'</li>';
html += '<li>'+data['date']+'</li>';
View
1  widgets/hostinfo/main.py
@@ -1,6 +1,7 @@
from core.widget import BaseWidget
class HostInfoWidget(BaseWidget):
+ tags = [ 'customWidget','system' ]
def collectData(self):
return {
"uname": self.runSystemCommand('uname -snrmo'),
View
1  widgets/memory/main.py
@@ -1,6 +1,7 @@
from core.widget import BaseWidget
class MemoryWidget(BaseWidget):
+ tags = [ 'system' ]
def collectData(self):
meminfo = file('/proc/meminfo', 'r')
total = meminfo.readline()[0:-4]
View
1  widgets/network/main.py
@@ -1,6 +1,7 @@
from core.widget import BaseWidget
class NetworkWidget(BaseWidget):
+ tags = [ 'system' ]
prevValues = {'rx':0, 'tx':0}
def collectData(self):
View
3  widgets/processes/main.js
@@ -1,7 +1,6 @@
(function(){
var w = $.extend({}, Widget);
-
- w.classes = 'doubleWidth'
+
w.mainTpl = '<div class="processesData"></div>';
w.tableTpl = '<table><tr><th>user</th><th title="CPU usage">cpu</th><th title="Memory usage">mem</th><th>command</th></tr>$1</table>';
w.tableRowTpl = '<tr><td>$1</td><td class="tar">$3</td><td class="tar">$4</td>'+
View
1  widgets/processes/main.py
@@ -1,5 +1,6 @@
from core.widget import BaseWidget
class ProcessesWidget(BaseWidget):
+ tags = ['doubleWidth','system']
def collectData(self):
return self.runSystemCommand('ps -A -o "user pid %cpu %mem cmd" --sort -%cpu | head -11 | tail -10')
View
1  widgets/processor/main.py
@@ -1,6 +1,7 @@
from core.widget import BaseWidget
class ProcessorWidget(BaseWidget):
+ tags = [ 'system' ]
cores = 1
def __init__(self, config={}):
Please sign in to comment.
Something went wrong with that request. Please try again.