/* --- BEGIN COPYRIGHT BLOCK --- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Copyright (C) 2013 Red Hat, Inc. * All rights reserved. * --- END COPYRIGHT BLOCK --- * * @author Endi S. Dewata */ // TODO: load labels from server var TokenStatus = { UNINITIALIZED : "Uninitialized", ACTIVE : "Active", TEMP_LOST : "Temporarily lost", PERM_LOST : "Permanently lost", DAMAGED : "Physically damaged", TEMP_LOST_PERM_LOST : "Temporarily lost then permanently lost", TERMINATED : "Terminated" }; var TokenModel = Model.extend({ urlRoot: "/tps/rest/tokens", parseResponse: function(response) { return { id: response.id, tokenID: response.TokenID, userID: response.UserID, type: response.Type, status: response.Status, nextStates: response.NextStates, appletID: response.AppletID, keyInfo: response.KeyInfo, policy: response.Policy, createTimestamp: response.CreateTimestamp, modifyTimestamp: response.ModifyTimestamp }; }, createRequest: function(attributes) { return { id: this.id, TokenID: attributes.tokenID, UserID: attributes.userID, Type: attributes.type, AppletID: attributes.appletID, KeyInfo: attributes.keyInfo, Policy: attributes.policy, CreateTimestamp: attributes.createTimestamp, ModifyTimestamp: attributes.modifyTimestamp }; }, changeStatus: function(options) { var self = this; $.ajax({ type: "POST", url: self.url() + "?status=" + options.status, dataType: "json" }).done(function(data, textStatus, jqXHR) { self.set(self.parseResponse(data)); if (options.success) options.success.call(self, data, textStatus, jqXHR); }).fail(function(jqXHR, textStatus, errorThrown) { if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown); }); } }); var TokenCollection = Collection.extend({ model: TokenModel, urlRoot: "/tps/rest/tokens", getEntries: function(response) { return response.entries; }, getLinks: function(response) { return response.Link; }, parseEntry: function(entry) { return new TokenModel({ id: entry.id, tokenID: entry.TokenID, userID: entry.UserID, type: entry.Type, status: entry.Status, nextStates: entry.NextStates, appletID: entry.AppletID, keyInfo: entry.KeyInfo, policy: entry.Policy, createTimestamp: entry.CreateTimestamp, modifyTimestamp: entry.ModifyTimestamp }); } }); var TokenDialog = Dialog.extend({ loadField: function(input) { var self = this; var name = input.attr("name"); if (name != "status") { TokenDialog.__super__.loadField.call(self, input); return; } var select = input.empty(); var status = self.entry.status; $('