Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactors buildObjectIdentity into super class #949

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions kbase-extension/static/kbase/js/kbwidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,28 @@ define (
return 'uuid-' + result;
},

buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) {
var obj = {};
if (wsRef) {
obj['ref'] = wsRef;
} else {
if (/^\d+$/.exec(workspaceID))
obj['wsid'] = workspaceID;
else
obj['workspace'] = workspaceID;

// same for the id
if (/^\d+$/.exec(objectID))
obj['objid'] = objectID;
else
obj['name'] = objectID;

if (objectVer)
obj['ver'] = objectVer;
}
return obj;
},

}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,28 +461,6 @@ define (
});
},

buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) {
var obj = {};
if (wsRef) {
obj['ref'] = wsRef;
} else {
if (/^\d+$/.exec(workspaceID))
obj['wsid'] = workspaceID;
else
obj['workspace'] = workspaceID;

// same for the id
if (/^\d+$/.exec(objectID))
obj['objid'] = objectID;
else
obj['name'] = objectID;

if (objectVer)
obj['ver'] = objectVer;
}
return obj;
},

clientError: function(error){
this.loading(false);
this.showMessage(error.error.error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Base class for viewers visualizaing expression of a set of conditions from various aspects
*
*
* The descendant classes should override:
* 1. getSubmtrixParams - to set params for get_submatrix_stat method from the KBaseFeatureValues service
* 2. buildWidget - to create a custom visuzualization
*
*
*
*
*
* Pavel Novichkov <[email protected]>
Expand Down Expand Up @@ -73,7 +73,7 @@ define([

// Create a message pane
this.$messagePane = $("<div/>").addClass("kbwidget-message-pane kbwidget-hide-message");
this.$elem.append(this.$messagePane);
this.$elem.append(this.$messagePane);

return this;
},
Expand All @@ -86,12 +86,12 @@ define([
"service_wizard");
this.genericClient = new GenericClient(serviceWizardURL, auth);
} else {
this.featureValueClient = new KBaseFeatureValues(this.options.featureValueURL, auth);
this.featureValueClient = new KBaseFeatureValues(this.options.featureValueURL, auth);
}
this.ws = new Workspace(this.options.wsURL, auth);
this.ws = new Workspace(this.options.wsURL, auth);

// Let's go...
this.loadAndRender();
this.loadAndRender();
return this;
},

Expand Down Expand Up @@ -198,7 +198,7 @@ define([

var $vizContainer = $("<div/>");
this.$elem.append( $vizContainer );
this.buildWidget( $vizContainer );
this.buildWidget( $vizContainer );
},

buildOverviewDiv: function($containerDiv){
Expand Down Expand Up @@ -229,22 +229,22 @@ define([
{ sTitle: "Name", mData: "id"},
// { sTitle: "Function", mData: "function"},
{ sTitle: "Min", mData:"min" },
{ sTitle: "Max", mData:"max" },
{ sTitle: "Avg", mData:"avg" },
{ sTitle: "Max", mData:"max" },
{ sTitle: "Avg", mData:"avg" },
{ sTitle: "Std", mData:"std"},
{ sTitle: "Missing", mData:"missing_values" }
],
"oLanguage": {
"sEmptyTable": "No conditions found!",
"sSearch": "Search: "
}
}
} );

$overviewSwitch.click(function(){
$overvewContainer.toggle();
});
},

buildConditionsTableData: function(){
var submatrixStat = this.submatrixStat;
var tableData = [];
Expand Down Expand Up @@ -278,12 +278,12 @@ define([
.append($("<td />").append(value));
return $row;
},

loading: function(isLoading) {
if (isLoading)
this.showMessage("<img src='" + this.options.loadingImage + "'/>");
else
this.hideMessage();
this.hideMessage();
},

showMessage: function(message) {
Expand Down Expand Up @@ -318,44 +318,22 @@ define([
"and will be fixed shortly."
}
}

var $errorDiv = $("<div>")
.addClass("alert alert-danger")
.append("<b>Error:</b>")
.append("<br>" + errString);
this.$elem.empty();
this.$elem.append($errorDiv);
},
},

uuid: function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
},

buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) {
var obj = {};
if (wsRef) {
obj['ref'] = wsRef;
} else {
if (/^\d+$/.exec(workspaceID))
obj['wsid'] = workspaceID;
else
obj['workspace'] = workspaceID;

// same for the id
if (/^\d+$/.exec(objectID))
obj['objid'] = objectID;
else
obj['name'] = objectID;

if (objectVer)
obj['ver'] = objectVer;
}
return obj;
}

});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -240,28 +240,6 @@ define (
});
},

buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) {
var obj = {};
if (wsRef) {
obj['ref'] = wsRef;
} else {
if (/^\d+$/.exec(workspaceID))
obj['wsid'] = workspaceID;
else
obj['workspace'] = workspaceID;

// same for the id
if (/^\d+$/.exec(objectID))
obj['objid'] = objectID;
else
obj['name'] = objectID;

if (objectVer)
obj['ver'] = objectVer;
}
return obj;
},

clientError: function(error){
this.loading(false);
this.showMessage(error.error.error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,28 +504,6 @@ define (
this.$messagePane.empty();
},

buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) {
var obj = {};
if (wsRef) {
obj['ref'] = wsRef;
} else {
if (/^\d+$/.exec(workspaceID))
obj['wsid'] = workspaceID;
else
obj['workspace'] = workspaceID;

// same for the id
if (/^\d+$/.exec(objectID))
obj['objid'] = objectID;
else
obj['name'] = objectID;

if (objectVer)
obj['ver'] = objectVer;
}
return obj;
},

clientError: function(error){
this.loading(false);
this.showMessage(error.error.error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Base class for viewers visualizaing expression of a set of genes from various aspects
*
*
* The descendant classes should override:
* 1. getSubmtrixParams - to set params for get_submatrix_stat method from the KBaseFeatureValues service
* 2. buildWidget - to create a custom visuzualization
*
*
*
*
*
* Pavel Novichkov <[email protected]>
Expand Down Expand Up @@ -315,27 +315,6 @@ define([
return v.toString(16);
});
},
buildObjectIdentity: function (workspaceID, objectID, objectVer, wsRef) {
var obj = {};
if (wsRef) {
obj['ref'] = wsRef;
} else {
if (/^\d+$/.exec(workspaceID))
obj['wsid'] = workspaceID;
else
obj['workspace'] = workspaceID;

// same for the id
if (/^\d+$/.exec(objectID))
obj['objid'] = objectID;
else
obj['name'] = objectID;

if (objectVer)
obj['ver'] = objectVer;
}
return obj;
}

});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -323,27 +323,6 @@ define (
});
},

buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) {
var obj = {};
if (wsRef) {
obj['ref'] = wsRef;
} else {
if (/^\d+$/.exec(workspaceID))
obj['wsid'] = workspaceID;
else
obj['workspace'] = workspaceID;

// same for the id
if (/^\d+$/.exec(objectID))
obj['objid'] = objectID;
else
obj['name'] = objectID;

if (objectVer)
obj['ver'] = objectVer;
}
return obj;
},

clientError: function(error){
this.loading(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,28 +248,6 @@ define (
this.$elem.append($errorDiv);
},

buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) {
var obj = {};
if (wsRef) {
obj['ref'] = wsRef;
} else {
if (/^\d+$/.exec(workspaceID))
obj['wsid'] = workspaceID;
else
obj['workspace'] = workspaceID;

// same for the id
if (/^\d+$/.exec(objectID))
obj['objid'] = objectID;
else
obj['name'] = objectID;

if (objectVer)
obj['ver'] = objectVer;
}
return obj;
},

loading: function(doneLoading) {
if (doneLoading)
this.hideMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,28 +207,6 @@ define (
};
},

buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) {
var obj = {};
if (wsRef) {
obj['ref'] = wsRef;
} else {
if (/^\d+$/.exec(workspaceID))
obj['wsid'] = workspaceID;
else
obj['workspace'] = workspaceID;

// same for the id
if (/^\d+$/.exec(objectID))
obj['objid'] = objectID;
else
obj['name'] = objectID;

if (objectVer)
obj['ver'] = objectVer;
}
return obj;
},

loading: function(doneLoading) {
if (doneLoading)
this.hideMessage();
Expand Down
Loading