Skip to content
This repository was archived by the owner on Mar 21, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ html {
text-align: center;
}

.list .item.item-button-right {
padding-right: 45px;
}

.list .item.item-no-avatar {
padding: 10px;
padding-right: 45px;
}

.icon-spin {
-webkit-animation: spin 2s infinite linear;
-moz-animation: spin 2s infinite linear;
Expand Down Expand Up @@ -46,4 +55,4 @@ html {
to {
transform: rotate(360deg);
}
}
}
31 changes: 30 additions & 1 deletion app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ angular.module('ui.gravatar').config([
]);

locksmithApp.run(function($rootScope, $state, $localStorage) {
console.log('app.run');
$rootScope.$state = $state;
window.settings = $rootScope.$settings = $localStorage;

Expand All @@ -44,6 +45,9 @@ locksmithApp.run(function($rootScope, $state, $localStorage) {
if (typeof window.settings.bookmarks === 'undefined') {
window.settings.bookmarks = [];
}
if (typeof window.settings.favorites === 'undefined') {
window.settings.favorites = [];
}

$rootScope.jobs = 0;

Expand All @@ -59,6 +63,7 @@ locksmithApp.run(function($rootScope, $state, $localStorage) {
locksmithApp.config([
'$stateProvider', '$urlRouterProvider', '$httpProvider',
function($stateProvider, $urlRouterProvider, $httpProvider) {
console.log('app.config');
$httpProvider.interceptors.push(function($rootScope) {
return {
request: function(config) {
Expand Down Expand Up @@ -101,11 +106,36 @@ locksmithApp.config([
controller: 'BookmarkIndexController',
templateUrl: 'partials/bookmarks/list.html'
}).
state('bookmarks.favorites', {
url: '',
controller: 'FavoritesIndexController',
templateUrl: 'partials/favorites/list.html'
}).
state('bookmarks.show', {
url: '/:bookmarkId',
controller: 'BookmarkShowController',
templateUrl: 'partials/bookmarks/show.html'
}).
state('favorites', {
abstract: true,
url: '/favorites',
views: {
header: {
templateUrl: 'partials/header/favorites.html'
},
main: {
templateUrl: 'partials/favorites/index.html'
},
footer: {
templateUrl: 'partials/footer/footer.html'
}
}
}).
state('favorites.list', {
url: '',
controller: 'FavoritesIndexController',
templateUrl: 'partials/favorites/list.html'
}).
state('accounts', {
abstract: true,
url: '/accounts',
Expand Down Expand Up @@ -168,6 +198,5 @@ locksmithApp.config([
});

$urlRouterProvider.otherwise('/bookmarks');

}
]);
55 changes: 48 additions & 7 deletions app/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,55 @@ locksmithControllers.controller(
}
});

$scope.bookmarks = Bookmark.query();
if (typeof $scope.bookmarks.$promise !== 'undefined') {
$scope.bookmarks.$promise.then(function(bookmarks) {
window.settings.bookmarks = bookmarks.bookmarks;
});
}
Bookmark.query().$promise.then(function(bookmarks) {
// loop through all bookmarks, and check if they are included
// in the favorites. If so, mark them as such
for (i = 0; i < bookmarks.bookmarks.length; i++) {
var bookmark = bookmarks.bookmarks[i];
bookmarks.bookmarks[i].is_favorite = false;
if (window.settings.favorites.includes(parseInt(bookmark.id))) {
bookmarks.bookmarks[i].is_favorite = true;
}
}
$scope.bookmarks = bookmarks;

if (typeof $scope.bookmarks.$promise !== 'undefined') {
$scope.bookmarks.$promise.then(function(bookmarks) {
window.settings.bookmarks = bookmarks.bookmarks;
});
}
});


$scope.orderProp = 'name';
$('#search').focus();
}
]);

locksmithControllers.controller(
'FavoritesIndexController', ['$rootScope', '$scope', '$state', 'Bookmark', '$location', 'signin', '$ionicPopup', '$controller',

function($rootScope, $scope, $state, Bookmark, $location, signin, $ionicPopup, $controller) {
angular.extend(this, $controller('BookmarkIndexController', {
$scope: $scope
}));


}

]);


locksmithControllers.controller(
'BookmarkShowController', ['$scope', '$state', 'Bookmark', '$stateParams',
function($scope, $state, Bookmark, $stateParams) {

$scope.bookmarkId = $stateParams.bookmarkId;
$scope.bookmark = Bookmark.query({
Bookmark.query({
bookmarkId: $scope.bookmarkId
}).$promise.then(function(bookmark) {
bookmark.is_favorite = window.settings.favorites.includes(parseInt(bookmark.id));
$scope.bookmark = bookmark;
});

$scope.save = function() {
Expand All @@ -158,6 +188,16 @@ locksmithControllers.controller(
$scope.bookmark.$create();
}

if ($scope.bookmark.is_favorite) {
if (!window.settings.favorites.includes(parseInt($scope.bookmark.id))) {
window.settings.favorites.push(parseInt($scope.bookmarkId));
}
} else {
window.settings.favorites = window.settings.favorites.filter(function(id) {
return parseInt(id) != parseInt($scope.bookmarkId);
});
}

$state.go('bookmarks.list');
};

Expand All @@ -171,6 +211,7 @@ locksmithControllers.controller(
}
]);


locksmithControllers.controller(
'AccountIndexController', ['$scope', 'Account', '$location',
function($scope, Account, $location) {
Expand Down
8 changes: 4 additions & 4 deletions app/partials/bookmarks/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
/>
</label>
<a
class="item item-avatar item-button-right"
ng-class="{active: $index == position}"
class="item item-button-right"
ng-class="{active: $index == position, 'item-avatar': $settings.hide_avatars == false, 'item-no-avatar': $settings.hide_avatars}"
ng-click="getToken(bookmark)"
ng-repeat="bookmark in bookmarks.bookmarks
|byNameOrAccountNumber:query
|orderBy:orderProp"
>
<img ng-if="!gravatar(bookmark)" ng-src="{{bookmark.avatar_url}}" />
<img ng-if="gravatar(bookmark)" gravatar-src="bookmark.avatar_url || bookmark.name" />
<img ng-if="!gravatar(bookmark) && !$settings.hide_avatars" ng-src="{{bookmark.avatar_url}}" />
<img ng-if="gravatar(bookmark) && !$settings.hide_avatars" gravatar-src="bookmark.avatar_url || bookmark.name" />
<h2>{{bookmark.name}}</h2>
<p>{{bookmark.account_number}}/{{bookmark.role_name}}</p>
<button
Expand Down
17 changes: 17 additions & 0 deletions app/partials/bookmarks/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@
ng-model="bookmark.avatar_url"
/>
</label>

<div
class="item item-toggle"
ng-if="$settings.use_favorites"
>
Favorite
<label class="toggle toggle-balanced">
<input
type="checkbox"
ng-model="bookmark.is_favorite"
/>
<div class="track">
<div class="handle"></div>
</div>
</label>
</div>
</ion-list>

<div class="padding">
Expand All @@ -46,4 +62,5 @@
class="button button-block button-assertive"
ng-click="delete()"
>Delete Bookmark</button>

</div>
3 changes: 3 additions & 0 deletions app/partials/favorites/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ion-content overflow-scroll="true" class="has-header has-footer">
<div ui-view></div>
</ion-content>
20 changes: 20 additions & 0 deletions app/partials/favorites/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<ion-list ng-keydown="keydown($event)" id="bookmarks">
<a
class="item item-avatar item-button-right"
ng-if="bookmark.is_favorite"
ng-class="{active: $index == position, 'item-avatar': $settings.hide_avatars == false, 'item-no-avatar': $settings.hide_avatars}" ng-click="getToken(bookmark)"
ng-repeat="bookmark in bookmarks.bookmarks
|byNameOrAccountNumber:query
|orderBy:orderProp"
>
<img ng-if="!gravatar(bookmark) && !$settings.hide_avatars" ng-src="{{bookmark.avatar_url}}" />
<img ng-if="gravatar(bookmark) && !$settings.hide_avatars" gravatar-src="bookmark.avatar_url || bookmark.name" />
<h2>{{bookmark.name}}</h2>
<p>{{bookmark.account_number}}/{{bookmark.role_name}}</p>
<button
class="button button-clear button-positive"
ui-sref="bookmarks.show({bookmarkId: bookmark.id})"
ng-click="$event.stopPropagation()"
><i class="icon ion-ios-information-outline"></i></button>
</a>
</ion-list>
17 changes: 13 additions & 4 deletions app/partials/footer/footer.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
<div class="button-bar">

<button class="button button-clear"
ui-sref="favorites.list"
ng-if="$settings.use_favorites"
ng-class="{
'button-positive': $state.includes('favorites')
}"
><i title="favorites" class="icon ion-ios-heart"></i></button>

<button class="button button-clear"
ui-sref="bookmarks.list"
ng-class="{
'button-positive': $state.includes('bookmarks')
}"
><i class="icon ion-ios-unlocked"></i></button>
><i title="bookmarks" class="icon ion-ios-unlocked"></i></button>

<button class="button button-clear"
ng-show="$settings.account_management"
ui-sref="accounts.list"
ng-class="{
'button-positive': $state.includes('accounts')
}"
><i class="icon ion-cloud"></i></button>
><i title="accounts" class="icon ion-cloud"></i></button>

<button class="button button-clear"
ui-sref="settings"
ng-class="{
'button-positive': $state.includes('settings'),
'icon-spin': jobs > 0
}"
><i class="icon ion-gear-a"></i></button>
</div>
><i title="settings" class="icon ion-gear-a"></i></button>
</div>
1 change: 1 addition & 0 deletions app/partials/header/favorites.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1 id="title" class="title">Favorites</h1>
37 changes: 36 additions & 1 deletion app/partials/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<img class="full-image" src="dist/img/sentia.png" />
</div>
</div>

<div class="card">
<div class="item item-divider">Locksmith</div>

Expand Down Expand Up @@ -35,6 +35,7 @@
</label>
</div>


<div
ng-show="$is_extension && !$settings.use_switch_role"
class="item item-toggle"
Expand Down Expand Up @@ -138,6 +139,40 @@
</div>
</form>

<div class="card">
<div class="item item-divider">Interface</div>

<div
class="item item-toggle"
>
Hide avatars
<label class="toggle toggle-balanced">
<input
type="checkbox"
ng-model="$settings.hide_avatars"
/>
<div class="track">
<div class="handle"></div>
</div>
</label>
</div>

<div class="item item-toggle">
Use Favorites
<label class="toggle toggle-balanced">
<input
type="checkbox"
ng-model="$settings.use_favorites"
/>
<div class="track">
<div class="handle"></div>
</div>
</label>
</div>


</div>


<p>&nbsp;</p>
</ion-content>