forked from 0x2620/pandora
better theming of statistics; use capabilities in menu, not 'isAdmin'
This commit is contained in:
parent
4fa8f142f4
commit
9098e22b68
5 changed files with 57 additions and 32 deletions
|
@ -32,6 +32,9 @@
|
|||
"canEditSitePages": {"staff": true, "admin": true},
|
||||
"canEditUsers": {"admin": true},
|
||||
"canImportAnnotations": {},
|
||||
"canManageTitlesAndNames": {"staff": true, "admin": true},
|
||||
"canManagePlacesAndEvents": {"staff": true, "admin": true},
|
||||
"canManageUsers": {"staff": true, "admin": true},
|
||||
"canPlayClips": {"guest": 2, "member": 2, "friend": 4, "staff": 4, "admin": 4},
|
||||
"canPlayVideo": {"guest": 1, "member": 1, "friend": 4, "staff": 4, "admin": 4},
|
||||
"canSeeDebugMenu": {"staff": true, "admin": true},
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
"canEditSitePages": {"staff": true, "admin": true},
|
||||
"canEditUsers": {"admin": true},
|
||||
"canImportAnnotations": {"member": true, "staff": true, "admin": true},
|
||||
"canManageTitlesAndNames": {"member": true, "staff": true, "admin": true},
|
||||
"canManagePlacesAndEvents": {"member": true, "staff": true, "admin": true},
|
||||
"canManageUsers": {"staff": true, "admin": true},
|
||||
"canPlayClips": {"guest": 1, "member": 1, "staff": 4, "admin": 4},
|
||||
"canPlayVideo": {"guest": 1, "member": 1, "staff": 4, "admin": 4},
|
||||
"canSeeDebugMenu": {"staff": true, "admin": true},
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
'use strict';
|
||||
pandora.ui.mainMenu = function() {
|
||||
|
||||
var isAdmin = pandora.user.level == 'admin',
|
||||
isGuest = pandora.user.level == 'guest',
|
||||
var isGuest = pandora.user.level == 'guest',
|
||||
ui = pandora.user.ui,
|
||||
findState = pandora.getFindState(ui.find),
|
||||
that = Ox.MainMenu({
|
||||
|
@ -31,8 +30,7 @@ pandora.ui.mainMenu = function() {
|
|||
{},
|
||||
{ id: 'preferences', title: 'Preferences...', disabled: isGuest, keyboard: 'control ,' },
|
||||
{ id: 'archives', title: 'Archives...', disabled: /*isGuest*/ true },
|
||||
{ id: 'upload', title: 'Upload...',
|
||||
disabled: !pandora.site.capabilities.canUploadVideo[pandora.user.level]},
|
||||
{ id: 'upload', title: 'Upload...', disabled: !pandora.site.capabilities.canUploadVideo[pandora.user.level]},
|
||||
{},
|
||||
{ id: 'signup', title: 'Sign Up...', disabled: !isGuest },
|
||||
isGuest ? { id: 'signin', title: 'Sign In...' }
|
||||
|
@ -134,14 +132,14 @@ pandora.ui.mainMenu = function() {
|
|||
{ id: 'findsimilar', title: 'Find Similar Clips...', disabled: true}
|
||||
] },
|
||||
{ id: 'dataMenu', title: 'Data', items: [
|
||||
{ id: 'titles', title: 'Manage Titles...', disabled: !isAdmin },
|
||||
{ id: 'names', title: 'Manage Names...', disabled: !isAdmin },
|
||||
{ id: 'titles', title: 'Manage Titles...', disabled: !pandora.site.capabilities.canManageTitlesAndNames[pandora.user.level] },
|
||||
{ id: 'names', title: 'Manage Names...', disabled: !pandora.site.capabilities.canManageTitlesAndNames[pandora.user.level] },
|
||||
{},
|
||||
{ id: 'places', title: 'Manage Places...', disabled: isGuest },
|
||||
{ id: 'events', title: 'Manage Events...', disabled: isGuest },
|
||||
{ id: 'places', title: 'Manage Places...', disabled: !pandora.site.capabilities.canManagePlacesAndEvents[pandora.user.level] },
|
||||
{ id: 'events', title: 'Manage Events...', disabled: !pandora.site.capabilities.canManagePlacesAndEvents[pandora.user.level] },
|
||||
{},
|
||||
{ id: 'users', title: 'Manage Users...', disabled: !isAdmin },
|
||||
{ id: 'statistics', title: 'Statistics...', disabled: !isAdmin }
|
||||
{ id: 'users', title: 'Manage Users...', disabled: !pandora.site.capabilities.canManageUsers[pandora.user.level] },
|
||||
{ id: 'statistics', title: 'Statistics...', disabled: !pandora.site.capabilities.canManageUsers[pandora.user.level] }
|
||||
] },
|
||||
{ id: 'helpMenu', title: 'Help', items: [
|
||||
{ id: 'help', title: pandora.site.site.name + ' Help', keyboard: 'control ?' }
|
||||
|
|
|
@ -93,8 +93,8 @@ pandora.ui.statisticsDialog = function() {
|
|||
|
||||
$tabPanel;
|
||||
|
||||
//Ox.getJSON('/static/json/deleteme.json', function(result) {
|
||||
///*
|
||||
Ox.getJSON('/static/json/deleteme.json', function(result) {
|
||||
/*
|
||||
pandora.api.findUsers({
|
||||
keys: ['browser', 'email', 'firstseen', 'lastseen', 'level', 'location', 'system'],
|
||||
query: {
|
||||
|
@ -104,7 +104,7 @@ pandora.ui.statisticsDialog = function() {
|
|||
range: [0, 1000000],
|
||||
sort: [{key: 'username', operator: '+'}]
|
||||
}, function(result) {
|
||||
//*/
|
||||
*/
|
||||
|
||||
var data = {},
|
||||
flagCountry = {},
|
||||
|
@ -273,7 +273,7 @@ pandora.ui.statisticsDialog = function() {
|
|||
.css({
|
||||
padding: '16px',
|
||||
overflowY: 'auto',
|
||||
background: Ox.Theme() == 'classic'
|
||||
background: pandora.user.ui.theme == 'classic'
|
||||
? 'rgb(240, 240, 240)'
|
||||
: 'rgb(16, 16, 16)'
|
||||
});
|
||||
|
@ -282,12 +282,18 @@ pandora.ui.statisticsDialog = function() {
|
|||
var isYearOrMonth = ['year', 'month'].indexOf(key) > -1;
|
||||
Ox.Chart({
|
||||
color: function(value) {
|
||||
var split = value.split('-');
|
||||
return isYearOrMonth ? Ox.rgb(
|
||||
Ox.mod(8 - parseInt(split[1], 10), 12) * 30, 1, 0.5
|
||||
).map(Math.round) : Ox.rgb(
|
||||
(Math.abs(11.5 - parseInt(split[0], 10)) - 0.5) * -11, 1, 0.5
|
||||
).map(Math.round);
|
||||
var split = value.split('-'),
|
||||
color = isYearOrMonth ? Ox.rgb(
|
||||
Ox.mod(8 - parseInt(split[1], 10), 12) * 30, 1, 0.5
|
||||
).map(Math.round) : Ox.rgb(
|
||||
(Math.abs(11.5 - parseInt(split[0], 10)) - 0.5) * -11, 1, 0.5
|
||||
).map(Math.round);
|
||||
if (pandora.user.ui.theme == 'classic') {
|
||||
color = color.map(function(c) {
|
||||
return c - 64;
|
||||
});
|
||||
}
|
||||
return color;
|
||||
},
|
||||
data: data[mode][key],
|
||||
formatKey: function(value) {
|
||||
|
@ -323,9 +329,15 @@ pandora.ui.statisticsDialog = function() {
|
|||
['continent', 'region', 'country', 'city'].forEach(function(key) {
|
||||
Ox.Chart({
|
||||
color: function(value) {
|
||||
return Ox.getGeoColor(
|
||||
var color = Ox.getGeoColor(
|
||||
key == 'continent' ? value : value.split(', ')[1]
|
||||
);
|
||||
if (pandora.user.ui.theme == 'classic') {
|
||||
color = color.map(function(c) {
|
||||
return c - 64;
|
||||
});
|
||||
}
|
||||
return color;
|
||||
},
|
||||
data: data[mode][key],
|
||||
formatKey: function(value) {
|
||||
|
@ -408,7 +420,7 @@ pandora.ui.statisticsDialog = function() {
|
|||
['system', 'browser'].forEach(function(key) {
|
||||
Ox.Chart({
|
||||
color: function(value) {
|
||||
var name = value;
|
||||
var color, name = value;
|
||||
if (version) {
|
||||
Ox.forEach(names[key], function(v) {
|
||||
if (new RegExp('^' + v).test(value)) {
|
||||
|
@ -417,7 +429,13 @@ pandora.ui.statisticsDialog = function() {
|
|||
}
|
||||
});
|
||||
}
|
||||
return colors[key][name];
|
||||
color = colors[key][name];
|
||||
if (pandora.user.ui.theme == 'classic') {
|
||||
color = color.map(function(c) {
|
||||
return c - 64;
|
||||
});
|
||||
}
|
||||
return color;
|
||||
},
|
||||
data: data[mode][key + version],
|
||||
formatKey: function(value) {
|
||||
|
@ -486,11 +504,17 @@ pandora.ui.statisticsDialog = function() {
|
|||
if (i == 0) {
|
||||
Ox.Chart({
|
||||
color: function(value) {
|
||||
return Ox.zip(value.split(' / ').map(function(v, i) {
|
||||
var color = Ox.zip(value.split(' / ').map(function(v, i) {
|
||||
return colors[i == 0 ? 'system' : 'browser'][v];
|
||||
})).map(function(c) {
|
||||
return Math.round(Ox.sum(c) / 2);
|
||||
})
|
||||
});
|
||||
if (pandora.user.ui.theme == 'classic') {
|
||||
color = color.map(function(c) {
|
||||
return c - 64;
|
||||
});
|
||||
}
|
||||
return color;
|
||||
},
|
||||
data: data[mode].systemandbrowser,
|
||||
formatKey: function(value) {
|
||||
|
|
|
@ -171,18 +171,15 @@ pandora.ui.usersDialog = function() {
|
|||
},
|
||||
{
|
||||
format: function(value, data) {
|
||||
var country;
|
||||
if (!value) {
|
||||
country = (Ox.getCountryByCode(
|
||||
data.email.split('.').pop().replace(/(edu|gov|mil)/i, 'us')
|
||||
) || {}).name || '';
|
||||
}
|
||||
value = value || (Ox.getCountryByCode(
|
||||
data.email.split('.').pop().replace(/(edu|gov|mil)/i, 'us')
|
||||
) || {}).name || '';
|
||||
return Ox.Element({
|
||||
element: '<img>',
|
||||
tooltip: value
|
||||
})
|
||||
.attr({
|
||||
src: Ox.getFlagByGeoname(value || country, 16)
|
||||
src: Ox.getFlagByGeoname(value, 16)
|
||||
})
|
||||
.css({
|
||||
width: '14px',
|
||||
|
|
Loading…
Reference in a new issue