diff options
| author | Yoggzo <yogg@epsina.com> | 2016-02-29 14:20:13 +0100 |
|---|---|---|
| committer | Yoggzo <yogg@epsina.com> | 2016-02-29 14:20:13 +0100 |
| commit | cfce59d6dc120848624e105614575ae0f48af81b (patch) | |
| tree | 348540cbed9dfce254a64ceee69977e9954b65e1 /client | |
| parent | 6349739a6c42d413e1bc1ea5068336187055c277 (diff) | |
merge
Diffstat (limited to 'client')
40 files changed, 232 insertions, 37 deletions
diff --git a/client/images/spin/128x128/Preloader_1.gif b/client/images/spin/128x128/Preloader_1.gif Binary files differnew file mode 100644 index 0000000..dafe17e --- /dev/null +++ b/client/images/spin/128x128/Preloader_1.gif diff --git a/client/images/spin/128x128/Preloader_10.gif b/client/images/spin/128x128/Preloader_10.gif Binary files differnew file mode 100644 index 0000000..cdfa680 --- /dev/null +++ b/client/images/spin/128x128/Preloader_10.gif diff --git a/client/images/spin/128x128/Preloader_2.gif b/client/images/spin/128x128/Preloader_2.gif Binary files differnew file mode 100644 index 0000000..3cb9003 --- /dev/null +++ b/client/images/spin/128x128/Preloader_2.gif diff --git a/client/images/spin/128x128/Preloader_3.gif b/client/images/spin/128x128/Preloader_3.gif Binary files differnew file mode 100644 index 0000000..7f7d415 --- /dev/null +++ b/client/images/spin/128x128/Preloader_3.gif diff --git a/client/images/spin/128x128/Preloader_4.gif b/client/images/spin/128x128/Preloader_4.gif Binary files differnew file mode 100644 index 0000000..78baff6 --- /dev/null +++ b/client/images/spin/128x128/Preloader_4.gif diff --git a/client/images/spin/128x128/Preloader_5.gif b/client/images/spin/128x128/Preloader_5.gif Binary files differnew file mode 100644 index 0000000..c9c1530 --- /dev/null +++ b/client/images/spin/128x128/Preloader_5.gif diff --git a/client/images/spin/128x128/Preloader_6.gif b/client/images/spin/128x128/Preloader_6.gif Binary files differnew file mode 100644 index 0000000..3203d7f --- /dev/null +++ b/client/images/spin/128x128/Preloader_6.gif diff --git a/client/images/spin/128x128/Preloader_7.gif b/client/images/spin/128x128/Preloader_7.gif Binary files differnew file mode 100644 index 0000000..2eb19be --- /dev/null +++ b/client/images/spin/128x128/Preloader_7.gif diff --git a/client/images/spin/128x128/Preloader_8.gif b/client/images/spin/128x128/Preloader_8.gif Binary files differnew file mode 100644 index 0000000..3ba8217 --- /dev/null +++ b/client/images/spin/128x128/Preloader_8.gif diff --git a/client/images/spin/128x128/Preloader_9.gif b/client/images/spin/128x128/Preloader_9.gif Binary files differnew file mode 100644 index 0000000..7018192 --- /dev/null +++ b/client/images/spin/128x128/Preloader_9.gif diff --git a/client/images/spin/32x32/Preloader_1.gif b/client/images/spin/32x32/Preloader_1.gif Binary files differnew file mode 100644 index 0000000..b810330 --- /dev/null +++ b/client/images/spin/32x32/Preloader_1.gif diff --git a/client/images/spin/32x32/Preloader_10.gif b/client/images/spin/32x32/Preloader_10.gif Binary files differnew file mode 100644 index 0000000..f9c462f --- /dev/null +++ b/client/images/spin/32x32/Preloader_10.gif diff --git a/client/images/spin/32x32/Preloader_2.gif b/client/images/spin/32x32/Preloader_2.gif Binary files differnew file mode 100644 index 0000000..f23998f --- /dev/null +++ b/client/images/spin/32x32/Preloader_2.gif diff --git a/client/images/spin/32x32/Preloader_3.gif b/client/images/spin/32x32/Preloader_3.gif Binary files differnew file mode 100644 index 0000000..bb7c60d --- /dev/null +++ b/client/images/spin/32x32/Preloader_3.gif diff --git a/client/images/spin/32x32/Preloader_4.gif b/client/images/spin/32x32/Preloader_4.gif Binary files differnew file mode 100644 index 0000000..117c756 --- /dev/null +++ b/client/images/spin/32x32/Preloader_4.gif diff --git a/client/images/spin/32x32/Preloader_5.gif b/client/images/spin/32x32/Preloader_5.gif Binary files differnew file mode 100644 index 0000000..7169708 --- /dev/null +++ b/client/images/spin/32x32/Preloader_5.gif diff --git a/client/images/spin/32x32/Preloader_6.gif b/client/images/spin/32x32/Preloader_6.gif Binary files differnew file mode 100644 index 0000000..9087ded --- /dev/null +++ b/client/images/spin/32x32/Preloader_6.gif diff --git a/client/images/spin/32x32/Preloader_7.gif b/client/images/spin/32x32/Preloader_7.gif Binary files differnew file mode 100644 index 0000000..0b1e633 --- /dev/null +++ b/client/images/spin/32x32/Preloader_7.gif diff --git a/client/images/spin/32x32/Preloader_8.gif b/client/images/spin/32x32/Preloader_8.gif Binary files differnew file mode 100644 index 0000000..6816be3 --- /dev/null +++ b/client/images/spin/32x32/Preloader_8.gif diff --git a/client/images/spin/32x32/Preloader_9.gif b/client/images/spin/32x32/Preloader_9.gif Binary files differnew file mode 100644 index 0000000..e38dd5a --- /dev/null +++ b/client/images/spin/32x32/Preloader_9.gif diff --git a/client/images/spin/64x64/Preloader_1.gif b/client/images/spin/64x64/Preloader_1.gif Binary files differnew file mode 100644 index 0000000..2004c5f --- /dev/null +++ b/client/images/spin/64x64/Preloader_1.gif diff --git a/client/images/spin/64x64/Preloader_10.gif b/client/images/spin/64x64/Preloader_10.gif Binary files differnew file mode 100644 index 0000000..944ec82 --- /dev/null +++ b/client/images/spin/64x64/Preloader_10.gif diff --git a/client/images/spin/64x64/Preloader_2.gif b/client/images/spin/64x64/Preloader_2.gif Binary files differnew file mode 100644 index 0000000..9821827 --- /dev/null +++ b/client/images/spin/64x64/Preloader_2.gif diff --git a/client/images/spin/64x64/Preloader_3.gif b/client/images/spin/64x64/Preloader_3.gif Binary files differnew file mode 100644 index 0000000..52b81ba --- /dev/null +++ b/client/images/spin/64x64/Preloader_3.gif diff --git a/client/images/spin/64x64/Preloader_4.gif b/client/images/spin/64x64/Preloader_4.gif Binary files differnew file mode 100644 index 0000000..3408b5d --- /dev/null +++ b/client/images/spin/64x64/Preloader_4.gif diff --git a/client/images/spin/64x64/Preloader_5.gif b/client/images/spin/64x64/Preloader_5.gif Binary files differnew file mode 100644 index 0000000..6f0585d --- /dev/null +++ b/client/images/spin/64x64/Preloader_5.gif diff --git a/client/images/spin/64x64/Preloader_6.gif b/client/images/spin/64x64/Preloader_6.gif Binary files differnew file mode 100644 index 0000000..c577f24 --- /dev/null +++ b/client/images/spin/64x64/Preloader_6.gif diff --git a/client/images/spin/64x64/Preloader_7.gif b/client/images/spin/64x64/Preloader_7.gif Binary files differnew file mode 100644 index 0000000..5f6dd5e --- /dev/null +++ b/client/images/spin/64x64/Preloader_7.gif diff --git a/client/images/spin/64x64/Preloader_8.gif b/client/images/spin/64x64/Preloader_8.gif Binary files differnew file mode 100644 index 0000000..b57e4d8 --- /dev/null +++ b/client/images/spin/64x64/Preloader_8.gif diff --git a/client/images/spin/64x64/Preloader_9.gif b/client/images/spin/64x64/Preloader_9.gif Binary files differnew file mode 100644 index 0000000..fc3ddb7 --- /dev/null +++ b/client/images/spin/64x64/Preloader_9.gif diff --git a/client/index.html b/client/index.html index ba183df..8d81ac3 100644 --- a/client/index.html +++ b/client/index.html @@ -26,6 +26,9 @@ <div class="col-lg-12"> <!-- Login Overlay --> <div ng-include="'./partials/login.html'"></div> + <!-- Machine Details Overlay --> + <div ng-include="'./partials/home/machineDetails.html'"></div> + <!-- Nav --> <div ng-include="'./partials/nav.html'"></div> </div> @@ -81,7 +84,9 @@ <script src="./js/controllers/login.js"></script> <script src="./js/controllers/status.js"></script> <script src="./js/controllers/home/main.js"></script> + <script src="./js/controllers/home/machineDetails.js"></script> <script src="./js/controllers/network/main.js"></script> + diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js new file mode 100644 index 0000000..f84a073 --- /dev/null +++ b/client/js/controllers/home/machineDetails.js @@ -0,0 +1,39 @@ +/** + * The home controller + * + * @param {$scope} $scope The $scope service from angular + */ +mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$timeout', function ($scope, Compute, $rootScope, $timeout) +{ + + $scope.machine={}; + $("#waitingForToggleMachine").hide(); + + $scope.$on('showMachineDetailsEvent', function(eventName ,machine){ + $scope.machine=machine; + $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); + }); + + + $scope.toggleMachineState=function(){ + $("#waitingForToggleMachine").show(); + + // Fake timeout + $timeout(function(){ + $("#waitingForToggleMachine").hide(); + }, 3000); + $timeout(function(){ + $scope.machine.online=!$scope.machine.online; + + }, 3000); + + + }; + + $scope.applyModifications=function(){ + //Todo + } + + + +}]); diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index d25bfad..4e3bcda 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -3,15 +3,22 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) +mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($scope, Compute, $rootScope) { - var updatePage=function(){ // TODO Update graph etc... } // Retrieve all Data Compute.pullData(updatePage); - + + Compute.getMachines(function(adzda){}); + + $scope.raiseShowMachineDetailsEvent=function(){ + var machine={name: "Machine 1", online:true}; + $rootScope.$broadcast("showMachineDetailsEvent", machine); + } + + }]); diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 829fc1d..1a89563 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -13,14 +13,19 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s if(!Identity.isAlreadyLogin()){ $('#loginModal').modal({backdrop: 'static', keyboard: false}); } + + // Manager logout event $scope.$on('logoutEvent', function(){ + Identity.logout(); $('#loginModal').modal({backdrop: 'static', keyboard: false}); }); - + + // Hide loading button and message alert $('#loadingLoginButton').hide(); $('#failedToLoginAlert').hide(); - + + // Defined function for login $scope.loginAction=function(){ // Begin login state for template diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index e01df34..940d794 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -10,13 +10,11 @@ mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($ { // Give profile to model - $scope.profile=Identity.profile; + $scope.profile=Identity.getProfile(); // Function to logout - $scope.logout=function(){ - Identity.logout(); + $scope.raiseLogoutEvent=function(){ $rootScope.$broadcast('logoutEvent'); - }; }]); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index c5c8da9..8148948 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -2,11 +2,12 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ - + // Create data var data={}; data.machines={}; + // Parser var parseGetMachinesAnswer=function(response, failedToSendRequest){ @@ -16,8 +17,24 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Get Machine var getMachines=function(callback){ + var params={ + "token" : Identity.getToken(), + "task" : "compute", + "action":"getServer", + "serverId":"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd" + }; + var result=$http.post('../server/index.php', - $.param({"token" : Identity.profile.token, "task" : "Compute"})); + $.param(params)); + + // Wait and handle the response + result.then(function (response){ + console.log(response.data.Servers); + callback(parseGetMachinesAnswer(response, false)); + },function(response){ + alert(response.status); + callback(parseGetMachinesAnswer(response, true)); + }); }; @@ -31,8 +48,8 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Return services objects return { - getMachines: getMachines - pullData: pullData + getMachines: getMachines, + pullData: pullData, data:data }; diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 8ee664c..b1d2a48 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -7,37 +7,47 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ var profile={}; profile.username=null; profile.projectname=null; - profile.token=null; - - - /** - * Save profile in cookies - */ - var saveCookieForSession=function(){ - $cookies.putObject('profile', 5); - }; - + var token=null; + /* * @returns {boolean} Return true if a cookie is found (and load it in profile) false else */ var isAlreadyLogin=function(){ + + // Load cookies var profileInCookie=$cookies.getObject('profile'); - console.log(profileInCookie); + var tokenPart_0InCookie=$cookies.getObject('token.part_0'); + var tokenPart_1InCookie=$cookies.getObject('token.part_1'); + - if(typeof profileInCookie !== 'undefined'){ + // Check if cookie is defined + if(typeof profileInCookie !== 'undefined' + && typeof tokenPart_0InCookie !== 'undefined' + && typeof tokenPart_1InCookie !== 'undefined' + ){ + + // If yes, put it into variables angular.extend(profile, profileInCookie); + token=tokenPart_0InCookie+tokenPart_1InCookie; + + // Return I'm Login return true; } + // Return I'm not Login return false; } + + /* * Destroy profile cookies */ var logout=function(){ $cookies.remove('profile'); + $cookies.remove('token.part_0'); + $cookies.remove('token.part_1'); } @@ -49,15 +59,28 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ */ var parseLoginAnswer=function(response, failedToSendRequest){ - + // Defined return object var requestParserResult={}; requestParserResult.status=1; requestParserResult.failReason=null; if (typeof response.data.token !== 'undefined') { + // Set status code requestParserResult.status=0; - profile.token=response.data.token; - saveCookieForSession(); + + // Find the middle of the token to split it + var middle=parseInt(response.data.token.length/2); + + // Create expire date (cookie expire in 55 mins) + var expireDate=new Date(); + expireDate.setMinutes(expireDate.getMinutes()+55); + + // Save profile + $cookies.putObject('profile', profile, {'expires': expireDate}); + // Save first part of token + $cookies.putObject('token.part_0', response.data.token.substring(0, middle), {'expires': expireDate}); + // Save second part of token + $cookies.putObject('token.part_1', response.data.token.substring(middle, response.data.token.length), {'expires': expireDate}); } else if(failedToSendRequest){ requestParserResult.failReason="Failed to send request"; @@ -69,7 +92,6 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ return requestParserResult; }; - /** * Function to connect to OpenStack @@ -87,24 +109,39 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ profile.projectname=projectname; var result=$http.post('../server/index.php', - $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); + $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); // Wait and handle the response result.then(function (response){ - callback(parseLoginAnswer(response), false); + callback(parseLoginAnswer(response, false)); },function(response){ - callback(parseLoginAnswer(response), true) + callback(parseLoginAnswer(response, true)); }); }; + /* + * Get the profile + */ + var getProfile=function(){ + return profile; + } + + /* + * Get the token + */ + var getToken=function(){ + return token; + } + // Return services objects return { login: login, - profile: profile, + getProfile: getProfile, isAlreadyLogin: isAlreadyLogin, - logout:logout + logout:logout, + getToken:getToken }; diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html new file mode 100644 index 0000000..606edcf --- /dev/null +++ b/client/partials/home/machineDetails.html @@ -0,0 +1,84 @@ +<div class="modal" id="machineDetailsModal" ng-controller="machineDetailsCtrl" > + <div class="modal-dialog"> + <div class="modal-content"></div> + </div> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>--> + <h4 class="modal-title">Machine</h4> + + </div> + <div class="modal-body"> + + <form class="form-horizontal" role="form"> + <div class="form-group"> + <label class="control-label col-sm-2" for="email">Name</label> + <div class="col-sm-10"> + <p class="form-control-static">{{ machine.name }}</p> + </div> + </div> + <div class="form-group"> + <label class="control-label col-sm-2" for="pwd">State</label> + <div class="col-sm-10"> + <span ng-if="machine.online">Online</span> + <span ng-if="!machine.online">Offline</span> + + <button class="btn btn-danger" ng-if="machine.online" ng-click="toggleMachineState()">Turn Off</button> + <button class="btn btn-success" ng-if="!machine.online" ng-click="toggleMachineState()">Turn On</button> + <img src="images/spin/32x32/Preloader_1.gif" id="waitingForToggleMachine"></span> + + + </div> + </div> + <fieldset class="form-group"> + <label class="control-label col-sm-2">RAM</label> + <select class="col-sm-20" id="ramSelected"> + <option>128 MB</option> + <option>512 MB</option> + <option>1024 MB</option> + <option>2048 MB</option> + <option>4096 MB</option> + </select> + </fieldset> + + <fieldset class="form-group"> + <label class="control-label col-sm-2">Disk</label> + <select class="col-sm-20" id="ramSelected"> + <option>1 Go</option> + <option>2 Go</option> + <option>5 Go</option> + <option>10 Go</option> + <option>25 Go</option> + <option>50 Go</option> + <option>100 Go</option> + <option>150 Go</option> + <option>200 Go</option> + </select> + </fieldset> + + <fieldset class="form-group"> + <label class="control-label col-sm-2">Image</label> + <select class="col-sm-20" id="ramSelected"> + <option>Cirros</option> + <option>Debian</option> + <option>Tiny Core</option> + <option>Centos</option> + </select> + </fieldset> + + + + + + </form> + + + </div> + <div class="modal-footer"> + <a href="#" data-dismiss="modal" class="btn btn-primary">Apply</a> + <a href="#" data-dismiss="modal" class="btn btn-default">Cancel</a> + </div> + </div> + </div> +</div> diff --git a/client/partials/home/main.html b/client/partials/home/main.html index 7a5045a..37638d3 100644 --- a/client/partials/home/main.html +++ b/client/partials/home/main.html @@ -1,8 +1,11 @@ - <div class="panel panel-default"> + <div class="panel panel-default" ng-controller="homeCtrl"> <div class="panel-heading"> Home </div> <div class="panel-body"> Main Content + <button ng-click="raiseShowMachineDetailsEvent()" > Show Machine details</button> + <div id="test"> + </div> </div> -</div>
\ No newline at end of file +</div> diff --git a/client/partials/nav.html b/client/partials/nav.html index 3c72844..b3ef76a 100644 --- a/client/partials/nav.html +++ b/client/partials/nav.html @@ -32,7 +32,7 @@ <li><a href="#">Informations</a></li> <li><a href="#">Settings</a></li> <li role="separator" class="divider"></li> - <li><a href="#" ng-click="logout()">Logout</a></li> + <li><a href="#" ng-click="raiseLogoutEvent()">Logout</a></li> </ul> </li> </ul> |
