Skip to content

Commit

Permalink
Merge branch 'rules'
Browse files Browse the repository at this point in the history
* rules: (73 commits)
  Update Blocks
  Add text block
  Update logic_operation mutation
  Update persistence block (add mutation)
  Update persistence block
  Remove item rules tab
  Add message file!
  Update HABmin to update blocks.
  Update persistence block
  Updated error handling within blocks to allow for changes in block definitions without error!
  Update UTF-8 for new files
  Update blocks
  Update rule filename
  no message
  Update blocks
  Add XML back into blockly to support mutations.
  Updated block editor to add new blocks and updated implementation.
  Update blocks
  Add constants section
  Support renaming of different variable types separately.
  ...
  • Loading branch information
cdjackson committed Jun 10, 2014
2 parents e242f9c + 4a84c6a commit fbf729e
Show file tree
Hide file tree
Showing 86 changed files with 32,743 additions and 186 deletions.
19 changes: 19 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ module.exports = function (grunt) {
src: ['js/jsprintf.js', 'js/moment.js', 'js/highcharts.js', 'js/highcharts-more.js', 'js/jit.js', 'js/ext-all.js', 'js/jquery.min.js', 'js/jquery.atmosphere.js'],
dest: 'build/webapps/habmin/js/'
},
extuxblockly: {
expand: true,
flatten: true,
src: ['js/extux/blockly/*.js'],
dest: 'build/webapps/habmin/js/extux/blockly'
},
extuxgrid: {
expand: true,
flatten: true,
Expand Down Expand Up @@ -117,6 +123,16 @@ module.exports = function (grunt) {
expand: true,
src: ['js/extux/statusbar/images/**'],
dest: 'build/webapps/habmin/'
},
blocklymedia: {
expand: true,
src: ['js/extux/blockly/media/**'],
dest: 'build/webapps/habmin/js/extux/blockly/media'
},
blocklymsg: {
expand: true,
src: ['js/extux/blockly/msg/**'],
dest: 'build/webapps/habmin/js/extux/blockly/msg'
}
},
cssmin: {
Expand Down Expand Up @@ -151,6 +167,9 @@ module.exports = function (grunt) {
'json-minify': {
language: {
files: 'build/webapps/habmin/app/language/*.json'
},
blocklymsg: {
files: 'build/webapps/habmin/js/extjs/blockly/msg/*.json'
}
},
compress: {
Expand Down
Binary file modified addons/org.openhab.io.habmin-1.5.0-SNAPSHOT.jar
Binary file not shown.
36 changes: 31 additions & 5 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Ext.Loader.setConfig({
'Ext.ux': 'js/extux',
'Ext.ux.window': 'js/extux/notification',
'Ext.ux.aceeditor': 'js/extux/aceeditor',
'Ext.ux.blockly': 'js/extux/blockly',
'Ext.ux.grid': 'js/extux/grid',
'openHAB': 'app'
}
Expand All @@ -90,6 +91,7 @@ Ext.require([
'Ext.ux.grid.QuickFilter',
'Ext.ux.statusbar.StatusBar',
'Ext.ux.aceeditor.Panel',
'Ext.ux.blockly.Blockly',
'Ext.ux.window.Notification',
'openHAB.graph.*',
'openHAB.config.*',
Expand Down Expand Up @@ -128,6 +130,7 @@ var itemConfigStore;
var itemFormatStore;
var translationServiceStore;
var ruleLibraryStore;
var designStore;
var ruleStore;
var cronRuleStore;
var chartStore;
Expand Down Expand Up @@ -255,8 +258,6 @@ Ext.Ajax.on('requestexception', function (conn, response, options, eOpts) {
ajaxOutstandingRequestCount--;
});

//Ext.getBody().on("contextmenu", Ext.emptyFn, null, {preventDefault: true});

/**
* Load a country language file
* @param countryCode the two digit ISO country code
Expand Down Expand Up @@ -756,7 +757,7 @@ function createUI() {
});

//======= Rule Template Store
Ext.define('RuleTemplateModel', {
/* Ext.define('RuleTemplateModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'name'},
Expand Down Expand Up @@ -789,6 +790,29 @@ function createUI() {
limitParam: undefined
},
autoLoad: true
});*/

//======= Design Store
// Load the rules for this item
designStore = Ext.create('Ext.data.JsonStore', {
fields: [
{name: 'id'},
{name: 'name'}
],
proxy: {
type: 'rest',
url: HABminBaseURL + '/config/designer',
reader: {
type: 'json',
root: 'designs'
},
headers: {'Accept': 'application/json'},
pageParam: undefined,
startParam: undefined,
sortParam: undefined,
limitParam: undefined
},
autoLoad: true
});

//======= Widgets Store
Expand Down Expand Up @@ -825,7 +849,7 @@ function createUI() {


//======= Rule Store
Ext.define('RuleModel', {
/* Ext.define('RuleModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'item'},
Expand All @@ -851,7 +875,7 @@ function createUI() {
limitParam: undefined
},
autoLoad: true
});
});*/


//======= Item Config Store
Expand Down Expand Up @@ -1005,6 +1029,7 @@ function createUI() {
},
items: [
{
// margin: '0 0 0 0',
xtype: 'combobox',
fieldLabel: language.personalisation_Language,
itemId: 'language',
Expand All @@ -1020,6 +1045,7 @@ function createUI() {
value: languageCode
},
{
// margin: '0 0 0 0',
xtype: 'combobox',
fieldLabel: language.personalisation_PersistenceStore,
itemId: 'persistence',
Expand Down
5 changes: 1 addition & 4 deletions app/automation/automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Ext.define('openHAB.automation.automation', {
icon: 'images/compass.png',
id: 'maintabAutomation',
cls: 'empty',
autoDestroy: true,

initComponent: function () {
this.title = language.mainTab_Automation;
Expand Down Expand Up @@ -84,10 +85,6 @@ Ext.define('openHAB.automation.automation', {
}
});

var chartGraph = Ext.create('openHAB.automation.ruleProperties');

propertyContainer.add(chartGraph);

this.items = [accordion, propertyContainer];

this.callParent();
Expand Down
2 changes: 1 addition & 1 deletion app/automation/ruleLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Ext.define('openHAB.automation.ruleLibrary', {
this.title = language.rule_LibraryTitle;

var ruleList = Ext.create('Ext.grid.Panel', {
store: ruleLibraryStore,
// store: ruleLibraryStore,
header: false,
split: true,
// tbar:toolbar,
Expand Down
169 changes: 137 additions & 32 deletions app/automation/ruleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,60 +40,165 @@ Ext.define('openHAB.automation.ruleList', {
extend: 'Ext.panel.Panel',
layout: 'fit',
icon: 'images/application-list.png',
items: [],

initComponent: function () {
this.title = language.rule_ListTitle;

var me = this;

var toolbar = Ext.create('Ext.toolbar.Toolbar', {
items: [
{
icon: 'images/minus-button.png',
itemId: 'delete',
text: language.delete,
cls: 'x-btn-icon',
disabled: true,
tooltip: language.rule_ListDeleteTip,
handler: function () {
// Get the item name to delete
var record = ruleList.getSelectionModel().getSelection()[0];
if (record == null)
return;

// Make sure we really want to do this!!!
var ruleName = record.get('name');
Ext.Msg.show({
title: language.rule_ListConfirmDeleteTitle,
msg: sprintf(language.rule_ListConfirmDeleteMsg, ruleName),
buttons: Ext.Msg.YESNO,
config: {
obj: this,
name: ruleName,
id: record.get('id')
},
fn: deleteRule,
icon: Ext.MessageBox.QUESTION
});
}
},
{
icon: 'images/plus-button.png',
itemId: 'add',
text: language.add,
cls: 'x-btn-icon',
disabled: false,
tooltip: language.rule_ListAddTip,
handler: function () {
var ruleDesigner = Ext.create('openHAB.automation.ruleProperties', {
blockly: {
blocks: {
block: [
{
type: 'openhab_rule',
deletable: false,
movable: false,
fields: [
{name: "NAME", value: language.rule_DesignerNewRule}
]
}
]
}
}
});

if (ruleDesigner == null)
return;

Ext.getCmp('automationPropertyContainer').setNewProperty(ruleDesigner);
}
}
]
});

var ruleList = Ext.create('Ext.grid.Panel', {
store: ruleStore,
store: designStore,
header: false,
split: true,
// tbar:toolbar,
tbar: toolbar,
collapsible: false,
multiSelect: false,
columns: [
{
text: language.rule_ListItem,
flex: 3,
dataIndex: 'item'
/*,
renderer:function (value, metadata, record) {
var icon = "";
var ref = itemConfigStore.findExact("name", value);
if (ref != -1) {
if (itemConfigStore.getAt(ref).get('icon') != "")
icon = '<img src="../images/' + itemConfigStore.getAt(ref).get('icon') + '.png" align="left" height="16">';
}
return '<div>' + icon + '</div><div style="margin-left:20px">' + value + '</div>';
}*/
},
{
text: language.rule_ListRule,
flex: 4,
dataIndex: 'label'
/*,
renderer:function (value, metadata, record, row, col, store, gridView) {
var img = '';
if (record.get("persistence") != null) {
var services = record.get("persistence");
if (services != "")
img = '<img src="images/database-small.png">';
}
return '<span>' + value + '</span><span style="float:right">' + img + '</span>';
}*/
flex: 1,
dataIndex: 'name'
}
],
listeners: {
itemclick: function (grid, record) {
if (record == null)
return;

Ext.Ajax.request({
url: HABminBaseURL + "/config/designer/" + record.get("id"),
headers: {'Accept': 'application/json'},
method: 'GET',
success: function (response, opts) {
var json = Ext.decode(response.responseText);
if(json == null)
return;
var ruleDesigner = Ext.create('openHAB.automation.ruleProperties', {
ruleId: json.id,
blockly: {
blocks: json
}
});

if (ruleDesigner == null)
return;

Ext.getCmp('automationPropertyContainer').setNewProperty(ruleDesigner);
},
failure: function (result, request) {
handleStatusNotification(NOTIFICATION_ERROR,
sprintf(language.rule_ListGetError, options.config.name));
},
callback: function (options, success, response) {
// Enable toolbar
toolbar.getComponent('delete').enable();
}
});


}
}
});

this.items = ruleList;

this.callParent();


function deleteRule(button, text, options) {
if (button !== 'yes')
return;

// Tell OH to Remove the item
Ext.Ajax.request({
url: HABminBaseURL + "/config/designer/" + options.config.id,
headers: {'Accept': 'application/json'},
method: 'DELETE',
success: function (response, opts) {
handleStatusNotification(NOTIFICATION_OK,
sprintf(language.rule_ListDeleteOk, options.config.name));
},
failure: function (result, request) {
handleStatusNotification(NOTIFICATION_ERROR,
sprintf(language.rule_ListDeleteError, options.config.name));
},
callback: function (options, success, response) {
// Reload the store
designStore.reload();

// Disable delete
toolbar.getComponent('delete').disable();

// Clear the design
Ext.getCmp('automationPropertyContainer').removeProperty();
}
});
}
}
})
;
Loading

0 comments on commit fbf729e

Please sign in to comment.