diff options
author | seshukm <seshu.kumar.m@huawei.com> | 2017-03-01 15:25:44 +0530 |
---|---|---|
committer | seshukm <seshu.kumar.m@huawei.com> | 2017-03-01 15:27:39 +0530 |
commit | f580c044220ba7d2f190666e029d8380b268ff63 (patch) | |
tree | 198596efc3664b51ab57454e12e642a20d921fc7 /provincemgr/src/main/webapp | |
parent | d9865520f9303c415836d4247947ddc7731e0c59 (diff) |
Code for the province Mgmt
IssueId : GSO-241
Change-Id: I5f19ccc729bb358e5b1bc5edb4d9a82807848b99
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
Diffstat (limited to 'provincemgr/src/main/webapp')
4 files changed, 552 insertions, 0 deletions
diff --git a/provincemgr/src/main/webapp/provincemgr/index.html b/provincemgr/src/main/webapp/provincemgr/index.html new file mode 100644 index 00000000..8e4d9b03 --- /dev/null +++ b/provincemgr/src/main/webapp/provincemgr/index.html @@ -0,0 +1,52 @@ +<!-- + + Copyright 2017, Huawei Technologies Co., Ltd. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> + +<!DOCTYPE html> +<html> +<head lang="en"> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Province Management</title> + <link href="thirdparty/css/bootstrap.min.css" rel="stylesheet"/> + <!--Pulling Awesome Font --> + <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> + + <link href="thirdparty/css/zTreeStyle.css" rel="stylesheet"/> + <link href="thirdparty/css/magic-check.css" rel="stylesheet"/> + <link rel="stylesheet"; href="https://unpkg.com/ng-table@2.0.2/bundles/ng-table.min.css"> + <link href="framework/css/open-ostyle.css" rel="stylesheet"/> + + <script src="thirdparty/js/angular.min.js"></script> + <script src="thirdparty/js/angular-ui-router.min.js"></script> + <script src="https://unpkg.com/ng-table@2.0.2/bundles/ng-table.min.js"></script> + <script src="thirdparty/js/jquery_1.12.4.min.js"></script> + <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> + <script type="text/javascript" src="thirdparty/js/bootstrap.min.js"></script> + <script src="js/app.js"></script> + <script src="js/rest.js"></script> + <script src="framework/js/DataService.js"></script> + <script src="thirdparty/js/mustache.js"></script> + <script src="thirdparty/js/jquery.ztree.core-3.5.js"></script> + +</head> + +<body ng-app="ProvinceManagementApp" onload="loadTemplate()"> +<ui-view></ui-view> +</body> +</html>
\ No newline at end of file diff --git a/provincemgr/src/main/webapp/provincemgr/js/app.js b/provincemgr/src/main/webapp/provincemgr/js/app.js new file mode 100644 index 00000000..1af3d538 --- /dev/null +++ b/provincemgr/src/main/webapp/provincemgr/js/app.js @@ -0,0 +1,294 @@ +/*
+
+ Copyright 2017, Huawei Technologies Co., Ltd.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+var app = angular.module("ProvinceManagementApp", ["ui.router", "ngTable"])
+
+ .config(function($stateProvider, $urlRouterProvider, $urlMatcherFactoryProvider){
+
+ $urlMatcherFactoryProvider.caseInsensitive(true);
+ $urlRouterProvider.otherwise('/provinceMgmt');
+ $stateProvider
+ .state("" +
+ "provinceMgmt", {
+ url: "/provinceMgmt",
+ templateUrl : "templates/management.html",
+ controller : "managementCtrl"
+ })
+ })
+
+
+ .controller("managementCtrl", function($scope, $log, provinceDataService, $state, $compile, NgTableParams){
+ $scope.message = "Management";
+
+ $scope.init = function() {
+ provinceDataService.getAllProvinceData()
+ .then(function(data){
+ $scope.provinceData = data.provinceData;
+ console.log("Data: ");
+ loadButtons();
+ $log.info(data.provinceData);
+ }, function(reason){
+ $scope.message = "Error is :" + JSON.stringify(reason);
+ });
+
+ /*DataService.post("http://localhost:4000/api/getAllJSONData", {"wdgtType":$scope.provinceTip})
+ .then(function(data){
+ $scope.provinceTipData = data.data.provinceTip;
+ });*/
+ }
+
+ function loadButtons() {
+
+ console.log("modelTemplate issss"+modelTemplate);
+ var def_button_tpl = $(modelTemplate).filter('#defaultButtons').html();
+ var def_iconbutton_tpl = $(modelTemplate).filter('#defaultIconButtons').html();
+ var dialog = $(modelTemplate).filter('#dialog').html();
+
+ var add_data = {"title":"Create", "type":"btn btn-default", "gType": "plus-icon", "iconPosition":"left", "clickAction":"showAddModal()"};
+
+ var delete_data = {"title":"Delete Selected", "type":"btn btn-default", "gType": "delete-icon", "iconPosition":"left", "clickAction":"deleteData()"};
+ var addhtml = Mustache.to_html(def_iconbutton_tpl, add_data);
+ var deletehtml = Mustache.to_html(def_iconbutton_tpl, delete_data);
+ $('#provinceAction').html($compile(addhtml)($scope));
+
+
+
+ $('#provinceAction').append($compile(deletehtml)($scope));
+
+ $('#managementDialog').html($compile(dialog)($scope));
+
+ $scope.checkboxes = { 'checked': false, items: {} };
+
+ $scope.tableParams = new NgTableParams({count: 5, sorting: {province_name: 'asc'} //{page: 1,count: 10,filter: {name: 'M'},sorting: {name: 'desc'}
+ }, { counts:[5, 10, 20, 50], dataset: $scope.provinceData});
+
+ $scope.$watch('checkboxes.checked', function(value) {
+ angular.forEach($scope.provinceData, function(item) {
+ if (angular.isDefined(item.id)) {
+ $scope.checkboxes.items[item.id] = value;
+ }
+ });
+ });
+
+ var text = $(modelTemplate).filter('#textfield').html();
+ var ipv4 = $(modelTemplate).filter('#ipv4').html();
+ var number = $(modelTemplate).filter('#numeric').html();
+
+ $('#managementDialog .modalHeader').html('<h5 class="modal-title titlestyle">Modal Header</h5>');
+ $('#managementDialog .modalBodyContent').html('<div class="form-group row"> <label class="col-xs-4 col-form-label labelstyle">Name</label> <div class="col-xs-8 provinceName" > </div> </div>');
+ $('#managementDialog .modalBodyContent').append('<div class="form-group row"> <label class="col-xs-4 col-form-label labelstyle">IP Address</label> <div class="col-xs-8 ipAddress" > </div> </div>');
+ $('#managementDialog .modalBodyContent').append(' <div class="form-group row"> <label for="port" class="col-xs-4 col-form-label labelstyle">Port</label> <div class="col-xs-8 port" > </div> </div>');
+ $('#managementDialog .modalBodyContent').append(' <div class="form-group row"> <label for="desc" class="col-xs-4 col-form-label labelstyle">Description</label> <div class="col-xs-8 desc" > </div> </div>');
+
+
+
+ var dataText = {"ErrMsg" : {"errmsg" : "Please input Name.", "modalVar":"province.province_name", "placeholder":"Name", "errtag":"ptextboxErr", "errfunc":"validatetextbox", "required":true}};
+ $('#managementDialog .provinceName').html($compile(Mustache.to_html(text, dataText.ErrMsg))($scope));
+
+ var dataIP = {"ErrMsg" : {"errmsg" : "Please input IP Address.", "modalVar":"province.ip", "placeholder":"IP Address"}};
+ $('#managementDialog .ipAddress').html($compile(Mustache.to_html(ipv4, dataIP.ErrMsg))($scope));
+
+ var dataNum = {"ErrMsg" : {"errmsg" : "Please input port.", "modalVar":"province.port", "placeholder":"Port"}};
+ $('#managementDialog .port').html($compile(Mustache.to_html(number, dataNum.ErrMsg))($scope));
+
+ var dataText = {"ErrMsg" : {"errmsg" : "Please input description.", "modalVar":"province.desc", "placeholder":"Description"}};
+ $('#managementDialog .desc').html($compile(Mustache.to_html(text, dataText.ErrMsg))($scope));
+
+ var modelSubmit_data = {"title":"OK", "clickAction":"saveData(province.id)"};
+ var modelSubmit_html = Mustache.to_html(def_button_tpl, modelSubmit_data);
+ $('#managementDialog #footerBtns').html($compile(modelSubmit_html)($scope));
+
+ var modelBtn_data = {"title":"Cancel", "clickAction":"closeModal()"};
+ var modelBtn_html = Mustache.to_html(def_button_tpl, modelBtn_data);
+ $('#managementDialog #footerBtns').append($compile(modelBtn_html)($scope));
+ }
+
+ $scope.validatetextbox = function (value){
+ if($scope.province.province_name) {
+ $scope.ptextboxErr = false;
+ }
+ else
+ $scope.ptextboxErr = true;
+ }
+
+ $scope.checkAll = function() {
+ console.log("Checked ..");
+ angular.forEach($scope.provinceData, function(data) {
+ $scope.checkboxes.items[user.id]
+ });
+ };
+
+ $scope.closeModal = function() {
+ console.log("Closing Modal...");
+ $('#managementDialog').modal('hide');
+ }
+
+ $scope.showAddModal = function() {
+ console.log("Showing Modal to Add data");
+ $scope.province = {};
+ $scope.textboxErr = false;
+ $scope.ipv4Err = false;
+ $scope.numericErr = false;
+ //$("#myModal").modal();
+ $("#uniModal").modal({}).draggable();
+ }
+ $scope.saveData = function(id) {
+ if(id) {
+ //edit data
+ console.log("Editing data.." + JSON.stringify($scope.province));
+ provinceDataService.editProvinceData($scope.province)
+ .then(function (data) {
+ $scope.message = "Success :-)";
+ $state.reload();
+ },
+ function (reason) {
+ $scope.message = reason.status + " " + reason.statusText;
+ });
+ }
+ else {
+ console.log("Adding data.." + JSON.stringify($scope.province));
+ provinceDataService.addProvinceData($scope.province)
+ .then(function (data) {
+ $scope.message = "Success :-)";
+ $state.reload();
+ },
+ function (reason) {
+ $scope.message = reason.status + " " + reason.statusText;
+ });
+ }
+ $('#uniModal').modal('hide');
+ }
+
+ /*$scope.deleteIndividualData = function(id) {
+ var deleteArr = [];
+ //$log.info($scope.checkboxes);
+ deleteArr.push(id);
+
+ console.log("To be deleted : "+deleteArr);
+ //$log.info(deleteArr);
+
+
+ provinceDataService.post("http://localhost:4000/api/deleteProvinceData", {'idList':deleteArr})
+ .then(function(data){
+ $scope.message = "Successfully deleted :-)";
+ $state.reload();
+ },
+ function(reason){
+ //$log.info(reason);
+ $scope.message = reason.status + " " + reason.statusText;
+ });
+ }*/
+ $scope.deleteData = function(id) {
+ var confirmation=false;
+ var dialog_tpl = $(modelTemplate).filter('#personDialog').html();
+ var error = {"err_data" : { "title": "Error",
+ "showClose": "true",
+ "closeBtnTxt": "Cancel",
+ "icon": "glyphicon glyphicon-exclamation-sign",
+ "iconColor": "icon_error",
+ "msg": "Do you really wanted to Delete?.",
+ "buttons": [
+ {
+ "text": "OK", "action": "deleteConfirmation("+id+")"
+ }]
+ }};
+ var html = Mustache.to_html(dialog_tpl, error.err_data);
+ $($compile(html)($scope)).modal({backdrop: "static"});
+ }
+
+ $scope.deleteConfirmation = function(id) {
+ console.log("data in province data is :");
+ $log.info($scope.provinceData);
+ var deleteArr = [];
+ if (typeof id !== "undefined"){
+
+ deleteArr.push(id);
+ }else{
+ angular.forEach($scope.checkboxes.items, function (value, key) {
+ if (value) {
+ console.log("deleting name is :" + key);
+ deleteArr.push(key);
+ }
+ });
+
+ }
+
+ console.log("To be deleted : " + deleteArr);
+
+ for(var i = 0; i < deleteArr.length; i++) {
+ console.log("To be deleted : "+deleteArr[i]);
+ provinceDataService.deleteProvinceData(deleteArr[i])
+ .then(function(data){
+ $scope.message = "Successfully deleted :-)";
+ $state.reload();
+ },
+ function(reason){
+ $scope.message = reason.status + " " + reason.statusText;
+ });
+ }
+
+ /* provinceDataService.post("http://localhost:4000/api/deleteProvinceData", {'idList':deleteArr})
+ .then(function (data) {
+ $scope.message = "Successfully deleted :-)";
+ $state.reload();
+ },
+ function (reason) {
+ $scope.message = reason.status + " " + reason.statusText;
+ });*/
+ }
+
+ $scope.editData = function(id) {
+ $scope.textboxErr = false;
+ $scope.ipv4Err = false;
+ $scope.numericErr = false;
+ console.log("To be edited : " + id);
+ var dataFound = false;
+ angular.forEach($scope.provinceData, function(data) {
+ if(!dataFound) {
+ if (data.id == id) {
+ console.log("Found : " + data.id);
+ $scope.province = data;
+
+ $("#uniModal").modal();
+ dataFound = true;
+ }
+ }
+ });
+ }
+
+ })
+
+var modelTemplate = "";
+function loadTemplate() {
+ $.get('framework/template.html', function (template) {
+ modelTemplate += template;
+ });
+ $.get('framework/templateContainer.html', function (template) {
+ modelTemplate += template;
+ });
+ $.get('framework/templateWidget.html', function (template) {
+ //console.log("Template is : "+template);
+ modelTemplate += template;
+ });
+ $.get('framework/templateNotification.html', function (template) {
+ modelTemplate += template;
+ });
+ $.get('framework/templateFunctional.html', function (template) {
+ modelTemplate += template;
+ });
+}
\ No newline at end of file diff --git a/provincemgr/src/main/webapp/provincemgr/js/rest.js b/provincemgr/src/main/webapp/provincemgr/js/rest.js new file mode 100644 index 00000000..1192c848 --- /dev/null +++ b/provincemgr/src/main/webapp/provincemgr/js/rest.js @@ -0,0 +1,94 @@ +/*
+
+ Copyright 2017, Huawei Technologies Co., Ltd.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+
+app.factory("provinceDataService", function($http,DataService, $log){
+ var uri = 'http://192.168.9.13:18008';
+ return {
+ getAllProvinceData : function() {
+ /*return $http({
+ url: 'http://localhost:4000/api/getAllProvinceData',
+ method: 'GET',
+ headers: {'Content-Type': 'application/json'}
+ }).then(function(response){
+ //$log.info(response);
+ return response.data;
+ });*/
+ return DataService.get(uri+'/api/getAllProvinceData')
+ .then(function(response){
+ $log.info("in get data service data is :"+response);
+ console.log(response);
+ return response;
+ });
+ },
+ addProvinceData : function(provinceDetail) {
+ /*return $http({
+ url: 'http://localhost:4000/api/addProvinceData',
+ method: 'POST',
+ data: provinceDetail,
+ headers: {'Content-Type': 'application/json '}
+ }).then(function(response){
+ console.log("Response : ");
+ $log.info(response.data);
+ return response.data;
+ });*/
+ return DataService.post(uri+'/api/addProvinceData', provinceDetail)
+ .then(function(response){
+ console.log("Successfully added.. Data returned in DataService is");
+ console.log(response);
+ return response;
+ });
+ },
+ deleteProvinceData : function(id) {
+ /*return $http({
+ url: 'http://localhost:4000/api/deleteProvinceData',
+ method: 'POST',
+ data: {'idList':idList},
+ headers: {'Content-Type': 'application/json'}
+ }).then(function(response){
+ console.log("Successfully Deleted..");
+ $log.info(response);
+ return response.data;
+ });*/
+ return DataService.delete(uri+'/api/deleteProvinceData'+"/"+id)
+ .then(function(response){
+ $log.info("in delete data service data is :"+response);
+ console.log(response);
+ return response;
+ });
+ },
+ editProvinceData : function(provinceDetail) {
+ /*return $http({
+ url: 'http://localhost:4000/api/editProvinceData',
+ method: 'POST',
+ data: provinceDetail,
+ headers: {'Content-Type': 'application/json'}
+ }).then(function(response){
+ console.log("Successfully Edited...");
+ $log.info(response);
+ return response.data;
+ });*/
+ return DataService.put(uri+'/api/editProvinceData', provinceDetail)
+ .then(function(response){
+ console.log("Successfully edited.. Data returned in DataService is");
+ console.log(response);
+ return response;
+ });
+ }
+ }
+});
diff --git a/provincemgr/src/main/webapp/provincemgr/templates/management.html b/provincemgr/src/main/webapp/provincemgr/templates/management.html new file mode 100644 index 00000000..819c1534 --- /dev/null +++ b/provincemgr/src/main/webapp/provincemgr/templates/management.html @@ -0,0 +1,112 @@ +<!--
+
+ Copyright 2017, Huawei Technologies Co., Ltd.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<div class="homecontent center">
+<div class="col-md-12 col-sm-12 col-lg-12">
+ <h4>{{message}}</h4>
+ <br><br>
+ <div id="provinceAction" ng-init="init()">
+
+ </div>
+ <br>
+ <br>
+
+ <table ng-table="tableParams" class="table table-bordered table-striped customtable" show-filter="true">
+ <tr ng-repeat="provinceData in $data">
+ <td header="'ng-table/headers/checkbox.html'">
+ <input type="checkbox" ng-model="checkboxes.items[provinceData.id]" />
+ </td>
+ <td title="'Name'" filter="{ province_name: 'text'}" sortable="'province_name'">
+ {{provinceData.province_name}}
+ </td>
+ <td title="'IP Address'" filter="{ ip: 'text'}" sortable="'ip'">
+ {{provinceData.ip}}
+ </td>
+ <td title="'Port'" filter="{ port: 'number'}" sortable="'port'">
+ {{provinceData.port}}
+ </td>
+ <td title="'Description'" filter="{ port: 'text'}" sortable="'desc'">
+ {{provinceData.desc}}
+ </td>
+ <td title="'Action'">
+ <span ng-click="editData(provinceData.id)" style="cursor: pointer;margin: 0 5px"> <img src="framework/images/edit.png" height="15" align="left"/></span>
+ <span ng-click="deleteData(provinceData.id)" style="cursor: pointer;margin: 0 5px"><img src="framework/images/delete.png" height="15" align="middle"/></span>
+ </td>
+ </tr>
+ </table>
+
+
+ <script type="text/ng-template" id="ng-table/headers/checkbox.html">
+ <input type="checkbox" ng-model="checkboxes.checked" name="filter-checkbox" value="" />
+ </script>
+
+ <!--<div id="myTable"></div>-->
+
+
+ <!-- Modal
+ <div id="myModal" class="modal fade" role="dialog">
+ <div class="modal-dialog">
+
+ <!– Modal content–>
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal">×</button>
+ <h5 class="modal-title titlestyle">Modal Header</h5>
+ </div>
+ <form name="provinceForm" method="post"><!– ng-submit="saveData(province.id)"–>
+ <div class="modal-body">
+
+ <div class="form-group row">
+ <label class="col-xs-4 col-form-label labelstyle">Name</label>
+ <div class="col-xs-8 provinceName" >
+ <!–<input class="form-control" ng-model="province.province_name" type="text" value="" placeholder="Province Name" id="pname" required><br>–>
+ </div>
+ </div>
+ <div class="form-group row">
+ <label class="col-xs-4 col-form-label labelstyle">IP Address</label>
+ <div class="col-xs-8 ipAddress" >
+ <!–<input class="form-control" ng-model="province.ip" type="ipv4" pattern="((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$" value="" placeholder="IP Address" id="ipaddress" required><br>–>
+ </div>
+ </div>
+ <div class="form-group row">
+ <label for="port" class="col-xs-4 col-form-label labelstyle">Port</label>
+ <div class="col-xs-8 port" >
+ <!–<input class="form-control" ng-model="province.port" type="number" value="" placeholder="Port" id="port" required>–>
+
+ </div>
+ </div>
+
+ <!–<input type="submit" class="btn btn-default" value="validate"/>–>
+
+ </div>
+
+ <div id="footerBtns" class="modal-footer">
+ <!–<button type="button" class="btn btn-default" ng-click="addData(province._id)" data-dismiss="modal" ng-disabled="provinceForm.$invalid">OK</button>–>
+ <!–<input type="submit" class="btn btn-default" value="Submit"/>–>
+ <!–<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>–>
+ </div>
+ </form>
+ </div>
+
+
+ </div>
+ </div>-->
+ <!--<div id="myModal" class="modal-header">-->
+ <div id="managementDialog"></div>
+ <!--</div>-->
+</div>
+</div>
\ No newline at end of file |