PageSourceSearch

http://www.schemaadapter.com/src/modules/admin/AdminController.js?ver=1.5

js schemaadapter.com collected 2026-10-04 12:47:50 UTC 3,689 bytes, 150 lines download raw bytes

1(function(){
2
3  angular
4       .module('admin')
5       .controller('AdminController', [
6          'AuthFactory',
7          'currentAuth',
8          '$firebaseArray',
9          '$mdDialog',          
10          'SweetAlert',
11          AdminController
12       ]);
13
14  
15  /**
16   * Admin Controller
17   * @constructor
18   */
19  function AdminController(AuthFactory,currentAuth,$firebaseArray,$mdDialog,SweetAlert) {    
20
21  	AuthFactory.$onAuth(function(authData) {
22  		currentAuth = authData;
23  		if (currentAuth)
24		{
25			contactRef = new Firebase(FIREBASE_URL + 'contacts'),  		
26	  		contactList = $firebaseArray(contactRef);	  			  	
27		}		
28  	});
29
30  	var postRef = new Firebase(FIREBASE_URL+'schemaPosts'),
31
32		postList = $firebaseArray(postRef),
33	
34		errorAlert = function(errorMessage) {
35        return $mdDialog.alert()
36          .title('Oops!')
37          .content(errorMessage)
38          .clickOutsideToClose(true)
39          .ok('Close');
40    },
41
42    newPostDialog = function($event) {      
43	    $mdDialog.show({
44	      controller: DialogController,
45	      controllerAs: 'dc',
46	      templateUrl: './src/modules/admin/views/newPostForm.html',
47	      targetEvent: $event,
48	      clickOutsideToClose: false,
49	      fullscreen: true,
50	    });		    
51    },
52
53    /**
54     * Dialog Controller
55     */
56    DialogController = function($mdDialog, SweetAlert) {
57      
58      var newPost = {},
59
60  	  cancel = function() {	      	  	
61        $mdDialog.cancel();		        
62      },
63
64      save = function() {
65      	postList.$add({
66        	title: newPost.title ? newPost.title : null,
67        	body: newPost.body ? newPost.body : null,
68        	author: newPost.author ? newPost.author : null,
69        	slug: newPost.slug ? newPost.slug : null,
70        	h1: newPost.h1 ? newPost.h1 : null,
71        	h2: newPost.h2 ? newPost.h2 : null,
72        	image: newPost.image ? newPost.image : null,
73        	category: newPost.category ? newPost.category : null,
74        	date: (new Date()).toString()
75        }).then(function(){
76                     
77		  $mdDialog.cancel();
78		  SweetAlert.swal('Success!', 'Your blog post was submitted, thank you!', 'success');    
79
80		  //d4b64eed4e
81		  //b572e1068649984e1479d613b0f353c1-us14           
82		  
83		})
84  
85      },
86
87      setUrl = function(fileUrl) {
88      	newPost.image = fileUrl;
89      },
90
91      self = this;
92      self.newPost = newPost;
93      self.cancel = cancel;
94      self.setUrl = setUrl;
95      self.save = save;
96    },
97
98	ref = new Firebase(FIREBASE_URL),
99	loginData = {
100		username: '',
101		password: ''
102	},
103	contactRef,
104	contactList = [],
105	adminHeader = function()
106	{
107		return currentAuth ? 'Admin Dashboard' : 'Admin Login';
108	},
109	cardAlignment = function()
110	{
111		return currentAuth ? 'stretch center' : 'center center';
112	},
113	sortOrder = "['Last Name']",
114	signin = function()
115	{
116		AuthFactory.$authWithPassword({
117			email	: loginData.username,
118			password: loginData.password
119		}).then(function(authData) {		  
120			// Successful login; clear form
121			loginData.username = '';
122			loginData.password = '';			
123		}).catch(function(error) {
124		  SweetAlert.swal('Oops!',error.message, 'error'); // Show error to user		  
125		});		
126
127	},
128	isAuthenticated = function()
129	{
130		return currentAuth ? true : false;
131	},
132	totalContacts = function() {
133		return contactList.length;
134	},
135	getContactList = function() {
136		return contactList;
137	},
138    self = this;
139    self.adminHeader = adminHeader,
140    self.cardAlignment = cardAlignment,
141    self.sortOrder = sortOrder,
142    self.signin = signin,	
143	self.isAuthenticated = isAuthenticated;
144	self.contactList = getContactList,
145	self.totalContacts = totalContacts,
146	self.loginData = loginData;
147	self.newPostDialog = newPostDialog;		
148  }
149
150})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.