mirror of https://github.com/portainer/portainer
Add build support for http request
parent
7b7bb46844
commit
0f8da44165
|
@ -11,6 +11,7 @@ angular.module('dockerui', ['dockerui.services', 'dockerui.filters'])
|
||||||
$routeProvider.otherwise({redirectTo: '/'});
|
$routeProvider.otherwise({redirectTo: '/'});
|
||||||
}])
|
}])
|
||||||
// This is your docker url that the api will use to make requests
|
// This is your docker url that the api will use to make requests
|
||||||
.constant('DOCKER_ENDPOINT', 'http://192.168.1.9:4243\:4243')
|
.constant('DOCKER_ENDPOINT', 'http://192.168.1.9')
|
||||||
.constant('UI_VERSION', 'v0.1')
|
.constant('DOCKER_PORT', ':4243')
|
||||||
|
.constant('UI_VERSION', 'v0.2')
|
||||||
.constant('DOCKER_API_VERSION', 'v1.1');
|
.constant('DOCKER_API_VERSION', 'v1.1');
|
||||||
|
|
|
@ -278,12 +278,15 @@ function StartContainerController($scope, $routeParams, $location, Container) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function BuilderController($scope, Image) {
|
function BuilderController($scope, Dockerfile) {
|
||||||
$scope.template = '/partials/builder.html';
|
$scope.template = '/partials/builder.html';
|
||||||
|
|
||||||
ace.config.set('basePath', '/lib/ace-builds/src-noconflict/');
|
ace.config.set('basePath', '/lib/ace-builds/src-noconflict/');
|
||||||
|
|
||||||
$scope.build = function() {
|
$scope.build = function() {
|
||||||
|
Dockerfile.build(editor.getValue(), function(e) {
|
||||||
|
console.log(e);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,12 +53,32 @@ angular.module('dockerui.services', ['ngResource'])
|
||||||
get: {method: 'GET'}
|
get: {method: 'GET'}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.factory('Settings', function(DOCKER_ENDPOINT, DOCKER_API_VERSION, UI_VERSION) {
|
.factory('Settings', function(DOCKER_ENDPOINT, DOCKER_PORT, DOCKER_API_VERSION, UI_VERSION) {
|
||||||
|
var url = DOCKER_ENDPOINT;
|
||||||
|
if (DOCKER_PORT) {
|
||||||
|
url = url + DOCKER_PORT + '\\' + DOCKER_PORT;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
displayAll: false,
|
displayAll: false,
|
||||||
endpoint: DOCKER_ENDPOINT,
|
endpoint: DOCKER_ENDPOINT,
|
||||||
version: DOCKER_API_VERSION,
|
version: DOCKER_API_VERSION,
|
||||||
url: DOCKER_ENDPOINT + '/' + DOCKER_API_VERSION,
|
rawUrl: DOCKER_ENDPOINT + '/' + DOCKER_API_VERSION,
|
||||||
uiVersion: UI_VERSION
|
uiVersion: UI_VERSION,
|
||||||
};
|
url: url
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.factory('Dockerfile', function(Settings) {
|
||||||
|
return {
|
||||||
|
settings: Settings,
|
||||||
|
build: function(file, callback) {
|
||||||
|
var data = new FormData();
|
||||||
|
var dockerfile = new Blob([file], { type: 'text/text' });
|
||||||
|
data.append('Dockerfile', dockerfile);
|
||||||
|
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
request.onload = callback;
|
||||||
|
request.open('POST', 'http://192.168.1.9:4243/v1.1/build');
|
||||||
|
request.send(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue