{
    "type": "Ext.app.Controller",
    "reference": {
        "name": "items",
        "type": "array"
    },
    "codeClass": null,
    "userConfig": {
        "designer|userClassName": "Download"
    },
    "designerId": "e53043e0-57d4-458d-8d4f-8d2e838df789",
    "cn": [
        {
            "type": "fixedfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "application"
                ],
                "fn": "init",
                "implHandler": [
                    "this.control({\r",
                    "\t'#downloadZip': {\r",
                    "\t\tclick: this.downloadZip\r",
                    "\t},\r",
                    "\t'#downloadWeek': {\r",
                    "\t\tclick: this.downloadWeek\r",
                    "\t},\r",
                    "\t'#downloadLatest': {\r",
                    "\t\tclick: this.downloadLatest\r",
                    "\t}\r",
                    "});"
                ]
            },
            "designerId": "5ff6da42-d734-4749-94e0-754f5b397c0b"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "leftSide",
                "selector": "#leftSide"
            },
            "designerId": "b2e5c8f6-205c-4d63-82cf-0c27ed111154"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "btn"
                ],
                "fn": "downloadZip",
                "implHandler": [
                    "var data = {\r",
                    "\taction: 'monthZip'\r",
                    "};\r",
                    "\r",
                    "this.download(btn, data);"
                ]
            },
            "designerId": "98ef54be-30e4-4329-9514-fb9acc0a5a16"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "btn"
                ],
                "fn": "downloadWeek",
                "implHandler": [
                    "var data = {\r",
                    "\taction: 'weekZip'\r",
                    "};\r",
                    "\r",
                    "this.download(btn, data);"
                ]
            },
            "designerId": "e70ef3a9-54e5-4d8e-80b8-681bb142b9b0"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "btn"
                ],
                "fn": "downloadLatest",
                "implHandler": [
                    "var data = {\r",
                    "\taction: 'latestZip'\r",
                    "};\r",
                    "\r",
                    "this.download(btn, data);"
                ]
            },
            "designerId": "923d5b5e-cc5d-4c88-b22a-708a6f262202"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "btn",
                    "data"
                ],
                "fn": "download",
                "implHandler": [
                    "btn.blur();\r",
                    "btn.disable();\r",
                    "\r",
                    "var panel = this.getLeftSide();\r",
                    "panel.setLoading(true);\r",
                    "\r",
                    "Ext.Ajax.request({\r",
                    "\turl: '../../service/system_logs.php',\r",
                    "\tmethod: 'POST',\r",
                    "\tparams: Ext.Object.fromQueryString(document.location.search),\r",
                    "\tjsonData: data,\r",
                    "\tsuccess: function(response, object){\r",
                    "\t\tvar filename = Ext.JSON.decode(response.responseText).result;\r",
                    "\t\tif(!Ext.isEmpty(filename)) {\r",
                    "\t\t\tvar url = '../../service/system_logs.php'+document.location.search+'&action='+data.action+'&filename='+filename;\r",
                    "\r",
                    "\t\t\tvar iframe = document.getElementById(\"hiddenIFrameCurrent\");\r",
                    "\t\t\tif(iframe === null) {\r",
                    "\t\t\t\tiframe = document.createElement('iframe');\r",
                    "\t\t\t\tiframe.id = \"hiddenIFrameCurrent\";\r",
                    "\t\t\t\tiframe.style.display = 'none';\r",
                    "\t\t\t\tdocument.body.appendChild(iframe);\r",
                    "\t\t\t}\r",
                    "\t\t\tiframe.src = url;\r",
                    "\r",
                    "\t\t\tsetTimeout(function(){\r",
                    "\t\t\t\tpanel.setLoading(false);\r",
                    "\t\t\t\tbtn.enable();\r",
                    "\t\t\t}, 1500);\r",
                    "\t\t}\r",
                    "\t\telse {\r",
                    "\t\t\tbtn.enable();\r",
                    "\t\t\tpanel.setLoading(false);\r",
                    "\t\t}\r",
                    "\t},\r",
                    "\tfailure: function(response, object){\r",
                    "\t\tpanel.setLoading(false);\r",
                    "\t\tvar text = response.responseText;\r",
                    "\t\tExt.Error.raise({\r",
                    "\t\t\tmsg: 'Failed to get log content',\r",
                    "\t\t\toption: text,   // whatever was passed into the method\r",
                    "\t\t\t'object': object // other arbitrary info\r",
                    "\t\t});\r",
                    "\t},\r",
                    "\tscope: this\r",
                    "});\r",
                    ""
                ]
            },
            "designerId": "027b2987-f073-47af-a40b-91af6b0604d3"
        }
    ]
}