3 Copyright 2016-2017, Huawei Technologies Co., Ltd.
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
20 var app = angular.module("POCApp", ["ui.router", "ngTable"])
22 /*.run(function($rootScope, $location, $state, LoginService) {
23 $rootScope.$on("$stateChangeStart", function(event, toState, toParams, fromState, fromParams){
24 if (toState.authenticate && !LoginService.isAuthenticated()){
25 // User isn’t authenticated
26 $state.transitionTo("login");
27 event.preventDefault();
31 .config(function($stateProvider, $urlRouterProvider, $urlMatcherFactoryProvider){
32 //$routeProvider.caseInsensitiveMatch = true;
33 $urlMatcherFactoryProvider.caseInsensitive(true);
34 $urlRouterProvider.otherwise('/login');
35 //$locationProvider.html5Mode(true).hashPrefix('!');
39 templateUrl : 'templates/login.html',
40 controller : 'LoginController',
45 templateUrl : 'templates/register.html',
46 controller : 'registerController',
51 templateUrl : "templates/home.html",
52 controller : "homeCtrl",
57 templateUrl : "templates/tree.html",
58 controller : "treeCtrl",
61 .state("home.accordion", {
63 templateUrl : "templates/accordion.html",
64 controller : "accordionCtrl",
69 templateUrl : "templates/tabs.html",
70 controller : "tabsCtrl",
73 .state("home.vtabs", {
75 templateUrl : "templates/verticalTab.html",
76 controller : "vTabCtrl",
79 .state("home.table", {
81 templateUrl : "templates/table.html",
82 controller : "tableCtrl",
85 .state("home.buttons", {
87 templateUrl : "templates/buttons.html",
88 controller : "buttonsCtrl",
91 /*state for radio button and checkboxes-------------------------------------------------*/
92 .state("home.radiobuttons", {
94 templateUrl : "templates/radioButtons.html",
95 controller : "radioCtrl",
98 .state("home.checkboxes", {
100 templateUrl : "templates/checkBoxes.html",
101 controller : "checkBoxCtrl",
104 .state("home.dropdown", {
106 templateUrl: "templates/dropdown.html",
107 controller: "dropdownCtrl",
111 .state("home.list", {
113 /*template:"<h3>Under Progress</h3>",*/
114 templateUrl : "templates/list.html",
115 controller : "listCtrl",
119 .state("home.provinceMgmt", {
121 templateUrl : "templates/management.html",
122 controller : "managementCtrl",
125 .state("home.tooltip", {
127 templateUrl : "templates/textarea.html",
128 controller : "toolCtrl",
132 .state("home.notification", {
133 url: "/notification",
134 templateUrl : "templates/notification.html",
135 controller : "notificationCtrl",
138 .state("home.functional", {
140 templateUrl : "templates/functional.html",
141 controller : "functionalCtrl",
147 .controller('LoginController', function($scope, $rootScope, $stateParams, $state, LoginService) {
148 $rootScope.title = "AngularJS Login Sample";
150 $scope.formSubmit = function() {
151 LoginService.login($scope.user)
152 .then(function (data) {
155 $scope.user.username = '';
156 $scope.user.password = '';
157 $state.transitionTo('home.tree');
160 $scope.error = "Incorrect username/password !";
162 }, function (reason) {
163 $scope.error = "Incorrect username/password !";
168 .controller('registerController', function($scope, $state, LoginService){
169 $scope.formSubmit = function() {
170 if($scope.user.password === $scope.user.confpassword) {
171 LoginService.registerUser($scope.user)
172 .then(function (data) {
173 $state.transitionTo("login");
175 console.log("Failed to register");
179 console.log("Password not matched...");
180 var dialog_tpl = $(modelTemplate).filter('#personDialog').html();
181 var data = {'title':'Error',showClose:true, 'closeBtnTxt':'Ok', 'icon':'glyphicon glyphicon-exclamation-sign','iconColor':'icon_error','msg':'Password and Confirm password does not match.', buttons:[]};
182 var html = Mustache.to_html(dialog_tpl, data);
183 $(html).modal({backdrop: "static"}); //backdrop: "static" - for grayed out and no outside click work, backdrop: false - no grayed out*/
187 .controller("homeCtrl", function($scope, $state, DataService){
188 $scope.message = "Home Page";
190 /*$scope.geticonClass = function() {
191 if($( "#panel1" ).hasClass( "in" )){
192 return "openo_accordion_ui-icon-expand";
195 return "openo_accordion_ui-icon-expand.current";
203 /* $scope.accordionLoaded = function() {
204 if(modelTemplate != null) {
205 console.log("left menu loading..");
209 console.log("left menu not loading..");
213 function menuaccordion() {
214 var accordion_tpl = $(modelTemplate).filter('#menu_accordion').html();
216 $.getJSON('./data/homelinks.json', function (accordion) {
217 var html = Mustache.to_html(accordion_tpl, accordion.accordion_data);
218 $('#accordionmenuid').html(html);
224 /* Tree Controller */
225 .controller("treeCtrl", function($scope,DataService,$log){
226 $scope.message = "Tree Data";
228 /*$scope.treeLoaded = function() {
229 if(modelTemplate != null) {
230 console.log("Tree data loading..");
234 console.log("Tree data not loading..");
237 $scope.init = function() {
238 $scope.param="treeData";
239 $scope.shortNote="shortNote";
240 DataService.getAllData($scope.param)
241 .then(function(data){
242 $scope.treeData = data;
244 console.log("inside tree");
245 $log.info($scope.treeData);
247 DataService.getAllData($scope.shortNote)
248 .then(function(data1){
249 $scope.treeTip = data1.treeTip;
250 console.log("inside treeTip");
255 zNodes = $scope.treeData;
256 $.fn.zTree.init($("#tree1"), setting, zNodes);
261 /* Accordian Controller */
262 .controller("accordionCtrl", function($scope,DataService, $log){
264 $scope.message = "Accordion";
266 $scope.accordionLoaded = function() {
267 if(modelTemplate != null) {
268 console.log("accordion loading..");
273 console.log("accordion not loading..");
277 $scope.init = function() {
278 $scope.param="accordionData";
279 $scope.accordionTip="shortNote";
280 DataService.getAllData($scope.param)
281 .then(function(data){
282 $scope.accordion = data;
284 console.log("inside accordion");
287 DataService.getAllData($scope.accordionTip)
288 .then(function(data){
289 $scope.accordionTipData = data.accordionTip;
290 console.log("inside accordion");
295 function accordion() {
297 var accordion_tpl = $(modelTemplate).filter('#accordion').html();
298 console.log("in acc" );
299 var html = Mustache.to_html(accordion_tpl, $scope.accordion.accordion_data);
300 $('#accordion').html(html);
303 .controller("tabsCtrl", function($scope, $state, DataService, $log){
304 $scope.message = "Tabs";
305 $scope.tabLoaded = function() {
306 if(modelTemplate != null) {
307 console.log("Tab is loading..");
311 console.log("Not ready..");
315 $scope.init = function() {
316 $scope.param="tabData";
317 $scope.tabTip="shortNote";
318 DataService.getAllData($scope.param)
319 .then(function(data){
320 $scope.tabdata = data;
322 console.log("inside tabs");
325 DataService.getAllData($scope.tabTip)
326 .then(function(data){
327 $scope.tabTipData = data.tabTip;
332 function loadTabData() {
333 var tab_tpl = $(modelTemplate).filter('#tabs').html();
334 var html = Mustache.to_html(tab_tpl, $scope.tabdata.tabData);
335 $('#tabArea').html(html);
339 .controller("vTabCtrl", function($scope, $state, DataService){
340 $scope.message = "Vertical Tabs";
342 $scope.vtabLoaded = function() {
343 if(modelTemplate != null) {
344 console.log("Vertical Tab is loading..");
348 console.log("Not ready..");
352 $scope.init = function() {
353 $scope.param="vtabData";
354 $scope.vtabTip="shortNote";
355 DataService.getAllData($scope.param)
356 .then(function(vtabdata){
357 $scope.data = vtabdata;
359 console.log("inside vTab");
361 DataService.getAllData($scope.vtabTip)
362 .then(function(vtabdata){
363 $scope.vtabTipdata = vtabdata.vtabTip;
364 console.log("inside vTab");
368 function loadvTabData() {
370 var vtab_tpl = $(modelTemplate).filter('#vtabs').html();
371 var html = Mustache.to_html(vtab_tpl, $scope.data.vtabData);
372 $('#vtabArea').html(html);
375 .controller("tableCtrl", function($scope, $state, DataService){
376 $scope.message = "Tables";
378 $scope.tableLoaded = function() {
379 if(modelTemplate != null) {
380 console.log("Table is loading..");
384 console.log("Not ready..");
388 $scope.init = function() {
389 $scope.param="tableData";
390 $scope.tableTip="shortNote";
391 DataService.getAllData($scope.param)
392 .then(function(data){
393 $scope.tableData = data;
395 console.log("inside table");
398 DataService.getAllData($scope.tableTip)
399 .then(function(data){
400 $scope.tableTipData = data.tableTip;
401 console.log("inside table");
405 function loadTableData() {
407 var table_tpl = $(modelTemplate).filter('#table').html();
409 var html = Mustache.to_html(table_tpl, $scope.tableData.basic_table_data);
410 $('#basictableArea').html(html);
412 var html = Mustache.to_html(table_tpl, $scope.tableData.str_table_data);
413 $('#strippedtableArea').html(html);
415 var html = Mustache.to_html(table_tpl, $scope.tableData.cond_table_data);
416 $('#condensedtableArea').html(html);
420 /* Buttons Controller */
421 .controller("buttonsCtrl", function($scope,DataService,$log){
422 $scope.message = "Types of Buttons";
423 $scope.buttonTip="shortNote";
425 $scope.init = function() {
426 $scope.param="buttonsData";
427 DataService.getAllData($scope.param)
428 .then(function(data){
429 $scope.buttons = data;
434 console.log("inside accordion");
437 DataService.getAllData($scope.buttonTip)
438 .then(function(data){
439 $scope.buttonTipData = data.buttonTip;
440 console.log("inside table");
444 function defaultButtons(){
445 console.log("Default buttons Loaded..");
446 //Here your view content is fully loaded !!
447 var def_button_tpl = $(modelTemplate).filter('#defaultButtons').html();
448 var def_icon_button_tpl = $(modelTemplate).filter('#defaultIconButtons').html();
450 var html = Mustache.to_html(def_button_tpl, $scope.buttons.default_btn_data.def_button);
451 $('#defaultButtonArea').html(html);
453 var html = Mustache.to_html(def_icon_button_tpl, $scope.buttons.default_btn_data.def_print_button);
454 $('#defaultButtonArea').append(html);
456 var html = Mustache.to_html(def_icon_button_tpl, $scope.buttons.default_btn_data.def_print_button_right);
457 $('#defaultButtonArea').append(html);
461 function visualButtons(){
462 console.log("Loaded..");
463 //Here your view content is fully loaded !!
464 var visual_button_tpl = $(modelTemplate).filter('#visualButtons').html();
466 var html = Mustache.to_html(visual_button_tpl, $scope.buttons.visual_btn_data.vis_pri_btn_data);
467 $('#visualButtonArea').html(html);
469 var html = Mustache.to_html(visual_button_tpl, $scope.buttons.visual_btn_data.vis_sec_btn_data);
470 $('#visualButtonArea').append(html);
472 var html = Mustache.to_html(visual_button_tpl, $scope.buttons.visual_btn_data.vis_succ_btn_data);
473 $('#visualButtonArea').append(html);
475 var html = Mustache.to_html(visual_button_tpl, $scope.buttons.visual_btn_data.vis_inf_btn_data);
476 $('#visualButtonArea').append(html);
478 var html = Mustache.to_html(visual_button_tpl, $scope.buttons.visual_btn_data.vis_warn_btn_data);
479 $('#visualButtonArea').append(html);
481 var html = Mustache.to_html(visual_button_tpl, $scope.buttons.visual_btn_data.vis_dang_btn_data);
482 $('#visualButtonArea').append(html);
484 var html = Mustache.to_html(visual_button_tpl, $scope.buttons.visual_btn_data.vis_link_btn_data);
485 $('#visualButtonArea').append(html);
488 function sizeButtons() {
489 var size_button_tpl = $(modelTemplate).filter('#sizeButtons').html();
491 var html = Mustache.to_html(size_button_tpl, $scope.buttons.diffSize_btn_data.size_small_btn_data);
492 $('#sizeButtonArea').html(html);
494 var html = Mustache.to_html(size_button_tpl, $scope.buttons.diffSize_btn_data.size_large_btn_data);
495 $('#sizeButtonArea').append(html);
497 var html = Mustache.to_html(size_button_tpl, $scope.buttons.diffSize_btn_data.size_block_btn_data);
498 $('#sizeButtonArea').append(html);
502 function iconButtons() {
503 var icon_button_tpl = $(modelTemplate).filter('#iconButtons').html();
505 var html = Mustache.to_html(icon_button_tpl, $scope.buttons.icon_btn_data.search_icon_btn_data);
506 $('#iconButtonArea').html(html);
508 var html = Mustache.to_html(icon_button_tpl, $scope.buttons.icon_btn_data.search_icon_styled_btn_data);
509 $('#iconButtonArea').append(html);
511 var html = Mustache.to_html(icon_button_tpl, $scope.buttons.icon_btn_data.print_icon_btn_data);
512 $('#iconButtonArea').append(html);
516 $scope.defaultButtonsLoaded = function() {
517 if(modelTemplate != null) {
518 console.log("default buttons loading..");
522 console.log("default buttons not loading..");
526 $scope.visualButtonsLoaded = function() {
527 if(modelTemplate != null) {
528 console.log("visual buttons loading..");
532 console.log("visual buttons not loading..");
536 $scope.sizeButtonsLoaded = function() {
537 if(modelTemplate != null) {
538 console.log("size buttons loading..");
542 console.log("size buttons not loading..");
546 $scope.iconButtonsLoaded = function() {
547 if(modelTemplate != null) {
548 console.log("icon buttons loading..");
552 console.log("icon buttons not loading..");
556 /* Drop down----------------------*/
557 .controller("dropdownCtrl", function($scope, DataService) {
558 $scope.message = "You selected drop down";
559 $scope.subIsLoaded = function () {
560 if (modelTemplate != null) {
561 console.log("Loading..");
565 console.log("Not Loaded..");
569 $scope.init = function() {
570 $scope.param="dropdownData";
571 $scope.dropdownTip="shortNote";
572 DataService.getAllData($scope.param)
573 .then(function(data){
574 $scope.dropdown = data;
577 DataService.getAllData($scope.dropdownTip)
578 .then(function(data){
579 $scope.dropdownTipData = data.dropdownTip;
580 console.log("inside table");
583 function loadDrop() {
584 var drop_tpl = $(modelTemplate).filter('#dropDown').html();
585 var dropHeader_tpl = $(modelTemplate).filter('#dropDownHeader').html();
586 var dropSimple_tpl = $(modelTemplate).filter('#simpleDropdownTmpl').html();
588 var html = Mustache.to_html(drop_tpl, $scope.dropdown.dropped_down_data);
589 $('#dropArea').html(html);
591 var html = Mustache.to_html(drop_tpl, $scope.dropdown.dropped_up_data);
592 $('#dropAreaUP').html(html);
594 var html = Mustache.to_html(dropHeader_tpl, $scope.dropdown.dropHeader_data);
595 $('#dropAreaHeader').html(html);
597 var html = Mustache.to_html(dropSimple_tpl, $scope.dropdown.dropSimple_data);
598 $('#plainDropDown').html(html);
602 .controller("radioCtrl", function($scope, DataService, $log) {
603 $scope.message = "You selected radio button tab";
604 var lodedOnce = false;
605 $scope.subIsLoaded = function() {
606 if(modelTemplate != null) {
607 console.log("Loading..");
611 console.log("Not Loaded..");
615 $scope.init = function() {
616 $scope.param="radioData";
617 $scope.radioTip="shortNote";
618 DataService.getAllData($scope.param)
619 .then(function(data){
620 $scope.radioButton = data;
622 console.log("inside button");
626 DataService.getAllData($scope.radioTip)
627 .then(function(data){
628 $scope.radioTipData = data.radioTip;
629 console.log("inside table");
632 function loadRadioBtn(){
633 console.log("lodedOnce : "+lodedOnce);
635 var radio_button_tpl = $(modelTemplate).filter('#radioButtons').html();
636 var html = Mustache.to_html(radio_button_tpl, $scope.radioButton .radio_btn_default_data);
637 $('#radioBtnArea').html(html);
639 var html = Mustache.to_html(radio_button_tpl, $scope.radioButton .radio_btn_primary_data);
640 $('#radioBtnArea').append(html);
642 var html = Mustache.to_html(radio_button_tpl, $scope.radioButton .radio_btn_success_data);
643 $('#radioBtnArea').append(html);
645 var html = Mustache.to_html(radio_button_tpl, $scope.radioButton .radio_btn_danger_data);
646 $('#radioBtnArea').append(html);
648 var html = Mustache.to_html(radio_button_tpl, $scope.radioButton .radio_btn_Warn_data);
649 $('#radioBtnArea').append(html);
651 var html = Mustache.to_html(radio_button_tpl, $scope.radioButton .radio_btn_info_data);
652 $('#radioBtnArea').append(html);
656 .controller("checkBoxCtrl", function($scope, DataService) {
657 $scope.message = "You selected checkbox tab";
658 $scope.subIsLoaded = function() {
659 if(modelTemplate != null) {
660 console.log("Loading..");
664 console.log("Not Loaded..");
667 $scope.init = function() {
668 $scope.param="checkboxData";
669 $scope.checkboxTip="shortNote";
670 DataService.getAllData($scope.param)
671 .then(function(data){
672 $scope.checkBox = data;
675 DataService.getAllData($scope.checkboxTip)
676 .then(function(data){
677 $scope.checkboxTipData = data.checkboxTip;
678 console.log("inside table");
681 function loadCheckBox() {
682 var check_box_tpl = $(modelTemplate).filter('#checkBoxes').html();
684 var html = Mustache.to_html(check_box_tpl, $scope.checkBox.checkbox_default_data);
685 $('#CheckBoxArea').html(html);
687 var html = Mustache.to_html(check_box_tpl, $scope.checkBox.checkbox_primary_data);
688 $('#CheckBoxArea').append(html);
690 var html = Mustache.to_html(check_box_tpl, $scope.checkBox.checkbox_success_data);
691 $('#CheckBoxArea').append(html);
693 var html = Mustache.to_html(check_box_tpl, $scope.checkBox.checkbox_danger_data);
694 $('#CheckBoxArea').append(html);
696 var html = Mustache.to_html(check_box_tpl, $scope.checkBox.checkbox_warn_data);
697 $('#CheckBoxArea').append(html);
699 var html = Mustache.to_html(check_box_tpl, $scope.checkBox.checkbox_info_data);
700 $('#CheckBoxArea').append(html);
702 /*$.getJSON('./data/checkboxData.json', function(c_data) {
703 var html = Mustache.to_html(check_box_tpl, c_data.checkbox_default_data);
704 $('#CheckBoxArea').html(html);
706 var html = Mustache.to_html(check_box_tpl, c_data.checkbox_primary_data);
707 $('#CheckBoxArea').append(html);
709 var html = Mustache.to_html(check_box_tpl, c_data.checkbox_success_data);
710 $('#CheckBoxArea').append(html);
712 var html = Mustache.to_html(check_box_tpl, c_data.checkbox_danger_data);
713 $('#CheckBoxArea').append(html);
715 var html = Mustache.to_html(check_box_tpl, c_data.checkbox_warn_data);
716 $('#CheckBoxArea').append(html);
718 var html = Mustache.to_html(check_box_tpl, c_data.checkbox_info_data);
719 $('#CheckBoxArea').append(html);
724 /* Reference Code -- Remove after use */
725 .controller("coursesCtrl", function($scope, DataService){
726 $scope.message = "Courses Offered";
727 $scope.courses = ["Java", "C/C++", "JavaScript", "AngularJS", "NodeJS", "HTML", "Python", "Action Script"];
728 $scope.showDialog = function() {
729 /*var dialog_tpl = $(modelTemplate).filter('#personDialog').html();
730 var data = {'title':'Shahid Noor','showClose':true,'closeBtnTxt':'Cancel','icon':'glyphicon glyphicon-off','iconColor':'icon_warn','msg':'Good! There is a message that can be used to show on the screen. There is a message that can be used to show on the screen', buttons:[{"text": "Ok", 'action':'callThis()'},{"text": "Show"}]};
731 var html = Mustache.to_html(dialog_tpl, data);
732 $(html).modal({backdrop: "static"}); //backdrop: "static" - for grayed out and no outside click work, backdrop: false - no grayed out*/
734 var def_button_tpl = $(modelTemplate).filter('#visualButtons').html();
735 var def_btn_data = {'title':"asas", 'type':'primary'};
736 var html = Mustache.to_html(def_button_tpl, def_btn_data);
737 $('#sampleArea').html(html);
740 // $scope.$on('$viewContentLoaded', function(){
742 console.log("Loaded..");
743 //Here your view content is fully loaded !!
744 var def_button_tpl = $(modelTemplate).filter('#dropDown').html();
745 var def_btn_data = {'title':'Shahid Noor','position':'down', items:[{"itemLabel": "Ok"},{"itemLabel": "Show"}]};
746 var html = Mustache.to_html(def_button_tpl, def_btn_data);
747 $('#sampleArea').html(html);
750 $scope.subIsLoaded = function() {
751 if(modelTemplate != null) {
752 console.log("Loading..");
756 console.log("Not Loaded..");
761 .controller("toolCtrl", function($scope, DataService, $compile, $log){
762 $scope.toolTip = "shortNote";
763 $scope.toolTipContent = "textArea";
765 DataService.getAllData($scope.toolTipContent)
766 .then(function(data){
767 $log.info(data.Note.placement);
768 $scope.noteContent = data.Note.message;
769 $scope.notePlacement = data.Note.placement;
770 $scope.errMsg = data.ErrMsg;
771 console.log($scope.noteContent + " " + $scope.notePlacement);
774 DataService.getAllData($scope.toolTip)
775 .then(function(data){
776 $scope.toolTipData = data.toolTip;
780 //$('[data-toggle="popover"]').popover();
784 function loadTextArea() {
785 var text = $(modelTemplate).filter('#textfield').html();
786 var email = $(modelTemplate).filter('#email').html();
787 var url = $(modelTemplate).filter('#url').html();
788 var password = $(modelTemplate).filter('#password').html();
789 var numeric = $(modelTemplate).filter('#numeric').html();
790 var dot = $(modelTemplate).filter('#dot').html();
791 var dateinput = $(modelTemplate).filter('#dateinput').html();
792 var monthinput = $(modelTemplate).filter('#monthinput').html();
793 var weekinput = $(modelTemplate).filter('#weekinput').html();
794 var timeinput = $(modelTemplate).filter('#timeinput').html();
795 var ipv4 = $(modelTemplate).filter('#ipv4').html();
796 var ipv6 = $(modelTemplate).filter('#ipv6').html();
797 var textarea = $(modelTemplate).filter('#textarea').html();
799 var note = $(modelTemplate).filter('#note').html();
801 var dataText = {"errMsg" : {"textboxErr" : "The name is required.", "modalVar":"province.province_name", "placeholder":""}};
802 var html = Mustache.to_html(text, dataText.errMsg);
803 $('#fname').html($compile(html)($scope));
805 var html = Mustache.to_html(email, $scope.errMsg);
806 $('#email').html($compile(html)($scope));
808 var html = Mustache.to_html(url, $scope.errMsg);
809 $('#url').html($compile(html)($scope));
811 var html = Mustache.to_html(password, $scope.errMsg);
812 $('#password').html($compile(html)($scope));
814 var dataNum = {"errMsg" : {"numericErr" : "The number is required.", "modalVar":"province.port", "placeholder":""}};
815 var html = Mustache.to_html(numeric, dataNum.errMsg);
816 $('#numeric').html($compile(html)($scope));
819 var html = Mustache.to_html(dot, $scope.errMsg);
820 $('#dot').html($compile(html)($scope));
822 var html = Mustache.to_html(dateinput, $scope.errMsg);
823 $('#dateinput').html($compile(html)($scope));
825 var html = Mustache.to_html(monthinput, $scope.errMsg);
826 $('#monthinput').html($compile(html)($scope));
828 var html = Mustache.to_html(weekinput, $scope.errMsg);
829 $('#weekinput').html($compile(html)($scope));
831 var html = Mustache.to_html(timeinput, $scope.errMsg);
832 $('#timeinput').html($compile(html)($scope));
834 var dataIP = {"errMsg" : {"ipv4Err" : "The ipv4 is required.", "modalVar":"province.ip", "placeholder":""}};
835 var html = Mustache.to_html(ipv4, dataIP.errMsg);
836 $('#ipv4').html($compile(html)($scope));
838 var html = Mustache.to_html(ipv6, $scope.errMsg);
839 $('#ipv6').html($compile(html)($scope));
841 var html = Mustache.to_html(textarea, $scope.errMsg);
842 $('#textarea').html($compile(html)($scope));
846 var html = Mustache.to_html(note, {"placement":$scope.notePlacement});
847 $('#note').html(html);
848 $("#noteanchor").popover({
849 template: '<div class="popover fade bottom in customPopover"><div class="arrow"></div>'+$scope.noteContent+'</div>'
852 $scope.validatetextbox = function (value){
854 $scope.textboxErr = false;
857 $scope.textboxErr = true;
860 $scope.validateemail = function (value){
862 $scope.emailErr = false;
865 $scope.emailErr = true;
868 $scope.validateurl = function (value){
870 $scope.urlErr = false;
873 $scope.urlErr = true;
876 $scope.validatepassword = function (value){
877 if($scope.password) {
878 $scope.passwordErr = false;
881 $scope.passwordErr = true;
884 $scope.validatenumeric = function (value){
886 $scope.numericErr = false;
889 $scope.numericErr = true;
892 $scope.validatedot = function (value){
893 if($scope.datetime) {
894 $scope.dotErr = false;
897 $scope.dotErr = true;
900 $scope.validatedateinput = function (value){
902 $scope.dateinputErr = false;
905 $scope.dateinputErr = true;
908 $scope.validatemonthinput = function (value){
910 $scope.monthinputErr = false;
913 $scope.monthinputErr = true;
916 $scope.validateweek = function (value){
918 $scope.weekinputErr = false;
921 $scope.weekinputErr = true;
924 $scope.validatetime = function (value){
926 $scope.timeinputErr = false;
929 $scope.timeinputErr = true;
932 $scope.validateipv4 = function (value){
934 $scope.ipv4Err = false;
937 $scope.ipv4Err = true;
940 $scope.validateipv6 = function (value){
942 $scope.ipv6Err = false;
945 $scope.ipv6Err = true;
949 $scope.validatetextarea = function (value){
950 if($scope.textarea) {
951 $scope.textareaErr = false;
954 $scope.textareaErr = true;
971 .controller("notificationCtrl", function($scope, DataService){
972 $scope.message = "Notification and Messages";
973 $scope.notificationTip = "shortNote";
976 $scope.templateLoaded = function() {
977 if(modelTemplate != null) {
978 console.log("Loading..");
982 console.log("Not Loaded..");
985 $scope.init = function() {
986 $scope.param="notificationData";
987 $scope.notificationTip="shortNote";
988 DataService.getAllData($scope.param)
989 .then(function(data){
990 $scope.notification = data;
992 DataService.getAllData($scope.notificationTip)
993 .then(function(data){
994 $scope.notificationTipData = data.notificationTip;
998 $scope.showError = function() {
999 dialog_tpl = $(modelTemplate).filter('#personDialog').html();
1000 var html = Mustache.to_html(dialog_tpl, $scope.notification.err_data);
1001 $(html).modal({backdrop: "static"});//backdrop: "static" - for grayed out and no outside click work, backdrop: false - no grayed out*!
1004 $scope.showWarning = function() {
1005 dialog_tpl = $(modelTemplate).filter('#personDialog').html();
1006 var html = Mustache.to_html(dialog_tpl, $scope.notification.warn_data);
1010 $scope.showInfo = function() {
1011 dialog_tpl = $(modelTemplate).filter('#personDialog').html();
1012 var html = Mustache.to_html(dialog_tpl, $scope.notification.info_data);
1015 $scope.showConfirm = function() {
1016 dialog_tpl = $(modelTemplate).filter('#personDialog').html();
1017 var html = Mustache.to_html(dialog_tpl, $scope.notification.confirm_data);
1018 $(html).modal({backdrop: "static"}); //backdrop: "static" - for grayed out and no outside click work, backdrop: false - no grayed out*!/
1023 .controller("functionalCtrl", function($scope, DataService){
1024 $scope.message = "Functional Flow";
1027 $scope.templateLoaded = function() {
1028 if(modelTemplate != null) {
1029 console.log("Loading..");
1033 console.log("Not Loaded..");
1037 $scope.init = function() {
1038 $scope.param="functionalData";
1039 $scope.functionalTip="shortNote";
1040 DataService.getAllData($scope.param)
1041 .then(function(data){
1042 $scope.functional = data;
1044 DataService.getAllData($scope.functionalTip)
1045 .then(function(data){
1046 $scope.functionalTipData = data.functionalTip;
1049 $scope.showCreate = function() {
1050 dialog_tpl = $(modelTemplate).filter('#functionalDialog').html();
1051 var html = Mustache.to_html(dialog_tpl, $scope.functional.create_data);
1054 $scope.showModify = function() {
1055 dialog_tpl = $(modelTemplate).filter('#functionalDialog').html();
1056 var html = Mustache.to_html(dialog_tpl, $scope.functional.modify_data);
1059 $scope.showDelete = function() {
1060 dialog_tpl = $(modelTemplate).filter('#functionalDialog').html();
1061 var html = Mustache.to_html(dialog_tpl, $scope.functional.delete_data);
1064 $scope.showWorkflow = function() {
1065 dialog_tpl = $(modelTemplate).filter('#functionalDialog').html();
1066 var html = Mustache.to_html(dialog_tpl, $scope.functional.workflow_data);
1071 .controller("listCtrl", function($scope, $log, DataService){
1072 $scope.message = "List Page";
1073 $scope.listTip = "shortNote";
1074 $scope.init = function() {
1075 console.log("Shahid... ng-init");
1076 $scope.param="list";
1077 DataService.getAllData($scope.param)
1078 .then(function(data){
1079 $scope.mainlistItem = data;
1080 }, function(reason){
1081 $scope.portfolios = [];
1085 DataService.getAllData($scope.listTip)
1086 .then(function(data){
1087 $scope.listTipData = data.listTip;
1090 $scope.loadSubMenuPage = function(index) {
1091 $log.info($scope.mainlistItem);
1092 $scope.subMenuListItem = $scope.mainlistItem[index].subMenu;
1093 $scope.subsubMenuListItem = [];
1095 $scope.loadSubSubMenuPage = function(index) {
1096 $log.info($scope.subMenuListItem);
1097 console.log("index: "+index);
1098 $scope.subsubMenuListItem = $scope.subMenuListItem[index].subsubMenu;
1102 .controller("managementCtrl", function($scope, $log, DataService, $state, $compile, NgTableParams){
1103 $scope.message = "Management";
1104 $scope.provinceTip = "shortNote";
1105 /*$scope.provinceData = [
1106 {id:1, province_name:'First', ip:'192.168.1.45', port:'8080'},
1107 {id:2, province_name:'Second', ip:'192.168.1.5', port:'8081'},
1108 {id:3, province_name:'Third', ip:'192.168.1.15', port:'8082'},
1109 {id:4, province_name:'Fourth', ip:'192.168.1.28', port:'8083'},
1110 {id:5, province_name:'Fifth', ip:'192.168.1.19', port:'8084'}
1113 $scope.init = function() {
1114 console.log("Shahid... ng-init");
1115 DataService.getAllProvinceData()
1116 .then(function(data){
1117 $scope.provinceData = data.provinceData;
1118 console.log("Data: ");
1120 $log.info(data.provinceData);
1121 }, function(reason){
1122 $scope.message = "Error is :" + JSON.stringify(reason);
1125 DataService.getAllData($scope.provinceTip)
1126 .then(function(data){
1127 $scope.provinceTipData = data.provinceTip;
1131 /*DataService.getAllProvinceData()
1132 .then(function(data){
1133 $scope.provinceData = data.provinceData;
1134 console.log("Data: ");
1135 $log.info(data.provinceData);
1136 }, function(reason){
1137 $scope.message = "Error is :" + JSON.stringify(reason);
1139 /*DataService.getAllData($scope.provinceTip)
1140 .then(function(data){
1141 $scope.provinceTipData = data.provinceTip;
1144 function loadButtons() {
1145 var def_button_tpl = $(modelTemplate).filter('#defaultButtons').html();
1146 var add_data = {"title":"Add", "clickAction":"showAddModal()"};
1147 var delete_data = {"title":"Delete Selected", "clickAction":"deleteData()"};
1148 var addhtml = Mustache.to_html(def_button_tpl, add_data);
1149 var deletehtml = Mustache.to_html(def_button_tpl, delete_data);
1150 $('#provinceAction').html($compile(addhtml)($scope));
1151 $('#provinceAction').append($compile(deletehtml)($scope));
1153 $scope.checkboxes = { 'checked': false, items: {} };
1155 //var data = [{id: 1, name: "Moroni", age: 50}, {id: 2, name: "ABC", age: 30}, {id: 3, name: "Morhoni", age: 10}, {id: 4, name: "DABC", age: 31}, {id: 5, name: "Noor", age: 30}, {id: 6, name: "ABCD", age: 40}, {id: 7, name: "DABC", age: 31}, {id: 8, name: "Noor", age: 30}, {id: 9, name: "ABCD", age: 40}, {id: 10, name: "DABC", age: 31}, {id: 11, name: "Noor", age: 30}, {id: 12, name: "ABCD", age: 40}];
1156 $scope.tableParams = new NgTableParams({count: 5, sorting: {province_name: 'asc'} //{page: 1,count: 10,filter: {name: 'M'},sorting: {name: 'desc'}
1157 }, { counts:[5, 10, 20, 50], dataset: $scope.provinceData});
1159 $scope.$watch('checkboxes.checked', function(value) {
1160 angular.forEach($scope.provinceData, function(item) {
1161 if (angular.isDefined(item.id)) {
1162 $scope.checkboxes.items[item.id] = value;
1167 var text = $(modelTemplate).filter('#textfield').html();
1168 var ipv4 = $(modelTemplate).filter('#ipv4').html();
1169 var number = $(modelTemplate).filter('#numeric').html();
1171 var dataText = {"ErrMsg" : {"textboxErr" : "The name is required.", "modalVar":"province.province_name", "placeholder":"Name"}};
1172 $('#myModal .provinceName').html($compile(Mustache.to_html(text, dataText.ErrMsg))($scope));
1174 var dataIP = {"ErrMsg" : {"ipv4Err" : "The ipv4 is required.", "modalVar":"province.ip", "placeholder":"IP Address"}};
1175 $('#myModal .ipAddress').html($compile(Mustache.to_html(ipv4, dataIP.ErrMsg))($scope));
1177 var dataNum = {"ErrMsg" : {"numericErr" : "The number is required.", "modalVar":"province.port", "placeholder":"Port"}};
1178 $('#myModal .port').html($compile(Mustache.to_html(number, dataNum.ErrMsg))($scope));
1180 var modelSubmit_data = {"title":"Submit", "clickAction":"saveData(province.id)"};
1181 var modelSubmit_html = Mustache.to_html(def_button_tpl, modelSubmit_data);
1182 $('#myModal #footerBtns').html($compile(modelSubmit_html)($scope));
1184 var modelDelete_data = {"title":"Close", "clickAction":"closeModal()"};
1185 var modelDelete_html = Mustache.to_html(def_button_tpl, modelDelete_data);
1186 $('#myModal #footerBtns').append($compile(modelDelete_html)($scope));
1189 $scope.validatetextbox = function (value){
1190 if($scope.province.province_name) {
1191 $scope.textboxErr = false;
1194 $scope.textboxErr = true;
1196 $scope.validateipv4 = function (value){
1197 if($scope.province.ip) {
1198 $scope.ipv4Err = false;
1201 $scope.ipv4Err = true;
1203 $scope.validatenumeric = function (value){
1204 if($scope.province.port) {
1205 $scope.numericErr = false;
1208 $scope.numericErr = true;
1211 $scope.closeModal = function() {
1212 console.log("Closing Modal...");
1213 $('#myModal').modal('hide');
1217 $scope.checkAll = function() {
1218 console.log("Checked ..");
1219 angular.forEach($scope.provinceData, function(data) {
1220 //data.select = $scope.selectAll;
1221 $scope.checkboxes.items[user.id]
1225 $scope.showAddModal = function() {
1226 console.log("Showing Modal to Add data");
1227 $scope.province = {};
1228 $scope.textboxErr = false;
1229 $scope.ipv4Err = false;
1230 $scope.numericErr = false;
1231 $("#myModal").modal();
1233 $scope.saveData = function(id) {
1236 console.log("Editing data.." + JSON.stringify($scope.province));
1237 DataService.editProvinceData($scope.province)
1238 .then(function (data) {
1239 $scope.message = "Success :-)";
1241 //$state.go($state.current.name, {}, {reload: true})
1244 //$log.info(reason);
1245 $scope.message = reason.status + " " + reason.statusText;
1249 console.log("Adding data.." + JSON.stringify($scope.province));
1250 DataService.addProvinceData($scope.province)
1251 .then(function (data) {
1252 $scope.message = "Success :-)";
1254 //$state.go($state.current.name, {}, {reload: true})
1257 //$log.info(reason);
1258 $scope.message = reason.status + " " + reason.statusText;
1261 $('#myModal').modal('hide');
1264 $scope.deleteData = function() {
1266 //$log.info($scope.checkboxes);
1267 angular.forEach($scope.checkboxes.items, function(value , key) {
1270 deleteArr.push(key);
1274 console.log("To be deleted : "+deleteArr);
1275 //$log.info(deleteArr);
1276 DataService.deleteProvinceData(deleteArr)
1277 .then(function(data){
1278 $scope.message = "Successfully deleted :-)";
1282 //$log.info(reason);
1283 $scope.message = reason.status + " " + reason.statusText;
1287 $scope.deleteIndividualData = function(id) {
1289 //$log.info($scope.checkboxes);
1292 console.log("To be deleted : "+deleteArr);
1293 //$log.info(deleteArr);
1294 DataService.deleteProvinceData(deleteArr)
1295 .then(function(data){
1296 $scope.message = "Successfully deleted :-)";
1300 //$log.info(reason);
1301 $scope.message = reason.status + " " + reason.statusText;
1305 $scope.editData = function(id) {
1306 $scope.textboxErr = false;
1307 $scope.ipv4Err = false;
1308 $scope.numericErr = false;
1309 console.log("To be edited : " + id);
1310 var dataFound = false;
1311 angular.forEach($scope.provinceData, function(data) {
1313 if (data.id == id) {
1314 console.log("Found : " + data.id);
1315 $scope.province = data;
1316 /*$scope.province.province_name = data.province_name;
1317 $scope.province.ip = data.ip;
1318 $scope.province.port = data.port;*/
1320 $("#myModal").modal();
1330 function loadTemplate() {
1331 $.get('template.html', function(template) {
1332 modelTemplate = template;
1336 function callThis() {
1337 alert("Going Great!");
1340 function searchTable() {
1341 var filter, table, tr, td;
1342 filter = $("#myInput").val().toUpperCase();
1343 table = $("#myTable_search");
1344 tr = $("#myTable_search tr");
1346 // Loop through all table rows, and hide those who don't match the search query
1347 for (var i = 0; i < tr.length; i++) {
1348 td = tr[i].getElementsByTagName("td")[0];
1350 if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
1351 tr[i].style.display = "";
1353 tr[i].style.display = "none";
1359 function linkClicked(state) {
1360 console.log("State to : " + state);