rxcms-dbms_plugin 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/MIT-LICENSE +20 -0
 - data/README.rdoc +3 -0
 - data/Rakefile +29 -0
 - data/app/assets/javascripts/alliance_dbms_plugin/configure.js +555 -0
 - data/app/assets/javascripts/alliance_dbms_plugin/index.js +7 -0
 - data/app/assets/javascripts/alliance_dbms_plugin/installer.js +101 -0
 - data/app/assets/stylesheets/dbms_engine.css +4 -0
 - data/app/assets/stylesheets/dbms_installer.css +4 -0
 - data/app/controllers/dbms_connection_controller.rb +291 -0
 - data/app/controllers/dbms_engine_controller.rb +70 -0
 - data/app/controllers/dbms_installer_controller.rb +138 -0
 - data/app/controllers/dbms_services_controller.rb +33 -0
 - data/app/helpers/dbms_engine_helper.rb +49 -0
 - data/app/helpers/dbms_installer_helper.rb +2 -0
 - data/app/helpers/dbms_plugin_helper.rb +30 -0
 - data/app/models/database.rb +47 -0
 - data/app/views/dbms_engine/configure.html.erb +165 -0
 - data/app/views/dbms_engine/index.html.erb +1 -0
 - data/app/views/dbms_engine/installer.html.erb +55 -0
 - data/config/dbms/dbms_config.yml +8 -0
 - data/config/routes.rb +25 -0
 - data/db/migrate/20130828071533_create_databases.rb +8 -0
 - data/lib/rxcms-dbms_plugin/classes/executor.rb +153 -0
 - data/lib/rxcms-dbms_plugin/engine.rb +14 -0
 - data/lib/rxcms-dbms_plugin/version.rb +3 -0
 - data/lib/rxcms-dbms_plugin.rb +5 -0
 - data/lib/tasks/rxcms-dbms_plugin_tasks.rake +4 -0
 - metadata +174 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6a5c7b2e40fce8215804e11922e889f6bc1c8ac8
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 90ff1466b76e644a54ce462f99ff33545feff513
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 62b5dc9acedd100a71c041c9b2ce62eadaa69f6d278ab81145e767492ed3b4fa6e82ee0753f55f90b0c67e083302b4f17e8aa9f6f002214bac517a8e68221f3d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: bbc9af329dbc6aff233b4ab81f692d543fd5a9aa4e76b629a4eb8999267c20603c2bde1440224c1d3e87ab1ee550f4c884b02de28d822fc758b7a4d536df9b87
         
     | 
    
        data/MIT-LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright 2013 YOURNAME
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 4 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 5 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 6 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 7 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 8 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 9 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 12 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 15 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 16 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 17 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 18 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 19 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 20 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.rdoc
    ADDED
    
    
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env rake
         
     | 
| 
      
 2 
     | 
    
         
            +
            begin
         
     | 
| 
      
 3 
     | 
    
         
            +
              require 'bundler/setup'
         
     | 
| 
      
 4 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 5 
     | 
    
         
            +
              puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
            begin
         
     | 
| 
      
 8 
     | 
    
         
            +
              require 'rdoc/task'
         
     | 
| 
      
 9 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 10 
     | 
    
         
            +
              require 'rdoc/rdoc'
         
     | 
| 
      
 11 
     | 
    
         
            +
              require 'rake/rdoctask'
         
     | 
| 
      
 12 
     | 
    
         
            +
              RDoc::Task = Rake::RDocTask
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            RDoc::Task.new(:rdoc) do |rdoc|
         
     | 
| 
      
 16 
     | 
    
         
            +
              rdoc.rdoc_dir = 'rdoc'
         
     | 
| 
      
 17 
     | 
    
         
            +
              rdoc.title    = 'RxcmsDbmsPlugin'
         
     | 
| 
      
 18 
     | 
    
         
            +
              rdoc.options << '--line-numbers'
         
     | 
| 
      
 19 
     | 
    
         
            +
              rdoc.rdoc_files.include('README.rdoc')
         
     | 
| 
      
 20 
     | 
    
         
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
         
     | 
| 
      
 24 
     | 
    
         
            +
            load 'rails/tasks/engine.rake'
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            Bundler::GemHelper.install_tasks
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,555 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            var const_key_regex = /^[a-zA-Z\-]+$/i;
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            function reloadStoredQueriesList()
         
     | 
| 
      
 4 
     | 
    
         
            +
            {
         
     | 
| 
      
 5 
     | 
    
         
            +
                $.getJSON("/dbms/connection/query/all", function(response){
         
     | 
| 
      
 6 
     | 
    
         
            +
                    if (response.status == "success")
         
     | 
| 
      
 7 
     | 
    
         
            +
                    {
         
     | 
| 
      
 8 
     | 
    
         
            +
                        // Get previous selection
         
     | 
| 
      
 9 
     | 
    
         
            +
                        var prevActiveObj = $($(".storedQuery").filter(function(){
         
     | 
| 
      
 10 
     | 
    
         
            +
                            return $(this).hasClass("active");
         
     | 
| 
      
 11 
     | 
    
         
            +
                        }).first());
         
     | 
| 
      
 12 
     | 
    
         
            +
                        var prevActiveObjKey = null;
         
     | 
| 
      
 13 
     | 
    
         
            +
                        if (prevActiveObj != null && prevActiveObj != undefined)
         
     | 
| 
      
 14 
     | 
    
         
            +
                        {
         
     | 
| 
      
 15 
     | 
    
         
            +
                            prevActiveObjKey = $(prevActiveObj.find("span:first")).text();
         
     | 
| 
      
 16 
     | 
    
         
            +
                        }
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                        $("#storeQueryList li:not(:first)").remove();
         
     | 
| 
      
 19 
     | 
    
         
            +
                        for (var i = 0; i < response.data.length; i++)
         
     | 
| 
      
 20 
     | 
    
         
            +
                        {
         
     | 
| 
      
 21 
     | 
    
         
            +
                            var cloned = $("#storeQueryDummy").clone();
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                            $(cloned.find("a:first span:first")).text(response.data[i].key);
         
     | 
| 
      
 24 
     | 
    
         
            +
                            var responseData = JSON.parse(response.data[i].value);
         
     | 
| 
      
 25 
     | 
    
         
            +
                            $(cloned.find("a:first input[type=checkbox]:first")).attr("checked", responseData.enabled);
         
     | 
| 
      
 26 
     | 
    
         
            +
                            $(cloned.find("a:first input[type=checkbox]:first")).on("click", function(e){
         
     | 
| 
      
 27 
     | 
    
         
            +
                                e.stopPropagation();
         
     | 
| 
      
 28 
     | 
    
         
            +
                                var checked = $(this).is(":checked").toString();
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                                var id = $($(this).parents("li:first")).attr("data-store-id");
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                                $.ajax({
         
     | 
| 
      
 33 
     | 
    
         
            +
                                    url: "/dbms/connection/query/update/" + id,
         
     | 
| 
      
 34 
     | 
    
         
            +
                                    cache: false,
         
     | 
| 
      
 35 
     | 
    
         
            +
                                    type: "PUT",
         
     | 
| 
      
 36 
     | 
    
         
            +
                                    data: {
         
     | 
| 
      
 37 
     | 
    
         
            +
                                        "enabled" : checked
         
     | 
| 
      
 38 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 39 
     | 
    
         
            +
                                    before_send: function(){
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 42 
     | 
    
         
            +
                                    error: function(){
         
     | 
| 
      
 43 
     | 
    
         
            +
                                        Messenger().post("Unable to contact server");
         
     | 
| 
      
 44 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 45 
     | 
    
         
            +
                                    success: function(response){
         
     | 
| 
      
 46 
     | 
    
         
            +
                                        if (response.status == "success")
         
     | 
| 
      
 47 
     | 
    
         
            +
                                        {
         
     | 
| 
      
 48 
     | 
    
         
            +
                                            Messenger().post("The stored query was successfully updated");
         
     | 
| 
      
 49 
     | 
    
         
            +
                                        }
         
     | 
| 
      
 50 
     | 
    
         
            +
                                        else
         
     | 
| 
      
 51 
     | 
    
         
            +
                                        {
         
     | 
| 
      
 52 
     | 
    
         
            +
                                            Messenger().post("Unable to update the stored query");
         
     | 
| 
      
 53 
     | 
    
         
            +
                                        }
         
     | 
| 
      
 54 
     | 
    
         
            +
                                    }
         
     | 
| 
      
 55 
     | 
    
         
            +
                                });
         
     | 
| 
      
 56 
     | 
    
         
            +
                            });
         
     | 
| 
      
 57 
     | 
    
         
            +
                            $(cloned.find("a:first span:eq(1)")).on("click", function(e){
         
     | 
| 
      
 58 
     | 
    
         
            +
                                e.stopPropagation();
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                                var $this = $(this);
         
     | 
| 
      
 61 
     | 
    
         
            +
                                var id = $($(this).parents("li:first")).attr("data-store-id");
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                                $.ajax({
         
     | 
| 
      
 64 
     | 
    
         
            +
                                    url: "/dbms/connection/query/delete/" + id,
         
     | 
| 
      
 65 
     | 
    
         
            +
                                    cache: false,
         
     | 
| 
      
 66 
     | 
    
         
            +
                                    type: "DELETE",
         
     | 
| 
      
 67 
     | 
    
         
            +
                                    before_send: function(){
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 70 
     | 
    
         
            +
                                    error: function(){
         
     | 
| 
      
 71 
     | 
    
         
            +
                                        Messenger().post("Unable to contact server");
         
     | 
| 
      
 72 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 73 
     | 
    
         
            +
                                    success: function(response){
         
     | 
| 
      
 74 
     | 
    
         
            +
                                        if (response.status == "success")
         
     | 
| 
      
 75 
     | 
    
         
            +
                                        {
         
     | 
| 
      
 76 
     | 
    
         
            +
                                            var activeQueryObj = $($(".storedQuery").filter(function(){
         
     | 
| 
      
 77 
     | 
    
         
            +
                                                return $(this).hasClass("active");
         
     | 
| 
      
 78 
     | 
    
         
            +
                                            }).first());
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                                            if ($(activeQueryObj).find("span:eq(1)").get(0) == $this.get(0))
         
     | 
| 
      
 81 
     | 
    
         
            +
                                            {
         
     | 
| 
      
 82 
     | 
    
         
            +
                                                 $("#updateSqlBtn").attr("disabled","disabled");
         
     | 
| 
      
 83 
     | 
    
         
            +
                                                 $("#updateSqlBtn").hide();
         
     | 
| 
      
 84 
     | 
    
         
            +
                                                 $("#saveSqlBtn").show();
         
     | 
| 
      
 85 
     | 
    
         
            +
                                                 $($("#resultTable thead:first").find("tr:first")).html("");
         
     | 
| 
      
 86 
     | 
    
         
            +
                                                 $("#resultTable tbody:first").html("");
         
     | 
| 
      
 87 
     | 
    
         
            +
                                            }
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                                            reloadStoredQueriesList();
         
     | 
| 
      
 90 
     | 
    
         
            +
                                            Messenger().post("The stored query was successfully deleted");
         
     | 
| 
      
 91 
     | 
    
         
            +
                                        }
         
     | 
| 
      
 92 
     | 
    
         
            +
                                        else
         
     | 
| 
      
 93 
     | 
    
         
            +
                                        {
         
     | 
| 
      
 94 
     | 
    
         
            +
                                            Messenger().post("Unable to delete the stored query");
         
     | 
| 
      
 95 
     | 
    
         
            +
                                        }
         
     | 
| 
      
 96 
     | 
    
         
            +
                                    }
         
     | 
| 
      
 97 
     | 
    
         
            +
                                });
         
     | 
| 
      
 98 
     | 
    
         
            +
                            });
         
     | 
| 
      
 99 
     | 
    
         
            +
                            cloned.attr("data-store-id", response.data[i].id);
         
     | 
| 
      
 100 
     | 
    
         
            +
                            cloned.attr("data-store-language", responseData.language);
         
     | 
| 
      
 101 
     | 
    
         
            +
                            cloned.addClass("storedQuery");
         
     | 
| 
      
 102 
     | 
    
         
            +
                            cloned.removeAttr("id");
         
     | 
| 
      
 103 
     | 
    
         
            +
                            cloned.css("display","block");
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                            // set active if equal
         
     | 
| 
      
 106 
     | 
    
         
            +
                            if (prevActiveObjKey != null)
         
     | 
| 
      
 107 
     | 
    
         
            +
                                if ($(cloned.find("span:first")).text() == prevActiveObjKey)
         
     | 
| 
      
 108 
     | 
    
         
            +
                                    cloned.addClass("active");
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                            $("#storeQueryList").append(cloned);
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                        }
         
     | 
| 
      
 113 
     | 
    
         
            +
                    }
         
     | 
| 
      
 114 
     | 
    
         
            +
                    else
         
     | 
| 
      
 115 
     | 
    
         
            +
                    {
         
     | 
| 
      
 116 
     | 
    
         
            +
                        Messenger().post("unable to get list of stored queries");
         
     | 
| 
      
 117 
     | 
    
         
            +
                    }
         
     | 
| 
      
 118 
     | 
    
         
            +
                });
         
     | 
| 
      
 119 
     | 
    
         
            +
            }
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
            $(function(){
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                var elem = $("#saveSqlBtn");
         
     | 
| 
      
 124 
     | 
    
         
            +
                var updateElem = $("#updateSqlBtn");
         
     | 
| 
      
 125 
     | 
    
         
            +
                $.data(elem, "sqlResult", 0);
         
     | 
| 
      
 126 
     | 
    
         
            +
                $.data(updateElem, "sqlResult", 0);
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                Messenger.options = {
         
     | 
| 
      
 129 
     | 
    
         
            +
                    extraClasses: 'messenger-fixed messenger-on-bottom messenger-on-right',
         
     | 
| 
      
 130 
     | 
    
         
            +
                    theme: 'air'
         
     | 
| 
      
 131 
     | 
    
         
            +
                };
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
                $("#dbmsTypeSelect").on("change", function(){
         
     | 
| 
      
 134 
     | 
    
         
            +
                    $(".connectorContainer").fadeOut("fast");
         
     | 
| 
      
 135 
     | 
    
         
            +
                    switch($(this).val())
         
     | 
| 
      
 136 
     | 
    
         
            +
                    {
         
     | 
| 
      
 137 
     | 
    
         
            +
                        case "mysql2":
         
     | 
| 
      
 138 
     | 
    
         
            +
                            $("#sql").fadeIn("fast");
         
     | 
| 
      
 139 
     | 
    
         
            +
                            $("#portTxt").val("3306");
         
     | 
| 
      
 140 
     | 
    
         
            +
                            break;
         
     | 
| 
      
 141 
     | 
    
         
            +
                        case "sqlite":
         
     | 
| 
      
 142 
     | 
    
         
            +
                            $("#sqlite").fadeIn("fast");
         
     | 
| 
      
 143 
     | 
    
         
            +
                            break;
         
     | 
| 
      
 144 
     | 
    
         
            +
                        case "postgresql":
         
     | 
| 
      
 145 
     | 
    
         
            +
                            $("#sql").fadeIn("fast");
         
     | 
| 
      
 146 
     | 
    
         
            +
                            $("#portTxt").val("5432");
         
     | 
| 
      
 147 
     | 
    
         
            +
                            break;
         
     | 
| 
      
 148 
     | 
    
         
            +
                        default:
         
     | 
| 
      
 149 
     | 
    
         
            +
                    }
         
     | 
| 
      
 150 
     | 
    
         
            +
                });
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                $(".sqlProceedBtn").on("click", function(){
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
                    if ($("#dbmsTypeSelect").val() == "sqlite")
         
     | 
| 
      
 155 
     | 
    
         
            +
                    {
         
     | 
| 
      
 156 
     | 
    
         
            +
                        if ($("#dbTxtSqlite").val().length == 0)
         
     | 
| 
      
 157 
     | 
    
         
            +
                        {
         
     | 
| 
      
 158 
     | 
    
         
            +
                            Messenger().post("Path to database is required");
         
     | 
| 
      
 159 
     | 
    
         
            +
                            return;
         
     | 
| 
      
 160 
     | 
    
         
            +
                        }
         
     | 
| 
      
 161 
     | 
    
         
            +
                    }
         
     | 
| 
      
 162 
     | 
    
         
            +
                    else
         
     | 
| 
      
 163 
     | 
    
         
            +
                    {
         
     | 
| 
      
 164 
     | 
    
         
            +
                        var errors = "";
         
     | 
| 
      
 165 
     | 
    
         
            +
                        if ($("#hostTxt").val().length == 0) errors += "Host is required.<br />"
         
     | 
| 
      
 166 
     | 
    
         
            +
                        if ($("#portTxt").val().length == 0) errors += "Port is required.<br />"
         
     | 
| 
      
 167 
     | 
    
         
            +
                        if ($("#dbTxt").val().length == 0) errors += "Database is required.<br />"
         
     | 
| 
      
 168 
     | 
    
         
            +
                        if ($("#userTxt").val().length == 0) errors += "User is required.<br />"
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                        if (errors.length > 0)
         
     | 
| 
      
 171 
     | 
    
         
            +
                        {
         
     | 
| 
      
 172 
     | 
    
         
            +
                            Messenger().post(errors);
         
     | 
| 
      
 173 
     | 
    
         
            +
                            return;
         
     | 
| 
      
 174 
     | 
    
         
            +
                        }
         
     | 
| 
      
 175 
     | 
    
         
            +
                    }
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
                    $("#sqlProceedBtn").attr("disabled","disabled");
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
                    $.post("/dbms/connection/make",
         
     | 
| 
      
 180 
     | 
    
         
            +
                    {
         
     | 
| 
      
 181 
     | 
    
         
            +
                        "type" : $("#dbmsTypeSelect").val(),
         
     | 
| 
      
 182 
     | 
    
         
            +
                        "host" : $("#hostTxt").val(),
         
     | 
| 
      
 183 
     | 
    
         
            +
                        "port" : $("#portTxt").val(),
         
     | 
| 
      
 184 
     | 
    
         
            +
                        "database": $("#dbmsTypeSelect").val() == "sqlite" ? $("#dbTxtSqlite").val() : $("#dbTxt").val(),
         
     | 
| 
      
 185 
     | 
    
         
            +
                        "user" : $("#userTxt").val(),
         
     | 
| 
      
 186 
     | 
    
         
            +
                        "password" : $("#passwordTxt").val()
         
     | 
| 
      
 187 
     | 
    
         
            +
                    }
         
     | 
| 
      
 188 
     | 
    
         
            +
                    ,function(response){
         
     | 
| 
      
 189 
     | 
    
         
            +
                        if (response.status == "success")
         
     | 
| 
      
 190 
     | 
    
         
            +
                        {
         
     | 
| 
      
 191 
     | 
    
         
            +
                            Messenger().post("Connection to database server was established, creating persistent database records...");
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                            $.post("/dbms/installer/before_process", {
         
     | 
| 
      
 194 
     | 
    
         
            +
                                "dbmsAdapter" : $("#dbmsTypeSelect").val(),
         
     | 
| 
      
 195 
     | 
    
         
            +
                                "dbmsHost" : $("#hostTxt").val(),
         
     | 
| 
      
 196 
     | 
    
         
            +
                                "dbmsPort" : $("#portTxt").val(),
         
     | 
| 
      
 197 
     | 
    
         
            +
                                "dbmsDatabase" : $("#dbmsTypeSelect").val() == "sqlite" ? $("#dbTxtSqlite").val() : $("#dbTxt").val(),
         
     | 
| 
      
 198 
     | 
    
         
            +
                                "dbmsUser" : $("#userTxt").val(),
         
     | 
| 
      
 199 
     | 
    
         
            +
                                "dbmsPassword" : $("#passwordTxt").val()
         
     | 
| 
      
 200 
     | 
    
         
            +
                            }, function(response){
         
     | 
| 
      
 201 
     | 
    
         
            +
                                if (response.status == "success")
         
     | 
| 
      
 202 
     | 
    
         
            +
                                {
         
     | 
| 
      
 203 
     | 
    
         
            +
                                    Messenger().post("All done, reloading...");
         
     | 
| 
      
 204 
     | 
    
         
            +
                                    location.reload();
         
     | 
| 
      
 205 
     | 
    
         
            +
                                }
         
     | 
| 
      
 206 
     | 
    
         
            +
                                else
         
     | 
| 
      
 207 
     | 
    
         
            +
                                {
         
     | 
| 
      
 208 
     | 
    
         
            +
                                    $("#sqlProceedBtn").removeAttr("disabled");
         
     | 
| 
      
 209 
     | 
    
         
            +
                                    Messenger().post("There was a problem while doing initial processing");
         
     | 
| 
      
 210 
     | 
    
         
            +
                                }
         
     | 
| 
      
 211 
     | 
    
         
            +
                            }).error(function(){
         
     | 
| 
      
 212 
     | 
    
         
            +
                                    $("#sqlProceedBtn").removeAttr("disabled");
         
     | 
| 
      
 213 
     | 
    
         
            +
                                    Messenger().post("Unable to do initial processing");
         
     | 
| 
      
 214 
     | 
    
         
            +
                                })
         
     | 
| 
      
 215 
     | 
    
         
            +
                        }
         
     | 
| 
      
 216 
     | 
    
         
            +
                        else
         
     | 
| 
      
 217 
     | 
    
         
            +
                        {
         
     | 
| 
      
 218 
     | 
    
         
            +
                            Messenger().post("The current login information is invalid or component configuration items are malformed.");
         
     | 
| 
      
 219 
     | 
    
         
            +
                            location.reload();
         
     | 
| 
      
 220 
     | 
    
         
            +
                        }
         
     | 
| 
      
 221 
     | 
    
         
            +
                    }).error(function(){
         
     | 
| 
      
 222 
     | 
    
         
            +
                        $("#sqlProceedBtn").removeAttr("disabled");
         
     | 
| 
      
 223 
     | 
    
         
            +
                        Messenger().post("Unable to connect to server");
         
     | 
| 
      
 224 
     | 
    
         
            +
                    });
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
                    //$("#dataManagementConsole").fadeIn("fast");
         
     | 
| 
      
 227 
     | 
    
         
            +
                });
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
                // Populate stored query list
         
     | 
| 
      
 230 
     | 
    
         
            +
                reloadStoredQueriesList();
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
      
 232 
     | 
    
         
            +
                // Retrieve data from table
         
     | 
| 
      
 233 
     | 
    
         
            +
                $("#executeSqlBtn").on("click", function(){
         
     | 
| 
      
 234 
     | 
    
         
            +
                    var $this = $(this);
         
     | 
| 
      
 235 
     | 
    
         
            +
                    $($("#resultTable thead:first").find("tr:first")).html("");
         
     | 
| 
      
 236 
     | 
    
         
            +
                    $("#resultTable tbody:first").html("");
         
     | 
| 
      
 237 
     | 
    
         
            +
             
     | 
| 
      
 238 
     | 
    
         
            +
                    if ($("#sqlQueryTxt").val().length > 0)
         
     | 
| 
      
 239 
     | 
    
         
            +
                    {
         
     | 
| 
      
 240 
     | 
    
         
            +
                        $this.attr("disabled","disabled");
         
     | 
| 
      
 241 
     | 
    
         
            +
                        $.post("/dbms/connection/sql", {
         
     | 
| 
      
 242 
     | 
    
         
            +
                            "sql" : $("#sqlQueryTxt").val()
         
     | 
| 
      
 243 
     | 
    
         
            +
                        }, function(response){
         
     | 
| 
      
 244 
     | 
    
         
            +
                            if (response.status == "success")
         
     | 
| 
      
 245 
     | 
    
         
            +
                            {
         
     | 
| 
      
 246 
     | 
    
         
            +
                                var columns = response.data.columns;
         
     | 
| 
      
 247 
     | 
    
         
            +
                                var result = response.data.result;
         
     | 
| 
      
 248 
     | 
    
         
            +
             
     | 
| 
      
 249 
     | 
    
         
            +
                                // console.log("populating columns...");
         
     | 
| 
      
 250 
     | 
    
         
            +
                                // Populate Table columns with labels
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
                                if (columns.length > 0)
         
     | 
| 
      
 253 
     | 
    
         
            +
                                {
         
     | 
| 
      
 254 
     | 
    
         
            +
                                   for (var col = 0; col < columns.length; col++)
         
     | 
| 
      
 255 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 256 
     | 
    
         
            +
                                        var th = $("<th>" + columns[col] + "</th>")
         
     | 
| 
      
 257 
     | 
    
         
            +
                                        $($("#resultTable thead:first").find("tr:first")).append(th);
         
     | 
| 
      
 258 
     | 
    
         
            +
                                    }
         
     | 
| 
      
 259 
     | 
    
         
            +
                                    $("#saveSqlBtn").removeAttr("disabled");
         
     | 
| 
      
 260 
     | 
    
         
            +
                                    $("#updateSqlBtn").removeAttr("disabled");
         
     | 
| 
      
 261 
     | 
    
         
            +
                                }
         
     | 
| 
      
 262 
     | 
    
         
            +
                                else
         
     | 
| 
      
 263 
     | 
    
         
            +
                                {
         
     | 
| 
      
 264 
     | 
    
         
            +
                                    var th = $("<th>No data</th>");
         
     | 
| 
      
 265 
     | 
    
         
            +
                                    $($("#resultTable thead:first").find("tr:first")).append(th);
         
     | 
| 
      
 266 
     | 
    
         
            +
             
     | 
| 
      
 267 
     | 
    
         
            +
                                    $("#saveSqlBtn").attr("disabled","disabled");
         
     | 
| 
      
 268 
     | 
    
         
            +
                                    $("#updateSqlBtn").removeAttr("disabled");
         
     | 
| 
      
 269 
     | 
    
         
            +
                                }
         
     | 
| 
      
 270 
     | 
    
         
            +
                                // console.log("populating records...")
         
     | 
| 
      
 271 
     | 
    
         
            +
                                // Populate table records
         
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
      
 273 
     | 
    
         
            +
                                for (var i = 0; i < result.length; i++)
         
     | 
| 
      
 274 
     | 
    
         
            +
                                {
         
     | 
| 
      
 275 
     | 
    
         
            +
                                    var row = $("<tr></tr>");
         
     | 
| 
      
 276 
     | 
    
         
            +
                                    for (var index in result[i])
         
     | 
| 
      
 277 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 278 
     | 
    
         
            +
                                        console.log(result[i][index]);
         
     | 
| 
      
 279 
     | 
    
         
            +
                                        var rowData = $("<td>" + result[i][index] + "</td>");
         
     | 
| 
      
 280 
     | 
    
         
            +
                                        $(row).append(rowData);
         
     | 
| 
      
 281 
     | 
    
         
            +
                                    }
         
     | 
| 
      
 282 
     | 
    
         
            +
                                    $("#resultTable tbody:first").append(row);
         
     | 
| 
      
 283 
     | 
    
         
            +
                                }
         
     | 
| 
      
 284 
     | 
    
         
            +
                                // console.log("done...");
         
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
      
 286 
     | 
    
         
            +
                                // set data for save button
         
     | 
| 
      
 287 
     | 
    
         
            +
                                $.data(elem, "sqlResult", columns.length);
         
     | 
| 
      
 288 
     | 
    
         
            +
                                $.data(updateElem, "sqlResult", columns.length);
         
     | 
| 
      
 289 
     | 
    
         
            +
                            }
         
     | 
| 
      
 290 
     | 
    
         
            +
                            else
         
     | 
| 
      
 291 
     | 
    
         
            +
                            {
         
     | 
| 
      
 292 
     | 
    
         
            +
                                if (response.message != undefined)
         
     | 
| 
      
 293 
     | 
    
         
            +
                                    Messenger().post(response.message);
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
                                if (response.data != undefined)
         
     | 
| 
      
 296 
     | 
    
         
            +
                                // set data for save button
         
     | 
| 
      
 297 
     | 
    
         
            +
                                    $.data(elem, "sqlResult", response.data.columns.length);
         
     | 
| 
      
 298 
     | 
    
         
            +
                            }
         
     | 
| 
      
 299 
     | 
    
         
            +
             
     | 
| 
      
 300 
     | 
    
         
            +
                            $this.removeAttr("disabled");
         
     | 
| 
      
 301 
     | 
    
         
            +
                        }).error(function(){
         
     | 
| 
      
 302 
     | 
    
         
            +
                            Messenger().post("Unable to contact server");
         
     | 
| 
      
 303 
     | 
    
         
            +
                            $this.removeAttr("disabled");
         
     | 
| 
      
 304 
     | 
    
         
            +
                        });
         
     | 
| 
      
 305 
     | 
    
         
            +
                    }
         
     | 
| 
      
 306 
     | 
    
         
            +
             
     | 
| 
      
 307 
     | 
    
         
            +
                });
         
     | 
| 
      
 308 
     | 
    
         
            +
             
     | 
| 
      
 309 
     | 
    
         
            +
                    // Save query to table
         
     | 
| 
      
 310 
     | 
    
         
            +
                elem.on("click", function(){
         
     | 
| 
      
 311 
     | 
    
         
            +
                    var iGood = $.data(elem, "sqlResult");
         
     | 
| 
      
 312 
     | 
    
         
            +
                    $("#processStoreQueryModalBtn").attr("data-igood", iGood);
         
     | 
| 
      
 313 
     | 
    
         
            +
             
     | 
| 
      
 314 
     | 
    
         
            +
                    if (iGood == 0)
         
     | 
| 
      
 315 
     | 
    
         
            +
                    {
         
     | 
| 
      
 316 
     | 
    
         
            +
                        Messenger().post("No 'select' queries were executed");
         
     | 
| 
      
 317 
     | 
    
         
            +
                    } else
         
     | 
| 
      
 318 
     | 
    
         
            +
                    {
         
     | 
| 
      
 319 
     | 
    
         
            +
                        $("#storedQueryKey").val("");
         
     | 
| 
      
 320 
     | 
    
         
            +
                        $("#storeQueryModal").modal();
         
     | 
| 
      
 321 
     | 
    
         
            +
                    }
         
     | 
| 
      
 322 
     | 
    
         
            +
                });
         
     | 
| 
      
 323 
     | 
    
         
            +
             
     | 
| 
      
 324 
     | 
    
         
            +
                updateElem.on("click", function(){
         
     | 
| 
      
 325 
     | 
    
         
            +
                    var iGood = $.data(updateElem, "sqlResult");
         
     | 
| 
      
 326 
     | 
    
         
            +
                    if (iGood == 0)
         
     | 
| 
      
 327 
     | 
    
         
            +
                    {
         
     | 
| 
      
 328 
     | 
    
         
            +
                        Messenger().post("No 'select' queries were executed");
         
     | 
| 
      
 329 
     | 
    
         
            +
                    }
         
     | 
| 
      
 330 
     | 
    
         
            +
                    else
         
     | 
| 
      
 331 
     | 
    
         
            +
                    {
         
     | 
| 
      
 332 
     | 
    
         
            +
                        // Perform update
         
     | 
| 
      
 333 
     | 
    
         
            +
                        var updateObj = $($(".storedQuery").filter(function(){
         
     | 
| 
      
 334 
     | 
    
         
            +
                            return $(this).hasClass("active");
         
     | 
| 
      
 335 
     | 
    
         
            +
                        }).first());
         
     | 
| 
      
 336 
     | 
    
         
            +
                        var id = updateObj.attr("data-store-id");
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
                        $.ajax({
         
     | 
| 
      
 339 
     | 
    
         
            +
                            url: "/dbms/connection/query/update/" + id,
         
     | 
| 
      
 340 
     | 
    
         
            +
                            cache: false,
         
     | 
| 
      
 341 
     | 
    
         
            +
                            type: "PUT",
         
     | 
| 
      
 342 
     | 
    
         
            +
                            data: {
         
     | 
| 
      
 343 
     | 
    
         
            +
                                "value" : $("#sqlQueryTxt").val().trim()
         
     | 
| 
      
 344 
     | 
    
         
            +
                            },
         
     | 
| 
      
 345 
     | 
    
         
            +
                            before_send: function(){
         
     | 
| 
      
 346 
     | 
    
         
            +
             
     | 
| 
      
 347 
     | 
    
         
            +
                            },
         
     | 
| 
      
 348 
     | 
    
         
            +
                            error: function(){
         
     | 
| 
      
 349 
     | 
    
         
            +
                                Messenger().post("Unable to contact server");
         
     | 
| 
      
 350 
     | 
    
         
            +
                            },
         
     | 
| 
      
 351 
     | 
    
         
            +
                            success: function(response){
         
     | 
| 
      
 352 
     | 
    
         
            +
                                if (response.status == "success")
         
     | 
| 
      
 353 
     | 
    
         
            +
                                {
         
     | 
| 
      
 354 
     | 
    
         
            +
                                    Messenger().post("The stored query was successfully updated");
         
     | 
| 
      
 355 
     | 
    
         
            +
                                }
         
     | 
| 
      
 356 
     | 
    
         
            +
                                else
         
     | 
| 
      
 357 
     | 
    
         
            +
                                {
         
     | 
| 
      
 358 
     | 
    
         
            +
                                    Messenger().post("Unable to update the stored query");
         
     | 
| 
      
 359 
     | 
    
         
            +
                                }
         
     | 
| 
      
 360 
     | 
    
         
            +
                            }
         
     | 
| 
      
 361 
     | 
    
         
            +
                        });
         
     | 
| 
      
 362 
     | 
    
         
            +
                    }
         
     | 
| 
      
 363 
     | 
    
         
            +
                });
         
     | 
| 
      
 364 
     | 
    
         
            +
             
     | 
| 
      
 365 
     | 
    
         
            +
                $("#processStoreQueryModalBtn").on("click", function(){
         
     | 
| 
      
 366 
     | 
    
         
            +
                    var iGood = parseInt($(this).attr("data-igood"));
         
     | 
| 
      
 367 
     | 
    
         
            +
             
     | 
| 
      
 368 
     | 
    
         
            +
                    if ($("#storedQueryKey").val().length > 0)
         
     | 
| 
      
 369 
     | 
    
         
            +
                    {
         
     | 
| 
      
 370 
     | 
    
         
            +
                        if (const_key_regex.test($("#storedQueryKey").val()))
         
     | 
| 
      
 371 
     | 
    
         
            +
                        {
         
     | 
| 
      
 372 
     | 
    
         
            +
                            if (iGood > 0)
         
     | 
| 
      
 373 
     | 
    
         
            +
                            {
         
     | 
| 
      
 374 
     | 
    
         
            +
                                $.post("/dbms/connection/query/store", {
         
     | 
| 
      
 375 
     | 
    
         
            +
                                    "key" : $("#storedQueryKey").val().trim(),
         
     | 
| 
      
 376 
     | 
    
         
            +
                                    "value" : $("#sqlQueryTxt").val().trim()
         
     | 
| 
      
 377 
     | 
    
         
            +
                                }, function(response){
         
     | 
| 
      
 378 
     | 
    
         
            +
                                    if (response.status == "success")
         
     | 
| 
      
 379 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 380 
     | 
    
         
            +
                                        $("#storeQueryModal").modal("hide");
         
     | 
| 
      
 381 
     | 
    
         
            +
                                        $("#saveSqlBtn").attr("disabled","disabled");
         
     | 
| 
      
 382 
     | 
    
         
            +
                                        $("#saveSqlBtn").show();
         
     | 
| 
      
 383 
     | 
    
         
            +
                                        $("#updateSqlBtn").attr("disabled","disabled");
         
     | 
| 
      
 384 
     | 
    
         
            +
                                        $("#updateSqlBtn").hide();
         
     | 
| 
      
 385 
     | 
    
         
            +
                                        $($("#resultTable thead:first").find("tr:first")).html("");
         
     | 
| 
      
 386 
     | 
    
         
            +
                                        $("#resultTable tbody:first").html("");
         
     | 
| 
      
 387 
     | 
    
         
            +
                                        reloadStoredQueriesList();
         
     | 
| 
      
 388 
     | 
    
         
            +
                                        Messenger().post("Query has been successfully stored");
         
     | 
| 
      
 389 
     | 
    
         
            +
                                    } else
         
     | 
| 
      
 390 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 391 
     | 
    
         
            +
                                        Messenger().post(response.message);
         
     | 
| 
      
 392 
     | 
    
         
            +
                                    }
         
     | 
| 
      
 393 
     | 
    
         
            +
                                }).error(function(){
         
     | 
| 
      
 394 
     | 
    
         
            +
                                    Messenger().post("Unable to contact server");
         
     | 
| 
      
 395 
     | 
    
         
            +
                                });
         
     | 
| 
      
 396 
     | 
    
         
            +
                            }
         
     | 
| 
      
 397 
     | 
    
         
            +
                            else
         
     | 
| 
      
 398 
     | 
    
         
            +
                            {
         
     | 
| 
      
 399 
     | 
    
         
            +
                                Messenger().post("Query has no results");
         
     | 
| 
      
 400 
     | 
    
         
            +
                            }
         
     | 
| 
      
 401 
     | 
    
         
            +
                        }
         
     | 
| 
      
 402 
     | 
    
         
            +
                        else
         
     | 
| 
      
 403 
     | 
    
         
            +
                        {
         
     | 
| 
      
 404 
     | 
    
         
            +
                            Messenger().post("stored query key is invalid");
         
     | 
| 
      
 405 
     | 
    
         
            +
                        }
         
     | 
| 
      
 406 
     | 
    
         
            +
                    }
         
     | 
| 
      
 407 
     | 
    
         
            +
                    else
         
     | 
| 
      
 408 
     | 
    
         
            +
                    {
         
     | 
| 
      
 409 
     | 
    
         
            +
                        Messenger().post("stored query key is required");
         
     | 
| 
      
 410 
     | 
    
         
            +
                    }
         
     | 
| 
      
 411 
     | 
    
         
            +
                });
         
     | 
| 
      
 412 
     | 
    
         
            +
             
     | 
| 
      
 413 
     | 
    
         
            +
                $("#sqlQueryTxt").on("change", function(){
         
     | 
| 
      
 414 
     | 
    
         
            +
                    // Unimplemented
         
     | 
| 
      
 415 
     | 
    
         
            +
                });
         
     | 
| 
      
 416 
     | 
    
         
            +
             
     | 
| 
      
 417 
     | 
    
         
            +
                $("#sqlQueryTxt").on("keyup", function(){
         
     | 
| 
      
 418 
     | 
    
         
            +
                    $("#saveSqlBtn").attr("disabled","disabled");
         
     | 
| 
      
 419 
     | 
    
         
            +
                    $("#updateSqlBtn").attr("disabled","disabled");
         
     | 
| 
      
 420 
     | 
    
         
            +
                });
         
     | 
| 
      
 421 
     | 
    
         
            +
             
     | 
| 
      
 422 
     | 
    
         
            +
                $("#storeQueryList").on("click", ".storedQuery", function(e){
         
     | 
| 
      
 423 
     | 
    
         
            +
                    e.stopPropagation();
         
     | 
| 
      
 424 
     | 
    
         
            +
             
     | 
| 
      
 425 
     | 
    
         
            +
                    $(this).siblings().removeClass("active");
         
     | 
| 
      
 426 
     | 
    
         
            +
                    if ($(this).hasClass("active"))
         
     | 
| 
      
 427 
     | 
    
         
            +
                    {
         
     | 
| 
      
 428 
     | 
    
         
            +
                        $(this).removeClass("active");
         
     | 
| 
      
 429 
     | 
    
         
            +
                        $("#sqlQueryTxt").val("");
         
     | 
| 
      
 430 
     | 
    
         
            +
                        $("#updateSqlBtn").hide();
         
     | 
| 
      
 431 
     | 
    
         
            +
                        $("#localeSqlBtn").hide();
         
     | 
| 
      
 432 
     | 
    
         
            +
                        $("#saveSqlBtn").show();
         
     | 
| 
      
 433 
     | 
    
         
            +
                        $("#saveSqlBtn").attr("disabled","disabled");
         
     | 
| 
      
 434 
     | 
    
         
            +
                        $($("#resultTable thead:first").find("tr:first")).html("");
         
     | 
| 
      
 435 
     | 
    
         
            +
                        $("#resultTable tbody:first").html("");
         
     | 
| 
      
 436 
     | 
    
         
            +
                    }
         
     | 
| 
      
 437 
     | 
    
         
            +
                    else
         
     | 
| 
      
 438 
     | 
    
         
            +
                    {
         
     | 
| 
      
 439 
     | 
    
         
            +
                        $(this).addClass("active");
         
     | 
| 
      
 440 
     | 
    
         
            +
                        $("#resultTable tbody:first").html("");
         
     | 
| 
      
 441 
     | 
    
         
            +
                        $($("#resultTable thead:first").find("tr:first")).html("");
         
     | 
| 
      
 442 
     | 
    
         
            +
                        $("#updateSqlBtn").attr("disabled","disabled");
         
     | 
| 
      
 443 
     | 
    
         
            +
                        $("#updateSqlBtn").show();
         
     | 
| 
      
 444 
     | 
    
         
            +
                        $("#localeSqlBtn").show();
         
     | 
| 
      
 445 
     | 
    
         
            +
                        $("#saveSqlBtn").hide();
         
     | 
| 
      
 446 
     | 
    
         
            +
             
     | 
| 
      
 447 
     | 
    
         
            +
                        var id = $(this).attr("data-store-id");
         
     | 
| 
      
 448 
     | 
    
         
            +
                        $.getJSON("/dbms/connection/query/one/" + id + "/dbms_stored_query", function(response){
         
     | 
| 
      
 449 
     | 
    
         
            +
                            if (response.status == "success")
         
     | 
| 
      
 450 
     | 
    
         
            +
                            {
         
     | 
| 
      
 451 
     | 
    
         
            +
                                var data = JSON.parse(response.data.value);
         
     | 
| 
      
 452 
     | 
    
         
            +
                                $("#sqlQueryTxt").val(data.sql);
         
     | 
| 
      
 453 
     | 
    
         
            +
                            } else
         
     | 
| 
      
 454 
     | 
    
         
            +
                            {
         
     | 
| 
      
 455 
     | 
    
         
            +
                                Messenger().post("Unable to get stored query with that key");
         
     | 
| 
      
 456 
     | 
    
         
            +
                            }
         
     | 
| 
      
 457 
     | 
    
         
            +
                        }).error(function(){
         
     | 
| 
      
 458 
     | 
    
         
            +
                            Messenger().post("Unable to contact server");
         
     | 
| 
      
 459 
     | 
    
         
            +
                        });
         
     | 
| 
      
 460 
     | 
    
         
            +
                    }
         
     | 
| 
      
 461 
     | 
    
         
            +
                });
         
     | 
| 
      
 462 
     | 
    
         
            +
             
     | 
| 
      
 463 
     | 
    
         
            +
                $("#storeQueryLanguageModal").on("shown", function(){
         
     | 
| 
      
 464 
     | 
    
         
            +
                    $("#storeQueryLanguageSelect").attr('disabled','disabled');
         
     | 
| 
      
 465 
     | 
    
         
            +
             
     | 
| 
      
 466 
     | 
    
         
            +
                    $.getJSON("/manager/s/items/list/locale", function(response){
         
     | 
| 
      
 467 
     | 
    
         
            +
                        $("#storeQueryLanguageSelect").append($('<option value="none" data-value=""></option>'));
         
     | 
| 
      
 468 
     | 
    
         
            +
             
     | 
| 
      
 469 
     | 
    
         
            +
                        for (var i = 0; i < response.length; i++)
         
     | 
| 
      
 470 
     | 
    
         
            +
                        {
         
     | 
| 
      
 471 
     | 
    
         
            +
                            var langItem = $("<option></option>");
         
     | 
| 
      
 472 
     | 
    
         
            +
                            langItem.attr("value", response[i].value);
         
     | 
| 
      
 473 
     | 
    
         
            +
                            langItem.attr("data-value", response[i].id);
         
     | 
| 
      
 474 
     | 
    
         
            +
                            langItem.text(response[i].key);
         
     | 
| 
      
 475 
     | 
    
         
            +
             
     | 
| 
      
 476 
     | 
    
         
            +
                            $("#storeQueryLanguageSelect").append(langItem);
         
     | 
| 
      
 477 
     | 
    
         
            +
                        }
         
     | 
| 
      
 478 
     | 
    
         
            +
             
     | 
| 
      
 479 
     | 
    
         
            +
                        var updateObj = $($(".storedQuery").filter(function(){
         
     | 
| 
      
 480 
     | 
    
         
            +
                            return $(this).hasClass("active");
         
     | 
| 
      
 481 
     | 
    
         
            +
                        }).first());
         
     | 
| 
      
 482 
     | 
    
         
            +
                        var currentLanguageKey = updateObj.attr("data-store-language");
         
     | 
| 
      
 483 
     | 
    
         
            +
             
     | 
| 
      
 484 
     | 
    
         
            +
                        $("#storeQueryLanguageSelect").val(currentLanguageKey);
         
     | 
| 
      
 485 
     | 
    
         
            +
                        $("#storeQueryLanguageSelect").removeAttr("disabled");
         
     | 
| 
      
 486 
     | 
    
         
            +
                    }).error(function(){
         
     | 
| 
      
 487 
     | 
    
         
            +
                        $("#storeQueryLanguageSelect").append($('<option value="" data-value="">error when retrieving</option>'));
         
     | 
| 
      
 488 
     | 
    
         
            +
                    });
         
     | 
| 
      
 489 
     | 
    
         
            +
                });
         
     | 
| 
      
 490 
     | 
    
         
            +
             
     | 
| 
      
 491 
     | 
    
         
            +
                $("#storeQueryLanguageModal").on("hidden", function(){
         
     | 
| 
      
 492 
     | 
    
         
            +
                    $("#storeQueryLanguageSelect").html("");
         
     | 
| 
      
 493 
     | 
    
         
            +
                });
         
     | 
| 
      
 494 
     | 
    
         
            +
             
     | 
| 
      
 495 
     | 
    
         
            +
                $("#storeQueryLanguageSelect").on("change", function(){
         
     | 
| 
      
 496 
     | 
    
         
            +
                    var languageKey = $(this).val();
         
     | 
| 
      
 497 
     | 
    
         
            +
             
     | 
| 
      
 498 
     | 
    
         
            +
                    var updateObj = $($(".storedQuery").filter(function(){
         
     | 
| 
      
 499 
     | 
    
         
            +
                        return $(this).hasClass("active");
         
     | 
| 
      
 500 
     | 
    
         
            +
                    }).first());
         
     | 
| 
      
 501 
     | 
    
         
            +
                    var id = updateObj.attr("data-store-id");
         
     | 
| 
      
 502 
     | 
    
         
            +
             
     | 
| 
      
 503 
     | 
    
         
            +
                    $.ajax({
         
     | 
| 
      
 504 
     | 
    
         
            +
                        url: "/dbms/connection/query/update/" + id,
         
     | 
| 
      
 505 
     | 
    
         
            +
                        cache: false,
         
     | 
| 
      
 506 
     | 
    
         
            +
                        type: "PUT",
         
     | 
| 
      
 507 
     | 
    
         
            +
                        data: {
         
     | 
| 
      
 508 
     | 
    
         
            +
                            "language" : languageKey
         
     | 
| 
      
 509 
     | 
    
         
            +
                        },
         
     | 
| 
      
 510 
     | 
    
         
            +
                        before_send: function(){
         
     | 
| 
      
 511 
     | 
    
         
            +
             
     | 
| 
      
 512 
     | 
    
         
            +
                        },
         
     | 
| 
      
 513 
     | 
    
         
            +
                        error: function(){
         
     | 
| 
      
 514 
     | 
    
         
            +
                            Messenger().post("Unable to contact server");
         
     | 
| 
      
 515 
     | 
    
         
            +
                        },
         
     | 
| 
      
 516 
     | 
    
         
            +
                        success: function(response){
         
     | 
| 
      
 517 
     | 
    
         
            +
                            if (response.status == "success")
         
     | 
| 
      
 518 
     | 
    
         
            +
                            {
         
     | 
| 
      
 519 
     | 
    
         
            +
                                updateObj.attr("data-store-language",languageKey);
         
     | 
| 
      
 520 
     | 
    
         
            +
                                Messenger().post("The stored query was successfully updated");
         
     | 
| 
      
 521 
     | 
    
         
            +
                            }
         
     | 
| 
      
 522 
     | 
    
         
            +
                            else
         
     | 
| 
      
 523 
     | 
    
         
            +
                            {
         
     | 
| 
      
 524 
     | 
    
         
            +
                                Messenger().post("Unable to update the stored query");
         
     | 
| 
      
 525 
     | 
    
         
            +
                            }
         
     | 
| 
      
 526 
     | 
    
         
            +
                        }
         
     | 
| 
      
 527 
     | 
    
         
            +
                    });
         
     | 
| 
      
 528 
     | 
    
         
            +
             
     | 
| 
      
 529 
     | 
    
         
            +
                });
         
     | 
| 
      
 530 
     | 
    
         
            +
             
     | 
| 
      
 531 
     | 
    
         
            +
                $("#localeSqlBtn").on("click", function(){
         
     | 
| 
      
 532 
     | 
    
         
            +
                    $("#storeQueryLanguageModal").modal();
         
     | 
| 
      
 533 
     | 
    
         
            +
                    $("#storeQueryLanguageModal").modal("show");
         
     | 
| 
      
 534 
     | 
    
         
            +
                });
         
     | 
| 
      
 535 
     | 
    
         
            +
             
     | 
| 
      
 536 
     | 
    
         
            +
                $("#uninstallBtn").on("click", function(){
         
     | 
| 
      
 537 
     | 
    
         
            +
                    var $this = $(this);
         
     | 
| 
      
 538 
     | 
    
         
            +
                    $this.attr("disabled","disabled");
         
     | 
| 
      
 539 
     | 
    
         
            +
                    $.post("/dbms/installer/uninstall", function(response){
         
     | 
| 
      
 540 
     | 
    
         
            +
                        if (response.status == "success")
         
     | 
| 
      
 541 
     | 
    
         
            +
                        {
         
     | 
| 
      
 542 
     | 
    
         
            +
                            Messenger().post("Successfully uninstalled, redirecting...");
         
     | 
| 
      
 543 
     | 
    
         
            +
                            location.reload();
         
     | 
| 
      
 544 
     | 
    
         
            +
                        }
         
     | 
| 
      
 545 
     | 
    
         
            +
                        else
         
     | 
| 
      
 546 
     | 
    
         
            +
                        {
         
     | 
| 
      
 547 
     | 
    
         
            +
                            $this.removeAttr("disabled");
         
     | 
| 
      
 548 
     | 
    
         
            +
                            Messenger().post("Unable to uninstall component");
         
     | 
| 
      
 549 
     | 
    
         
            +
                        }
         
     | 
| 
      
 550 
     | 
    
         
            +
                    }).error(function(){
         
     | 
| 
      
 551 
     | 
    
         
            +
                        Messenger().post("Unable to contact server");
         
     | 
| 
      
 552 
     | 
    
         
            +
                        $this.removeAttr("disabled");
         
     | 
| 
      
 553 
     | 
    
         
            +
                    })
         
     | 
| 
      
 554 
     | 
    
         
            +
                });
         
     | 
| 
      
 555 
     | 
    
         
            +
            });
         
     |