authtoken_collection.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* global Backbone */
  2. /**
  3. * @author Christoph Wurst <christoph@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2016, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. (function(OC) {
  22. 'use strict';
  23. OC.Settings = OC.Settings || {};
  24. var AuthTokenCollection = OC.Backbone.Collection.extend({
  25. model: OC.Settings.AuthToken,
  26. /**
  27. * Show recently used sessions/devices first
  28. *
  29. * @param {OC.Settigns.AuthToken} t1
  30. * @param {OC.Settigns.AuthToken} t2
  31. * @returns {Boolean}
  32. */
  33. comparator: function (t1, t2) {
  34. var ts1 = parseInt(t1.get('lastActivity'), 10);
  35. var ts2 = parseInt(t2.get('lastActivity'), 10);
  36. return ts2 - ts1;
  37. },
  38. tokenType: null,
  39. url: OC.generateUrl('/settings/personal/authtokens')
  40. });
  41. OC.Settings.AuthTokenCollection = AuthTokenCollection;
  42. })(OC);