mirror of https://github.com/rancher/ui.git
Fetch envvars from backend
This commit is contained in:
parent
94b57541ec
commit
aba5efbedb
|
|
@ -1,5 +1,5 @@
|
||||||
import Component from 'ember-component';
|
import Component from 'ember-component';
|
||||||
import injectService from 'ember-service/inject';
|
import { inject as service } from '@ember/service';
|
||||||
import observer from 'ember-metal/observer';
|
import observer from 'ember-metal/observer';
|
||||||
import { bind, once, scheduleOnce } from 'ember-runloop';
|
import { bind, once, scheduleOnce } from 'ember-runloop';
|
||||||
import CodeMirror from 'codemirror';
|
import CodeMirror from 'codemirror';
|
||||||
|
|
@ -9,7 +9,7 @@ export default Component.extend({
|
||||||
layout,
|
layout,
|
||||||
tagName: 'textarea',
|
tagName: 'textarea',
|
||||||
|
|
||||||
codeMirror: injectService(),
|
codeMirror: service(),
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
@ -17,7 +17,6 @@ export default Component.extend({
|
||||||
var cur = editor.getCursor();
|
var cur = editor.getCursor();
|
||||||
var end = cur.ch, start = end;
|
var end = cur.ch, start = end;
|
||||||
var matched = this.get('codeMirror').getMatchedHint(editor.getValue(),editor);
|
var matched = this.get('codeMirror').getMatchedHint(editor.getValue(),editor);
|
||||||
console.log(matched);
|
|
||||||
return {list: matched.matchedArry, from: CodeMirror.Pos(cur.line, start - matched.index), to: CodeMirror.Pos(cur.line, end)};
|
return {list: matched.matchedArry, from: CodeMirror.Pos(cur.line, start - matched.index), to: CodeMirror.Pos(cur.line, end)};
|
||||||
});
|
});
|
||||||
this._codeMirror = this.get('codeMirror').fromTextArea(this.get('elementId'), this.get('element'));
|
this._codeMirror = this.get('codeMirror').fromTextArea(this.get('elementId'), this.get('element'));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
|
import { singleton } from 'pipeline/utils/pipelineStep';
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
hintAry: null,
|
hintAry: null,
|
||||||
|
|
@ -7,10 +8,6 @@ export default Component.extend({
|
||||||
positionX: 0,
|
positionX: 0,
|
||||||
positionY: 0,
|
positionY: 0,
|
||||||
codeMirror: service(),
|
codeMirror: service(),
|
||||||
didInsertElement(){
|
|
||||||
debugger
|
|
||||||
this.get('codeMirror').set('hintAry', this.get('hintAry'));
|
|
||||||
},
|
|
||||||
positionStyle: function(){
|
positionStyle: function(){
|
||||||
var positionX = this.get('positionX'), positionY=this.get('positionY');
|
var positionX = this.get('positionX'), positionY=this.get('positionY');
|
||||||
return [
|
return [
|
||||||
|
|
@ -157,6 +154,7 @@ export default Component.extend({
|
||||||
},
|
},
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
singleton.hintAry = this.get('hintAry');
|
||||||
this.$(document).on('keyup', 'input:not(.js-disable-hint)', (e) => {
|
this.$(document).on('keyup', 'input:not(.js-disable-hint)', (e) => {
|
||||||
$.fn.E_INPUT_HINT.startHint(e.target, ( /*hint*/ ) => {});
|
$.fn.E_INPUT_HINT.startHint(e.target, ( /*hint*/ ) => {});
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ export default Component.extend(ThrottledResize, {
|
||||||
showProtip: true,
|
showProtip: true,
|
||||||
status: 'connecting',
|
status: 'connecting',
|
||||||
socket: null,
|
socket: null,
|
||||||
pipeline: service(),
|
|
||||||
logHeight: 300,
|
logHeight: 300,
|
||||||
globalStore: service(),
|
globalStore: service(),
|
||||||
onlyCombinedLog: true,
|
onlyCombinedLog: true,
|
||||||
|
|
@ -74,31 +73,6 @@ export default Component.extend(ThrottledResize, {
|
||||||
inst = this.get('instance');
|
inst = this.get('instance');
|
||||||
var isFollow = ($body.scrollTop() + $body.outerHeight() + 10) >= body.scrollHeight;
|
var isFollow = ($body.scrollTop() + $body.outerHeight() + 10) >= body.scrollHeight;
|
||||||
|
|
||||||
|
|
||||||
// var logs = '';
|
|
||||||
// message.trim().split(/\n/).forEach((line) => {
|
|
||||||
// var match = line.match(/^\[?([^ \]]+)\]?\s?/);
|
|
||||||
// var dateStr, msg;
|
|
||||||
// if (match) {
|
|
||||||
// msg = line.substr(match[0].length);
|
|
||||||
// var date = new Date(match[1] * 1);
|
|
||||||
// dateStr = '<span class="log-date">' + Util.escapeHtml(date.toLocaleDateString()) + ' ' + Util.escapeHtml(date.toLocaleTimeString()) + ' </span>';
|
|
||||||
// } else {
|
|
||||||
// msg = line;
|
|
||||||
// dateStr = '<span class="log-date">Unknown Date</span>';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // body.insertAdjacentHTML('beforeend',
|
|
||||||
// // '<div class="log-msg">' +
|
|
||||||
// // dateStr +
|
|
||||||
// // AnsiUp.ansi_to_html(Util.escapeHtml(msg)) +
|
|
||||||
// // '</div>'
|
|
||||||
// // );
|
|
||||||
// logs += '<div class="log-msg">' +
|
|
||||||
// dateStr +
|
|
||||||
// AnsiUp.ansi_to_html(Util.escapeHtml(msg)) +
|
|
||||||
// '</div>';
|
|
||||||
// });
|
|
||||||
var logs = message;
|
var logs = message;
|
||||||
|
|
||||||
var logsAry = inst.activityLogs;
|
var logsAry = inst.activityLogs;
|
||||||
|
|
@ -113,10 +87,7 @@ export default Component.extend(ThrottledResize, {
|
||||||
};
|
};
|
||||||
|
|
||||||
var activity = inst.activity;
|
var activity = inst.activity;
|
||||||
// var params = `?activityId=${activity.id}&stageOrdinal=${inst.stageIndex}&stepOrdinal=${inst.stepIndex}`;
|
|
||||||
// var url = ("ws://" + window.location.host + this.get('pipeline.pipelinesEndpoint') + '/ws/log' + params);
|
|
||||||
// var socket = new WebSocket(url);
|
|
||||||
// this.set('socket', socket);
|
|
||||||
let fetchLog = ()=>{
|
let fetchLog = ()=>{
|
||||||
if(inst.stageIndex===-1||inst.stepIndex===-1){
|
if(inst.stageIndex===-1||inst.stepIndex===-1){
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,7 @@ export default Component.extend({
|
||||||
dragDom: null,
|
dragDom: null,
|
||||||
model: null,
|
model: null,
|
||||||
pipeline: null,
|
pipeline: null,
|
||||||
envvars: ['CICD_GIT_COMMIT',
|
envvars: '[]',
|
||||||
'CICD_GIT_REPO_NAME',
|
|
||||||
'CICD_GIT_BRANCH',
|
|
||||||
'CICD_GIT_URL',
|
|
||||||
'CICD_PIPELINE_ID',
|
|
||||||
'CICD_PIPELINE_NAME',
|
|
||||||
'CICD_TRIGGER_TYPE',
|
|
||||||
'CICD_EXECUTION_ID',
|
|
||||||
'CICD_EXECUTION_SEQUENCE'].map(ele=>`\${${ele}}`),
|
|
||||||
systemVars: null,
|
systemVars: null,
|
||||||
envvarsLoading: true,
|
envvarsLoading: true,
|
||||||
modalService: service('modal'),
|
modalService: service('modal'),
|
||||||
|
|
@ -39,6 +31,7 @@ export default Component.extend({
|
||||||
}.property('editable'),
|
}.property('editable'),
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
this.set('envvars', JSON.parse(this.get('envvars')).map(ele=>`\${${ele}}`));
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
dragStart: function(content, e) {
|
dragStart: function(content, e) {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,13 @@ export default Route.extend({
|
||||||
let accounts = globalStore.findAll('sourceCodeCredential');
|
let accounts = globalStore.findAll('sourceCodeCredential');
|
||||||
let clusterPipeline = globalStore.find('clusterPipeline', `${clusterId}:${clusterId}`, {forceReload: true});
|
let clusterPipeline = globalStore.find('clusterPipeline', `${clusterId}:${clusterId}`, {forceReload: true});
|
||||||
let projectDockerCredentials = projectStore.all('dockerCredential');
|
let projectDockerCredentials = projectStore.all('dockerCredential');
|
||||||
return hash({accounts, clusterPipeline, projectDockerCredentials} ).then(({accounts, clusterPipeline, projectDockerCredentials})=>{
|
return clusterPipeline.then((pipeline)=>{
|
||||||
|
clusterPipeline = pipeline;
|
||||||
|
return clusterPipeline.followLink('envvars')
|
||||||
|
}).then((envvars)=>{
|
||||||
|
return hash({accounts, clusterPipeline, projectDockerCredentials,envvars})
|
||||||
|
})
|
||||||
|
.then(({accounts, clusterPipeline, projectDockerCredentials, envvars})=>{
|
||||||
let pipeline = globalStore.createRecord({type:'pipeline', projectId , stages: this.get('precanStages')});
|
let pipeline = globalStore.createRecord({type:'pipeline', projectId , stages: this.get('precanStages')});
|
||||||
if(!accounts.content.length){
|
if(!accounts.content.length){
|
||||||
return {
|
return {
|
||||||
|
|
@ -40,6 +46,7 @@ export default Route.extend({
|
||||||
accounts,
|
accounts,
|
||||||
clusterPipeline,
|
clusterPipeline,
|
||||||
projectDockerCredentials,
|
projectDockerCredentials,
|
||||||
|
envvars,
|
||||||
repositories: [],
|
repositories: [],
|
||||||
language: 'Custom'
|
language: 'Custom'
|
||||||
};
|
};
|
||||||
|
|
@ -50,6 +57,7 @@ export default Route.extend({
|
||||||
accounts,
|
accounts,
|
||||||
clusterPipeline,
|
clusterPipeline,
|
||||||
projectDockerCredentials,
|
projectDockerCredentials,
|
||||||
|
envvars,
|
||||||
repositories: res,
|
repositories: res,
|
||||||
language: 'Custom'
|
language: 'Custom'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
<section class="pipeline-container">
|
<section class="pipeline-container">
|
||||||
{{pipeline-stages
|
{{pipeline-stages
|
||||||
clusterPipeline=model.clusterPipeline
|
clusterPipeline=model.clusterPipeline
|
||||||
|
envvars=model.envvars
|
||||||
pipeline=model.pipeline
|
pipeline=model.pipeline
|
||||||
stagesDraggable=true
|
stagesDraggable=true
|
||||||
accounts=model.accounts
|
accounts=model.accounts
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,25 @@ export default Route.extend({
|
||||||
let accounts = globalStore.findAll('sourceCodeCredential');
|
let accounts = globalStore.findAll('sourceCodeCredential');
|
||||||
let clusterPipeline = globalStore.find('clusterPipeline', `${clusterId}:${clusterId}`);
|
let clusterPipeline = globalStore.find('clusterPipeline', `${clusterId}:${clusterId}`);
|
||||||
let projectDockerCredentials = projectStore.all('dockerCredential');
|
let projectDockerCredentials = projectStore.all('dockerCredential');
|
||||||
return hash({
|
return clusterPipeline.then((cPipeline)=>{
|
||||||
|
clusterPipeline = cPipeline;
|
||||||
|
return clusterPipeline.followLink('envvars')
|
||||||
|
}).then((envvars)=>{
|
||||||
|
return hash({
|
||||||
pipeline,
|
pipeline,
|
||||||
pipelineHistory,
|
pipelineHistory,
|
||||||
accounts,
|
accounts,
|
||||||
clusterPipeline,
|
clusterPipeline,
|
||||||
projectDockerCredentials,
|
projectDockerCredentials,
|
||||||
}).then(({
|
envvars
|
||||||
|
})
|
||||||
|
}).then(({
|
||||||
pipeline,
|
pipeline,
|
||||||
pipelineHistory,
|
pipelineHistory,
|
||||||
accounts,
|
accounts,
|
||||||
clusterPipeline,
|
clusterPipeline,
|
||||||
projectDockerCredentials,
|
projectDockerCredentials,
|
||||||
|
envvars
|
||||||
})=>{
|
})=>{
|
||||||
var piplineObj;
|
var piplineObj;
|
||||||
if(params.mode === 'duplicate'){
|
if(params.mode === 'duplicate'){
|
||||||
|
|
@ -61,6 +68,7 @@ export default Route.extend({
|
||||||
accounts,
|
accounts,
|
||||||
clusterPipeline,
|
clusterPipeline,
|
||||||
projectDockerCredentials,
|
projectDockerCredentials,
|
||||||
|
envvars,
|
||||||
repositories: [],
|
repositories: [],
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -73,6 +81,7 @@ export default Route.extend({
|
||||||
accounts,
|
accounts,
|
||||||
clusterPipeline,
|
clusterPipeline,
|
||||||
projectDockerCredentials,
|
projectDockerCredentials,
|
||||||
|
envvars,
|
||||||
repositories: res,
|
repositories: res,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
<section class="pipeline-container">
|
<section class="pipeline-container">
|
||||||
{{pipeline-stages
|
{{pipeline-stages
|
||||||
clusterPipeline=model.clusterPipeline
|
clusterPipeline=model.clusterPipeline
|
||||||
|
envvars=model.envvars
|
||||||
pipeline=model.pipeline
|
pipeline=model.pipeline
|
||||||
stagesDraggable=false
|
stagesDraggable=false
|
||||||
accounts=model.accounts
|
accounts=model.accounts
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,14 @@
|
||||||
import CodeMirror from 'codemirror';
|
import CodeMirror from 'codemirror';
|
||||||
import Service from 'ember-service';
|
import Service from 'ember-service';
|
||||||
|
import { singleton } from 'pipeline/utils/pipelineStep';
|
||||||
|
import { set, get } from '@ember/object';
|
||||||
|
|
||||||
export default Service.extend({
|
export default Service.extend({
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this._instances = Object.create(null);
|
this._instances = Object.create(null);
|
||||||
},
|
},
|
||||||
hintAry: ['CICD_GIT_COMMIT',
|
|
||||||
'CICD_GIT_REPO_NAME',
|
|
||||||
'CICD_GIT_BRANCH',
|
|
||||||
'CICD_GIT_URL',
|
|
||||||
'CICD_PIPELINE_ID',
|
|
||||||
'CICD_PIPELINE_NAME',
|
|
||||||
'CICD_TRIGGER_TYPE',
|
|
||||||
'CICD_EXECUTION_ID',
|
|
||||||
'CICD_EXECUTION_SEQUENCE'].map(ele=>`\${${ele}}`),
|
|
||||||
fromTextArea(id, textarea) {
|
fromTextArea(id, textarea) {
|
||||||
return this.registerInstance(id, CodeMirror.fromTextArea(textarea));
|
return this.registerInstance(id, CodeMirror.fromTextArea(textarea));
|
||||||
},
|
},
|
||||||
|
|
@ -37,7 +31,7 @@ export default Service.extend({
|
||||||
delete this._instances[id];
|
delete this._instances[id];
|
||||||
},
|
},
|
||||||
getMatchedHint(value, editor) {
|
getMatchedHint(value, editor) {
|
||||||
var hintAry = this.get('hintAry');
|
var hintAry = singleton.hintAry;
|
||||||
var cur = editor.getCursor();
|
var cur = editor.getCursor();
|
||||||
var cursorPosition = cur.ch;
|
var cursorPosition = cur.ch;
|
||||||
var cursorValue = editor.getLine(cur.line).slice(0, cursorPosition);
|
var cursorValue = editor.getLine(cur.line).slice(0, cursorPosition);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import Service from '@ember/service';
|
import Service from '@ember/service';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
|
|
||||||
|
|
||||||
export default Service.extend({
|
export default Service.extend({
|
||||||
globalStore: service(),
|
globalStore: service(),
|
||||||
scope: service(),
|
scope: service(),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
const DEFAULT_REGISTRY = 'index.docker.io';
|
const DEFAULT_REGISTRY = 'index.docker.io';
|
||||||
|
|
||||||
|
export let singleton = {
|
||||||
|
hintAry: []
|
||||||
|
}
|
||||||
|
|
||||||
export function analyzeImageRepo (images) {
|
export function analyzeImageRepo (images) {
|
||||||
if(!images){
|
if(!images){
|
||||||
return '';
|
return '';
|
||||||
|
|
@ -35,6 +39,7 @@ export function analyzeImageRepo (images) {
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const environmentTypes = [{
|
export const environmentTypes = [{
|
||||||
label: 'C',
|
label: 'C',
|
||||||
value: 'gcc:latest',
|
value: 'gcc:latest',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue