Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
wizard: hello (login/passwords) page works now
  • Loading branch information
perexg committed Dec 9, 2015
1 parent fe15abf commit 7b95b15
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 41 deletions.
45 changes: 31 additions & 14 deletions src/access.c
Expand Up @@ -1087,10 +1087,14 @@ access_entry_create(const char *uuid, htsmsg_t *conf)
/**
*
*/
static void
access_entry_destroy(access_entry_t *ae)
void
access_entry_destroy(access_entry_t *ae, int delconf)
{
access_ipmask_t *ai;
char ubuf[UUID_HEX_SIZE];

if (delconf)
hts_settings_remove("accesscontrol/%s", idnode_uuid_as_str(&ae->ae_id, ubuf));

TAILQ_REMOVE(&access_entries, ae, ae_link);
idnode_unlink(&ae->ae_id);
Expand Down Expand Up @@ -1185,10 +1189,7 @@ static void
access_entry_class_delete(idnode_t *self)
{
access_entry_t *ae = (access_entry_t *)self;
char ubuf[UUID_HEX_SIZE];

hts_settings_remove("accesscontrol/%s", idnode_uuid_as_str(&ae->ae_id, ubuf));
access_entry_destroy(ae);
access_entry_destroy(ae, 1);
}

static void
Expand Down Expand Up @@ -1602,6 +1603,13 @@ const idclass_t access_entry_class = {
.name = N_("Comment"),
.off = offsetof(access_entry_t, ae_comment),
},
{
.type = PT_BOOL,
.id = "wizard",
.name = N_("Wizard"),
.off = offsetof(access_entry_t, ae_wizard),
.opts = PO_NOUI
},
{}
}
};
Expand Down Expand Up @@ -1704,11 +1712,16 @@ passwd_entry_create(const char *uuid, htsmsg_t *conf)
return pw;
}

static void
passwd_entry_destroy(passwd_entry_t *pw)
void
passwd_entry_destroy(passwd_entry_t *pw, int delconf)
{
char ubuf[UUID_HEX_SIZE];

if (pw == NULL)
return;

if (delconf)
hts_settings_remove("passwd/%s", idnode_uuid_as_str(&pw->pw_id, ubuf));
TAILQ_REMOVE(&passwd_entries, pw, pw_link);
idnode_unlink(&pw->pw_id);
free(pw->pw_username);
Expand Down Expand Up @@ -1738,10 +1751,7 @@ static void
passwd_entry_class_delete(idnode_t *self)
{
passwd_entry_t *pw = (passwd_entry_t *)self;
char ubuf[UUID_HEX_SIZE];

hts_settings_remove("passwd/%s", idnode_uuid_as_str(&pw->pw_id, ubuf));
passwd_entry_destroy(pw);
passwd_entry_destroy(pw, 1);
}

static const char *
Expand Down Expand Up @@ -1838,6 +1848,13 @@ const idclass_t passwd_entry_class = {
.name = N_("Comment"),
.off = offsetof(passwd_entry_t, pw_comment),
},
{
.type = PT_BOOL,
.id = "wizard",
.name = N_("Wizard"),
.off = offsetof(passwd_entry_t, pw_wizard),
.opts = PO_NOUI
},
{}
}
};
Expand Down Expand Up @@ -2070,11 +2087,11 @@ access_done(void)

pthread_mutex_lock(&global_lock);
while ((ae = TAILQ_FIRST(&access_entries)) != NULL)
access_entry_destroy(ae);
access_entry_destroy(ae, 0);
while ((at = TAILQ_FIRST(&access_tickets)) != NULL)
access_ticket_destroy(at);
while ((pw = TAILQ_FIRST(&passwd_entries)) != NULL)
passwd_entry_destroy(pw);
passwd_entry_destroy(pw, 0);
while ((ib = TAILQ_FIRST(&ipblock_entries)) != NULL)
ipblock_entry_destroy(ib);
free((void *)superuser_username);
Expand Down
10 changes: 10 additions & 0 deletions src/access.h
Expand Up @@ -58,6 +58,7 @@ typedef struct passwd_entry {
char *pw_password2;

int pw_enabled;
int pw_wizard;

char *pw_comment;
} passwd_entry_t;
Expand Down Expand Up @@ -97,6 +98,7 @@ typedef struct access_entry {
char *ae_lang_ui;

int ae_index;
int ae_wizard;
int ae_enabled;
int ae_uilevel;
int ae_uilevel_nochange;
Expand Down Expand Up @@ -265,6 +267,12 @@ access_get_by_addr(struct sockaddr *src);
access_entry_t *
access_entry_create(const char *uuid, htsmsg_t *conf);

/**
*
*/
void
access_entry_destroy(access_entry_t *ae, int delconf);

/**
*
*/
Expand All @@ -287,6 +295,8 @@ access_destroy_by_channel_tag(struct channel_tag *ct, int delconf);
passwd_entry_t *
passwd_entry_create(const char *uuid, htsmsg_t *conf);
void
passwd_entry_destroy(passwd_entry_t *ae, int delconf);
void
passwd_entry_save(passwd_entry_t *pw);

/**
Expand Down
14 changes: 11 additions & 3 deletions src/webui/static/app/idnode.js
Expand Up @@ -1202,6 +1202,11 @@ tvheadend.idnode_editor_win = function(_uilevel, conf)
conf.win = null;
}

if (conf.fullData) {
display(conf.fullData, conf, conf.winTitle || _('Edit'));
return;
}

var params = conf.params || {};

var uuids = null;
Expand Down Expand Up @@ -1229,7 +1234,7 @@ tvheadend.idnode_editor_win = function(_uilevel, conf)
d = d[0];
if (conf.modifyData)
conf.modifyData(conf, d);
var title = conf.title;
var title = conf.winTitle;
if (!title) {
if (uuids && uuids.length > 1)
title = String.format(_('Edit {0} ({1} entries)'),
Expand Down Expand Up @@ -1545,8 +1550,10 @@ tvheadend.idnode_grid = function(panel, conf)
grid.getView().refresh();
};

function build(d)
{
function build(d) {
if (grid)
return;

if (conf.builder)
conf.builder(conf);

Expand Down Expand Up @@ -2483,6 +2490,7 @@ tvheadend.idnode_tree = function(panel, conf)
function builder() {
if (tree)
return;

if (conf.builder)
conf.builder(conf);

Expand Down
17 changes: 9 additions & 8 deletions src/webui/static/app/tvheadend.js
Expand Up @@ -51,14 +51,15 @@ tvheadend.uilevel_match = function(target, current) {
*/
tvheadend.select_tab = function(id)
{
var i = Ext.getCmp(id);
var c = i ? i.ownerCt : null;
while (c) {
if ('activeTab' in c)
c.setActiveTab(i);
i = c;
c = c.ownerCt;
}
var i = Ext.getCmp(id);
var c = i ? i.ownerCt : null;
while (c) {
if ('activeTab' in c) {
c.setActiveTab(i);
}
i = c;
c = c.ownerCt;
}
}

/**
Expand Down
23 changes: 19 additions & 4 deletions src/webui/static/app/wizard.js
Expand Up @@ -2,6 +2,8 @@
* Wizard
*/

tvheadend.wizard_delayed_activation = null;

tvheadend.wizard_start = function(page) {

var w = null;
Expand All @@ -20,6 +22,8 @@ tvheadend.wizard_start = function(page) {
tvheadend.wizard = null;
if (conf.win)
conf.win.close();
tvheadend.wizard_delayed_activation.cancel();
tvheadend.wizard_delayed_activation = null;
}

function getparam(data, prefix) {
Expand Down Expand Up @@ -90,10 +94,10 @@ tvheadend.wizard_start = function(page) {
d = json_decode(d);
var m = d[0];
var last = getparam(m, 'page_next_') === null;
tvheadend.idnode_editor_win('basic', m, {
tvheadend.idnode_editor_win('basic', {
build: pbuild,
fullData: m,
url: 'api/wizard/' + page,
saveURL: 'api/wizard/' + page + '/save',
winTitle: m.caption,
iconCls: 'wizard',
comet: m.events,
Expand All @@ -117,10 +121,19 @@ tvheadend.wizard_start = function(page) {
});
}

function activate_tab() {
if (page in tabMapping)
tvheadend.select_tab(tabMapping[page]);
}

tvheadend.wizard = page;

if (page in tabMapping)
tvheadend.select_tab(tabMapping[page]);
var delay = 1000;
if (tvheadend.wizard_delayed_activation == null) {
tvheadend.wizard_delayed_activation = new Ext.util.DelayedTask();
delay = 1;
}
tvheadend.wizard_delayed_activation.delay(1000, activate_tab);

tvheadend.Ajax({
url: 'api/wizard/' + page + '/load',
Expand All @@ -130,6 +143,8 @@ tvheadend.wizard_start = function(page) {
success: build,
failure: function(response, options) {
Ext.MessageBox.alert(_('Unable to obtain wizard page!'), response.statusText);
tvheadend.wizard_delayed_activation.cancel();
tvheadend.wizard_delayed_activation = null;
}
});

Expand Down

0 comments on commit 7b95b15

Please sign in to comment.