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