Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
wizard: more work - add icon+text, and activate tabs according the co…
…nfiguration phase!
  • Loading branch information
perexg committed Dec 4, 2015
1 parent 38c6fc4 commit 605fd6b
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 12 deletions.
21 changes: 18 additions & 3 deletions src/api/api_wizard.c
Expand Up @@ -49,17 +49,31 @@ wizard_idnode_save_simple
}

static int
wizard_cancel
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
wizard_page
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp, const char *page )
{
pthread_mutex_lock(&global_lock);
free(config.wizard);
config.wizard = strdup("");
config.wizard = strdup(page);
config_save();
pthread_mutex_unlock(&global_lock);
return 0;
}

static int
wizard_cancel
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
return wizard_page(perm, opaque, op, args, resp, "");
}

static int
wizard_start
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
return wizard_page(perm, opaque, op, args, resp, "hello");
}

void
api_wizard_init ( void )
{
Expand All @@ -74,6 +88,7 @@ api_wizard_init ( void )
{ "wizard/status/save", ACCESS_ADMIN, wizard_idnode_save_simple, wizard_status },
{ "wizard/mapping/load", ACCESS_ADMIN, wizard_idnode_load_simple, wizard_mapping },
{ "wizard/mapping/save", ACCESS_ADMIN, wizard_idnode_save_simple, wizard_mapping },
{ "wizard/start", ACCESS_ADMIN, wizard_start, NULL },
{ "wizard/cancel", ACCESS_ADMIN, wizard_cancel, NULL },
{ NULL },
};
Expand Down
1 change: 1 addition & 0 deletions src/webui/static/app/acleditor.js
Expand Up @@ -21,6 +21,7 @@ tvheadend.acleditor = function(panel, index)
'channel_tag_exclude,channel_tag,comment';

tvheadend.idnode_grid(panel, {
id: 'access_entry',
url: 'api/access/entry',
titleS: _('Access Entry'),
titleP: _('Access Entries'),
Expand Down
1 change: 1 addition & 0 deletions src/webui/static/app/chconf.js
Expand Up @@ -193,6 +193,7 @@ tvheadend.channel_tab = function(panel, index)
};

tvheadend.idnode_grid(panel, {
id: 'channels',
url: 'api/channel',
all: 1,
comet: 'channel',
Expand Down
20 changes: 20 additions & 0 deletions src/webui/static/app/config.js
Expand Up @@ -4,13 +4,33 @@

tvheadend.baseconf = function(panel, index) {

var wizardButton = {
name: 'wizard',
builder: function() {
return new Ext.Toolbar.Button({
tooltip: _('Start initial configuration wizard'),
iconCls: 'wizard',
text: _('Start wizard')
});
},
callback: function(conf) {
tvheadend.Ajax({
url: 'api/wizard/start',
success: function() {
window.location.reload();
}
});
}
};

tvheadend.idnode_simple(panel, {
url: 'api/config',
title: _('Base'),
iconCls: 'baseconf',
tabIndex: index,
comet: 'config',
labelWidth: 250,
tbar: [wizardButton],
postsave: function(data, abuttons) {
var l = data['uilevel'];
if (l >= 0) {
Expand Down
12 changes: 12 additions & 0 deletions src/webui/static/app/ext.css
Expand Up @@ -596,6 +596,9 @@
background-image: url(../icons/arrow_right.png) !important;
}

.finish {
background-image: url(../icons/accept.png) !important;
}

.x-linked {
display: inline-block;
Expand Down Expand Up @@ -682,6 +685,15 @@
color: white;
}

.x-wizard-icon {
float: right;
}

.x-wizard-description {
margin: 5px;
font: normal 12px arial, tahoma, helvetica, sans-serif;
}

/* Table styles for webUI help */

.hts-doc-text table, .hts-doc-text th, .hts-doc-text td {
Expand Down
7 changes: 6 additions & 1 deletion src/webui/static/app/idnode.js
Expand Up @@ -1129,6 +1129,8 @@ tvheadend.idnode_editor = function(_uilevel, item, conf)
});

build();
if (conf.build)
conf.build(conf, panel);
return panel;
};

Expand All @@ -1141,7 +1143,7 @@ tvheadend.idnode_editor_win = function(_uilevel, item, conf)
var width = p.fixedWidth;
var w = new Ext.ux.Window({
title: conf.winTitle,
iconCls: 'edit',
iconCls: conf.iconCls || 'edit',
layout: 'fit',
autoWidth: width ? false : true,
autoHeight: true,
Expand Down Expand Up @@ -1929,6 +1931,7 @@ tvheadend.idnode_grid = function(panel, conf)
}

var dpanel = new Ext.Panel({
id: conf.id || null,
border: false,
header: false,
layout: 'fit',
Expand Down Expand Up @@ -2473,6 +2476,7 @@ tvheadend.idnode_tree = function(panel, conf)
}

var dpanel = new Ext.Panel({
id: conf.id || null,
border: false,
header: false,
layout: 'fit',
Expand Down Expand Up @@ -2703,6 +2707,7 @@ tvheadend.idnode_simple = function(panel, conf)
}

var dpanel = new Ext.Panel({
id: conf.id || null,
border: false,
header: false,
layout: 'fit',
Expand Down
1 change: 1 addition & 0 deletions src/webui/static/app/mpegts.js
Expand Up @@ -61,6 +61,7 @@ tvheadend.networks = function(panel, index)
}

tvheadend.idnode_grid(panel, {
id: 'mpegts_network',
url: 'api/mpegts/network',
titleS: _('Network'),
titleP: _('Networks'),
Expand Down
1 change: 1 addition & 0 deletions src/webui/static/app/status.js
Expand Up @@ -476,6 +476,7 @@ tvheadend.status_streams = function(panel, index)
}

var dpanel = new Ext.Panel({
id: 'status_streams',
border: false,
header: false,
layout: 'fit',
Expand Down
1 change: 1 addition & 0 deletions src/webui/static/app/tvadapters.js
@@ -1,6 +1,7 @@
tvheadend.tvadapters = function(panel, index) {

tvheadend.idnode_tree(panel, {
id: 'tvadapters',
url: 'api/hardware/tree',
title: _('TV adapters'),
iconCls: 'tvCards',
Expand Down
48 changes: 47 additions & 1 deletion src/webui/static/app/wizard.js
Expand Up @@ -5,6 +5,13 @@
tvheadend.wizard_start = function(page) {

var w = null;
var tabMapping = {
hello: 'access_entry',
network: 'mpegts_network',
input: 'tvadapters',
status: 'status_streams',
mapping: 'channels',
}

function cancel(conf) {
tvheadend.Ajax({
Expand All @@ -26,6 +33,17 @@ tvheadend.wizard_start = function(page) {
return null;
}

function getvalue(data, prefix) {
var m = data.params;
var l = prefix.length;
for (var i = 0; i < m.length; i++) {
var id = m[i].id;
if (id === prefix)
return m[i].value;
}
return null;
}

function newpage(conf, prefix) {
var p = getparam(conf.fullData, prefix);
if (p)
Expand All @@ -46,12 +64,28 @@ tvheadend.wizard_start = function(page) {
});
buttons.splice(0, 0, prevBtn);
}

function pbuild(conf, panel) {
var data = conf.fullData;
var icon = getvalue(data, 'icon');
var text = getvalue(data, 'description');
var c = '';
if (icon)
c += '<img class="x-wizard-icon" src="' + icon + '"/>';
c += '<div class="x-wizard-description">' + text + '</div>';
var p = new Ext.Panel({
width: 570,
html: c
});
panel.insert(0, p);
}

function build(d) {
d = json_decode(d);
var m = d[0];
var last = getparam(m, 'page_next_') === null;
tvheadend.idnode_editor_win('basic', m, {
build: pbuild,
fullData: m,
url: 'api/wizard/' + page,
winTitle: m.caption,
Expand All @@ -68,7 +102,7 @@ tvheadend.wizard_start = function(page) {
buildbtn: buildbtn,
labelWidth: 250,
saveText: last ? _('Finish') : _('Save & Next'),
saveIconCls: last ? 'exit' : 'next',
saveIconCls: last ? 'finish' : 'next',
cancel: cancel,
uilevel: 'expert',
help: function() {
Expand All @@ -78,6 +112,18 @@ tvheadend.wizard_start = function(page) {
}

tvheadend.wizard = page;

if (page in tabMapping) {
var i = Ext.getCmp(tabMapping[page]);
var c = i ? i.ownerCt : null;
while (c) {
if ('activeTab' in c)
c.setActiveTab(i);
i = c;
c = c.ownerCt;
}
}

tvheadend.Ajax({
url: 'api/wizard/' + page + '/load',
params: {
Expand Down

0 comments on commit 605fd6b

Please sign in to comment.