Changeset 1273 for MDService2/trunk/MDService2/WebContent
- Timestamp:
- 05/08/11 01:04:30 (13 years ago)
- Location:
- MDService2/trunk/MDService2/WebContent/scripts
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js
r1252 r1273 9 9 var page_record_count = 10; 10 10 var formatquerystring_len = 25; 11 var workspace;11 //var workspace; 12 12 13 13 function Workspace(){ 14 14 15 15 }; 16 Workspace.save = function(type){ 17 var JSONText = JSON.stringify(jsonw["WorkspaceProfile"]); 16 Workspace.save = function(type, query, id, iq){ 17 var JSONText; 18 var qdata = "/"; 19 /* 20 if (type == "ADMIN"){ 21 JSONText = JSON.stringify(json_admin["WorkspaceProfile"]); 22 } else { 23 JSONText = JSON.stringify(jsonw["WorkspaceProfile"]); 24 } 25 */ 18 26 //var JSONText = JSON.stringify({"aa.a":"r"}); 19 27 //notifyUser(JSONText,'debug'); 20 $.post("/MDService2/workspaceprofilesave/" + type,{"data":JSONText}); 21 }; 22 Workspace.saveQuery = function(query){ 23 //queryset id 24 var id = parseInt($("#qts_select option:selected").val()); 25 var iq = 0; 26 var queries = jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"]; 27 28 //var iq = $('#userqueries').children().size(); 29 if (queries == "null"){ 30 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"] = [{}]; 31 } else { 32 iq = queries.length; 33 } 34 var jsonq = query.toJSON(); 35 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq] = jsonq; 36 Workspace.save("USER"); 37 appendQueryUI(jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq],iq, $('#userqueries')); 38 39 }; 28 29 JSONText = JSON.stringify(jsonw["WorkspaceProfile"]); 30 if (query != undefined){ 31 qdata = "/" + query.id; 32 } 33 $.post("/MDService2/workspaceprofilesave/" + type + qdata,{"data":JSONText}, function(data) { 34 query.id = $(data).text(); 35 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq]["id"] = query.id; 36 appendQueryUI(jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq],iq, $('#userqueries')); 37 // alert("success"); 38 }); 39 //.success(function() { alert("second success"); }) 40 //.error(function(e) { alert("error"); }) 41 //.complete(function() { alert("complete"); }); 42 43 44 }; 45 /* 46 Workspace.newQueryID = function(){ 47 var new_id; 48 49 loadAdminFile(); 50 json_admin["Admin"]["maxqid"] = parseInt(json_admin["Admin"]["maxqid"]) + 1; 51 new_id = json_admin["Admin"]["maxqid"]; 52 Workspace.save("ADMIN"); 53 return new_id; 54 }; 55 */ 40 56 function Collection(index, name){ 41 57 this.index = index; … … 49 65 */ 50 66 function Query(collection, columns, query , squery) { 67 this.id = 0; 51 68 this.collection = collection; // [] 52 69 this.columns = columns; // string … … 125 142 }; 126 143 144 Query.prototype.save = function(){ 145 //queryset id 146 var id = parseInt($("#qts_select option:selected").val()); 147 var iq = 0; 148 var queries = jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"]; 149 150 //var iq = $('#userqueries').children().size(); 151 if (queries == "null"){ 152 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"] = [{}]; 153 } else { 154 iq = queries.length; 155 } 156 // create queryID 157 this.id = 0;//Workspace.newQueryID();//id + "_" + iq; 158 var jsonq = this.toJSON(); 159 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq] = jsonq; 160 Workspace.save("USER", this, id, iq); 161 //appendQueryUI(jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq],iq, $('#userqueries')); 162 163 }; 164 165 127 166 Query.prototype.getcolumnstext = function (){ 128 167 … … 195 234 str = Query.queryliststring(this.squery, this.query) + coll + " @" + this.repository.toString(); 196 235 return str; 236 }; 237 238 Query.prototype.publish = function() { 239 $.post("/MDService2/virtualcollection/USER/" + this.id,""); 197 240 }; 198 241 … … 245 288 } 246 289 247 var jsonq = {"name":"", 290 var jsonq = {"id":this.id, 291 "name":"", 248 292 "squerystring":this.squery, 249 293 "querystring":this.query, … … 253 297 "startItem" : this.startItem, 254 298 "maximumItems" : this.maximumItems, 255 "options" : json_options, "bookmark" : "0", "time" : str_time}; 299 "options" : json_options, 300 "bookmark" : "0", 301 "time" : str_time}; 256 302 257 303 jsonq.name = Query.fullformatstring(jsonq); -
MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui.js
r1266 r1273 228 228 }); 229 229 230 $('.cmd_publish').live('click', function(event){ 231 var query = $(this).parent().data('query'); 232 query.publish(); 233 }); 230 234 231 235 ////////////////////////////////////////////// … … 351 355 qid = $(this).data('query').listid; 352 356 notifyUser("here I would save query: " + qid, "debug"); 353 Workspace.saveQuery($(this).data('query')); 357 $(this).data('query').save(); 358 //Workspace.saveQuery($(this).data('query')); 354 359 }); 355 360 -
MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui_load.js
r1266 r1273 34 34 35 35 }; 36 /* 37 function loadAdminFile(){ 38 json_admin = {'Admin':{'maxqid':'0','QueryIndices':'null'}}; 39 40 jQuery.getJSON("/MDService2/workspaceprofile/admin",function(data){ 41 json_admin = preprocessJSON(data); 42 }); 43 } 44 */ 36 45 function loadWorkspaceProfiles(){ 37 46 //empty json … … 39 48 $('#qts_input').val(""); 40 49 41 jQuery.getJSON("/MDService2/workspaceprofile/server",function(data){42 notifyUser(data['WorkspaceProfile'],'debug');43 var json = preprocessJSON(data);44 $("#serverqs").attr("data",JSON.stringify(json));45 loadQuerysets(json["WorkspaceProfile"]["Querysets"],"server");46 loadRepositories(json["WorkspaceProfile"]["Repositories"]);47 loadCollections(true);48 loadTerms();49 loadTermsAutocomplete();50 createTooltip(null);51 });52 53 50 // USER WORKSPACEPROFILE 54 51 jQuery.getJSON("/MDService2/workspaceprofile/user",function(data){ 55 52 notifyUser(data['WorkspaceProfile'],'debug'); 56 53 jsonw = preprocessJSON(data); 54 55 jQuery.getJSON("/MDService2/workspaceprofile/server",function(data){ 56 notifyUser(data['WorkspaceProfile'],'debug'); 57 var json = preprocessJSON(data); 58 $("#serverqs").attr("data",JSON.stringify(json)); 59 loadQuerysets(json["WorkspaceProfile"]["Querysets"],"server"); 60 loadRepositories(json["WorkspaceProfile"]["Repositories"]); 61 loadCollections(true); 62 loadTerms(); 63 loadTermsAutocomplete(); 64 createTooltip(null); 65 66 67 }); 68 57 69 loadQuerysets(jsonw["WorkspaceProfile"]["Querysets"],"user"); 58 70 //loadTermsets(jsonw["WorkspaceProfile"]["CustomTermsets"]); 59 71 createTooltip(this); 60 72 }); 73 74 61 75 62 76 } … … 259 273 json.name + '</a></span>' + 260 274 del + 261 '< div class="detail" >' +275 '<span class="cmd cmd_publish"></span><div class="detail" >' + 262 276 name + 263 277 '<div class="cmds-elem-prop"><span class="label">squery:</span><span class="value">' + squery + '</span></div>' + … … 276 290 $(qs).append(x); 277 291 292 var query = new Query([],"","",""); 293 query.load(json); 294 $(qs).find("[href='"+ id + "_" + i + "']").closest('.cmds-elem-plus').data('query',query); 278 295 $(qs).find('.detail').css({'z-index' : '1000'}); 279 296 … … 366 383 367 384 function preprocessJSON(json){ 385 if (json["Admin"] != undefined) { 386 if (json["Admin"]["QueryIndices"] != undefined){ 387 if (String(json["Admin"]["QueryIndices"]) != "null") { 388 if (json["Admin"].QueryIndices[0] == undefined){ 389 var jj = json["Admin"]["QueryIndices"]["item"]; 390 delete json["Admin"]["QueryIndices"]["item"]; 391 json["Admin"]["QueryIndices"] = [{}]; 392 json["Admin"]["QueryIndices"][0] = jj; 393 } 394 } 395 } 396 } 397 398 368 399 if (json["WorkspaceProfile"]["CustomTermsets"] != undefined){ 369 400 -
MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui_settings.js
r1234 r1273 12 12 13 13 //VARIABLES 14 var jsonw ;14 var jsonw, json_admin; 15 15 var url_params; 16 16 var local_collections = false;
Note: See TracChangeset
for help on using the changeset viewer.