diff --git a/Makefile b/Makefile index fb11c7516..efc1779fb 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,9 @@ REF = HEAD VERSION = $(shell git describe --always $(REF)) -all: ts less - -clean: - rm js/*.js - -ts: - tsc js/*.ts +all: less less: less css/*.less > css/app.css -.PHONY: all clean hash ts less +.PHONY: all less diff --git a/README.md b/README.md index 21ba1b571..ca73374fb 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ Open js/app.(ts/js - js file if you don't want to compile typescript) and change * Angular.js * Less * Flatstrap ( Flat Twitter Bootstrap ) -* Typescript ( I'm debating if this is providing any value. ) ###License - MIT diff --git a/js/app.js b/js/app.js index ace5c058a..b5ea70d84 100644 --- a/js/app.js +++ b/js/app.js @@ -1,35 +1,13 @@ 'use strict'; -angular.module('dockerui', [ - 'dockerui.services', - 'dockerui.filters' -]).config([ - '$routeProvider', - function ($routeProvider) { - $routeProvider.when('/', { - templateUrl: 'partials/home.html', - controller: 'HomeController' - }); - $routeProvider.when('/containers/', { - templateUrl: 'partials/containers.html', - controller: 'ContainersController' - }); - $routeProvider.when('/containers/:id/', { - templateUrl: 'partials/container.html', - controller: 'ContainerController' - }); - $routeProvider.when('/images/', { - templateUrl: 'partials/images.html', - controller: 'ImagesController' - }); - $routeProvider.when('/images/:id/', { - templateUrl: 'partials/image.html', - controller: 'ImageController' - }); - $routeProvider.when('/settings', { - templateUrl: 'partials/settings.html', - controller: 'SettingsController' - }); - $routeProvider.otherwise({ - redirectTo: '/' - }); - }]).constant('DOCKER_ENDPOINT', 'http://192.168.1.9:4243\:4243'); + +angular.module('dockerui', ['dockerui.services', 'dockerui.filters']) + .config(['$routeProvider', function ($routeProvider) { + $routeProvider.when('/', {templateUrl: 'partials/home.html', controller: 'HomeController'}); + $routeProvider.when('/containers/', {templateUrl: 'partials/containers.html', controller: 'ContainersController'}); + $routeProvider.when('/containers/:id/', {templateUrl: 'partials/container.html', controller: 'ContainerController'}); + $routeProvider.when('/images/', {templateUrl: 'partials/images.html', controller: 'ImagesController'}); + $routeProvider.when('/images/:id/', {templateUrl: 'partials/image.html', controller: 'ImageController'}); + $routeProvider.when('/settings', {templateUrl: 'partials/settings.html', controller: 'SettingsController'}); + $routeProvider.otherwise({redirectTo: '/'}); + }]) + .constant('DOCKER_ENDPOINT', 'http://192.168.1.9:4243\:4243'); diff --git a/js/app.ts b/js/app.ts deleted file mode 100644 index 330e27f30..000000000 --- a/js/app.ts +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -declare var angular: any; - -angular.module('dockerui', ['dockerui.services', 'dockerui.filters']) - .config(['$routeProvider', ($routeProvider: any) => { - $routeProvider.when('/', {templateUrl: 'partials/home.html', controller: 'HomeController'}); - $routeProvider.when('/containers/', {templateUrl: 'partials/containers.html', controller: 'ContainersController'}); - $routeProvider.when('/containers/:id/', {templateUrl: 'partials/container.html', controller: 'ContainerController'}); - $routeProvider.when('/images/', {templateUrl: 'partials/images.html', controller: 'ImagesController'}); - $routeProvider.when('/images/:id/', {templateUrl: 'partials/image.html', controller: 'ImageController'}); - $routeProvider.when('/settings', {templateUrl: 'partials/settings.html', controller: 'SettingsController'}); - $routeProvider.otherwise({redirectTo: '/'}); - }]) - .constant('DOCKER_ENDPOINT', 'http://192.168.1.9:4243\:4243'); - diff --git a/js/controllers.js b/js/controllers.js index 5bc07c993..6df90d70b 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -1,124 +1,92 @@ -var __extends = this.__extends || function (d, b) { - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var MastheadController = (function () { - function MastheadController($scope) { - $scope.template = 'partials/masthead.html'; - $scope.hclass = 'active'; + +function MastheadController($scope) { + $scope.template = 'partials/masthead.html'; + + $scope.hclass = 'active'; + $scope.cclass = ''; + $scope.iclass = ''; + $scope.sclass = ''; + + $scope.linkChange = function(link) { + $scope.hclass = ''; $scope.cclass = ''; $scope.iclass = ''; $scope.sclass = ''; - $scope.linkChange = function (link) { - $scope.hclass = ''; - $scope.cclass = ''; - $scope.iclass = ''; - $scope.sclass = ''; - switch(link) { - case 'home': - $scope.hclass = 'active'; - break; - case 'containers': - $scope.cclass = 'active'; - break; - case 'images': - $scope.iclass = 'active'; - break; - case 'settings': - $scope.sclass = 'active'; - break; - default: - console.log('Not supported:' + link); - } - }; - } - return MastheadController; -})(); -var SideBarController = (function () { - function SideBarController($scope, Container) { - $scope.template = 'partials/sidebar.html'; - Container.query({ - }, function (d) { - $scope.containers = d; - }); - } - return SideBarController; -})(); -var HomeController = (function () { - function HomeController() { - } - return HomeController; -})(); -var SettingsController = (function () { - function SettingsController() { - } - return SettingsController; -})(); -var ContainerControllerBase = (function () { - function ContainerControllerBase() { } - ContainerControllerBase.prototype.start = function ($scope, $routeParams, Container) { - Container.start({ - id: $routeParams.id - }, function (d) { - $scope.response = d; - }); + + switch(link) { + case 'home': + $scope.hclass = 'active'; + break; + case 'containers': + $scope.cclass = 'active'; + break; + case 'images': + $scope.iclass = 'active'; + break; + case 'settings': + $scope.sclass = 'active'; + break; + default: + console.log('Not supported:' + link); + } }; - ContainerControllerBase.prototype.stop = function ($scope, $routeParams, Container) { - Container.stop({ - id: $routeParams.id - }, function (d) { - $scope.response = d; +} + +function SideBarController($scope, Container) { + $scope.template = 'partials/sidebar.html'; + + Container.query({}, function(d) { + $scope.containers = d; + }); +} + +function HomeController() { + +} + +function SettingsController() { + +} + +function ContainerController($scope, $routeParams, Container) { + + $scope.start = function(){ + Container.start({id: $routeParams.id}, function(d) { + $scope.response = d; + }); + }; + + $scope.stop = function() { + Container.stop({id: $routeParams.id}, function(d) { + $scope.response = d; }); }; - ContainerControllerBase.prototype.remove = function ($scope, $routeParams, Container) { - if(confirm("Are you sure you want to remove the container?")) { - Container.remove({ - id: $routeParams.id - }, function (d) { - $scope.response = d; + + $scope.remove = function() { + if (confirm("Are you sure you want to remove the container?")) { + Container.remove({id: $routeParams.id}, function(d) { + $scope.response = d; }); } }; - return ContainerControllerBase; -})(); -var ContainerController = (function (_super) { - __extends(ContainerController, _super); - function ContainerController($scope, $routeParams, Container) { - var _this = this; - _super.call(this); - $scope.start = function () { - return _this.start($scope, $routeParams, Container); - }; - $scope.stop = function () { - return _this.stop($scope, $routeParams, Container); - }; - $scope.remove = function () { - return _this.remove($scope, $routeParams, Container); - }; - Container.get({ - id: $routeParams.id - }, function (d) { - $scope.container = d; - }); - } - return ContainerController; -})(ContainerControllerBase); -var ContainersController = (function (_super) { - __extends(ContainersController, _super); - function ContainersController($scope, $routeParams, Container) { - var _this = this; - _super.call(this); - $scope.start = function () { - return _this.start($scope, $routeParams, Container); - }; - $scope.stop = function () { - return _this.stop($scope, $routeParams, Container); - }; - Container.query({ - }, function (d) { - $scope.containers = d; + + $scope.changes = []; + + $scope.getChanges = function() { + Container.changes({id: $routeParams.id}, function(d) { + $scope.changes = d; }); - } - return ContainersController; -})(ContainerControllerBase); + }; + + Container.get({id: $routeParams.id}, function(d) { + $scope.container = d; + }); + + $scope.getChanges(); +} + +function ContainersController($scope, Container) { + Container.query({}, function(d) { + $scope.containers = d; + }); +} diff --git a/js/controllers.ts b/js/controllers.ts deleted file mode 100644 index 47e5ae263..000000000 --- a/js/controllers.ts +++ /dev/null @@ -1,108 +0,0 @@ - -class MastheadController { - constructor($scope: any) { - $scope.template = 'partials/masthead.html'; - - $scope.hclass = 'active'; - $scope.cclass = ''; - $scope.iclass = ''; - $scope.sclass = ''; - - $scope.linkChange = (link: string) => { - $scope.hclass = ''; - $scope.cclass = ''; - $scope.iclass = ''; - $scope.sclass = ''; - - switch(link) { - case 'home': - $scope.hclass = 'active'; - break; - case 'containers': - $scope.cclass = 'active'; - break; - case 'images': - $scope.iclass = 'active'; - break; - case 'settings': - $scope.sclass = 'active'; - break; - default: - console.log('Not supported:' + link); - } - }; - } -} - -class SideBarController { - constructor($scope: any, Container: any) { - $scope.template = 'partials/sidebar.html'; - - Container.query({}, (d) => { - $scope.containers = d; - }); - } -} - -class HomeController { - constructor() { - - } -} - -class SettingsController { - constructor() { - - } -} - -class ContainerControllerBase { - //Start the current container - start($scope: any, $routeParams: any, Container: any) { - Container.start({id: $routeParams.id}, (d) => { - $scope.response = d; - }); - } - - //Stop the current container - stop($scope: any, $routeParams: any, Container: any) { - Container.stop({id: $routeParams.id}, (d) => { - $scope.response = d; - }); - } - - //Remove the current container - remove($scope: any, $routeParams: any, Container: any) { - if (confirm("Are you sure you want to remove the container?")) { - Container.remove({id: $routeParams.id}, (d) => { - $scope.response = d; - }); - } - } -} - -class ContainerController extends ContainerControllerBase { - constructor($scope: any, $routeParams: any, Container: any) { - super(); - $scope.start = () => this.start($scope, $routeParams, Container); - $scope.stop = () => this.stop($scope, $routeParams, Container); - $scope.remove = () => this.remove($scope, $routeParams, Container); - - Container.get({id: $routeParams.id}, (d) => { - $scope.container = d; - }); - } -} - -class ContainersController extends ContainerControllerBase { - constructor($scope: any, $routeParams: any, Container: any) { - super(); - $scope.start = () => this.start($scope, $routeParams, Container); - $scope.stop = () => this.stop($scope, $routeParams, Container); - - Container.query({}, (d) => { - $scope.containers = d; - }); - } -} - diff --git a/js/filters.js b/js/filters.js index 0997bb02a..c068dd12a 100644 --- a/js/filters.js +++ b/js/filters.js @@ -1,30 +1,27 @@ 'use strict'; -angular.module('dockerui.filters', []).filter('truncate', function () { - return function (text, length, end) { - if(isNaN(length)) { - length = 10; - } - if(end === undefined) { - end = "..."; - } - if(text.length <= length || text.length - end.length <= length) { - return text; - } else { - return String(text).substring(0, length - end.length) + end; - } - }; -}).filter('statusbadge', function () { - return function (text) { - if(text === 'Ghost') { - return 'important'; - } - return 'success'; - }; -}).filter('isactive', function ($location) { - return function (text) { - if(text == $location) { - return 'active'; - } - return ''; - }; -}); + +angular.module('dockerui.filters', []) + .filter('truncate', function() { + return function(text, length, end) { + if (isNaN(length)) + length = 10; + + if (end === undefined) + end = "..."; + + if (text.length <= length || text.length - end.length <= length) { + return text; + } + else { + return String(text).substring(0, length-end.length) + end; + } + }; + }) + .filter('statusbadge', function() { + return function(text) { + if (text === 'Ghost') { + return 'important'; + } + return 'success'; + }; + }); diff --git a/js/filters.ts b/js/filters.ts deleted file mode 100644 index a212b3d7f..000000000 --- a/js/filters.ts +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -declare var angular: any; - -angular.module('dockerui.filters', []) - .filter('truncate', () => { - return (text: string, length:any, end:string) => { - if (isNaN(length)) - length = 10; - - if (end === undefined) - end = "..."; - - if (text.length <= length || text.length - end.length <= length) { - return text; - } - else { - return String(text).substring(0, length-end.length) + end; - } - }; - }) - .filter('statusbadge', () => { - return (text: string) => { - if (text === 'Ghost') { - return 'important'; - } - return 'success'; - }; - }) - .filter('isactive', ($location: any) => { - return (text: string) => { - if (text == $location) { - return 'active'; - } - return ''; - }; - }); - diff --git a/js/services.js b/js/services.js index 7c1f4c5f0..daab27383 100644 --- a/js/services.js +++ b/js/services.js @@ -1,123 +1,33 @@ 'use strict'; -angular.module('dockerui.services', [ - 'ngResource' -]).factory('Container', function ($resource, DOCKER_ENDPOINT) { - return $resource(DOCKER_ENDPOINT + '/containers/:id/:action', { - }, { - query: { - method: 'GET', - params: { - all: 0, - action: 'json' - }, - isArray: true - }, - get: { - method: 'GET', - params: { - action: 'json' - } - }, - start: { - method: 'POST', - params: { - action: 'start' - } - }, - stop: { - method: 'POST', - params: { - t: 5, - action: 'stop' - } - }, - restart: { - method: 'POST', - params: { - t: 5, - action: 'restart' - } - }, - kill: { - method: 'POST', - params: { - action: 'kill' - } - }, - changes: { - method: 'GET', - params: { - action: 'chagnes' - } - }, - create: { - method: 'POST', - params: { - action: 'create' - } - }, - remove: { - method: 'DELETE', - params: { - v: 0 - } - } + +angular.module('dockerui.services', ['ngResource']) + .factory('Container', function($resource, DOCKER_ENDPOINT) { + // Resource for interacting with the docker containers + // http://docs.docker.io/en/latest/api/docker_remote_api.html#containers + return $resource(DOCKER_ENDPOINT + '/containers/:id/:action', {}, { + query: {method: 'GET', params:{ all: 0, action: 'json'}, isArray: true}, + get :{method: 'GET', params: { action:'json'}}, + start: {method: 'POST', params: { action: 'start'}}, + stop: {method: 'POST', params: {t: 5, action: 'stop'}}, + restart: {method: 'POST', params: {t: 5, action: 'restart' }}, + kill :{method: 'POST', params: {action:'kill'}}, + changes :{method: 'GET', params: {action:'changes'}, isArray: true}, + create :{method: 'POST', params: {action:'create'}}, + remove :{method: 'DELETE', params: {v:0}} + }); + }) + .factory('Image', function($resource, DOCKER_ENDPOINT) { + // Resource for docker images + // http://docs.docker.io/en/latest/api/docker_remote_api.html#images + return $resource(DOCKER_ENDPOINT + '/images/:name/:action', {}, { + query: {method: 'GET', params:{ all: 0, action: 'json'}, isArray: true}, + get :{method: 'GET', params: { action:'json'}}, + search :{method: 'GET', params: { action:'search'}}, + history :{method: 'GET', params: { action:'history'}}, + create :{method: 'POST', params: {action:'create'}}, + insert :{method: 'POST', params: {action:'insert'}}, + push :{method: 'POST', params: {action:'push'}}, + tag :{method: 'POST', params: {action:'tag'}}, + delete :{method: 'DELETE'} + }); }); -}).factory('Image', function ($resource, DOCKER_ENDPOINT) { - return $resource(DOCKER_ENDPOINT + '/images/:name/:action', { - }, { - query: { - method: 'GET', - params: { - all: 0, - action: 'json' - }, - isArray: true - }, - get: { - method: 'GET', - params: { - action: 'json' - } - }, - search: { - method: 'GET', - params: { - action: 'search' - } - }, - history: { - method: 'GET', - params: { - action: 'history' - } - }, - create: { - method: 'POST', - params: { - action: 'create' - } - }, - insert: { - method: 'POST', - params: { - action: 'insert' - } - }, - push: { - method: 'POST', - params: { - action: 'push' - } - }, - tag: { - method: 'POST', - params: { - action: 'tag' - } - }, - delete: { - method: 'DELETE' - } - }); -}); diff --git a/js/services.ts b/js/services.ts deleted file mode 100644 index 074946e35..000000000 --- a/js/services.ts +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -declare var angular: any; - -angular.module('dockerui.services', ['ngResource']) - .factory('Container', ($resource: any, DOCKER_ENDPOINT: string) => { - // Resource for interacting with the docker containers - // http://docs.docker.io/en/latest/api/docker_remote_api.html#containers - return $resource(DOCKER_ENDPOINT + '/containers/:id/:action', {}, { - query: {method: 'GET', params:{ all: 0, action: 'json'}, isArray: true}, - get :{method: 'GET', params: { action:'json'}}, - start: {method: 'POST', params: { action: 'start'}}, - stop: {method: 'POST', params: {t: 5, action: 'stop'}}, - restart: {method: 'POST', params: {t: 5, action: 'restart' }}, - kill :{method: 'POST', params: {action:'kill'}}, - changes :{method: 'GET', params: {action:'chagnes'}}, - create :{method: 'POST', params: {action:'create'}}, - remove :{method: 'DELETE', params: {v:0}} - }); - }) - .factory('Image', ($resource: any, DOCKER_ENDPOINT: string) => { - // Resource for docker images - // http://docs.docker.io/en/latest/api/docker_remote_api.html#images - return $resource(DOCKER_ENDPOINT + '/images/:name/:action', {}, { - query: {method: 'GET', params:{ all: 0, action: 'json'}, isArray: true}, - get :{method: 'GET', params: { action:'json'}}, - search :{method: 'GET', params: { action:'search'}}, - history :{method: 'GET', params: { action:'history'}}, - create :{method: 'POST', params: {action:'create'}}, - insert :{method: 'POST', params: {action:'insert'}}, - push :{method: 'POST', params: {action:'push'}}, - tag :{method: 'POST', params: {action:'tag'}}, - delete :{method: 'DELETE'} - }); - }); - diff --git a/partials/container.html b/partials/container.html index e0635ec8d..b72d3789e 100644 --- a/partials/container.html +++ b/partials/container.html @@ -33,10 +33,28 @@ Running: {{ container.State.Running }} - +
+
+ Changes: +
+
+ +
+
+ +
+ +
+ +
+