Repository: ambari Updated Branches: refs/heads/trunk f5558eb82 -> 8ead0a50b
http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/modal/deleteUdf.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/modal/deleteUdf.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/modal/deleteUdf.js new file mode 100644 index 0000000..3cc5a55 --- /dev/null +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/modal/deleteUdf.js @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); + +App.DeleteUdfController = Ember.ObjectController.extend({ + needs:['pigUdfs'], + actions:{ + confirm:function () { + this.get('controllers.pigUdfs').send('deleteUdf',this.get('content')); + } + } +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/modal/pigModal.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/modal/pigModal.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/modal/pigModal.js index 9bb2950..f7d19f3 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/modal/pigModal.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/modal/pigModal.js @@ -44,7 +44,13 @@ App.PigModalComponent = Ember.Component.extend({ }, keyUp:function (e) { if (e.keyCode == 27) { - this.sendAction('close'); + return this.sendAction('close'); + } + }, + keyDown:function (e) { + if (e.keyCode == 13 && this.get('targetObject.isValid')) { + this.$('.modal').modal('hide'); + return this.sendAction('ok'); } }, show: function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pig.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pig.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pig.js index 1a1ac4d..33bfed4 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pig.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pig.js @@ -31,9 +31,7 @@ App.PigController = Em.ArrayController.extend({ this.send('showAlert', {'message':Em.I18n.t('scripts.alert.script_saved',{title: script.get('title')}),status:'success'}); }.bind(this), onFail = function(error){ - var trace = null; - if (error && error.responseJSON.trace) - trace = error.responseJSON.trace; + var trace = (error && error.responseJSON.trace)?error.responseJSON.trace:null; this.send('showAlert', {'message':Em.I18n.t('scripts.alert.save_error'),status:'error',trace:trace}); }.bind(this); @@ -50,9 +48,7 @@ App.PigController = Em.ArrayController.extend({ this.send('showAlert', {'message':Em.I18n.t('scripts.alert.script_deleted',{title : model.get('title')}),status:'success'}); }.bind(this); var onFail = function(error){ - var trace = null; - if (error && error.responseJSON.trace) - trace = error.responseJSON.trace; + var trace = (error && error.responseJSON.trace)?error.responseJSON.trace:null; this.send('showAlert', {'message':Em.I18n.t('scripts.alert.delete_failed'),status:'error',trace:trace}); }.bind(this); script.deleteRecord(); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigAlert.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigAlert.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigAlert.js index 65273a9..c95921c 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigAlert.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigAlert.js @@ -23,7 +23,7 @@ App.PigAlertController = Ember.ArrayController.extend({ needs: ['pigErrorLog'], actions:{ removeAlertObject:function (alert) { - this.content.removeObject(alert) + this.content.removeObject(alert); }, showErrorLog:function (context) { errorLogController = this.get('controllers.pigErrorLog'); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/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 6c39c67..2c2318b 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 @@ -36,7 +36,7 @@ App.PigScriptsController = Em.ArrayController.extend(App.Pagination,{ var file = this.store.createRecord('file',{ id:filePath, fileContent:'' - }) + }); } catch (e) { return this.createScriptError(script,e); } http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigUdfs.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigUdfs.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigUdfs.js index da41427..8494755 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigUdfs.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/pigUdfs.js @@ -26,6 +26,9 @@ App.PigUdfsController = Em.ArrayController.extend(App.Pagination,{ createUdf:function (udf) { return udf.save().then(this.onCreateSuccess.bind(this),this.onCreateFail.bind(this)); }, + deleteUdfModal:function(udf){ + return this.send('openModal','deleteUdf',udf); + }, deleteUdf:function(udf){ udf.deleteRecord(); return udf.save().then(this.onDeleteSuccess.bind(this),this.onDeleteFail.bind(this)); @@ -38,13 +41,11 @@ App.PigUdfsController = Em.ArrayController.extend(App.Pagination,{ }); }, onCreateFail:function (error) { - var trace = null; - if (error && error.responseJSON.trace) { - trace = error.responseJSON.trace; - } + var trace = (error && error.responseJSON.trace)?error.responseJSON.trace:null; this.send('showAlert', { message:Em.I18n.t('udfs.alert.create_failed'), - status:'error',trace:trace + status:'error', + trace:trace }); }, onDeleteSuccess: function(model){ @@ -54,10 +55,7 @@ App.PigUdfsController = Em.ArrayController.extend(App.Pagination,{ }); }, onDeleteFail:function(error){ - var trace = null; - if (error && error.responseJSON.trace) - trace = error.responseJSON.trace; - + var trace = (error && error.responseJSON.trace)?error.responseJSON.trace:null; this.send('showAlert', { message: Em.I18n.t('udfs.alert.delete_failed'), status:'error', http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/script.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/script.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/script.js index 1aced02..6b0707f 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/script.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/script.js @@ -38,7 +38,7 @@ App.ScriptController = Em.ObjectController.extend({ }, deleteJobSuccess:function (data) { - this.send('showAlert', {message:Em.I18n.t('job.alert.job_deleted'),status:'info'}) + this.send('showAlert', {message:Em.I18n.t('job.alert.job_deleted'),status:'info'}); }, deleteJobFailed:function (job,error) { var trace = (error.responseJSON)?error.responseJSON.trace:null; @@ -58,14 +58,19 @@ App.ScriptController = Em.ObjectController.extend({ staticTabs:function () { return [ {label:'Script',name:'script',url:'script.edit',target:this.get('controllers.pig.activeScript.id')}, - {label:'History',name:'history',url:'script.history',target:this.get('controllers.pig.activeScript.id')}, + {label:'History',name:'history',url:'script.history',target:this.get('controllers.pig.activeScript.id')} ]; }.property('controllers.pig.activeScript.id'), jobTabs:function () { var jobTabs = []; this.get('activeJobs').forEach(function (job) { - jobTabs.push({label:job.get('title') + ' - ' + job.get('status').decamelize().capitalize(), name:job.get('id'),url:'script.job',target:job.get('id')}) + jobTabs.push({ + label:job.get('title') + ' - ' + job.get('status').decamelize().capitalize(), + name:job.get('id'), + url:'script.job', + target:job.get('id') + }); }); return jobTabs; }.property('activeJobs.[]','activeJobs.@each.status'), @@ -81,15 +86,15 @@ App.ScriptController = Em.ObjectController.extend({ this.onPoll(); }, stop: function(){ - Em.run.cancel(this.get('timer')) + Em.run.cancel(this.get('timer')); }, onPoll: function() { this.get('jobs').forEach(function (job) { if (job.get('needsPing')) { job.reload(); } else { - this.jobs.removeObject(job) - }; + this.jobs.removeObject(job); + } }.bind(this)); if (this.get('jobs.length') > 0) { @@ -112,6 +117,6 @@ App.ScriptController = Em.ObjectController.extend({ activeJobsWatcher:function () { if (this.get('activeJobs.firstObject.scriptId') != this.get('controllers.pig.activeScript.id')) { this.set('activeJobs',[]); - }; + } }.observes('controllers.pig.activeScript.id') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptEdit.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptEdit.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptEdit.js index 816eb38..912a46e 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptEdit.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptEdit.js @@ -26,6 +26,7 @@ App.ScriptEditController = Em.ObjectController.extend({ titleWarn:false, tmpArgument:'', editor:null, + fullscreen:false, handleRenaming:function () { if (this.get('content.title')) { @@ -53,28 +54,28 @@ App.ScriptEditController = Em.ObjectController.extend({ } } else { controller.set('pigParams',[]); - }; + } }.observes('content.pigScript.fileContent','content.id'), oldTitle:'', actions: { rename:function (opt) { - var changedAttributes = this.get('content').changedAttributes() + var changedAttributes = this.get('content').changedAttributes(); - if (opt==='ask') { + if (opt === 'ask') { this.set('oldTitle',this.get('content.title')); this.set('isRenaming',true); - }; + } - if (opt==='cancel') { + if (opt === 'cancel') { this.set('content.title',this.get('oldTitle')); this.set('oldTitle',''); this.set('isRenaming',false); - }; + } - if (opt==='confirm') { - if (Em.isArray(changedAttributes.title) && this.get('content.title')) { + if (opt === this.get('content.title') && !Em.isBlank(this.get('content.title'))) { + if (Em.isArray(changedAttributes.title)) { this.get('content').save().then(function () { this.send('showAlert', {message:Em.I18n.t('editor.title_updated'),status:'success'}); }.bind(this)); @@ -117,6 +118,9 @@ App.ScriptEditController = Em.ObjectController.extend({ .then(executeMethod[operation].bind(this)) .then(this.executeSuccess.bind(this), this.executeError.bind(this)) .finally(Em.run.bind(this,this.set,'isExec',false)); + }, + fullscreen:function () { + this.toggleProperty('fullscreen'); } }, http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptJob.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptJob.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptJob.js index 8cd4fdc..d868823 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptJob.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptJob.js @@ -19,6 +19,7 @@ var App = require('app'); App.ScriptJobController = Em.ObjectController.extend(App.FileHandler,{ + fullscreen:false, scriptContents:function () { var promise = new Ember.RSVP.Promise(function(resolve,reject){ return this.get('content.pigScript').then(function (pigScript) { @@ -60,6 +61,9 @@ App.ScriptJobController = Em.ObjectController.extend(App.FileHandler,{ var file = (opt == 'results')?'jobResults.content.fileContent':'jobLogs.content.fileContent'; var suffix = (opt == 'results')?'_results.txt':'_logs.txt'; return this.downloadFile(this.get(file), this.get("suggestedFilenamePrefix")+suffix); + }, + fullscreen:function () { + this.toggleProperty('fullscreen'); } } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/splash.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/splash.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/splash.js index 49dd456..959d6d0 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/splash.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/splash.js @@ -23,7 +23,7 @@ App.SplashController = Ember.ObjectController.extend({ toggleStackTrace:function () { var value = this.get('isExpanded'); this.set('isExpanded', !value); - }, + } }, isExpanded: false, http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/initialize.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/initialize.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/initialize.js index 299b4c2..f4fca05 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/initialize.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/initialize.js @@ -68,10 +68,10 @@ App.register('lib:fileSaver', App.FileSaver); Ember.Handlebars.registerBoundHelper('showDate', function(date,format) { - return moment(date).format(format) + return moment(date).format(format); }); -Em.TextField.reopen(Em.I18n.TranslateableAttributes) +Em.TextField.reopen(Em.I18n.TranslateableAttributes); require('translations'); require('router'); @@ -113,6 +113,7 @@ require("controllers/errorLog"); require("controllers/modal/confirmAway"); require("controllers/modal/confirmDelete"); require("controllers/modal/deleteJob"); +require("controllers/modal/deleteUdf"); require("controllers/modal/createScript"); require("controllers/modal/createUdf"); require("controllers/modal/gotoCopy"); @@ -140,6 +141,7 @@ require("templates/modal/confirmAway"); require("templates/modal/confirmDelete"); require("templates/modal/createScript"); require("templates/modal/deleteJob"); +require("templates/modal/deleteUdf"); require("templates/modal/createUdf"); require("templates/modal/gotoCopy"); require("templates/modal/logDownload"); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/mixins/fileHandler.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/mixins/fileHandler.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/mixins/fileHandler.js index 0c2c93c..50ef3d2 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/mixins/fileHandler.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/mixins/fileHandler.js @@ -29,14 +29,14 @@ var _promise = function (controller, url, output) { controller.send('showAlert', {'message': Em.I18n.t('job.alert.promise_error', {status:response.status, message:response.message}), status:'error', trace: response.trace}); } - }) + }); }); }; App.FileHandler = Ember.Mixin.create({ fileProxy:function (url) { var promise, - host = this.store.adapterFor('application').get('host'); + host = this.store.adapterFor('application').get('host'), namespace = this.store.adapterFor('application').get('namespace'); url = [host, namespace, url].join('/'); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/mixins/pagination.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/mixins/pagination.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/mixins/pagination.js index 587ede9..fd6df47 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/mixins/pagination.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/mixins/pagination.js @@ -38,7 +38,7 @@ App.Pagination = Ember.Mixin.create({ pageWatcher:function () { if (this.get('page') > this.get('totalPages')) { this.set('page',this.get('totalPages') || 1); - }; + } }.observes('totalPages'), totalPages: function() { @@ -94,6 +94,6 @@ App.Pagination = Ember.Mixin.create({ paginationInfo: function () { var start = (this.get('page') - 1) * this.get('perPage') + 1; var end = start + this.get('paginatedContent.length') - 1; - return start + ' - ' + end + ' of ' + this.get('arrangedContent.length') + return start + ' - ' + end + ' of ' + this.get('arrangedContent.length'); }.property('page', 'arrangedContent.length', 'perPage') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/models/file.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/models/file.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/models/file.js index 297f697..1c7fa11 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/models/file.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/models/file.js @@ -22,5 +22,5 @@ App.File = DS.Model.extend({ fileContent: DS.attr('string'), hasNext:DS.attr('boolean'), page:DS.attr('number'), - pageCount:DS.attr('number'), + pageCount:DS.attr('number') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_job.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_job.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_job.js index b20a0ac..6bf40c1 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_job.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_job.js @@ -57,7 +57,7 @@ App.Job = DS.Model.extend({ var namespace = self.store.adapterFor('application').get('namespace'); var url = [host, namespace,'jobs',self.get('id')].join('/'); - self.set('isKilling',true) + self.set('isKilling',true); return Em.$.ajax(url, { type:'DELETE', contentType:'application/json', http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_script.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_script.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_script.js index ab06c21..c779264 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_script.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_script.js @@ -22,7 +22,7 @@ App.Script = DS.Model.extend({ title:DS.attr('string'), pigScript:DS.belongsTo('file', { async: true }), dateCreated:DS.attr('isodate', { defaultValue: moment()}), - templetonArguments:DS.attr('string', { defaultValue: '-useHCatalog'}), + templetonArguments:DS.attr('string'), // nav item identifier name:function (q){ return this.get('title')+this.get('id'); @@ -44,5 +44,9 @@ App.Script = DS.Model.extend({ dateCreatedUnix:function () { return moment(this.get('dateCreated')).unix(); - }.property('dateCreated') + }.property('dateCreated'), + + isBlankTitle:function () { + return Ember.isBlank(this.get('title')); + }.property('title') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/routes/script.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/routes/script.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/routes/script.js index f3e7fcd..3161e10 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/routes/script.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/routes/script.js @@ -49,11 +49,11 @@ App.ScriptRoute = Em.Route.extend({ var targetParams = transition.params[transition.targetName]; if (targetParams['script_id']) { return targetParams['script_id'] != this.controllerFor('pig').get('activeScriptId'); - }; + } if (targetParams['job_id'] && this.modelFor('script.history')) { return this.modelFor('script.history').get('content').filterBy('id',targetParams['job_id']).length == 0; - }; - }; + } + } return isScriptAway; } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/routes/scriptJob.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/routes/scriptJob.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/routes/scriptJob.js index 28ce908..e0059aa 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/routes/scriptJob.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/routes/scriptJob.js @@ -37,9 +37,7 @@ App.ScriptJobRoute = Em.Route.extend({ job.reload(); self.send('showAlert', {'message': Em.I18n.t('job.alert.job_killed',{title:self.get('title')}), status:'info'}); },function (reason) { - var trace = null; - if (reason && reason.responseJSON.trace) - trace = reason.responseJSON.trace; + var trace = (reason && reason.responseJSON.trace)?reason.responseJSON.trace:null; self.send('showAlert', {'message': Em.I18n.t('job.alert.job_kill_error'), status:'error', trace:trace}); }); } http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/styles/style.less ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/styles/style.less b/contrib/views/pig/src/main/resources/ui/pig-web/app/styles/style.less index b9c248a..c47eb83 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/styles/style.less +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/styles/style.less @@ -320,16 +320,29 @@ } .CodeMirror { .common-shadow-inset; - height:500px; + height:490px; .CodeMirror-hscrollbar { left: 0 !important; } } + .CodeMirror-fullscreen { + top: 88px; + } + #sgrip { + &:hover { + color: #111; + } + i { + position: relative; + left: 50%; + } + width: 100%; + text-shadow: 0 1px 2px rgba(0,0,0,.6); position: absolute; - left: 50%; cursor: s-resize; color: #999999; + zndex: 2; } .table-results { .argument { @@ -371,6 +384,7 @@ } } .panel-body { + position: relative; padding: 5px; background-color: #f5f5f5; border-bottom: 1px solid #dddddd; @@ -393,6 +407,19 @@ padding: 2px 5px 0 0; } } + .fullscreen-toggle { + &:hover { + color: #111; + } + cursor: pointer; + padding-left: 5px; + position: absolute; + right: 3px; + bottom: -22px; + z-index: 78; + color: #ddd; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); + } } .panel-footer { padding: 5px; @@ -431,6 +458,27 @@ } } } + &.fullscreen { + .panel-heading { + position: fixed; + top: 0; + right: 0px; + left: 0; + z-index: 77; + border-top: 1px solid #ddd; + border-right: 1px solid #ddd; + border-left: 1px solid #ddd; + } + .panel-body { + position: fixed; + top: 55px; + right: 0px; + left: 0; + z-index: 76; + border-right: 1px solid #ddd; + border-left: 1px solid #ddd; + } + } } .params-block { .block-title { @@ -540,28 +588,26 @@ background-color: #fcfcfc; } } - .CodeMirror { - .common-shadow-inset; - height: 215px; - border-bottom: 1px solid #dddddd; - cursor: not-allowed; - background-color: #fcfcfc; - .CodeMirror-gutters { - background-color: #fcfcfc; - } - .CodeMirror-hscrollbar { - left: 0 !important; - } - } #sgrip { - position: absolute; + &:hover { + color: #111; + } + i { + position: relative; left: 50%; - cursor: s-resize; - color: #999999; } - + width: 100%; + text-shadow: 0 1px 2px rgba(0,0,0,.6); + position: absolute; + cursor: s-resize; + color: #999999; + z-index: 2; + } .arguments-wrap { padding: 5px; + .alert { + padding: 6px 15px; + } .label { padding: 5px; display: inline-block; @@ -572,6 +618,17 @@ #scriptDetails { .body-title { + &.fullscreen { + position: fixed; + top: 0; + right: 0px; + left: 0; + z-index: 77; + border-top: 1px solid #ddd; + border-right: 1px solid #ddd; + border-left: 1px solid #ddd; + } + position: relative; padding: 5px; background-color: #fcfcfc; border-bottom: 1px solid #dddddd; @@ -581,6 +638,35 @@ border-radius: 0; margin-bottom: 0; } + .fullscreen-toggle { + &:hover { + color: #111; + } + cursor: pointer; + padding-left: 5px; + position: absolute; + right: 3px; + bottom: -22px; + z-index: 78; + color: #ddd; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); + } + .CodeMirror { + .common-shadow-inset; + height: 215px; + border-bottom: 1px solid #dddddd; + cursor: not-allowed; + background-color: #fcfcfc; + .CodeMirror-gutters { + background-color: #fcfcfc; + } + .CodeMirror-hscrollbar { + left: 0 !important; + } + } + .CodeMirror-fullscreen { + top: 30px; + } } .job-info { @@ -762,3 +848,14 @@ opacity: 0.89; margin-top: 0; } } + +.CodeMirror-fullscreen { + z-index: 75; + border-bottom: 1px solid #ddd; + border-right: 1px solid #ddd; + border-left: 1px solid #ddd; +} + +.CodeMirror-hints { + z-index: 78; +} http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createScript.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createScript.hbs b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createScript.hbs index cfe3f58..50fef58 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createScript.hbs +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createScript.hbs @@ -16,18 +16,18 @@ limitations under the License. }} -{{#pig-modal ok='confirm' close='cancel' escape-press='cancel'}} +{{#pig-modal ok='confirm' close='cancel'}} <div class="modal-header"> <button type="button" class="close" {{action "cancel" target="view"}} aria-hidden="true">×</button> <h4 class="modal-title">{{t 'scripts.modal.create_script'}}</h4> </div> <div class="modal-body"> - <div class="form-group"> + <div {{bind-attr class=":form-group titleErrorMessage:has-error"}}> <label>{{t 'scripts.title'}}</label> - {{input class="form-control" placeholderTranslation="scripts.modal.script_title_placeholder" valueBinding="content.title"}} + {{input class="form-control" placeholderTranslation="scripts.modal.script_title_placeholder" valueBinding="content.title" change=titleChange}} </div> - {{#if titleError}} - <div class="alert alert-danger">{{titleError}}</div> + {{#if content.isBlankTitle}} + <div {{bind-attr class=":alert :alert-danger titleErrorMessage::hide"}}>{{titleErrorMessage}}</div> {{/if}} <div class="form-group"> <label for="exampleInputPassword1">{{t 'scripts.path'}}</label> @@ -37,6 +37,6 @@ </div> <div class="modal-footer"> <button type="button" {{action "cancel" target="view"}} class="btn btn-default" >{{t 'common.cancel'}}</button> - <button type="button" {{action "ok" target="view"}} {{bind-attr class="titleError:disabled :btn :btn-success"}} >{{t 'common.create'}}</button> + <button type="button" {{action "ok" target="view"}} {{bind-attr class="content.isBlankTitle:disabled :btn :btn-success"}} >{{t 'common.create'}}</button> </div> {{/pig-modal}} http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createUdf.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createUdf.hbs b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createUdf.hbs index 6f1ffb2..c080728 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createUdf.hbs +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createUdf.hbs @@ -32,7 +32,7 @@ </div> </div> <div class="modal-footer"> - <button type="button" {{action "cancel" content target="view"}} class="btn btn-default" >{{t 'common.cancel'}}</button> - <button type="button" {{action "ok" target="view"}} {{bind-attr class=":btn :btn-success udfInvalid:disabled"}}>{{t 'common.create'}}</button> + <button type="button" {{action "cancel" content target="view"}} class="btn btn-default">{{t 'common.cancel'}}</button> + <button type="button" {{action "ok" target="view"}} {{bind-attr class=":btn :btn-success isValid::disabled"}}>{{t 'common.create'}}</button> </div> {{/pig-modal}} http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/deleteUdf.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/deleteUdf.hbs b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/deleteUdf.hbs new file mode 100644 index 0000000..39f0e68 --- /dev/null +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/deleteUdf.hbs @@ -0,0 +1,31 @@ +{{! + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +}} + +{{#pig-modal ok='confirm'}} + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h4 class="modal-title">{{t 'scripts.modal.confirm_delete'}}</h4> + </div> + <div class="modal-body"> + {{t 'udfs.modal.delete_udf' titleBinding="content.name" tagName="p"}} + </div> + <div class="modal-footer"> + <button type="button" {{action "cancel" target="view"}} class="btn btn-default" data-dismiss="modal">{{t 'common.cancel'}}</button> + <button type="button" {{action "ok" content target="view"}} class="btn btn-danger">{{t 'common.delete'}}</button> + </div> +{{/pig-modal}} http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/pig.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/pig.hbs b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/pig.hbs index bf27deb..d70ac7e 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/pig.hbs +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/pig.hbs @@ -25,22 +25,22 @@ <div class="nav-script-wrap"> <div class=" nav-script" > <div> - <button type="button" class="close_script" {{action closeScript}}> + <button type="button" class="close_script" tabindex="-1" {{action closeScript}}> <i class="fa fa-times"></i> </button> </div> <div class="script-title"> - {{#if activeScript.label}} - <span>{{activeScript.label}}</span> + {{#unless activeScript.isBlankTitle}} + <span>{{activeScript.title}}</span> {{else}} <span>...</span> - {{/if}} + {{/unless}} </div> <ul class="script-actions list-unstyled"> - <li><a href="#" {{action "saveScript" activeScript}} {{bind-attr class=":btn :btn-block saveEnabled::disabled"}} ><i class="fa fa-fw fa-save"></i> {{t 'common.save'}}</a></li> - <li><a href="#" {{action "copyScript" activeScript}} {{bind-attr class=":btn :btn-block disableScriptControls:disabled"}} ><i class="fa fa-fw fa-copy"></i> {{t 'common.copy'}}</a></li> + <li><a href="#" tabindex="-1" {{action "saveScript" activeScript}} {{bind-attr class=":btn :btn-block saveEnabled::disabled"}} ><i class="fa fa-fw fa-save"></i> {{t 'common.save'}}</a></li> + <li><a href="#" tabindex="-1" {{action "copyScript" activeScript}} {{bind-attr class=":btn :btn-block disableScriptControls:disabled"}} ><i class="fa fa-fw fa-copy"></i> {{t 'common.copy'}}</a></li> <li class="divider"></li> - <li><a href="#" {{action "deletescript" activeScript}} {{bind-attr class=":btn :btn-block disableScriptControls:disabled"}} ><i class="fa fa-fw fa-trash-o"></i> {{t 'common.delete'}}</a></li> + <li><a href="#" tabindex="-1" {{action "deletescript" activeScript}} {{bind-attr class=":btn :btn-block disableScriptControls:disabled"}} ><i class="fa fa-fw fa-trash-o"></i> {{t 'common.delete'}}</a></li> </ul> </div> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/pig/udfs.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/pig/udfs.hbs b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/pig/udfs.hbs index dab5a73..dfa6f7d 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/pig/udfs.hbs +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/pig/udfs.hbs @@ -36,7 +36,7 @@ <td> {{this.name}}</td> <td> {{this.path}}</td> <td> {{this.owner}}</td> - <td><a href="#" {{action "deleteUdf" this}} ><i class="fa fa-trash-o"></i> {{t 'common.delete'}}</a></td> + <td><a href="#" {{action "deleteUdfModal" this}} ><i class="fa fa-trash-o"></i> {{t 'common.delete'}}</a></td> </tr> {{/each}} </tbody> http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/edit.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/edit.hbs b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/edit.hbs index 95d830b..767e2bc 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/edit.hbs +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/edit.hbs @@ -17,9 +17,11 @@ }} <div class="edit-script"> - <div {{bind-attr class=":panel :panel-editscript scriptError:panel-danger:panel-default"}} > + <div {{bind-attr class=":panel :panel-editscript fullscreen:fullscreen scriptError:panel-danger:panel-default"}} > <div class="panel-heading"> {{outlet nav}} + + {{!-- Button --}} {{#unless isExec}} <div {{bind-attr class=":btn-group :pull-right isRenaming:hide"}}> <button {{action "execute" content 'execute' }} type="button" class="btn btn-primary">{{t 'editor.execute'}}</button> @@ -36,19 +38,20 @@ {{else}} <div class="spinner-sm pull-right"></div> {{/unless}} - {{#unless isRenaming}} + {{!-- Title --}} + {{#unless isRenaming}} <div class="script-title"> <h4> {{content.title}} <a href="#" {{action 'rename' 'ask'}} class="btn-rename"><i class="fa fa-pencil"></i></a></h4> </div> - {{else}} <div {{bind-attr class=":input-group :input-title titleWarn:has-error"}}> - {{input + {{view view.focusInput id="title" placeholderTranslation="scripts.modal.script_title_placeholder" class="form-control" valueBinding="content.title" + action='rename' }} <div class="input-group-btn"> <button type="button" {{action 'rename' 'cancel'}} {{bind-attr class=":btn :btn-default :btn-rename-cancel"}} > @@ -56,7 +59,7 @@ </button> </div> <div class="input-group-btn"> - <button type="button" {{action 'rename' 'confirm'}} {{bind-attr class=":btn :btn-success :btn-rename-confirm content.title::disabled"}} > + <button type="button" {{action 'rename' content.title}} {{bind-attr class=":btn :btn-success :btn-rename-confirm content.isBlankTitle:disabled"}} > <i class="fa fa-lg fa-check"></i> <span class="hidden-xs">{{t 'editor.save'}}</span> </button> </div> @@ -79,7 +82,8 @@ </ul> </div> </div> - <kbd class="file-path pull-right" data-toggle="tooltip" data-placement="bottom"{{translateAttr title="udfs.tooltips.path"}} > + <div class="fullscreen-toggle pull-right" {{action 'fullscreen'}} data-toggle="tooltip" data-placement="bottom" {{translateAttr title="editor.toggle_fullscreen"}}><i {{bind-attr class=":fa :fa-lg fullscreen:fa-compress:fa-expand"}} ></i></div> + <kbd class="file-path pull-right" data-toggle="tooltip" data-placement="bottom" {{translateAttr title="udfs.tooltips.path"}} > {{#unless content.pigScript.isLoaded}} <div class="spinner-sm"></div> {{else}} @@ -88,7 +92,7 @@ </kbd> </div> <div class="editor-container"> - {{code-mirror id="pig_script" content=content.pigScript codeMirror=editor}} + {{code-mirror id="pig_script" content=content.pigScript codeMirror=editor fullscreen=fullscreen}} <div class="ui-resizable-handle ui-resizable-s" id="sgrip"><i class="fa fa-ellipsis-h"></i></div> </div> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/job.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/job.hbs b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/job.hbs index 5b42f18..e184e09 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/job.hbs +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/job.hbs @@ -118,8 +118,9 @@ </h4> </div> {{#view "view.collapsePanel" id="scriptDetails" class="panel-collapse collapse" }} - <div class="panel-body body-title"> + <div {{bind-attr class=":panel-body :body-title :body-title-contents fullscreen:fullscreen "}} > {{t 'job.script_contents'}}: + <div class="fullscreen-toggle pull-right" {{action 'fullscreen'}} data-toggle="tooltip" data-placement="bottom" {{translateAttr title="editor.toggle_fullscreen"}}><i {{bind-attr class=":fa :fa-lg fullscreen:fa-compress:fa-expand"}} ></i></div> </div> {{#if scriptContents.isPending}} <div class="panel-body"> @@ -128,7 +129,7 @@ {{else}} {{#if scriptContents.isFulfilled}} <div class="editor-container"> - {{code-mirror id="pig_script" content=scriptContents readOnly=true}} + {{code-mirror id="pig_script" content=scriptContents readOnly=true fullscreen=fullscreen}} <div class="ui-resizable-handle ui-resizable-s" id="sgrip"><i class="fa fa-ellipsis-h"></i></div> </div> {{else}} @@ -143,9 +144,15 @@ {{t 'common.arguments'}}: </div> <div class="panel-body arguments-wrap"> - {{#each argumentsArray}} - <span class="label label-primary">{{this}}</span> - {{/each}} + {{#if argumentsArray}} + {{#each argumentsArray}} + <span class="label label-primary">{{this}}</span> + {{/each}} + {{else}} + <div class="alert alert-info" role="alert"> + {{t 'job.no_arguments_message'}} + </div> + {{/if}} </div> {{/view}} </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/translations.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/translations.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/translations.js index c7bf0b7..7ed48cf 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/translations.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/translations.js @@ -97,7 +97,8 @@ Ember.I18n.translations = { 'no_arguments_message':'This pig script has no arguments defined.', 'execute':'Execute', 'explain':'Explain', - 'syntax_check':'Syntax check' + 'syntax_check':'Syntax check', + 'toggle_fullscreen':'Toggle fullscreen (F11)' }, 'job':{ 'title': "Title", @@ -112,6 +113,7 @@ Ember.I18n.translations = { 'kill_job': "Kill Job", 'script_details': "Script Details", 'script_contents': "Script contents", + 'no_arguments_message':'This job was executed without arguments.', 'alert':{ 'job_started' :'Job started!', 'job_killed' :'{{title}} job killed', @@ -153,7 +155,8 @@ Ember.I18n.translations = { 'modal':{ 'create_udf':'Create UDF', 'udf_name':'UDF name', - 'hdfs_path':'/hdfs/path/to/udf' + 'hdfs_path':'/hdfs/path/to/udf', + 'delete_udf':'Are you sure you want to delete {{title}} udf?' } }, 'history':{ http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/views/pig/history.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/views/pig/history.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/views/pig/history.js index 9ad0ae1..7f94a3f 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/views/pig/history.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/views/pig/history.js @@ -21,11 +21,11 @@ var App = require('app'); App.PigHistoryView = Em.View.extend({ initTooltips:function () { if ( this.$('td:last-child a')) { - Em.run.next(this.addTooltip.bind(this)) + Em.run.next(this.addTooltip.bind(this)); } }.on('didInsertElement').observes('controller.page','controller.content.@each'), addTooltip:function () { - this.$('td:last-child a').tooltip({placement:'bottom'}) + this.$('td:last-child a').tooltip({placement:'bottom'}); }, scriptLink:Em.Component.extend({ tagName:'a', http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/views/script/edit.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/views/script/edit.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/views/script/edit.js index dcab6ce..97afe71 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/views/script/edit.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/views/script/edit.js @@ -20,7 +20,10 @@ var App = require('app'); App.ScriptEditView = Em.View.extend({ didInsertElement:function () { - $('.file-path').tooltip(); + $('.file-path, .fullscreen-toggle').tooltip(); + }, + willClearRender:function () { + this.set("controller.fullscreen", false); }, showTitleWarn:function () { if (this.get('controller.titleWarn')) { @@ -52,5 +55,13 @@ App.ScriptEditView = Em.View.extend({ this.send('sendArgument'); } } + }), + focusInput:Em.TextField.extend({ + becomeFocused: function () { + this.$().focus().val(this.$().val()); + }.on('didInsertElement'), + cancel:function (argument) { + this.sendAction('action','cancel'); + } }) }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/app/views/script/job.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/views/script/job.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/views/script/job.js index 5b8af7e..6582688 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/views/script/job.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/views/script/job.js @@ -27,9 +27,21 @@ App.ScriptJobView = Em.View.extend({ this.$().on('show.bs.collapse', function (e) { this.$().parent().find('.toggle-icon').addClass('fa-rotate-90'); }.bind(this)); + //fix for CodeMirror not rendered properly in hidden container + if (this.get('elementId') === "scriptDetails") { + this.$().on('shown.bs.collapse', function (e) { + var cme = this.$('.CodeMirror').get(0); + if (cme && cme.CodeMirror) { + cme.CodeMirror.setSize(null, this.$('.editor-container').height()); + } + }.bind(this)); + } }.on('didInsertElement'), unbindToggle:function () { this.$().off('hide.bs.collapse','show.bs.collapse'); }.on('willClearRender') - }) + }), + bindTooltips:function () { + $('.fullscreen-toggle').tooltip(); + }.on('didInsertElement') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/bower.json ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/bower.json b/contrib/views/pig/src/main/resources/ui/pig-web/bower.json index 7d6f5a1..bd31a7a 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/bower.json +++ b/contrib/views/pig/src/main/resources/ui/pig-web/bower.json @@ -14,6 +14,18 @@ "file-saver": "*" }, "overrides": { + "codemirror":{ + "main" : [ + "lib/codemirror.js", + "lib/codemirror.css", + "mode/pig/pig.js", + "addon/hint/show-hint.css", + "addon/hint/show-hint.js", + "addon/display/fullscreen.js", + "addon/display/fullscreen.css", + "addon/hint/anyword-hint.js" + ] + }, "bootstrap": { "main": [ "./dist/js/bootstrap.js" http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/config.coffee ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/config.coffee b/contrib/views/pig/src/main/resources/ui/pig-web/config.coffee index c194b0e..af208c1 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/config.coffee +++ b/contrib/views/pig/src/main/resources/ui/pig-web/config.coffee @@ -26,9 +26,11 @@ exports.config = defaultExtension: 'js' joinTo: 'static/javascripts/app.js': /^app/ - 'static/javascripts/vendor.js': /^bower_components|vendor/ + 'static/javascripts/vendor.js': /^bower_components|vendor/, + 'static/javascripts/test.js': /^test(\/|\\)(?!vendor)/ order: before: [ + 'bower_components/moment/moment.js', 'bower_components/jquery/dist/jquery.js', 'vendor/jquery-ui/core.js', 'vendor/jquery-ui/widget.js', http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/package.json ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/package.json b/contrib/views/pig/src/main/resources/ui/pig-web/package.json index 1bb3cfd..c863636 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/package.json +++ b/contrib/views/pig/src/main/resources/ui/pig-web/package.json @@ -5,6 +5,7 @@ "node": "~0.6.10 || 0.8 || 0.9" }, "scripts": { + "test": "node_modules/phantomjs/bin/phantomjs runner.js public/tests.html", "start": "brunch watch --server", "preinstall": "chmod +x node/npm/bin/node-gyp-bin/node-gyp", "postinstall" : "bash node/with_new_path.sh node node_modules/.bin/bower --allow-root install" @@ -18,5 +19,11 @@ "ember-precompiler-brunch": ">= 1.5.0", "less-brunch": "~1.7.1", "scaffolt": "^0.4.3" + }, + "devDependencies": { + "phantomjs": "^1.9.2", + "karma": "*", + "karma-qunit": "*", + "karma-phantomjs-launcher": "~0.1.2" } } http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/runner.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/runner.js b/contrib/views/pig/src/main/resources/ui/pig-web/runner.js new file mode 100644 index 0000000..4fd7894 --- /dev/null +++ b/contrib/views/pig/src/main/resources/ui/pig-web/runner.js @@ -0,0 +1,136 @@ +/* + * PhantomJS Runner QUnit Plugin (List Tests) 1.2.0 + * + * PhantomJS binaries: http://phantomjs.org/download.html + * Requires PhantomJS 1.6+ (1.7+ recommended) + * + * Run with: + * phantomjs runner-list.js [url-of-your-qunit-testsuite] + * + * e.g. + * phantomjs runner-list.js http://localhost/qunit/test/index.html + */ + +/*global phantom:false, require:false, console:false, window:false, QUnit:false */ + +(function() { + 'use strict'; + + var url, page, timeout, + args = require('system').args; + + // arg[0]: scriptName, args[1...]: arguments + if (args.length < 2 || args.length > 3) { + console.error('Usage:\n phantomjs runner-list.js [url-of-your-qunit-testsuite] [timeout-in-seconds]'); + phantom.exit(1); + } + + url = args[1]; + page = require('webpage').create(); + if (args[2] !== undefined) { + timeout = parseInt(args[2], 10); + } + + // Route `console.log()` calls from within the Page context to the main Phantom context (i.e. current `this`) + page.onConsoleMessage = function(msg) { + console.log(msg); + }; + + page.onInitialized = function() { + page.evaluate(addLogging); + }; + + page.onCallback = function(message) { + var result, + failed; + + if (message) { + if (message.name === 'QUnit.done') { + result = message.data; + failed = !result || !result.total || result.failed; + + if (!result.total) { + console.error('No tests were executed. Are you loading tests asynchronously?'); + } + + phantom.exit(failed ? 1 : 0); + } + } + }; + + page.open(url, function(status) { + if (status !== 'success') { + console.error('Unable to access network: ' + status); + phantom.exit(1); + } else { + // Cannot do this verification with the 'DOMContentLoaded' handler because it + // will be too late to attach it if a page does not have any script tags. + var qunitMissing = page.evaluate(function() { return (typeof QUnit === 'undefined' || !QUnit); }); + if (qunitMissing) { + console.error('The `QUnit` object is not present on this page.'); + phantom.exit(1); + } + + // Set a timeout on the test running, otherwise tests with async problems will hang forever + if (typeof timeout === 'number') { + setTimeout(function() { + console.error('The specified timeout of ' + timeout + ' seconds has expired. Aborting...'); + phantom.exit(1); + }, timeout * 1000); + } + + // Do nothing... the callback mechanism will handle everything! + } + }); + + function addLogging() { + window.document.addEventListener('DOMContentLoaded', function() { + var currentTestAssertions = []; + + QUnit.log(function(details) { + var response; + + console.log((details.result ? "? ": "? ") + details.message); + + if (!details.result) { + response = details.message || ''; + + if (typeof details.expected !== 'undefined') { + if (response) { + response += ', '; + } + + response += 'expected: ' + details.expected + ', but was: ' + details.actual; + } + + if (details.source) { + response += '\n' + details.source; + } + + console.log(' Failed assertion: ' + response); + } + }); + + QUnit.moduleStart(function( details ) { + if (details.name) { + console.log('\n' + details.name); + } + }); + + QUnit.testStart(function(result) { + console.log('\n' + result.name); + }); + + QUnit.done(function(result) { + console.log('\n' + 'Took ' + result.runtime + 'ms to run ' + result.total + ' tests. ' + result.passed + ' passed, ' + result.failed + ' failed.'); + + if (typeof window.callPhantom === 'function') { + window.callPhantom({ + 'name': 'QUnit.done', + 'data': result + }); + } + }); + }, false); + } +})(); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/test/spec.coffee ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/test/spec.coffee b/contrib/views/pig/src/main/resources/ui/pig-web/test/spec.coffee deleted file mode 100644 index ecf0374..0000000 --- a/contrib/views/pig/src/main/resources/ui/pig-web/test/spec.coffee +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Write your [mocha](http://visionmedia.github.com/mocha/) specs here. http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/test/unit/controllers/pig_test.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/test/unit/controllers/pig_test.js b/contrib/views/pig/src/main/resources/ui/pig-web/test/unit/controllers/pig_test.js new file mode 100644 index 0000000..9cee5ea --- /dev/null +++ b/contrib/views/pig/src/main/resources/ui/pig-web/test/unit/controllers/pig_test.js @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +moduleFor('controller:pig', 'App.PigController', { + needs:['controller:scriptEdit','controller:script'], +}); + +test('Can get active Script after active Script Id script is set', function () { + + var pig = this.subject(); + + var script = Ember.Object.create({ title: 'script_1', id:'1' }); + + Ember.run(function() { + + pig.set('model', [script]); + pig.set('activeScriptId', '1'); + + deepEqual(script, pig.get('activeScript'), 'script is set'); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/contrib/views/pig/src/main/resources/ui/pig-web/vendor/pig-hint.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/vendor/pig-hint.js b/contrib/views/pig/src/main/resources/ui/pig-web/vendor/pig-hint.js new file mode 100644 index 0000000..8d8b77e --- /dev/null +++ b/contrib/views/pig/src/main/resources/ui/pig-web/vendor/pig-hint.js @@ -0,0 +1,110 @@ +(function () { + + var pigKeywordsU = pigKeywordsL = pigTypesU = pigTypesL = pigBuiltinsU = pigBuiltinsL = []; + + var mimeMode = CodeMirror.mimeModes['text/x-pig']; + + Object.keys(mimeMode.keywords).forEach( function(w) { + pigKeywordsU.push(w.toUpperCase()); + pigKeywordsL.push(w.toLowerCase()); + }); + + Object.keys(mimeMode.types).forEach( function(w) { + pigTypesU.push(w.toUpperCase()); + pigTypesL.push(w.toLowerCase()); + }); + + Object.keys(mimeMode.builtins).forEach( function(w) { + pigBuiltinsU.push(w.toUpperCase()); + pigBuiltinsL.push(w.toLowerCase()); + }); + + function forEach(arr, f) { + for (var i = 0, e = arr.length; i < e; ++i) { + f(arr[i]); + } + } + + function arrayContains(arr, item) { + if (!Array.prototype.indexOf) { + var i = arr.length; + while (i--) { + if (arr[i] === item) { + return true; + } + } + return false; + } + return arr.indexOf(item) != -1; + } + + function scriptHint(editor, keywords, getToken) { + // Find the token at the cursor + var cur = editor.getCursor(), token = getToken(editor, cur), tprop = token; + // If it's not a 'word-style' token, ignore the token. + + if (!/^[\w$_]*$/.test(token.string)) { + token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state, + type: token.string == ":" ? "pig-type" : null}; + } + + if (!context) var context = []; + context.push(tprop); + + completionList = getCompletions(token, context); + completionList = completionList.sort(); + + return {list: completionList, + from: {line: cur.line, ch: token.start}, + to: {line: cur.line, ch: token.end}}; + } + + function toTitleCase(str) { + return str.replace(/(?:^|\s)\w/g, function(match) { + return match.toUpperCase(); + }); + } + + + function getCompletions(token, context) { + var found = [], start = token.string; + function maybeAdd(str) { + if (str.indexOf(start) == 0 && !arrayContains(found, str)) found.push(str); + } + + function gatherCompletions(obj) { + if(obj == ":") { + forEach(pigTypesL, maybeAdd); + } + else { + forEach(pigBuiltinsU, maybeAdd); + forEach(pigBuiltinsL, maybeAdd); + forEach(pigTypesU, maybeAdd); + forEach(pigTypesL, maybeAdd); + forEach(pigKeywordsU, maybeAdd); + forEach(pigKeywordsL, maybeAdd); + } + } + + if (context) { + // If this is a property, see if it belongs to some object we can + // find in the current environment. + var obj = context.pop(), base; + + if (obj.type == "pig-word") + base = obj.string; + else if(obj.type == "pig-type") + base = ":" + obj.string; + + while (base != null && context.length) + base = base[context.pop().string]; + if (base != null) gatherCompletions(base); + } + return found; + } + + CodeMirror.registerHelper("hint", "pig", function(cm, options) { + return scriptHint(cm, pigKeywordsU, function (e, cur) {return e.getTokenAt(cur);}); + }); + +})(); http://git-wip-us.apache.org/repos/asf/ambari/blob/f7414a76/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 79f951b..5d55074 100644 --- a/pom.xml +++ b/pom.xml @@ -234,6 +234,9 @@ <exclude>contrib/views/pig/src/main/resources/ui/pig-web/node/**</exclude> <exclude>contrib/views/pig/src/main/resources/ui/pig-web/bower_components/**</exclude> <exclude>contrib/views/pig/src/main/resources/ui/pig-web/vendor/**</exclude> + <exclude>contrib/views/pig/src/main/resources/ui/pig-web/app/assets/static/stylesheets/**</exclude> + <exclude>contrib/views/pig/src/main/resources/ui/pig-web/app/assets/static/javascripts/**</exclude> + <exclude>contrib/views/pig/src/main/resources/ui/pig-web/runner.js</exclude> <exclude>contrib/views/slider/src/main/resources/ui/public/**</exclude> <exclude>contrib/views/slider/src/main/resources/ui/node_modules/**</exclude> <exclude>contrib/views/slider/src/main/resources/ui/vendor/**</exclude>