hall: start moving admin stuff to hall-of-heroes / hall-of-patrons, so everyone can see contribs / backers

This commit is contained in:
Tyler Renelle 2014-01-05 18:03:47 -07:00
parent eeaeb5c006
commit a5db8628e2
10 changed files with 189 additions and 125 deletions

View file

@ -39,6 +39,7 @@ window.habitrpg = angular.module('habitrpg',
.when('/options/profile', '/options/profile/avatar')
.when('/options/groups', '/options/groups/tavern')
.when('/options/groups/guilds', '/options/groups/guilds/public')
.when('/options/groups/hall', '/options/groups/hall/heroes')
.when('/options/inventory', '/options/inventory/drops')
.when('/options/settings', '/options/settings/settings')
@ -84,16 +85,34 @@ window.habitrpg = angular.module('habitrpg',
url: "/groups",
templateUrl: "partials/options.social.html"
})
.state('options.social.tavern', {
url: "/tavern",
templateUrl: "partials/options.social.tavern.html",
controller: 'TavernCtrl'
})
.state('options.social.party', {
url: '/party',
templateUrl: "partials/options.social.party.html",
controller: 'PartyCtrl'
})
.state('options.social.hall', {
url: '/hall',
templateUrl: "partials/options.social.hall.html"
})
.state('options.social.hall.heroes', {
url: '/heroes',
templateUrl: "partials/options.social.hall.heroes.html",
controller: 'HallHeroesCtrl'
})
.state('options.social.hall.patrons', {
url: '/patrons',
templateUrl: "partials/options.social.hall.patrons.html",
controller: 'HallPatronsCtrl'
})
.state('options.social.guilds', {
url: '/guilds',
templateUrl: "partials/options.social.guilds.html",
@ -184,13 +203,6 @@ window.habitrpg = angular.module('habitrpg',
templateUrl: "partials/options.settings.export.html"
})
// Options > Settings
.state('options.admin', {
url: "/admin",
controller: 'AdminCtrl',
templateUrl: "partials/options.admin.html"
})
var settings = JSON.parse(localStorage.getItem(STORAGE_SETTINGS_ID));
if (settings && settings.auth) {
$httpProvider.defaults.headers.common['Content-Type'] = 'application/json;charset=utf-8';

View file

@ -1,20 +0,0 @@
"use strict";
habitrpg.controller("AdminCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'API_URL', '$resource',
function($scope, $rootScope, User, Notification, API_URL, $resource) {
var Contributor = $resource(API_URL + '/api/v2/admin/members/:uid', {uid:'@_id'});
$scope.profile = undefined;
$scope.loadUser = function(uuid){
$scope.profile = Contributor.get({uid:uuid});
}
$scope.save = function(profile) {
profile.$save(function(){
Notification.text("User updated");
$scope.profile = undefined;
$scope._uuid = undefined;
$scope.contributors = Contributor.query();
})
}
$scope.contributors = Contributor.query();
}])

View file

@ -0,0 +1,25 @@
"use strict";
habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'API_URL', '$resource',
function($scope, $rootScope, User, Notification, API_URL, $resource) {
var Hero = $resource(API_URL + '/api/v2/hall/heroes/:uid', {uid:'@_id'});
$scope.hero = undefined;
$scope.loadHero = function(uuid){
$scope.hero = Hero.get({uid:uuid});
}
$scope.saveHero = function(hero) {
hero.$save(function(){
Notification.text("User updated");
$scope.hero = undefined;
$scope._heroID = undefined;
$scope.heroes = Hero.query();
})
}
$scope.heroes = Hero.query();
}]);
habitrpg.controller("HallPatronsCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'API_URL', '$resource',
function($scope, $rootScope, User, Notification, API_URL, $resource) {
var Patron = $resource(API_URL + '/api/v2/hall/patrons/:uid', {uid:'@_id'});
$scope.patrons = Patron.query();
}]);

View file

@ -55,7 +55,7 @@
"js/controllers/inventoryCtrl.js",
"js/controllers/footerCtrl.js",
"js/controllers/challengesCtrl.js",
"js/controllers/adminCtrl.js"
"js/controllers/hallCtrl.js"
],
"css": [
"bower_components/bootstrap/docs/assets/css/bootstrap.css",

View file

@ -12,27 +12,37 @@ api.ensureAdmin = function(req, res, next) {
next();
}
api.getMember = function(req, res) {
api.getHeroes = function(req,res,next) {
User.find({'contributor.level':{$ne:null}})// {$exists:true} causes terrible performance http://goo.gl/GCxzC9
.select('contributor backer balance profile.name')
.sort('contributor.text')
.exec(function(err, users){
if (err) return next(err);
res.json(users);
});
}
api.getPatrons = function(req,res,next){
User.find({'backer.tier':{$ne:null}})
.select('contributor backer profile.name')
.sort('-backer.tier')
.exec(function(err, users){
if (err) return next(err);
res.json(users);
});
}
api.getHero = function(req,res,next) {
User.findById(req.params.uid)
.select('contributor balance profile.name purchased')
.exec(function(err, user){
if (err) return res.json(500,{err:err});
if (err) return next(err)
if (!user) return res.json(400,{err:'User not found'});
res.json(user);
});
}
api.listMembers = function(req, res) {
User.find({'contributor.level':{$ne:null}})// {$exists:true} causes terrible performance http://goo.gl/GCxzC9
.select('contributor balance profile.name')
.sort('contributor.text')
.exec(function(err, users){
if (err) return res.json(500,{err:err});
res.json(users);
});
}
api.updateMember = function(req, res) {
api.updateHero = function(req,res,next) {
async.waterfall([
function(cb){
User.findById(req.params.uid, cb);
@ -50,7 +60,7 @@ api.updateMember = function(req, res) {
member.save(cb);
}
], function(err, saved){
if (err) return res.json(500,{err:err});
if (err) return next(err);
res.json(204);
})
}

View file

@ -11,7 +11,7 @@ $ mocha test/user.mocha.coffee
user = require("../controllers/user")
groups = require("../controllers/groups")
auth = require("../controllers/auth")
admin = require("../controllers/admin")
hall = require("../controllers/hall")
challenges = require("../controllers/challenges")
dataexport = require("../controllers/dataexport")
nconf = require("nconf")
@ -491,24 +491,29 @@ module.exports = (swagger, v2) ->
action: groups.getMember
# ---------------------------------
# Admin
# Hall of Heroes / Patrons
# ---------------------------------
"/admin/members":
"/hall/heroes":
spec: {}
middleware:[auth.auth, admin.ensureAdmin]
action: admin.listMembers
middleware:[auth.auth]
action: hall.getHeroes
"/admin/members/{uid}:GET":
spec: path: "/admin/members/{uid}"
middleware:[auth.auth, admin.ensureAdmin]
action: admin.getMember
"/hall/heroes/{uid}:GET":
spec: path: "/hall/heroes/{uid}"
middleware:[auth.auth, hall.ensureAdmin]
action: hall.getHero
"/admin/members/{uid}:POST":
"/hall/heroes/{uid}:POST":
spec:
method: 'POST'
path: "/admin/members/{uid}"
middleware: [auth.auth, admin.ensureAdmin]
action: admin.updateMember
path: "/hall/heroes/{uid}"
middleware: [auth.auth, hall.ensureAdmin]
action: hall.updateHero
"/hall/patrons":
spec: {}
middleware:[auth.auth]
action: hall.getPatrons
# ---------------------------------

View file

@ -1,65 +0,0 @@
script(id='partials/options.admin.html', type="text/ng-template")
h2 Reward User
form.form-horizontal(ng-submit='loadUser(_uuid)')
.-options
.option-group.option-large
input.option-content(type='text', ng-model='_uuid', placeholder='UUID')
button.btn(type='submit') Load User
form.form-horizontal(ng-show='profile', ng-submit='save(profile)')
h3 {{profile.profile.name}}
.-options
.control-group.option-large
input.option-content(type='text', ng-model='profile.contributor.text', placeholder='Contributor Title (eg, "Blacksmith")')
.control-group.option-medium
input.option-content(type='number', step="any", ng-model='profile.contributor.level')
span.input-suffix Contrib Level
br
small [1-7] this determines which items, pets, and mounts are available. Also determines name-tag coloring. 
a(target='_blank', href='https://trello.com/c/wkFzONhE/277-contributor-gear') More details.
.control-group.option-large
textarea.option-content(style='height:15em;', placeholder='Contributions', ng-model='profile.contributor.contributions')
include ../shared/formatting-help
.control-group.option-medium
label.checkbox
input(type='checkbox', ng-model='profile.contributor.admin')
| Admin
hr
.control-group.option-medium
input.option-content(type='number', step="any", ng-model='profile.balance')
span.input-suffix Balance
p
small `user.balance` is in USD, <em>not</em> in Gems. Aka, if this number is 1, it means 4 gems. Only use this option when manually granting gems to players, don't use it when granting contributor levels. Contrib levels will automatically add 2G/lvl.
.control-group.option-medium
label.checkbox
input(type='checkbox', ng-model='profile.purchased.ads')
| Hide Ads
// h4 Backer Status
// Add backer stuff like tier, disable adds, etcs
button.btn-primary(type='submit') Save
br
br
br
h2 Current Contributors
table.table.table-striped
tr
thead
tr
th Name
th UUID
th Contrib Level
th Title
th Admin
th Contributions
tr(ng-repeat='contrib in contributors')
td
a.label(class='label-contributor-{{contrib.contributor.level}}', ng-click='clickMember(contrib._id, true)') {{contrib.profile.name}}
td {{contrib._id}}
td {{contrib.contributor.level}}
td {{contrib.contributor.text}}
td {{contrib.contributor.admin}}
td {{contrib.contributor.contributions}}

View file

@ -2,7 +2,6 @@ include ./profile
include ./social/index
include ./inventory/index
include ./settings
include ./admin
script(id='partials/options.html', type="text/ng-template")
.grid
@ -27,10 +26,6 @@ script(id='partials/options.html', type="text/ng-template")
a(ui-sref='options.settings')
i.icon-wrench
| Settings
li(ng-class="{ active: $state.includes('options.admin') }", ng-if='user.contributor.admin')
a(ui-sref='options.admin')
i.icon-cog
| Admin
.tab-content
.tab-pane.active

View file

@ -0,0 +1,96 @@
script(type='text/ng-template', id='partials/options.social.hall.html')
ul.nav.nav-tabs
li(ng-class="{ active: $state.includes('options.social.hall.heroes') }")
a(ui-sref='options.social.hall.heroes')
i.icon-eye-close
| Hall of Heroes
li(ng-class="{ active: $state.includes('options.social.hall.patrons') }")
a(ui-sref='options.social.hall.patrons')
| Hall of Patrons
.tab-content
.tab-pane.active
div(ui-view)
script(type='text/ng-template', id='partials/options.social.hall.heroes.html')
div.well(ng-if='user.contributor.admin')
h2 Reward User
form.form-horizontal(ng-submit='loadHero(_heroID)')
.-options
.option-group.option-large
input.option-content(type='text', ng-model='_heroID', placeholder='UUID')
button.btn(type='submit') Load User
form.form-horizontal(ng-show='hero', ng-submit='saveHero(hero)')
h3 {{hero.profile.name}}
.-options
.control-group.option-large
input.option-content(type='text', ng-model='hero.contributor.text', placeholder='Contributor Title (eg, "Blacksmith")')
.control-group.option-medium
input.option-content(type='number', step="any", ng-model='hero.contributor.level')
span.input-suffix Contrib Level
br
small [1-7] this determines which items, pets, and mounts are available. Also determines name-tag coloring.&nbsp;
a(target='_blank', href='https://trello.com/c/wkFzONhE/277-contributor-gear') More details.
.control-group.option-large
textarea.option-content(style='height:15em;', placeholder='Contributions', ng-model='hero.contributor.contributions')
//-include ../../shared/formatting-help
.control-group.option-medium
label.checkbox
input(type='checkbox', ng-model='hero.contributor.admin')
| Admin
hr
.control-group.option-medium
input.option-content(type='number', step="any", ng-model='hero.balance')
span.input-suffix Balance
p
small `user.balance` is in USD, <em>not</em> in Gems. Aka, if this number is 1, it means 4 gems. Only use this option when manually granting gems to players, don't use it when granting contributor levels. Contrib levels will automatically add 2G/lvl.
.control-group.option-medium
label.checkbox
input(type='checkbox', ng-model='hero.purchased.ads')
| Hide Ads
// h4 Backer Status
// Add backer stuff like tier, disable adds, etcs
button.btn-primary(type='submit') Save
table.table.table-striped
tr
thead
tr
th Name
th(ng-if='user.contributor.admin') UUID
th Contrib Level
th Title
th Contributions
tr(ng-repeat='hero in heroes')
td
span(ng-if='hero.contributor.admin',popover='Game Master',popover-trigger='mouseenter',popover-placement='right')
a.label(class='label-contributor-{{hero.contributor.level}}', ng-class='{"label-npc": hero.backer.npc}', ng-click='clickMember(hero._id, true)')
i.icon-star&nbsp;
| {{hero.profile.name}}
i.icon-star&nbsp;
span(ng-if='!hero.contributor.admin')
a.label(class='label-contributor-{{hero.contributor.level}}', ng-class='{"label-npc": hero.backer.npc}', ng-click='clickMember(hero._id, true)') {{hero.profile.name}}
td(ng-if='user.contributor.admin') {{hero._id}}
td {{hero.contributor.level}}
td {{hero.contributor.text}}
td
markdown(ng-model='hero.contributor.contributions', target='_blank')
script(type='text/ng-template', id='partials/options.social.hall.patrons.html')
table.table.table-striped
tr
thead
tr
th Name
th(ng-if='user.contributor.admin') UUID
th Backer Tier
tr(ng-repeat='patron in patrons')
td
a.label(class='label-contributor-{{patron.contributor.level}}', ng-class='{"label-npc": patron.backer.npc}', ng-click='clickMember(patron._id, true)') {{patron.profile.name}}
td(ng-if='user.contributor.admin') {{patron._id}}
td {{patron.backer.tier}}

View file

@ -2,10 +2,12 @@
// Subscribe to that ticket & change this when they fix
include ./challenges.jade
include ./hall.jade
script(type='text/ng-template', id='partials/options.social.tavern.html')
include ./tavern
script(type='text/ng-template', id='partials/options.social.party.html')
div(ng-show='group._id')
include ./group
@ -84,6 +86,10 @@ script(type='text/ng-template', id='partials/options.social.html')
a(ui-sref='options.social.challenges')
i.icon-bullhorn
| Challenges
li(ng-class="{ active: $state.includes('options.social.hall') }")
a(ui-sref='options.social.hall')
i.icon-flag
| Hall
.tab-content
.tab-pane.active