WIP quick repo switch
This commit is contained in:
parent
a563bbeae0
commit
500581da9a
|
@ -13,7 +13,8 @@
|
||||||
"Log",
|
"Log",
|
||||||
"moment",
|
"moment",
|
||||||
"Pusher",
|
"Pusher",
|
||||||
"md5"
|
"md5",
|
||||||
|
"key"
|
||||||
],
|
],
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"boss": true,
|
"boss": true,
|
||||||
|
|
82
app/components/travis-cmd.js
Normal file
82
app/components/travis-cmd.js
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
import Ember from 'ember';
|
||||||
|
import config from 'travis/config/environment';
|
||||||
|
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
keyboard: Ember.inject.service(),
|
||||||
|
auth: Ember.inject.service(),
|
||||||
|
|
||||||
|
classNameBindings: ['visible'],
|
||||||
|
classNames: ['travis-cmd'],
|
||||||
|
|
||||||
|
didInsertElement() {
|
||||||
|
this.get('keyboard').bind('t', this.show.bind(this));
|
||||||
|
this.get('keyboard').bind('esc', 'cmd', this.hide.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
show() {
|
||||||
|
this.loadSlugs();
|
||||||
|
this.set('visible', true);
|
||||||
|
this.get('keyboard').setScope('cmd');
|
||||||
|
},
|
||||||
|
|
||||||
|
hide() {
|
||||||
|
this.set('visible', false);
|
||||||
|
this.get('keyboard').setScope(null);
|
||||||
|
this.set('matches', null);
|
||||||
|
this.set('filterString', null);
|
||||||
|
this.set('results', null);
|
||||||
|
},
|
||||||
|
|
||||||
|
loadSlugs() {
|
||||||
|
this.set('loading', true);
|
||||||
|
|
||||||
|
$.ajax(config.apiEndpoint + '/repos/slugs', {
|
||||||
|
headers: {
|
||||||
|
Authorization: 'token ' + this.get('auth').token(),
|
||||||
|
Accept: 'application/json; version=2'
|
||||||
|
}
|
||||||
|
}).then((data) => {
|
||||||
|
this.set('loading', false);
|
||||||
|
this.set('repos', data.repositories);
|
||||||
|
this.onLoad();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
setTimeout( () => {
|
||||||
|
this.$('.input').focus();
|
||||||
|
}, 10);
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
filterChanged(value) {
|
||||||
|
let list = this.get('repos');
|
||||||
|
|
||||||
|
$.ajax("https://repos-filter-production.herokuapp.com/filter?phrase="+value, {
|
||||||
|
headers: { "Authorization": "token " + Travis.lookup('service:auth').token()
|
||||||
|
} }).then((response) => {
|
||||||
|
let repos = response.repositories;
|
||||||
|
repos = repos.sortBy('score').reverse();
|
||||||
|
let matches = repos.slice(0, 10).mapBy('match').map( (match) => match.replace(new RegExp('<|>', 'g'), (match) => match === '<' ? '<strong style="font-weight: 1000; color: #a80000">' : '</strong>' ) ).join('<br/>');
|
||||||
|
console.log(matches);
|
||||||
|
this.set('matches', matches);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.set('filterString', value);
|
||||||
|
},
|
||||||
|
|
||||||
|
keypress(event) {
|
||||||
|
if(event.keyCode === 27) {
|
||||||
|
this.hide();
|
||||||
|
} else if(event.keyCode === 13) {
|
||||||
|
let results;
|
||||||
|
if(results = this.get('results')) {
|
||||||
|
if(results[0]) {
|
||||||
|
let slug = results[0].original.slug;
|
||||||
|
console.log(slug);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
13
app/services/keyboard.js
Normal file
13
app/services/keyboard.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import Ember from 'ember';
|
||||||
|
|
||||||
|
let KeyboardService = Ember.Service.extend({
|
||||||
|
bind(keyName, scope, callback) {
|
||||||
|
key(...arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
setScope(scope) {
|
||||||
|
key.setScope(scope);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default KeyboardService;
|
|
@ -32,6 +32,7 @@
|
||||||
@import "app/modules/loading-indicator";
|
@import "app/modules/loading-indicator";
|
||||||
@import "app/modules/build-tile";
|
@import "app/modules/build-tile";
|
||||||
@import "app/modules/status-icon";
|
@import "app/modules/status-icon";
|
||||||
|
@import "app/modules/travis-cmd";
|
||||||
|
|
||||||
@import "app/animation/tractor";
|
@import "app/animation/tractor";
|
||||||
|
|
||||||
|
|
37
app/styles/app/modules/travis-cmd.scss
Normal file
37
app/styles/app/modules/travis-cmd.scss
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
.travis-cmd {
|
||||||
|
opacity: 0.3;
|
||||||
|
background: #000;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 10;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
position: fixed;
|
||||||
|
display: none;
|
||||||
|
|
||||||
|
.content {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.visible {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
width: 400px;
|
||||||
|
min-height: 60px;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.content, .input {
|
||||||
|
color: black;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
{{#popup-click-handler}}
|
{{#popup-click-handler}}
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
{{/popup-click-handler}}
|
{{/popup-click-handler}}
|
||||||
|
|
||||||
|
{{travis-cmd}}
|
||||||
|
|
15
app/templates/components/travis-cmd.hbs
Normal file
15
app/templates/components/travis-cmd.hbs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<div class="content">
|
||||||
|
{{#if loading}}
|
||||||
|
{{loading-indicator}}
|
||||||
|
{{else}}
|
||||||
|
|
||||||
|
<input type="text" class="input" value={{filterString}}
|
||||||
|
oninput={{action "filterChanged" value="target.value"}}
|
||||||
|
onkeydown={{action "keypress"}} />
|
||||||
|
|
||||||
|
<div class="matches">
|
||||||
|
{{{matches}}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
|
@ -19,7 +19,8 @@
|
||||||
"pretender": "~0.12.0",
|
"pretender": "~0.12.0",
|
||||||
"lodash": "~3.7.0",
|
"lodash": "~3.7.0",
|
||||||
"Faker": "~3.0.0",
|
"Faker": "~3.0.0",
|
||||||
"ceibo": "1.0.0"
|
"ceibo": "1.0.0",
|
||||||
|
"keymaster": "~1.6.3"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"ember": "2.2.1",
|
"ember": "2.2.1",
|
||||||
|
|
|
@ -15,9 +15,9 @@ module.exports = function(defaults) {
|
||||||
|
|
||||||
if (assetsHost = process.env.ASSETS_HOST) {
|
if (assetsHost = process.env.ASSETS_HOST) {
|
||||||
if (assetsHost.substr(-1) !== '/') {
|
if (assetsHost.substr(-1) !== '/') {
|
||||||
assetsHost = assetsHost + '/'
|
assetsHost = assetsHost + '/';
|
||||||
}
|
}
|
||||||
fingerprint.prepend = assetsHost
|
fingerprint.prepend = assetsHost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ module.exports = function(defaults) {
|
||||||
app.import('vendor/log.js');
|
app.import('vendor/log.js');
|
||||||
app.import('vendor/customerio.js');
|
app.import('vendor/customerio.js');
|
||||||
app.import('bower_components/moment/moment.js');
|
app.import('bower_components/moment/moment.js');
|
||||||
|
app.import('bower_components/keymaster/keymaster.js');
|
||||||
|
|
||||||
return app.toTree();
|
return app.toTree();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user