2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
22 * Create the Engine Service Table
24 function createEngineServiceTable() {
25 var tableId = config.engineService.tableId;
26 var headers = config.engineService.headers;
27 var table = createEngineTable($("." + config.engineService.parent), tableId, headers.map(function(a) {
30 var tableRow = document.createElement("tr");
32 for ( var h in headers) {
33 tableData += "<td id=" + tableId + "_" + headers[h].id + "></td>";
35 tableRow.innerHTML = tableData;
36 var actionTD = $(tableRow).find("#" + tableId + "_periodic_events");
38 .html('<input type="text" name="period" id="period" style="display:inline-block"><label class="ebSwitcher"><input type="checkbox" class="ebSwitcher-checkbox" /><div class="ebSwitcher-body"><div class="ebSwitcher-onLabel">Stopped</div><div class="ebSwitcher-switch"></div><div class="ebSwitcher-offLabel">Started</div></div></label>');
39 var period = actionTD.find("#period");
40 var switcher = actionTD.find(".ebSwitcher");
41 switcher.css('display', 'inline-block');
42 switcher.css('margin-left', '5px');
43 switcher.css('vertical-align', 'middle');
44 var checkbox = $(actionTD).find('input:checkbox:first');
45 checkbox.change(function(event) {
47 if (checkbox.prop('checked')) {
52 this.servicesCall.abort();
53 ajax_get(restRootURL + "periodiceventstartstop", startStopCallback, this.engineURL.hostname,
54 this.engineURL.port, {
55 engineId : this.engineId,
56 startstop : startstop,
58 }, resetPeriodicEvents);
60 $(table).children("#engineTableBody").append(tableRow);
64 * Check for any changes in the Engine Service Table data and update only where
67 function setEngineServiceData(engineId, modelId, server, port, periodicEvents) {
68 this.engineId = engineId;
69 var tableId = config.engineService.tableId;
70 var headers = config.engineService.headers.map(function(a) {
73 var data = [ engineId, server + ":" + port, modelId ];
75 var engineServiceTable = $("#engineServicesTable");
77 for ( var h in headers) {
78 var td = engineServiceTable.find("#" + tableId + "_" + headers[h]);
79 if (td.html() !== data[h]) {
80 engineServiceTable.find("#" + tableId + "_" + headers[h]).html(data[h]);
84 var actionTD = engineServiceTable.find("#" + tableId + "_periodic_events");
85 var checkbox = $(actionTD).find('input:checkbox:first');
86 if (checkbox.is(":checked") === periodicEvents) {
87 checkbox.prop("checked", !checkbox.prop("checked"));
92 * Resets the switcher for Periodic Events in the Engine Service Table
94 function resetPeriodicEvents() {
95 var engineServiceTable = $("#engineServicesTable");
96 var periodicEventsTD = $(engineServiceTable).find("#engineServicesTable_periodic_events");
97 var checkbox = $(periodicEventsTD).find('input:checkbox:first');
98 if (checkbox.is(":checked")) {
99 checkbox.prop("checked", false);