adminview-registration.js
5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2014 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
*/
define('screens/player/ui/adminview-registration', [
'underscore',
'jquery',
'screens/player/shared/serviceadmin',
'screens/player/store/store',
'screens/player/firmware/core/statusmodel/statusmodel',
'backbone',
'./baseview'
], function(_, $, ServiceAdmin, Store, StatusModel, Backbone, BaseView) {
'use strict';
var DEFAULT_OPTIONS = {
};
var RegistrationAdminView = BaseView.extend(/** @lends RegistrationAdminView.prototype */{
template: function(statusmodel) {
// The status is empty when the device is previewed
if (!statusmodel || !statusmodel.registrationState) {
return 'empty';
}
var html = '<h1>Device Registration</h1>';
switch (statusmodel.registrationState) {
case 'UNREGISTERED':
html += '<h2>State</h2><h3 class="aem-ScreensPlayer-registrationView-state">' + statusmodel.registrationState + '</h3>';
html += '<h2>Token</h2><h3 class="aem-ScreensPlayer-registrationView-token">' + statusmodel.registrationToken + '</h3>';
html += '<h2>Note</h2>Please select this device in the device control center and initiate the registration wizard.';
break;
case 'REGISTRATION':
html += '<h2>State</h2><h3 class="aem-ScreensPlayer-registrationView-state">' + statusmodel.registrationState + '</h3>';
html += '<h2>Token</h2><h3 class="aem-ScreensPlayer-registrationView-token">' + statusmodel.registrationToken + '</h3>';
html += '<h2>Note</h2>Verify that the code displayed in the device control center matches the one below and complete the registration wizard.';
html += '<h2>Registration Code</h2><b class="aem-ScreensPlayer-registrationView-code">' + statusmodel.registrationCode + '</b>';
break;
case 'REGISTERED':
html += '<h2>State</h2><h3 class="aem-ScreensPlayer-registrationView-state">' + statusmodel.registrationState + '</h3>';
html += '<h2>Note</h2>Device is registered with the AEM Screens server at <b class="aem-ScreensPlayer-registrationView-serverUrl">' + statusmodel.server + '</b>.<br>' +
'<br>' +
'Device id: <b class="aem-ScreensPlayer-registrationView-deviceId">' + statusmodel.deviceId + '</b>';
break;
case 'FAILURE':
html += '<h2>State</h2><h3 class="aem-ScreensPlayer-registrationView-state">' + statusmodel.registrationState + '</h3>';
html += '<h2>Note</h2>Error during registration request: <i class="aem-ScreensPlayer-registrationView-error">' + statusmodel.registrationError + '</i>';
break;
case 'LINK_DOWN':
html += '<h2>Link Down</h2>';
html += 'The device was not able to reach ' + statusmodel.server + '. Registration currently not possible.';
break;
default:
html += '<h2>Internal Error<h2>';
html += 'Internal error. Unknown registration state "' + statusmodel.registrationState + '".';
break;
}
return html;
},
className: 'aem-ScreensPlayer-admin-view',
events: {
},
/**
* @classdesc View that renders the admin menu
* @class AdminView
* @extends BaseView
*
* @param {Object} [options] An object of configurable options.
*/
constructor: function(options) {
this._initOptions(options, DEFAULT_OPTIONS);
RegistrationAdminView.__super__.constructor.apply(this, arguments);
this.$el.on('show', this.onShow.bind(this));
this.$el.on('hide', this.onHide.bind(this));
},
/**
* Event handler for when this view's contents are hidden
*/
onHide: function() {
var store = ServiceAdmin.getService(Store.serviceName);
if (this._statusModelChangeListener) {
store.unsubscribe(this._statusModelChangeListener);
this._statusModelChangeListener = null;
}
},
/**
* Event handler for when this view's contents are shown
*/
onShow: function() {
var store = ServiceAdmin.getService(Store.serviceName);
if (this._statusModelChangeListener) {
store.unsubscribe(this._statusModelChangeListener);
}
this._statusModelChangeListener = store.subscribe(this.render.bind(this), StatusModel.NAMESPACE);
this.render(store.getState()[StatusModel.NAMESPACE]);
},
render: function(statusmodel) {
this.$el.html(this.template(statusmodel));
return this;
}
});
// return module exports
return RegistrationAdminView;
});