Skip to content

Commit

Permalink
Program Manager optimizations + Packages Repository Browser
Browse files Browse the repository at this point in the history
- Added Package Browser and Installer to the Maintenance page (wip)
- Fixed occasional "object reference not set" error when compiling/starting a program
- Added recursion check to scheduler event expressions
  • Loading branch information
genemars committed Jan 13, 2016
1 parent 92a0948 commit a56df5e
Show file tree
Hide file tree
Showing 13 changed files with 312 additions and 285 deletions.
2 changes: 1 addition & 1 deletion BaseFiles/Common/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ <h4 data-ui-field="namelabel"></h4>
</ul>
<br clear="all" />
<div align="center" style="font-size:9pt;position:absolute;left:0;right:0;bottom:0;height:30px">
HomeGenie &copy; 2011-2015
HomeGenie &copy; 2011-2016
<a href="https://github.com/genielabs/HomeGenie" target="_blank">G-Labs</a>
</div>
</div><!-- /panel -->
Expand Down
65 changes: 47 additions & 18 deletions BaseFiles/Common/html/pages/configure/maintenance/_maintenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,7 @@ HG.WebApp.Maintenance.InitializePage = function () {
var contentText = page.find('[data-ui-field=browser_text]');
contentText.css('height', availHeight/2);
contentText.css('max-height', availHeight/2);
});
page.find('[id=systemsettings_browserepo]').on('popupafteropen', function (event) {
}).on('popupafteropen', function (event) {
HG.WebApp.Maintenance.BrowseRoot();
});
page.find('[data-ui-field=parent_folder]').on('click', function() {
Expand All @@ -332,60 +331,90 @@ HG.WebApp.Maintenance.InitializePage = function () {
browse(history.pop());
}
});
page.find('[data-ui-field=repository_browse]').on('click', function() {
// reset history and browse to new repo
history = [];
page.find('[data-ui-field=repository_files]').empty();
HG.WebApp.Maintenance.BrowseRepository(page.find('[data-ui-field=repository_url]').val());
page.find('[data-ui-field=install_package]').on('click', function() {
// TODO: install current package
});
page.find('[data-ui-field=repository_btn_category]').on('click', function(){
HG.WebApp.Maintenance._BrowserCategory = $(this).attr('data-category');
page.find('[data-ui-field=repository_browse]').on('click', function() {
HG.WebApp.Maintenance.BrowseRoot();
});

});
};

HG.WebApp.Maintenance._BrowserHistory = [];
HG.WebApp.Maintenance._BrowserCategory = 'programs';
HG.WebApp.Maintenance.BrowseRoot = function() {
// reset history and browse to new repo
HG.WebApp.Maintenance._BrowserHistory = [];
var page = $('#'+HG.WebApp.Maintenance.PageId);
HG.WebApp.Maintenance.BrowseRepository(page.find('[data-ui-field=repository_url]').val()+'/'+HG.WebApp.Maintenance._BrowserCategory);
HG.WebApp.Maintenance.BrowseRepository({ url: page.find('[data-ui-field=repository_url]').val()+'/packages', name:'' });
};
HG.WebApp.Maintenance.BrowseRepository = function(path) {
var page = $('#'+HG.WebApp.Maintenance.PageId);
var list = page.find('[data-ui-field=repository_files]');
var text = page.find('[data-ui-field=browser_text]');
var text = page.find('[data-ui-field=description_text]');
var info = page.find('[data-ui-field=package_info]');
var popup = page.find('[id=systemsettings_browserepo]');
var browse = HG.WebApp.Maintenance.BrowseRepository;
var history = HG.WebApp.Maintenance._BrowserHistory;
history.push(path);
$.get(path, function(data){
list.empty();
// show/hide ui elements as needed
if (history.length > 1)
page.find('[data-ui-field=parent_folder]').show();
else
page.find('[data-ui-field=parent_folder]').hide();
page.find('[data-ui-field=install_package]').hide();
text.html('');
info.hide();
// show current path
var cpath = '';
$.each(history, function(idx, p){
cpath+='<strong>'+p.name+'</strong> / ';
});
page.find('[data-ui-field=browser_path]').html(cpath);
// get current folder files
list.empty();
$.mobile.loading('show');
$.get(path.url, function(data){
$.each(data, function(idx,file){
if (file.type == 'dir') {
console.log(file);
var item = $('<li><a href="#" class="ui-btn ui-btn-icon-left ui-icon-fa-folder">'+file.name+'</a></li>');
list.append(item);
item.on('click', function() {
browse(file.url);
browse({ url: file.url, name: file.name });
});
} else if (file.name.toLowerCase() == 'package.json') {
$.get(file.download_url, function(package) {
package = $.parseJSON(package);
var pkginfo = '<strong>Files</strong>: '
pkginfo += package.programs.length+' automation programs, ';
pkginfo += package.widgets.length+' ui widgets, ';
pkginfo += package.interfaces.length+' mig interfaces';
pkginfo += '<br/><strong>Version</strong>: '+package.version;
pkginfo += '<br/><strong>Published</strong>: '+package.published;
pkginfo += '<br/><strong>Author</strong>: '+package.author;
pkginfo += '<br/><a href="'+package.homepage+'" target="_blank">Forum Thread</a><br/>';
info.html(pkginfo);
info.show();
page.find('[data-ui-field=browser_text]').scrollTop(0);
});
page.find('[data-ui-field=install_package]').show();
} else if (file.name.toLowerCase().endsWith('.md')) {
$.get(file.download_url, function(readme) {
text.html(markdown.toHTML(readme));
page.find('[data-ui-field=browser_text]').scrollTop(0);
});
} else if (file.type == 'file') {
var item = $('<li><a href="#" class="ui-btn ui-btn-icon-left ui-icon-fa-file-code-o">'+file.name+'</a></li>');
list.append(item);
item.on('click', function() {
//_this.ListFiles(file.url);
console.log(file);
//console.log(file);
});
}
});
list.listview().listview('refresh');
setTimeout(function(){
popup.popup().popup('reposition', { positionTo: 'window' });
$.mobile.loading('hide');
}, 300);
});
};
Expand Down
29 changes: 15 additions & 14 deletions BaseFiles/Common/html/pages/configure/maintenance/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ <h3><span data-locale-id="configure_system_options">System Options</span></h3>
</div>
</div>

<!--hr style="border:1px dotted black" /-->
<div class="ui-grid-a" style="display:none">
<hr style="border:1px dotted black" />
<div class="ui-grid-a">
<div class="ui-block-a">
<label data-locale-id="configure_system_addonsrepository">Install Add-on</label><br />
<label data-locale-id="configure_system_packagerepository">Install Package</label><br />
</div>
<div class="ui-block-b" style="float:right;width:150px">
<a href="#systemsettings_browserepo" data-rel="popup" data-transition="pop" class="ui-btn ui-corner-all" data-locale-id="configure_system_browserepository">
Expand Down Expand Up @@ -465,38 +465,39 @@ <h1 data-locale-id="configure_system_statistics_databasemaxsizechange">Maximum S
<div class="ui-corner-top" data-role="header">
<h2 data-locale-id="configure_system_browserepo">Repository Browser</h2>
<div class="ui-grid-b">
<div class="ui-block-a" style="width:5%;;padding-top:10px;padding-right:4px" align="right">
<div class="ui-block-a" style="width:5%;;padding-top:12px;padding-right:6px" align="right">
<i class="fa fa-globe fa-2x"></i>
</div>
<div class="ui-block-b" style="width:80%">
<input data-ui-field="repository_url" type="text" value="https://api.github.com/repos/genielabs/homegenie-addons/contents" />
<input data-ui-field="repository_url" type="text" value="https://api.github.com/repos/genielabs/homegenie-packages/contents" />
</div>
<div class="ui-block-c" style="width:15%" align="left">
<a data-ui-field="repository_browse" href="#" class="ui-btn ui-corner-all ui-btn-icon-left ui-icon-fa-github">Browse</a>
</div>
</div>
<div data-role="navbar" style="padding-right:4px">
<ul>
<li><a data-ui-field="repository_btn_category" data-category="programs" href="#" data-ajax="false" data-theme="b" class="ui-btn ui-btn-icon-left ui-icon-fa-code ui-btn-active">Programs</a></li>
<li><a data-ui-field="repository_btn_category" data-category="widgets" href="#" data-ajax="false" data-theme="b" class="ui-btn ui-btn-icon-left ui-icon-fa-cube">Widgets</a></li>
<li><a data-ui-field="repository_btn_category" data-category="interfaces" href="#" data-ajax="false" data-theme="b" class="ui-btn ui-btn-icon-left ui-icon-fa-wrench">MIG Interfaces</a></li>
</ul>
<div style="padding-left:8px">
<p data-ui-field="browser_path">current path</p>
</div>
</div>

<div>
<div class="ui-content trapScroll" data-ui-field="browser_files" style="height:180px;max-height:180px;overflow-y:scroll;overflow-x:hidden;">
<ul data-ui-field="repository_files"></ul>
</div>
<div data-ui-field="browser_text" class="trapScroll" style="border-top:2px solid gray;padding-left:10px;padding-right:10px;height:180px;max-height:180px;overflow-y:scroll;overflow-x:hidden;">
<div data-ui-field="browser_text" class="trapScroll" style="border-top:2px solid gray;height:180px;max-height:180px;overflow-y:scroll;overflow-x:hidden;">
<div data-ui-field="description_text" style="padding-left:10px;padding-right:10px;"></div>
<div class="ui-bar-inherit" data-ui-field="package_info" style="padding:10px;font-weight:normal"></div>
</div>
</div>

<div class="ui-grid-a ui-footer ui-bar-inherit">
<div class="ui-grid-b ui-footer ui-bar-inherit">
<div class="ui-block-a">
<a data-ui-field="parent_folder" class="ui-btn ui-shadow ui-corner-all ui-icon-back ui-btn-icon-left">Back</a>
</div>
<div class="ui-block-b" align="right">
<div class="ui-block-b" align="center">
<a data-ui-field="install_package" class="ui-btn ui-shadow ui-corner-all ui-icon-fa-download ui-btn-icon-left">Install Package</a>
</div>
<div class="ui-block-c" align="right">
<a class="ui-btn ui-corner-all ui-icon-delete ui-btn-icon-right" data-mini="true" href="#" data-rel="back">Close</a>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions HISTORY.TXT
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
RELEASE HISTORY

13/01/2016 v1.1-beta.513-wip
- Added Package Browser and Installer to the Maintenance page (wip)
- Fixed occasional "object reference not set" error when compiling/starting a program
- Added recursion check to scheduler event expressions
- Fixed bug in evaluating composite scheduler events using names (@)

Expand Down
Loading

0 comments on commit a56df5e

Please sign in to comment.