From 0f8da44165bc8b79ac11b2c4a19d414f7ea1e20a Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 18 Jun 2013 16:50:35 -0900 Subject: [PATCH] Add build support for http request --- js/app.js | 5 +++-- js/controllers.js | 5 ++++- js/services.js | 28 ++++++++++++++++++++++++---- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/js/app.js b/js/app.js index 386179a67..cb85fd625 100644 --- a/js/app.js +++ b/js/app.js @@ -11,6 +11,7 @@ angular.module('dockerui', ['dockerui.services', 'dockerui.filters']) $routeProvider.otherwise({redirectTo: '/'}); }]) // This is your docker url that the api will use to make requests - .constant('DOCKER_ENDPOINT', 'http://192.168.1.9:4243\:4243') - .constant('UI_VERSION', 'v0.1') + .constant('DOCKER_ENDPOINT', 'http://192.168.1.9') + .constant('DOCKER_PORT', ':4243') + .constant('UI_VERSION', 'v0.2') .constant('DOCKER_API_VERSION', 'v1.1'); diff --git a/js/controllers.js b/js/controllers.js index 57c2ff222..63fc8d319 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -278,12 +278,15 @@ function StartContainerController($scope, $routeParams, $location, Container) { }; } -function BuilderController($scope, Image) { +function BuilderController($scope, Dockerfile) { $scope.template = '/partials/builder.html'; ace.config.set('basePath', '/lib/ace-builds/src-noconflict/'); $scope.build = function() { + Dockerfile.build(editor.getValue(), function(e) { + console.log(e); + }); }; } diff --git a/js/services.js b/js/services.js index 72aa79f4e..d14af9e78 100644 --- a/js/services.js +++ b/js/services.js @@ -53,12 +53,32 @@ angular.module('dockerui.services', ['ngResource']) 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 { displayAll: false, endpoint: DOCKER_ENDPOINT, version: DOCKER_API_VERSION, - url: DOCKER_ENDPOINT + '/' + DOCKER_API_VERSION, - uiVersion: UI_VERSION - }; + rawUrl: DOCKER_ENDPOINT + '/' + DOCKER_API_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); + } + }; });