github.com/fanux/shipyard@v0.0.0-20161009071005-6515ce223235/controller/static/app/images/images.service.js (about) 1 (function(){ 2 'use strict'; 3 4 angular 5 .module('shipyard.images') 6 .factory('ImagesService', ImagesService); 7 8 ImagesService.$inject = ['$http']; 9 function ImagesService($http) { 10 return { 11 list: function() { 12 var promise = $http 13 .get('/images/json') 14 .then(function(response) { 15 return response.data; 16 }); 17 return promise; 18 }, 19 remove: function(image) { 20 var promise = $http 21 .delete('/images/' + image.Id + '?force=1') 22 .then(function(response) { 23 return response.data; 24 }); 25 return promise; 26 }, 27 tag: function(image, tagName) { 28 var versionTag="" 29 var colonIndex=tagName.lastIndexOf(":") 30 var slashIndex=tagName.lastIndexOf("/") 31 if (colonIndex>0 && colonIndex > slashIndex) { 32 versionTag=tagName.substring(colonIndex+1,tagName.length) 33 tagName=tagName.substring(0,colonIndex) 34 } 35 var promise = $http 36 .post('/images/' + image.Id + '/tag?repo=' + tagName + '&tag='+ versionTag ) 37 .then(function(response) { 38 return response.data; 39 }); 40 return promise; 41 } 42 } 43 } 44 })();