adminview-channels.js
3.65 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
/*
*
* 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-channels', [
'underscore',
'jquery',
'./baseview',
'./adminview-channel',
'screens/player/shared/serviceadmin',
'screens/player/store/store',
'screens/player/firmware/core/config/config'
], function(_, $, BaseView, ChannelView, ServiceAdmin, Store, Config) {
'use strict';
var DEFAULT_OPTIONS = {
};
var ChannelsAdminView = BaseView.extend(/** @lends ChannelsAdminView.prototype */{
template: function() {
return '<h1>Channels</h1>' +
'<table class="aem-ScreensPlayer-admin-channelsview-channels">' +
'<tr>' +
'<th>Title</th>' +
'<th>Role</th>' +
'<th>Online</th>' +
'<th>Cached</th>' +
'</tr>' +
'</table>';
},
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);
ChannelsAdminView.__super__.constructor.apply(this, arguments);
this.$el.on('show', this.onShow.bind(this));
this.$el.on('hide', this.onHide.bind(this));
ServiceAdmin.onServiceHighestRankedStart(Store.serviceName, function(store) {
store.requestState();
});
$('body').append(this.render().$el);
},
/**
* Event handler for when this view's contents are hidden
*/
onHide: function() {
var store = ServiceAdmin.getService(Store.serviceName);
if (this._channelsConfigChangeListener) {
store.unsubscribe(this._channelsConfigChangeListener);
this._channelsConfigChangeListener = null;
}
},
/**
* Event handler for when this view's contents are shown
*/
onShow: function() {
var store = ServiceAdmin.getService(Store.serviceName);
if (this._channelsConfigChangeListener) {
store.unsubscribe(this._channelsConfigChangeListener);
}
this._channelsConfigChangeListener = store.subscribe(this.render.bind(this), Config.NAMESPACES.CHANNELS);
this.render(store.getState()[Config.NAMESPACES.CHANNELS]);
},
render: function(channels) {
this.$el.html(this.template());
var $channels = this.$el.find('.aem-ScreensPlayer-admin-channelsview-channels');
if (channels) {
_.each(channels._list, function(channel) {
var channelView = new ChannelView();
$channels.append(channelView.render(channel).el);
}, this);
}
return this;
}
});
// return module exports
return ChannelsAdminView;
});