Files
habitica/website/client/js/controllers/memberModalCtrl.js
Matteo Pagliazzi f7be7205e7 Remove localstorage and add notifications (#7588)
* move remaining files frm /common/script/public to website/public

* remove localstorage

* add back noscript template and put all javascript in the footer

* fixes client side tests

* remove double quotes where possible

* simplify jade code and add tests for buildManifest

* loading page with logo and spinner

* better loading screen in landscape mode

* icon on top of text logo

* wip: user.notifications

* notifications: simpler and working code

* finish implementing notifications

* correct loading screen css and re-inline images

* add tests for user notifications

* split User model in multiple files

* remove old comment about missing .catch()

* correctly setup hooks and methods for User model. Cleanup localstorage

* include UserNotificationsService in static page js and split loading-screen css in its own file

* add cron notification and misc fixes

* remove console.log

* fix tests

* fix multiple notifications
2016-06-07 16:14:19 +02:00

70 lines
2.3 KiB
JavaScript

"use strict";
habitrpg
.controller("MemberModalCtrl", ['$scope', '$rootScope', 'Members', 'Shared', '$http', 'Notification', 'Groups', 'Chat', '$controller', 'Stats',
function($scope, $rootScope, Members, Shared, $http, Notification, Groups, Chat, $controller, Stats) {
$controller('RootCtrl', {$scope: $scope});
$rootScope.appLoaded = true;
$scope.timestamp = function(timestamp){
return moment(timestamp).format($rootScope.User.user.preferences.dateFormat.toUpperCase());
}
$scope.statCalc = Stats;
// We watch Members.selectedMember because it's asynchronously set, so would be a hassle to handle updates here
$scope.$watch( function() { return Members.selectedMember; }, function (member) {
if(member) {
$scope.profile = member;
}
});
$scope.sendPrivateMessage = function(uuid, message){
if (!message) return;
Members.sendPrivateMessage(message, uuid)
.then(function (response) {
Notification.text(window.env.t('messageSentAlert'));
$rootScope.User.sync();
$scope.$close();
});
};
//@TODO: We don't send subscriptions so the structure has changed in the back. Update this when we update the views.
$scope.gift = {
type: 'gems',
gems: {amount: 0, fromBalance: true},
subscription: {key: ''},
message: ''
};
$scope.sendGift = function (uuid) {
Members.transferGems($scope.gift.message, uuid, $scope.gift.gems.amount)
.then(function (response) {
Notification.text(window.env.t('sentGems'));
$rootScope.User.sync();
$scope.$close();
});
};
$scope.reportAbuse = function(reporter, message, groupId) {
message.flags[reporter._id] = true;
Chat.flagChatMessage(groupId, message.id)
.then(function(data){
Notification.text(window.env.t('abuseReported'));
$scope.$close();
});
};
$scope.clearFlagCount = function(message, groupId) {
Chat.clearFlagCount(groupId, message.id)
.then(function(data){
message.flagCount = 0;
Notification.text("Flags cleared");
$scope.$close();
});
}
}
]);