You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by pa...@apache.org on 2016/04/29 09:49:29 UTC
ambari git commit: AMBARI-16135. PIG View - unable to create scripts
when folders are specified (Ashwin Rajeev via pallavkul)
Repository: ambari
Updated Branches:
refs/heads/trunk 06ae6674c -> 287e2416c
AMBARI-16135. PIG View - unable to create scripts when folders are specified (Ashwin Rajeev via pallavkul)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/287e2416
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/287e2416
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/287e2416
Branch: refs/heads/trunk
Commit: 287e2416cc5c7472b6e254579ee574532450e649
Parents: 06ae667
Author: Pallav Kulshreshtha <pa...@gmail.com>
Authored: Fri Apr 29 13:18:29 2016 +0530
Committer: Pallav Kulshreshtha <pa...@gmail.com>
Committed: Fri Apr 29 13:18:29 2016 +0530
----------------------------------------------------------------------
.../ui/pig-web/app/controllers/pigScripts.js | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/287e2416/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigScripts.js
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigScripts.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigScripts.js
index 6dcb3fe..ef2ccfe 100644
--- a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigScripts.js
+++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigScripts.js
@@ -28,7 +28,7 @@ App.PigScriptsController = Em.ArrayController.extend(App.Pagination,{
},
confirmcreate:function (script,filePath) {
if (filePath) {
- return Em.RSVP.Promise.all([Em.RSVP.resolve(script), this.getOrCreateFile(filePath)])
+ return Em.RSVP.Promise.all([Em.RSVP.resolve(script), this.getOrCreateFile(filePath,script)])
.then(this.setFileAndSave.bind(this), Em.run.bind(this,'createScriptError', script));
} else {
script.save().then(this.createScriptSuccess.bind(this), Em.run.bind(this,'createScriptError',script));
@@ -42,16 +42,23 @@ App.PigScriptsController = Em.ArrayController.extend(App.Pagination,{
}
},
- getOrCreateFile: function (path) {
+ getOrCreateFile: function (path,script) {
var store = this.get('store');
-
+ var createNewFilePath = function(path,title){
+ var cleanedTitle = title.replace("[^a-zA-Z0-9 ]+", "").replace(" ", "_").toLowerCase();
+ var formattedDate = moment().format("YYYY-MM-DD_hh-mm-ss_SSSS");
+ var finalScriptName = cleanedTitle + "-" + formattedDate + ".pig";
+ return path + "/" + finalScriptName;
+ };
return new Em.RSVP.Promise(function (resolve, reject) {
store.find('file',path).then(function (file) {
resolve(file);
}, function (error) {
if (error.status === 404) {
+ store.recordForId('file', path).unloadRecord();
+ var newPath = createNewFilePath(path,script.get('title'));
var newFile = store.createRecord('file',{
- id:path,
+ id:newPath,
fileContent:''
});
@@ -67,6 +74,8 @@ App.PigScriptsController = Em.ArrayController.extend(App.Pagination,{
});
},
+
+
setFileAndSave: function (data) {
var script = data.objectAt(0),
file = data.objectAt(1);