diff --git a/mailadmin/static/app/scripts/main.js b/mailadmin/static/app/scripts/main.js index e27795d..25b870b 100644 --- a/mailadmin/static/app/scripts/main.js +++ b/mailadmin/static/app/scripts/main.js @@ -1,49 +1,234 @@ -$(document).ready(function() { - nunjucks.configure({ autoescape: true }); - var api_urls = { - fwd_list: '/api/forwards/', - fwd_delete: '/api/forward/', - fwd_create: '/api/forward/', - ou_list: '/api/orgunits/', - me: '/api/me/', - }; - if( $('body.home').length ) { - $.getJSON(api_urls.ou_list, function(data) { - var ou_html = nunjucks.render('orgunits.html', { - orgunits: data, - api_urls: api_urls - }); - - $(".orgunit-list").append(ou_html); - - /* Add listeners */ - $(".orgunit-list a").on('click', function(e) { - e.preventDefault(); - $(".orgunit-list li").removeClass('active'); - $(this).parent().toggleClass('active'); - // TODO: you are here - }); - }); - - $.getJSON(api_urls.fwd_list, function(data) { - if( !data.cpanelresult ) { - $(".forwards-container").html("No results."); - return; - } - - var forwards = data.cpanelresult.data; - var lists =_.groupBy(forwards, function(fwd) { return fwd.dest; }); - - var fw_html = nunjucks.render('list.html', { - lists: lists, - api_urls: api_urls - }); - - $(".forwards-container").html(fw_html); - - $("input[name=fwd-delete]").click(function() { - $(this).parent().parent().toggleClass('danger'); - }); - }); +(function() { + 'use strict'; + /*global moment, jQuery, document, _, $, window, List */ + function getParameterByName(name) { + name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); + var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), + results = regex.exec(location.search); + return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); } -}); \ No newline at end of file + + function parseEmails(text) { + if(text === undefined || text === "") { + return []; + } + /* Get each word from the text, split by spaces, end line, semicolon, + quotes, commas, colons, parens and brackets. */ + var words = text.split(/[\s\n;"',;:()<>[\]\\]+/), + emails = [], + distinct_emails; + + // Regex for identifying an email address. + var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + + // For each of the words, add to the array of emails if the word matches the email regex. + emails = _.filter(words, function(word) { + return word.match(re); + }); + emails = _.map(emails, function(el) { + return el.toLowerCase(); + }); + + return _.unique(emails); + } + function render_alert(msg, cssClass) { + return nunjucks.render('alert.html', {'msg': msg, 'cssClass': cssClass}); + } + + + $(document).ready(function() { + var csrf_token = $('meta[name=x-csrf-token]').attr('content'); + var api_urls = { + fwd_list: '/api/forwards/', + fwd_delete: '/api/forward/', + fwd_create: '/api/forward/', // + forwarder + ou_list: '/api/orgunits/', + me: '/api/me/', + }; + nunjucks.configure({ autoescape: true }); + + /* Home view (lists) */ + if( $('body.home').length ) { + $.getJSON(api_urls.ou_list, function(data) { + var ou_html = nunjucks.render('orgunits.html', { + orgunits: data, + api_urls: api_urls + }); + + $(".orgunit-list").append(ou_html); + + /* New list */ + var new_list_html = nunjucks.render('new_list.html', { + orgunits: data, + api_urls: api_urls + }); + + $('.new-list').html(new_list_html); + $('.new-list .js-new-list-name').on('keyup', function(e) { + var new_list_name = $('.new-list .js-new-list-name').val(); + if(new_list_name === '') { + new_list_name = 'Ny liste'; + } else { + var prefix = $('.new-list .prefix-select .active').attr('data-value'); + new_list_name = 'NY: ' + prefix + new_list_name + "@studentersamfundet.no"; + } + $('.new-list .panel-heading').text(new_list_name); + }); + $('.new-list textarea').on('keyup', function(e) { + var text = $(this).val(); + var emails = parseEmails(text); + + if(emails.length > 0) { + $('.new-list .email-counter').text(emails.length); + } else { + $('.new-list .email-counter').text(''); + } + }); + $('.js-add-list').on('click', function(e) { + $('.new-list .result').html(''); // reset errors + e.preventDefault(); + /* Validate */ + var new_list_name = $('.new-list .js-new-list-name').val(); + if(new_list_name.length === 0) { + $('.new-list-result').html(render_alert('Navn på epostliste mangler', 'danger')); + return; + } + var text = $('.new-list textarea').val(); + var emails = parseEmails(text); + if(emails.length === 0) { + $('.new-list-result').html(render_alert('Ingen eposter i epost-feltet...', 'danger')); + return; + } + // Valid form + var prefix = $('.new-list .prefix-select .active').attr('data-value'); + var dest = prefix + new_list_name + "@studentersamfundet.no"; + + var new_list = {}; + new_list[dest] = _.map(emails, function(el) { + return {'dest': dest, 'forward': el}; + }); + + var deferreds = []; + $.each(new_list[dest], function(i, el) { + el.csrfmiddlewaretoken = csrf_token; + deferreds.push($.post(api_urls.fwd_create, el, function() {}, 'json')); + }); + $.when.apply($, deferreds).then(function(){ + // Success + $('.new-list-result').html(render_alert('Lagt til ny liste: ' + dest, 'success')); + $('.new-list textarea').val(''); + $('.new-list .js-new-list-name').val(''); + }).fail(function(err){ + $('.new-list-result').html(render_alert('Kunne ikke opprette ny liste \'' + dest +'\': '+ err, 'danger')); + }); + var added_list_html = nunjucks.render('list.html', { + lists: new_list, + }); + $(".forwards-container").prepend(added_list_html); + + }); + + /* Add list filter listeners */ + $(".orgunit-list a").on('click', function(e) { + var prefix = $(this).attr('data-prefix'); + var querystring = $(this).attr('href'); + e.preventDefault(); + + /* Toggle selection */ + $(".orgunit-list li").removeClass('active'); + $(this).parent().toggleClass('active'); + + /* Update query string */ + window.history.pushState(null, null, querystring); + + /* Filter lists */ + var re_prefix = new RegExp('^'+prefix); + $(".fwdlist").each(function(el) { + var cur_name = $(this).attr('data-list-name'); + if(re_prefix.test(cur_name)) { + $(this).removeClass('hidden'); + } else { + $(this).addClass('hidden'); + } + }); + }); + }); + + /* Load lists */ + $.getJSON(api_urls.fwd_list, function(data) { + if( !data.cpanelresult ) { + $(".forwards-container").html("No results."); + return; + } + + var forwards = data.cpanelresult.data; + var lists =_.groupBy(forwards, function(fwd) { return fwd.dest; }); + var fw_html = nunjucks.render('list.html', { + lists: lists, + api_urls: api_urls + }); + + $(".forwards-container").html(fw_html); + + /* Toggle delete state */ + $("input[name=fwd-delete]").click(function() { + $(this).parent().parent().parent().toggleClass('danger'); + }); + }); + + $(".forwards-container").on('click', function(e) { + /* Add to delete selection */ + var target = $(e.target); + if( target.attr('name') == 'fwd-delete' ) { + var tbody = target.closest('tbody'); + var num_selected = tbody.find("[name=fwd-delete]:checked").length; + if(num_selected > 0) { + tbody.find('.btn-del').addClass('visible'); + } else { + tbody.find('.btn-del').removeClass('visible'); + } + } + /* Delete selected */ + else if( target.hasClass('js-del-selected') ) { + var list_name = target.attr('data-delete-list-name'); + var checked = $('[data-list-name="'+list_name+'"] [name="fwd-delete"]:checked'); + var delete_these = _.map(checked, function(el) { + return $(el).val(); + }); + var deferreds = []; + $.each(delete_these, function(i, el) { + var data = { + type: 'DELETE', + headers: {'X-CSRFToken': csrf_token}, + url: api_urls.fwd_delete + el + '/', + dataType: 'json' + }; + deferreds.push($.ajax(data)); + }); + $.when.apply($, deferreds).then(function(){ + // Success + checked.closest('tr').remove(); + // TODO remove list if no more rows + }).fail(function(err){ + $('[data-list-name="'+list_name+'"] .result-alert').html(render_alert('Kunne ikke fjerne epostaliaser', 'danger')); + }); + } + /* Add new */ + else if( target.hasClass('js-new-email') ) { + // TODO not working + var email_field = target.parent().parent().find('[name=new-email]'); + console.log(email_field); + if(email_field.get(0).checkValidity() === false) { + return true; + } + e.preventDefault(); + console.log(email_field.val()); + } + }); + /* New list toggle display */ + $('.new-list-btn').on('click', function() { + $('.new-list').toggleClass('visible'); + }); + } + }); +})(); \ No newline at end of file diff --git a/mailadmin/static/app/styles/main.scss b/mailadmin/static/app/styles/main.scss index 18a6a99..cbf2e31 100644 --- a/mailadmin/static/app/styles/main.scss +++ b/mailadmin/static/app/styles/main.scss @@ -1,8 +1,10 @@ +$icon-font-path: "../fonts/"; + @import "../../bower_components/bootstrap-sass-official/vendor/assets/stylesheets/bootstrap"; .login-form { margin: 0 auto; - max-width: 400px; + max-width: 300px; float: none; input[type=submit] { float: right; @@ -42,4 +44,58 @@ body { height: 100px; background-color: #f5f5f5; padding-top: 20px; +} + +/* Lists */ +.del-header { + text-align: center; + width: 82px; +} +.del-cell { + padding: 0 !important; +} +.del-label { + display: block; + height: 30px; + margin: 0; + text-align: center; + input { + margin: 0; + position: relative; + top: 6px; + } +} +.btn-del { + display: none; + &.visible { + display: block; + } +} +.forwards-container table > thead > tr > th:first-child, +.forwards-container table > tbody > tr > td:first-child + { + padding-left: 16px; +} +.forwards-container .badge { + float: right; + margin-right: 14px; +} +.new-list-btn { + margin-bottom: 20px; +} +.new-list { + display: none; + &.visible { + display: block; + } +} +.btn-add-list { + float: right; + margin-top: 10px; +} +/* Responsive fixes */ +@media(max-width: $screen-xs-max){ + td { + font-size: 13px; + } } \ No newline at end of file diff --git a/mailadmin/static/app/templates/alert.html b/mailadmin/static/app/templates/alert.html new file mode 100644 index 0000000..89c0ec9 --- /dev/null +++ b/mailadmin/static/app/templates/alert.html @@ -0,0 +1,4 @@ +
+ × + {{ msg }} +
\ No newline at end of file diff --git a/mailadmin/static/app/templates/list.html b/mailadmin/static/app/templates/list.html index a5d15f5..4508d5e 100644 --- a/mailadmin/static/app/templates/list.html +++ b/mailadmin/static/app/templates/list.html @@ -1,23 +1,27 @@ {% for list,members in lists %} -
+
{{ list }} {{members|length}}
- + {% for member in members %} - + {% endfor %} - +
MedlemSlettVelg
{{ member.forward }}
{{ member.forward }}
-
-
+
+ + +
+
+
{% endfor %} \ No newline at end of file diff --git a/mailadmin/static/app/templates/new_list.html b/mailadmin/static/app/templates/new_list.html new file mode 100644 index 0000000..a38d4d1 --- /dev/null +++ b/mailadmin/static/app/templates/new_list.html @@ -0,0 +1,20 @@ +
+
Ny liste
+
+
+ + + + + + @studentersamfundet.no +
+

Eposter

+ + +
+
\ No newline at end of file diff --git a/mailadmin/static/app/templates/orgunits.html b/mailadmin/static/app/templates/orgunits.html index 72734c0..19a8716 100644 --- a/mailadmin/static/app/templates/orgunits.html +++ b/mailadmin/static/app/templates/orgunits.html @@ -1,3 +1,3 @@ {% for ou in orgunits %} -
  • {{ ou.name }}
  • +
  • {{ ou.name }}
  • {% endfor %} \ No newline at end of file diff --git a/mailadmin/static/dist/scripts/main.js b/mailadmin/static/dist/scripts/main.js index e27795d..8c01055 100644 --- a/mailadmin/static/dist/scripts/main.js +++ b/mailadmin/static/dist/scripts/main.js @@ -1,49 +1,235 @@ -$(document).ready(function() { - nunjucks.configure({ autoescape: true }); - var api_urls = { - fwd_list: '/api/forwards/', - fwd_delete: '/api/forward/', - fwd_create: '/api/forward/', - ou_list: '/api/orgunits/', - me: '/api/me/', - }; - if( $('body.home').length ) { - $.getJSON(api_urls.ou_list, function(data) { - var ou_html = nunjucks.render('orgunits.html', { - orgunits: data, - api_urls: api_urls - }); - - $(".orgunit-list").append(ou_html); - - /* Add listeners */ - $(".orgunit-list a").on('click', function(e) { - e.preventDefault(); - $(".orgunit-list li").removeClass('active'); - $(this).parent().toggleClass('active'); - // TODO: you are here - }); - }); - - $.getJSON(api_urls.fwd_list, function(data) { - if( !data.cpanelresult ) { - $(".forwards-container").html("No results."); - return; - } - - var forwards = data.cpanelresult.data; - var lists =_.groupBy(forwards, function(fwd) { return fwd.dest; }); - - var fw_html = nunjucks.render('list.html', { - lists: lists, - api_urls: api_urls - }); - - $(".forwards-container").html(fw_html); - - $("input[name=fwd-delete]").click(function() { - $(this).parent().parent().toggleClass('danger'); - }); - }); +(function() { + 'use strict'; + /*global moment, jQuery, document, _, $, window, List */ + function getParameterByName(name) { + name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); + var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), + results = regex.exec(location.search); + return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); } -}); \ No newline at end of file + + function parseEmails(text) { + if(text === undefined || text === "") { + return []; + } + /* Get each word from the text, split by spaces, end line, semicolon, quotes, commas, colons, parens, + and brackets. + */ + var words = text.split(/[\s\n;"',;:()<>[\]\\]+/), + emails = [], + distinct_emails; + + // Regex for identifying an email address. + var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + + // For each of the words, add to the array of emails if the word matches the email regex. + emails = _.filter(words, function(word) { + return word.match(re); + }); + emails = _.map(emails, function(el) { + return el.toLowerCase(); + }); + + return _.unique(emails); + } + function render_alert(msg, cssClass) { + return nunjucks.render('alert.html', {'msg': msg, 'cssClass': cssClass}); + } + + + $(document).ready(function() { + var csrf_token = $('meta[name=x-csrf-token]').attr('content'); + var api_urls = { + fwd_list: '/api/forwards/', + fwd_delete: '/api/forward/', + fwd_create: '/api/forward/', // + forwarder + ou_list: '/api/orgunits/', + me: '/api/me/', + }; + nunjucks.configure({ autoescape: true }); + + /* Home view (lists) */ + if( $('body.home').length ) { + $.getJSON(api_urls.ou_list, function(data) { + var ou_html = nunjucks.render('orgunits.html', { + orgunits: data, + api_urls: api_urls + }); + + $(".orgunit-list").append(ou_html); + + /* New list */ + var new_list_html = nunjucks.render('new_list.html', { + orgunits: data, + api_urls: api_urls + }); + + $('.new-list').html(new_list_html); + $('.new-list .js-new-list-name').on('keyup', function(e) { + var new_list_name = $('.new-list .js-new-list-name').val(); + if(new_list_name === '') { + new_list_name = 'Ny liste'; + } else { + var prefix = $('.new-list .prefix-select .active').attr('data-value'); + new_list_name = 'NY: ' + prefix + new_list_name + "@studentersamfundet.no"; + } + $('.new-list .panel-heading').text(new_list_name); + }); + $('.new-list textarea').on('keyup', function(e) { + var text = $(this).val(); + var emails = parseEmails(text); + + if(emails.length > 0) { + $('.new-list .email-counter').text(emails.length); + } else { + $('.new-list .email-counter').text(''); + } + }); + $('.js-add-list').on('click', function(e) { + $('.new-list .result').html(''); // reset errors + e.preventDefault(); + /* Validate */ + var new_list_name = $('.new-list .js-new-list-name').val(); + if(new_list_name.length === 0) { + $('.new-list-result').html(render_alert('Navn på epostliste mangler', 'danger')); + return; + } + var text = $('.new-list textarea').val(); + var emails = parseEmails(text); + if(emails.length === 0) { + $('.new-list-result').html(render_alert('Ingen eposter i epost-feltet...', 'danger')); + return; + } + // Valid form + var prefix = $('.new-list .prefix-select .active').attr('data-value'); + var dest = prefix + new_list_name + "@studentersamfundet.no"; + + var new_list = {}; + new_list[dest] = _.map(emails, function(el) { + return {'dest': dest, 'forward': el}; + }); + + var deferreds = []; + $.each(new_list[dest], function(i, el) { + el.csrfmiddlewaretoken = csrf_token; + deferreds.push($.post(api_urls.fwd_create, el, function() {}, 'json')); + }); + $.when.apply($, deferreds).then(function(){ + // Success + $('.new-list-result').html(render_alert('Lagt til ny liste: ' + dest, 'success')); + $('.new-list textarea').val(''); + $('.new-list .js-new-list-name').val(''); + }).fail(function(err){ + $('.new-list-result').html(render_alert('Kunne ikke opprette ny liste \'' + dest +'\': '+ err, 'danger')); + }); + var added_list_html = nunjucks.render('list.html', { + lists: new_list, + }); + $(".forwards-container").prepend(added_list_html); + + }); + + /* Add list filter listeners */ + $(".orgunit-list a").on('click', function(e) { + var prefix = $(this).attr('data-prefix'); + var querystring = $(this).attr('href'); + e.preventDefault(); + + /* Toggle selection */ + $(".orgunit-list li").removeClass('active'); + $(this).parent().toggleClass('active'); + + /* Update query string */ + window.history.pushState(null, null, querystring); + + /* Filter lists */ + var re_prefix = new RegExp('^'+prefix); + $(".fwdlist").each(function(el) { + var cur_name = $(this).attr('data-list-name'); + if(re_prefix.test(cur_name)) { + $(this).removeClass('hidden'); + } else { + $(this).addClass('hidden'); + } + }); + }); + }); + + /* Load lists */ + $.getJSON(api_urls.fwd_list, function(data) { + if( !data.cpanelresult ) { + $(".forwards-container").html("No results."); + return; + } + + var forwards = data.cpanelresult.data; + var lists =_.groupBy(forwards, function(fwd) { return fwd.dest; }); + var fw_html = nunjucks.render('list.html', { + lists: lists, + api_urls: api_urls + }); + + $(".forwards-container").html(fw_html); + + /* Toggle delete state */ + $("input[name=fwd-delete]").click(function() { + $(this).parent().parent().parent().toggleClass('danger'); + }); + }); + + $(".forwards-container").on('click', function(e) { + /* Add to delete selection */ + var target = $(e.target); + if( target.attr('name') == 'fwd-delete' ) { + var tbody = target.closest('tbody'); + var num_selected = tbody.find("[name=fwd-delete]:checked").length; + if(num_selected > 0) { + tbody.find('.btn-del').addClass('visible'); + } else { + tbody.find('.btn-del').removeClass('visible'); + } + } + /* Delete selected */ + else if( target.hasClass('js-del-selected') ) { + var list_name = target.attr('data-delete-list-name'); + var checked = $('[data-list-name="'+list_name+'"] [name="fwd-delete"]:checked'); + var delete_these = _.map(checked, function(el) { + return $(el).val(); + }); + var deferreds = []; + $.each(delete_these, function(i, el) { + var data = { + type: 'DELETE', + headers: {'X-CSRFToken': csrf_token}, + url: api_urls.fwd_delete + el + '/', + dataType: 'json' + }; + deferreds.push($.ajax(data)); + }); + $.when.apply($, deferreds).then(function(){ + // Success + checked.closest('tr').remove(); + // TODO remove list if no more rows + }).fail(function(err){ + $('[data-list-name="'+list_name+'"] .result-alert').html(render_alert('Kunne ikke fjerne epostaliaser', 'danger')); + }); + } + /* Add new */ + else if( target.hasClass('js-new-email') ) { + // TODO not working + var email_field = target.parent().parent().find('[name=new-email]'); + console.log(email_field); + if(email_field.get(0).checkValidity() === false) { + return true; + } + e.preventDefault(); + console.log(email_field.val()); + } + }); + /* New list toggle display */ + $('.new-list-btn').on('click', function() { + $('.new-list').toggleClass('visible'); + }); + } + }); +})(); \ No newline at end of file diff --git a/mailadmin/static/dist/scripts/templates.js b/mailadmin/static/dist/scripts/templates.js index fefaecc..cc52c00 100644 --- a/mailadmin/static/dist/scripts/templates.js +++ b/mailadmin/static/dist/scripts/templates.js @@ -1,3 +1,25 @@ +(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["alert.html"] = (function() {function root(env, context, frame, runtime, cb) { +var lineno = null; +var colno = null; +var output = ""; +try { +output += "
    \n\t×\n\t"; +output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "msg"), env.autoesc); +output += "\n
    "; +cb(null, output); +; +} catch (e) { + cb(runtime.handleError(e, lineno, colno)); +} +} +return { +root: root +}; +})(); +})(); + (function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["list.html"] = (function() {function root(env, context, frame, runtime, cb) { var lineno = null; var colno = null; @@ -20,11 +42,13 @@ frame.set("loop.revindex0", t_2 - t_1 - 1); frame.set("loop.first", t_1 === 0); frame.set("loop.last", t_1 === t_2 - 1); frame.set("loop.length", t_2); -output += "\n
    \n\t
    \n\t
    "; +output += "\n
    \n\t
    \n\t
    "; output += runtime.suppressValue(t_4, env.autoesc); output += " "; output += runtime.suppressValue(env.getFilter("length").call(context, t_5), env.autoesc); -output += "
    \n\t\t\n\t\t\t\n\t\t \n\t\t\t \n\t\t\t \n\t\t \n\t \n\t \n\t\t\t"; +output += "\n\t\t
    MedlemSlett
    \n\t\t\t\n\t\t \n\t\t\t \n\t\t\t \n\t\t \n\t \n\t \n\t\t\t"; frame = frame.push(); var t_8 = t_5; if(t_8) {var t_7 = t_8.length; @@ -40,16 +64,26 @@ frame.set("loop.last", t_6 === t_7 - 1); frame.set("loop.length", t_7); output += "\n\t\t\t\t\n\t\t\t"; +output += runtime.suppressValue(runtime.memberLookup((t_9),"forward", env.autoesc), env.autoesc); +output += "\">\n\t\t\t"; ; } } frame = frame.pop(); -output += "\n\t\t\t\t\n\t\t\t\n\t\t
    MedlemVelg
    "; output += runtime.suppressValue(runtime.memberLookup((t_9),"forward", env.autoesc), env.autoesc); -output += "
    \n\t\t\t\t
    \n\t\t\t\t
    \n\t
    \n
    \n"; +output += "\n\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\n\t\t\n\t\t
    \n\t
    \n
    \n"; ; } } else { @@ -67,11 +101,13 @@ frame.set("loop.revindex0", t_2 - t_1 - 1); frame.set("loop.first", t_1 === 0); frame.set("loop.last", t_1 === t_2 - 1); frame.set("loop.length", t_2); -output += "\n
    \n\t
    \n\t
    "; +output += "\n
    \n\t
    \n\t
    "; output += runtime.suppressValue(t_10, env.autoesc); output += " "; output += runtime.suppressValue(env.getFilter("length").call(context, t_11), env.autoesc); -output += "
    \n\t\t\n\t\t\t\n\t\t \n\t\t\t \n\t\t\t \n\t\t \n\t \n\t \n\t\t\t"; +output += "\n\t\t
    MedlemSlett
    \n\t\t\t\n\t\t \n\t\t\t \n\t\t\t \n\t\t \n\t \n\t \n\t\t\t"; frame = frame.push(); var t_14 = t_11; if(t_14) {var t_13 = t_14.length; @@ -87,16 +123,26 @@ frame.set("loop.last", t_12 === t_13 - 1); frame.set("loop.length", t_13); output += "\n\t\t\t\t\n\t\t\t"; +output += runtime.suppressValue(runtime.memberLookup((t_15),"forward", env.autoesc), env.autoesc); +output += "\">\n\t\t\t"; ; } } frame = frame.pop(); -output += "\n\t\t\t\t\n\t\t\t\n\t\t
    MedlemVelg
    "; output += runtime.suppressValue(runtime.memberLookup((t_15),"forward", env.autoesc), env.autoesc); -output += "
    \n\t\t\t\t
    \n\t\t\t\t
    \n\t
    \n
    \n"; +output += "\n\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\n\t\t\n\t\t
    \n\t
    \n
    \n"; ; } } @@ -114,6 +160,54 @@ root: root })(); })(); +(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["new_list.html"] = (function() {function root(env, context, frame, runtime, cb) { +var lineno = null; +var colno = null; +var output = ""; +try { +output += "
    \n
    Ny liste
    \n
    \n \t
    \n\t\t\n\t\t\t\n\t\t\t
      \n\t\t\t"; +frame = frame.push(); +var t_3 = runtime.contextOrFrameLookup(context, frame, "orgunits"); +if(t_3) {var t_2 = t_3.length; +for(var t_1=0; t_1 < t_3.length; t_1++) { +var t_4 = t_3[t_1]; +frame.set("ou", t_4); +frame.set("loop.index", t_1 + 1); +frame.set("loop.index0", t_1); +frame.set("loop.revindex", t_2 - t_1); +frame.set("loop.revindex0", t_2 - t_1 - 1); +frame.set("loop.first", t_1 === 0); +frame.set("loop.last", t_1 === t_2 - 1); +frame.set("loop.length", t_2); +output += "\n\t\t\t\t"; +output += runtime.suppressValue(runtime.memberLookup((t_4),"prefix", env.autoesc), env.autoesc); +output += "-\n\t\t\t"; +; +} +} +frame = frame.pop(); +output += "\n\t\t\t
    \n\t\t
    \n\t\t\n\t\t@studentersamfundet.no\n\t
    \n \t

    Eposter

    \n \n \n
    \n
    "; +cb(null, output); +; +} catch (e) { + cb(runtime.handleError(e, lineno, colno)); +} +} +return { +root: root +}; +})(); +})(); + (function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["orgunits.html"] = (function() {function root(env, context, frame, runtime, cb) { var lineno = null; var colno = null; @@ -132,7 +226,9 @@ frame.set("loop.revindex0", t_2 - t_1 - 1); frame.set("loop.first", t_1 === 0); frame.set("loop.last", t_1 === t_2 - 1); frame.set("loop.length", t_2); -output += "\n
  • "; output += runtime.suppressValue(runtime.memberLookup((t_4),"name", env.autoesc), env.autoesc); diff --git a/mailadmin/static/dist/styles/main.css b/mailadmin/static/dist/styles/main.css index df3a4a9..3307f78 100644 --- a/mailadmin/static/dist/styles/main.css +++ b/mailadmin/static/dist/styles/main.css @@ -306,8 +306,8 @@ th { } @font-face { font-family: 'Glyphicons Halflings'; - src: url("bootstrap/glyphicons-halflings-regular.eot"); - src: url("bootstrap/glyphicons-halflings-regular.eot?#iefix") format("embedded-opentype"), url("bootstrap/glyphicons-halflings-regular.woff") format("woff"), url("bootstrap/glyphicons-halflings-regular.ttf") format("truetype"), url("bootstrap/glyphicons-halflings-regular.svg#glyphicons_halflingsregular") format("svg"); + src: url("../fonts/glyphicons-halflings-regular.eot"); + src: url("../fonts/glyphicons-halflings-regular.eot?#iefix") format("embedded-opentype"), url("../fonts/glyphicons-halflings-regular.woff") format("woff"), url("../fonts/glyphicons-halflings-regular.ttf") format("truetype"), url("../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular") format("svg"); } .glyphicon { position: relative; @@ -6517,7 +6517,7 @@ button.close { } .login-form { margin: 0 auto; - max-width: 400px; + max-width: 300px; float: none; } .login-form input[type=submit] { @@ -6562,3 +6562,65 @@ body { background-color: #f5f5f5; padding-top: 20px; } + +/* Lists */ +.del-header { + text-align: center; + width: 82px; +} + +.del-cell { + padding: 0 !important; +} + +.del-label { + display: block; + height: 30px; + margin: 0; + text-align: center; +} +.del-label input { + margin: 0; + position: relative; + top: 6px; +} + +.btn-del { + display: none; +} +.btn-del.visible { + display: block; +} + +.forwards-container table > thead > tr > th:first-child, +.forwards-container table > tbody > tr > td:first-child { + padding-left: 16px; +} + +.forwards-container .badge { + float: right; + margin-right: 14px; +} + +.new-list-btn { + margin-bottom: 20px; +} + +.new-list { + display: none; +} +.new-list.visible { + display: block; +} + +.btn-add-list { + float: right; + margin-top: 10px; +} + +/* Responsive fixes */ +@media (max-width: 767px) { + td { + font-size: 13px; + } +} diff --git a/mailadmin/templates/base.html b/mailadmin/templates/base.html index 25f703a..905ee08 100644 --- a/mailadmin/templates/base.html +++ b/mailadmin/templates/base.html @@ -3,6 +3,7 @@ + {% block "title" %}lister.neuf.no - Epostlister på Det Norske Studentersamfund{% endblock %} @@ -11,7 +12,6 @@ {% include "nav.html" %} - {% block "navigation" %}{% endblock %} {% block "body" %}{% endblock %}
    @@ -22,6 +22,7 @@
    + diff --git a/mailadmin/templates/home.html b/mailadmin/templates/home.html index 6fefa42..a81f9a7 100644 --- a/mailadmin/templates/home.html +++ b/mailadmin/templates/home.html @@ -1,23 +1,20 @@ {% extends "base.html" %} -{% block "body-css-classes" %}{% if user.is_authenticated %}home{% else %}login{% endif %}{% endblock %} +{% block "body-css-classes" %}home{% endblock %} {% block "body" %}
    - {% if not user.is_authenticated %} - - {% include "login_form.html" %} - {% else %} -
    -
    {% endblock %} \ No newline at end of file diff --git a/mailadmin/templates/index.html b/mailadmin/templates/index.html new file mode 100644 index 0000000..cd408be --- /dev/null +++ b/mailadmin/templates/index.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} +{% block "body-css-classes" %}index{% endblock %} +{% block "body" %} +
    +
    +

    Her kan du administrere epostlistene på Det Norske Studentersamfund.
    Logg inn med din DNS-konto under.

    +
    {% include "registration/login_form.html" %}
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/mailadmin/templates/nav.html b/mailadmin/templates/nav.html index 1329547..fca3683 100644 --- a/mailadmin/templates/nav.html +++ b/mailadmin/templates/nav.html @@ -2,16 +2,15 @@
    - -