HstUI.js 2.41 KB
/**
  * Project      :  AMDA-NG
  * Name         : HstUI.js
  * @plugin 	  amdaUI.HstUI
  * @extends 	  Ext.panel.Panel
  * @brief		 Hst view
  * @author Benjamin
  * @version $Id: HstUI.js 1123 2012-10-31 13:47:03Z benjamin $
  ********************************************************************************
  *    FT Id     :   Date   : Name - Description
  *******************************************************************************
  *  :          
  */

Ext.define('amdaUI.HstUI', {
    extend: 'amdaUI.AstroImagesUI',
    alias: 'widget.panelHst',
	
	getPreviewUrl : function(image)
	{
		return 'http://archive.stsci.edu/cgi-bin/hst_preview_search?ne=on&shrink=on&imfmt=gif&name='+image.get('name');
	},
	
	getImageLink : function(image)
	{
		return 'http://archive.stsci.edu/cgi-bin/mastpreview?mission=hst&dataid='+image.get('id');
	},
	
	getImageToSendUrl : function(image)
	{
		return 'http://archive.stsci.edu/cgi-bin/hst_preview_search?ne=on&imfmt=fits&name='+image.get('id');
	},
	
	getAcknowledgement : function()
	{
		return '<br/><a target="_blank"  href="http://archive.stsci.edu/">Mikulski Archive for Space Telescopes (MAST)</a>';
	},
	
	getTargetList : function()
	{
		return [
    	        ["saturn",  "Saturn"],
    	        ["jupiter", "Jupiter"],
    	        ["uranus", "Uranus"]];
	},
	
	onFinishGetImages : function(result, e)
	{	
		var t = e.getTransaction();
		if (e.status && result) 
		{	
		  if (result.success)
		  {
			this.createTree(result.result);
		  }
		  else
		  {
			  //ERROR
			  if (result.message)
				  Ext.Msg.show({title:'Error', msg: result.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
			  else
				  Ext.Msg.show({title:'Error', msg: 'Unknown error', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
		  }
		}
		else
		{
		  // FAILURE
	      Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
		}
	},
	
	refreshTree : function(o)
	{
		var startTime = Ext.Date.format(this.timeSelector.getStartTime(),"Y-m-d H:i:s");
		var stopTime = Ext.Date.format(this.timeSelector.getStopTime(),"Y-m-d H:i:s");     
        var planet = this.getTargetCombo().getValue();

        var obj = {
        		startTime : startTime,
        		stopTime  : stopTime,
        		planet    : planet
        };
        
        this.getImageTreePanel().setLoading(true);

        AmdaAction.getHstImagesUrl(obj,this.onFinishGetImages,this);
	}
});