diff --git a/src/js/plugins/frontPanel.js b/src/js/plugins/frontPanel.js new file mode 100644 index 0000000..8f7ccf6 --- /dev/null +++ b/src/js/plugins/frontPanel.js @@ -0,0 +1,677 @@ +import Plugin from '../core/plugin.js'; +class FrontPanel extends Plugin { + constructor(pluginData, api) { + super(pluginData, api); + this.displayName = 'Front Panel'; + } + render() { + var mainDiv = document.getElementById('main'); + mainDiv.innerHTML = ` +
+ Brightness +
+
+ Index +
+
+ +
+
+ +
+
+ brightness value +
+
+ - +
+
+ Brightness +
+
+ +
+
+ Index value +
+
+ +
+
+ +
+
+ Clock brightness +
+
+ +
+
+ clock brightness value +
+
+ - +
+
+ clock Brightness +
+
+ +
+
+ +
+
+ Preferences +
+
+ +
+
+ Preferences +
+
+ - +
+
+ Preference value +
+
+ +
+
+ +
+
+ is 24 hour clock +
+
+ - +
+
+ set 24 hour clock(true/false) +
+
+ +
+
+ +
+
+ Front panel lights info +
+
+ Supported lights +
+
+ - +
+
+ range +
+
+ - +
+
+ Min: +
+
+ - +
+
+ Max: +
+
+ - +
+
+ Step: +
+
+ - +
+
+ colorMode: +
+
+ - +
+
+ Clock test pattern +
+
+ show +
+
+ +
+
+ Time Interval +
+
+ +
+
+ +
+
+ LED +
+
+ ledIndicator +
+
+ +
+
+ brightness +
+
+ +
+
+ color +
+
+ +
+
+ Red +
+
+ +
+
+ Green +
+
+ +
+
+ Blue +
+
+ +
+
+ +
+
+ power LED On +
+
+ Index +
+
+ +
+
+ +
+
+ power LED Off +
+
+ Index +
+
+ +
+
+ +
+ `; + //values to get brightness + this.indexValue=document.getElementById('index'); + this.get_brightness = document.getElementById('get_brightnessBtn'); + this.briness_value=document.getElementById('briness_value'); + this.get_brightness.onclick = this.getBrightness.bind(this); + //values to set brightness + this.set_brightness = document.getElementById('set_brightnessBtn'); + this.briness_input=document.getElementById('briness_input'); + this.index_input=document.getElementById('index_input'); + this.set_brightness.onclick = this.setBrightness.bind(this); + //values to get clock brightness + this.get_clockBrightness = document.getElementById('get_clockBrightnessBtn'); + this.clockBriness_value=document.getElementById('clockBriness_value'); + this.get_clockBrightness.onclick = this.getClockBrightness().bind(this); + //values to set clock brightness + this.clockBriness_input=document.getElementById('clockBriness_input'); + this.set_clockBrightness = document.getElementById('set_clockBrightnessBtn'); + this.set_clockBrightness.onclick = this.setClockBrightness().bind(this); + //values to get preferences + this.preferences_value=document.getElementById('preferences_value'); + this.get_preferences = document.getElementById('get_preferencesBtn'); + this.get_preferences.onclick = this.getPreferences().bind(this); + //values to set preferences + this.preference_input=document.getElementById('preference_input'); + this.set_preferences = document.getElementById('set_preferencesBtn'); + this.set_preferences.onclick = this.setPreferences().bind(this); + //is24HourClock + this.is24HourClock=document.getElementById('is24HourClock') + this.set_24HourClockBtn=document.getElementById('set_24HourClock') + this.set_24HourClockBtn.onclick = this.set24HourClock().bind(this); + this.set24Hrclock_input=document.getElementById('24hrClock_input'); + //frontpanellightsinfo + this.supportedLightsInfo=document.getElementById('supportedLightsInfo'); + this.supportedLightsRange=document.getElementById('supportedLightsRange'); + this.supportedLightsMin=document.getElementById('supportedLightsMin'); + this.supportedLightsMax=document.getElementById('supportedLightsMax'); + this.supportedLightsStep=document.getElementById('supportedLightsStep'); + this.supportedLightscolorMode=document.getElementById('supportedLightscolorMode'); + //clockTestPattern + this.showValueClock=document.getElementById('showClk_input') + this.timeIntervalClock=document.getElementById('timeInt_input') + this.setClockTestPatnBtn=document.getElementById('set_ClockTestBtn') + this.setClockTestPatnBtn.onclick = this.setClockTestPatn().bind(this); + //LED + this.ledIndicator=document.getElementById('ledIndicator_input') + this.LEDBrightness=document.getElementById('LEDbrightness_input') + this.LEDColor=document.getElementById('ledcolor_input') + this.LEDRed=document.getElementById('LEDRed_input') + this.LEDGreen=document.getElementById('LEDGreen_input') + this.LEDBlue=document.getElementById('LEDBlue_input') + this.setLEDBtn=document.getElementById('set_LEDBtn') + this.setLEDBtn.onclick=this.setLED().bind(this); + //powerLEDOn + this.powerOnIndex=document.getElementById('powerOnIndex_input') + this.powerLEDOnBtn=document.getElementById('powerLEDOnBtn') + this.powerLEDOnBtn.onclick=this.powerOnLED().bind(this); + //powerLEDOff + this.powerOffIndex=document.getElementById('powerOffIndex_input') + this.powerLEDOffBtn=document.getElementById('powerLEDOffBtn') + this.powerLEDOffBtn.onclick=this.powerOffLED().bind(this); + } + getBrightness(){ + let indexPossibleVal=["data_led","record_led","power_led"] + this.briness_value.innerHTML = '-'; + if (this.indexValue.value == '') { + alert('Please provide index name of front panel indicator'); + }else{ + if(indexPossibleVal.includes(this.indexValue.value)){ + this.getBrightnessValue(this.indexValue.value).then(response => { + if(response.success){ + this.briness_value.innerHTML= response.brightness + } + }); + }else{ + alert(' Index name possible values are data_led, record_led, power_led'); + } + } + } + getBrightnessValue(indexVal){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'getBrightness', + params: { + index: indexVal, + + }, + }; + + return this.api.req(_rest, _rpc); + } + setBrightness(){ + + if (this.briness_input.value == '') { + alert('Please provide brightness'); + }else{ + this.setBrightnessValue(this.briness_input.value,this.index_input.value).then(response => { + if(response.success){ + alert("brightness set successfully") + }else{ + alert("Error in setting brightness") + } + }); + + } + } + setBrightnessValue(briInput,indexInput){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'setBrightness', + params: { + brightness: briInput, + index: indexInput + + }, + }; + + return this.api.req(_rest, _rpc); + } + getClockBrightness(){ + this.clockBriness_value.innerHTML = '-'; + this.getClockBrightnessValue().then(response => { + if(response.success){ + this.clockBriness_value.innerHTML= response.brightness + } + }); + + + } + getClockBrightnessValue(){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'getClockBrightness', + + }; + + return this.api.req(_rest, _rpc); + } + setClockBrightness(){ + + if (this.clockBriness_input.value == '') { + alert('Please provide clock brightness'); + }else{ + this.setClockBrightnessValue(this.clockBriness_input.value).then(response => { + if(response.success){ + alert("Clock brightness set successfully") + }else{ + alert("Error in setting clock brightness") + } + }); + + } + } + setClockBrightnessValue(clockBrightness){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'setClockBrightness', + params: { + brightness: clockBrightness + }, + }; + + return this.api.req(_rest, _rpc); + } + getPreferences(){ + this.preferences_value.innerHTML = '-'; + this.getPreferncesValue().then(response => { + if(response.success){ + this.preferences_value.innerHTML= response.preferences + } + }); + } + getPreferncesValue(){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'getPreferences', + + }; + + return this.api.req(_rest, _rpc); + } + setPreferences(){ + if (this.preference_input.value == '') { + alert('Please provide preference value'); + }else{ + this.setPreferencesValue(this.preference_input.value).then(response => { + if(response.success){ + alert("preferences set successfully") + }else{ + alert("Error in setting preferences") + } + }); + + } + } + setPreferencesValue(preference){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'setPreferences', + params: { + preferences: preference + }, + }; + + return this.api.req(_rest, _rpc); + } + is24HourClock(){ + const _rest = { + method : 'GET', + path : `${this.callsign}`, + }; + + const _rpc = { + plugin : this.callsign, + method : 'is24HourClock' + }; + + return this.api.req(_rest, _rpc); + } + update() { + this.is24HourClock.innerHTML="-" + this.is24HourClock().then( res => { + if(res.success){ + this.is24HourClock.innerHTML=res.is24Hour + } + + }) + this.supportedLightsInfo.innerHTML="-" + this.supportedLightsRange.innerHTML="-" + this.supportedLightsMin.innerHTML="-" + this.supportedLightsMax.innerHTML="-" + this.supportedLightsStep.innerHTML="-" + this.supportedLightscolorMode.innerHTML="-" + + this.getFrontPanelLightsInfo().then(result=>{ + if(result.success){ + this.supportedLightsInfo.innerHTML=result.supportedLights.toString(); + this.supportedLightsRange.innerHTML=result.supportedLightsInfo.power_led.range; + this.supportedLightsMin.innerHTML=result.supportedLightsInfo.power_led.min; + this.supportedLightsMax.innerHTML=result.supportedLightsInfo.power_led.max; + this.supportedLightsStep.innerHTML=result.supportedLightsInfo.power_led.step + this.supportedLightscolorMode.innerHTML=result.supportedLightsInfo.power_led.colorMode + } + }) + } + set24HourClock(){ + if (this.set24Hrclock_input.value == '') { + alert('Please provide input'); + }else{ + this.set24HourClockValue(this.set24Hrclock_input.value).then(response => { + if(response.success){ + alert("24/12 Hour clock set successfully") + }else{ + alert("Error in setting 24/12 Hour clock") + } + }); + + } + } + + set24HourClockValue(clockInput){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'set24HourClock', + params: { + is24Hour: clockInput + }, + }; + + return this.api.req(_rest, _rpc); + } + getFrontPanelLightsInfo(){ + const _rest = { + method : 'GET', + path : `${this.callsign}`, + }; + + const _rpc = { + plugin : this.callsign, + method : 'getFrontPanelLights' + }; + + return this.api.req(_rest, _rpc); + } + setClockTestPatn(){ + if (this.showValueClock.value == '') { + alert('Please provide show value'); + }else if(this.timeIntervalClock.value == ''){ + alert('Please provide time interval value'); + }else{ + this.setClockTestPattern(this.showValueClock.value,this.timeIntervalClock.value).then(response => { + if(response.success){ + alert("clock test pattern set successfully") + }else{ + alert("Error in setting clock test pattern ") + } + }); + + } + + } + setClockTestPattern(showValue,timeIntervalVal){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'setClockTestPattern', + params: { + show: showValue, + timeInterval: timeIntervalVal + }, + }; + + return this.api.req(_rest, _rpc); + } + setLED(){ + if (this.ledIndicator.value == '') { + alert('Please provide LED Indicator Value'); + }else if(this.LEDBrightness.value == ''){ + alert('Please provide LED Brightness value'); + }else{ + this.setLEDValues(this.ledIndicator.value,this.LEDBrightness.value,this.LEDColor.value,this,this.LEDRed.value,this.LEDGreen.value,this,this.LEDBlue.value).then(response => { + if(response.success){ + alert("LED Values set successfully") + }else{ + alert("Error in setting LED Values ") + } + }); + + } + + } + setLEDValues(LED_Indicator,LED_Brightness,LED_Color,LED_Red,LED_Green,LED_Blue){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'setLED', + params: { + ledIndicator: LED_Indicator, + brightness: LED_Brightness, + color: LED_Color, + red: LED_Red, + green: LED_Green, + blue: LED_Blue + }, + }; + + return this.api.req(_rest, _rpc); + + } + powerOnLED(){ + if (this.powerOnIndex.value == '') { + alert('Please provideIndex Value'); + }else{ + this.LEDPowerOn(this.powerOnIndex.value).then(response => { + if(response.success){ + alert("LED power on successfully") + }else{ + alert("Error in switching on power LED ") + } + }); + + } + } + LEDPowerOn(IndexVal){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'powerLedOn', + params: { + index: IndexVal + }, + }; + + return this.api.req(_rest, _rpc); + } + powerOffLED(){ + if (this.powerOffIndex.value == '') { + alert('Please provide Index Value'); + }else{ + this.LEDPowerOff(this.powerOffIndex.value).then(response => { + if(response.success){ + alert("LED power off successfully") + }else{ + alert("Error in switching off power LED ") + } + }); + + } + } + LEDPowerOff(IndexVal){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'powerLedOff', + params: { + index: IndexVal + }, + }; + + return this.api.req(_rest, _rpc); + } +} + +export default FrontPanel; \ No newline at end of file diff --git a/src/js/plugins/index.js b/src/js/plugins/index.js index d961e72..d5dc179 100644 --- a/src/js/plugins/index.js +++ b/src/js/plugins/index.js @@ -68,6 +68,8 @@ import Warehouse from './warehouse.js'; import XCast from './xcast.js' import WifiManager from './rdkservices/wifiManager.js' import LinearPlaybackControl from './linearplaybackcontrol.js'; +import SecurityAgent from './securityAgent.js'; +import FrontPanel from './frontPanel.js'; export default { ActivityMonitor, @@ -121,6 +123,8 @@ export default { Warehouse, WifiManager, XCast, - LinearPlaybackControl + LinearPlaybackControl, + SecurityAgent, + FrontPanel }; diff --git a/src/js/plugins/securityAgent.js b/src/js/plugins/securityAgent.js new file mode 100644 index 0000000..8971470 --- /dev/null +++ b/src/js/plugins/securityAgent.js @@ -0,0 +1,135 @@ +import Plugin from '../core/plugin.js'; + +class SecurityAgent extends Plugin { + constructor(pluginData, api) { + super(pluginData, api); + this.displayName = 'Security Agent'; + } + render() { + var mainDiv = document.getElementById('main'); + mainDiv.innerHTML = ` +
+ Create Token +
+
+ URL +
+
+ +
+ +
+ USER +
+
+ +
+
+ Hash +
+
+ +
+
+ +
+
+ Token +
+
+ - +
+
+ Validate Token +
+
+ Token +
+
+ +
+
+ +
+ + `; + this.URLValue=document.getElementById('URL'); + this.User=document.getElementById('User'); + this.Hash=document.getElementById('Hash'); + this.create_token = document.getElementById('create_token'); + this.create_token.onclick = this.createToken.bind(this); + this.value = document.getElementById('value'); + this.token=document.getElementById('token'); + this.validate_token = document.getElementById('validate_token'); + this.validate_token.onclick = this.validateToken.bind(this); + } + createToken() { + console.log("create token") + console.log("URL:::::",this.URLValue.value) + console.log("user name ::::",this.User.value) + console.log("hash ::::",this.Hash.value) + this.value.innerHTML = '-'; + if (this.URLValue.value == '') { + alert('Please provide URL'); + }else if(this.User.value == ''){ + alert('Please provide user name'); + }else if(this.Hash.value == ''){ + alert('Please provide random hash'); + } else { + this.getTokenValue(this.URLValue.value,this.User.value,this.Hash.value).then(response => { + this.value.innerHTML = response.token; + }); + } + } + getTokenValue(URL,User,Hash) { + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'createtoken', + params: { + url: URL, + user:User, + hash:Hash + }, + }; + + return this.api.req(_rest, _rpc); + } + validateToken(){ + if (this.token.value == '') { + alert('Please provide token'); + }else{ + this.validate(this.token.value).then(response => { + + if(response.valid===true){ + alert("token validated successfully") + }else{ + alert("validation unsuccessfull") + } + }); + } + + } + validate(token){ + const _rest = { + method: 'GET', + path: `${this.callsign}`, + }; + + const _rpc = { + plugin: this.callsign, + method: 'validate', + params: { + token:token + }, + }; + + return this.api.req(_rest, _rpc); + + } +} +export default SecurityAgent; \ No newline at end of file