diff --git a/management/server/webui/src/main/webapp/subutai-app/environment/advanced-controller.js b/management/server/webui/src/main/webapp/subutai-app/environment/advanced-controller.js index 321fc9e74ad..73e08f6f63b 100755 --- a/management/server/webui/src/main/webapp/subutai-app/environment/advanced-controller.js +++ b/management/server/webui/src/main/webapp/subutai-app/environment/advanced-controller.js @@ -3,7 +3,7 @@ angular.module('subutai.environment.adv-controller', []) .controller('AdvancedEnvironmentCtrl', AdvancedEnvironmentCtrl); -AdvancedEnvironmentCtrl.$inject = ['$scope', '$rootScope', 'environmentService', 'trackerSrv', 'SweetAlert', 'ngDialog', 'identitySrv']; +AdvancedEnvironmentCtrl.$inject = ['$scope', '$rootScope', 'environmentService', 'trackerSrv', 'SweetAlert', 'ngDialog', 'identitySrv', '$stateParams', '$location']; var graph = new joint.dia.Graph; var paper; @@ -17,7 +17,7 @@ var PEER_SPACE = 30; var RH_WIDTH = 100; var RH_SPACE = 10; -function AdvancedEnvironmentCtrl($scope, $rootScope, environmentService, trackerSrv, SweetAlert, ngDialog, identitySrv) { +function AdvancedEnvironmentCtrl($scope, $rootScope, environmentService, trackerSrv, SweetAlert, ngDialog, identitySrv, $stateParams, $location) { var vm = this; @@ -56,6 +56,8 @@ function AdvancedEnvironmentCtrl($scope, $rootScope, environmentService, tracker vm.isEditing = false; vm.downloadProgress = ''; vm.rhId = ''; + $scope.environmentMode = true + // $scope.environmentMode = false // functions @@ -65,16 +67,21 @@ function AdvancedEnvironmentCtrl($scope, $rootScope, environmentService, tracker vm.clearWorkspace = clearWorkspace; vm.addSettingsToTemplate = addSettingsToTemplate; vm.getFilteredTemplates = getFilteredTemplates; - + vm.changeMode = changeMode; vm.showResources = showResources; vm.addResource2Build = addResource2Build; vm.closePopup = closePopup; + vm.humanFileSize = humanFileSize //plugins actions vm.selectPlugin = selectPlugin; vm.setTemplatesByPlugin = setTemplatesByPlugin; vm.loadPrivateTemplates = loadPrivateTemplates; + function changeMode(mode) { + $location.path('/environment/simple/' + (vm.currentEnvironment.id? vm.currentEnvironment.id:'')) + } + function loadPrivateTemplates() { environmentService.getPrivateTemplates() .then(function (data) { @@ -903,14 +910,14 @@ function AdvancedEnvironmentCtrl($scope, $rootScope, environmentService, tracker function initJointJs() { - setTimeout(function () { - document.getElementById('js-environment-creation').addEventListener('destroyEnvironment', function (e) { - if (vm.editingEnv && vm.editingEnv.id == e.detail) { - clearWorkspace(); - vm.editingEnv = false; - } - }, false); - }, 1000); + // setTimeout(function () { + // document.getElementById('js-environment-creation').addEventListener('destroyEnvironment', function (e) { + // if (vm.editingEnv && vm.editingEnv.id == e.detail) { + // clearWorkspace(); + // vm.editingEnv = false; + // } + // }, false); + // }, 1000); paper = new joint.dia.Paper({ el: $('#js-environment-creation'), @@ -1299,6 +1306,118 @@ function AdvancedEnvironmentCtrl($scope, $rootScope, environmentService, tracker } } + function getContainersSortedByQuota(containers) { + + var sortedContainers = containers.length > 0 ? {} : null; + + for (var index = 0; index < containers.length; index++) { + + var container = containers[index]; + var remoteProxyContainer = !container.local && container.dataSource == "hub"; + + // We don't show on UI containers created by Hub, located on other peers. + // See details: io.subutai.core.environment.impl.adapter.EnvironmentAdapter. + if (remoteProxyContainer) { + continue; + } + + var quotaSize = containers[index].type; + var templateName = containers[index].templateName; + + if (!sortedContainers[quotaSize]) { + sortedContainers[quotaSize] = {}; + sortedContainers[quotaSize].quantity = 1; + sortedContainers[quotaSize].containers = {}; + sortedContainers[quotaSize].containers[templateName] = 1; + } else { + if (!sortedContainers[quotaSize].containers[templateName]) { + sortedContainers[quotaSize].quantity += 1; + sortedContainers[quotaSize].containers[templateName] = 1; + } else { + sortedContainers[quotaSize].quantity += 1; + sortedContainers[quotaSize].containers[templateName] += 1; + } + } + } + + for (var item in sortedContainers) { + sortedContainers[item].tooltip = ""; + for (var container in sortedContainers[item].containers) { + sortedContainers[item].tooltip += container + ": " + sortedContainers[item].containers[container] + "
"; + } + sortedContainers[item].tooltip += "Quota: " + item; + } + return sortedContainers; + } + + environmentService.getContainersType() + .success(function (data) { + vm.containersType = data; + }) + .error(function (data) { + VARS_MODAL_ERROR(SweetAlert, data); + }); + + environmentService.getContainersTypesInfo() + .success(function (data) { + vm.containersTypeInfo = []; + + for (var i = 0; i < data.length; i++) { + var type = data[i].key.split(/\.(.+)?/)[0]; + var property = data[i].key.split(/\.(.+)?/)[1]; + + if (vm.containersTypeInfo[type] === undefined) { + vm.containersTypeInfo[type] = {}; + } + + vm.containersTypeInfo[type][property] = data[i].value.replace(/iB/ig, "B"); + } + }); + + function humanFileSize(bytes, si) { + var thresh = si ? 1000 : 1024; + if(Math.abs(bytes) < thresh) { + return bytes + ' B'; + } + var units = si + ? ['kB','MB','GB','TB','PB','EB','ZB','YB'] + : ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB']; + var u = -1; + do { + bytes /= thresh; + ++u; + } while(Math.abs(bytes) >= thresh && u < units.length - 1); + return bytes.toFixed(1)+' '+units[u]; + } + + function loadEnvironment(environmentId) { + if (environmentId) { + environmentService.getEnvironments().success(function (data) { + var environmentsList = []; + for (var i = 0; i < data.length; ++i) { + data[i].containersByQuota = getContainersSortedByQuota(data[i].containers); + environmentsList.push(data[i]); + } + vm.currentEnvironment = findEnvironment(environmentsList, environmentId) + editEnvironment(vm.currentEnvironment) + }).error(function (error) { + console.log(error); + }); + } + } + + function findEnvironment(environments, environmentId) { + var result = null; + for (var i = 0; i < environments.length; i++) { + if (environments[i].id === environmentId) { + result = environments[i]; + break; + } + } + return result; + } + + loadEnvironment($stateParams.environmentId) } function placeRhSimple(model) { diff --git a/management/server/webui/src/main/webapp/subutai-app/environment/controller.js b/management/server/webui/src/main/webapp/subutai-app/environment/controller.js index 896a9586434..b23dda00b16 100755 --- a/management/server/webui/src/main/webapp/subutai-app/environment/controller.js +++ b/management/server/webui/src/main/webapp/subutai-app/environment/controller.js @@ -30,16 +30,16 @@ angular.module('subutai.environment.controller', []) // }; // } -EnvironmentViewCtrl.$inject = ['$scope', '$rootScope', 'environmentService', 'trackerSrv', 'identitySrv', 'SweetAlert', '$resource', '$compile', 'ngDialog', '$timeout', '$sce', '$stateParams', 'DTOptionsBuilder', 'DTColumnDefBuilder', '$state']; +EnvironmentViewCtrl.$inject = ['$scope', '$rootScope', '$location', 'environmentService', 'trackerSrv', 'identitySrv', 'SweetAlert', '$resource', '$compile', 'ngDialog', '$timeout', '$sce', '$stateParams', 'DTOptionsBuilder', 'DTColumnDefBuilder', '$state']; fileModel.$inject = ['$parse']; var fileUploader = {}; -function EnvironmentViewCtrl($scope, $rootScope, environmentService, trackerSrv, identitySrv, SweetAlert, $resource, $compile, ngDialog, $timeout, $sce, $stateParams, DTOptionsBuilder, DTColumnDefBuilder, $state) { +function EnvironmentViewCtrl($scope, $rootScope, $location, environmentService, trackerSrv, identitySrv, SweetAlert, $resource, $compile, ngDialog, $timeout, $sce, $stateParams, DTOptionsBuilder, DTColumnDefBuilder, $state) { var vm = this; - vm.activeMode = 'simple'; + vm.activeMode = 'list'; vm.currentEnvironment = {}; @@ -72,6 +72,7 @@ function EnvironmentViewCtrl($scope, $rootScope, environmentService, trackerSrv, vm.changeMode = changeMode; vm.destroyEnvironment = destroyEnvironment; + vm.editEnvironment = editEnvironment; vm.sshKey = sshKey; vm.getSSHfromFile = getSSHfromFile; vm.addSshKey = addSshKey; @@ -88,7 +89,7 @@ function EnvironmentViewCtrl($scope, $rootScope, environmentService, trackerSrv, vm.minimizeLogs = minimizeLogs; vm.getQuotaColor = getQuotaColor; vm.initDataTable = initDataTable; - + //share environment functions vm.shareEnvironmentWindow = shareEnvironmentWindow; vm.shareEnvironment = shareEnvironment; @@ -96,6 +97,10 @@ function EnvironmentViewCtrl($scope, $rootScope, environmentService, trackerSrv, vm.removeUserFromStack = removeUserFromStack; vm.humanFileSize = humanFileSize; + function editEnvironment(environmentId) { + $location.path('/environment/simple/'+environmentId) + } + function humanFileSize(bytes, si) { var thresh = si ? 1000 : 1024; if(Math.abs(bytes) < thresh) { @@ -423,8 +428,8 @@ function EnvironmentViewCtrl($scope, $rootScope, environmentService, trackerSrv, } ); - var destroyEnvEvent = new CustomEvent('destroyEnvironment', {'detail': environmentId}); - document.getElementById('js-environment-creation').dispatchEvent(destroyEnvEvent); + // var destroyEnvEvent = new CustomEvent('destroyEnvironment', {'detail': environmentId}); + // document.getElementById('js-environment-creation').dispatchEvent(destroyEnvEvent); vm.environments[key].status = 'UNDER_MODIFICATION'; diff --git a/management/server/webui/src/main/webapp/subutai-app/environment/partials/advanced.html b/management/server/webui/src/main/webapp/subutai-app/environment/partials/advanced.html index 9d94816e7b4..adb828a01c1 100644 --- a/management/server/webui/src/main/webapp/subutai-app/environment/partials/advanced.html +++ b/management/server/webui/src/main/webapp/subutai-app/environment/partials/advanced.html @@ -1,38 +1,57 @@ -
-
-
-
-
    -
  • - Peers -
  • -
  • - Templates -
  • -
+
+ +
+ +
+
+ + +
+
-
-
- -
-
- +
+ +
+ +
+
+
+
+
    +
  • + Peers +
  • +
  • + Templates +
  • +
-
    -
  • +
    +
    + +
    +
    + +
    +
      +
    • {{ template.name }} -
      -
      -
    • -
    -
    -
    -
    -
      -
    • +
      +
      +
    • +
    +
    +
    +
    +
      +
    • Peer {{peerId.substr(peerId.length - 3)}} -
      -
      - {{ peersResources.name }} +
      +
      + {{ peersResources.name }} +
      -
      -
    • -
    -
    -
    -
    -
    -
    -
    -
    - Resource hosts - - - +
  • +
+
+
-
-
    -
  • -
    +
    +
    +
    + Resource hosts + + + +
    +
    +
    +
      +
    • +
      - RH {{resourceHost.id.substr(resourceHost.length - 3)}} [MH] + RH {{resourceHost.id.substr(resourceHost.length - 3)}} [MH] - ({{resourceHost.hostname}}) -
      - -
      -
      -
      - - CPU: {{ resourceHost.cpu }} -
      -
      -
      -
      -
      - {{ 100 - resourceHost.cpuAvailable | number:1 }} % available -
      + ({{resourceHost.hostname}})
      -
      -
      - - HDD: {{ resourceHost.hdd / 1073741824 | number:1 }} Gb -
      -
      -
      -
      -
      - {{ resourceHost.hddAvailable / 1073741824 | number:1 }} Gb - available -
      -
      -
      -
      - - RAM: {{ resourceHost.memory / 1073741824 | number:1 }} Gb + +
      +
      +
      + + CPU: {{ resourceHost.cpu }} +
      +
      +
      +
      +
      + {{ 100 - resourceHost.cpuAvailable | number:1 }} % available +
      -
      -
      +
      +
      + + HDD: {{ resourceHost.hdd / 1073741824 | number:1 }} Gb +
      +
      +
      +
      +
      + {{ resourceHost.hddAvailable / 1073741824 | number:1 }} Gb + available +
      -
      - {{ resourceHost.memoryAvailable / 1073741824 | number:1 }} Gb - available +
      +
      + + RAM: {{ resourceHost.memory / 1073741824 | number:1 }} Gb +
      +
      +
      +
      +
      + {{ resourceHost.memoryAvailable / 1073741824 | number:1 }} Gb + available +
      -
      -
    • -
    -
    +
  • +
+
+
-
-
-
-
-
+
+
+
+
-
+
-
-
Choose plugin
-
-
-
    -
  • - goto - +
    +
    Choose plugin
    +
    +
    +
      +
    • + goto +