图书馆智能管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.3 KiB

5 months ago
  1. /* Licensed under the Apache License, Version 2.0 (the "License");
  2. * you may not use this file except in compliance with the License.
  3. * You may obtain a copy of the License at
  4. *
  5. * http://www.apache.org/licenses/LICENSE-2.0
  6. *
  7. * Unless required by applicable law or agreed to in writing, software
  8. * distributed under the License is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. * See the License for the specific language governing permissions and
  11. * limitations under the License.
  12. */
  13. flowableApp.controller('LandingController', ['$scope','$window', '$location', '$http', '$translate', '$modal', 'RuntimeAppDefinitionService', '$rootScope',
  14. function ($scope, $window, $location, $http, $translate, $modal, RuntimeAppDefinitionService, $rootScope) {
  15. $scope.model = {
  16. loading: true
  17. };
  18. $translate('APP.ACTION.DELETE').then(function(message) {
  19. $scope.appActions = [
  20. {
  21. text: message,
  22. click: 'deleteApp(app); '
  23. }
  24. ];
  25. });
  26. $scope.loadApps = function() {
  27. $scope.model.customAppsFetched = false;
  28. RuntimeAppDefinitionService.getApplications().then(function(result){
  29. $scope.model.apps = result.defaultApps.concat(result.customApps);
  30. $scope.model.customAppsFetched = true;
  31. $scope.model.customApps = result.customApps.length > 0;
  32. // Determine the full url with a context root (if any)
  33. var baseUrl = $location.absUrl();
  34. var index = baseUrl.indexOf('/#');
  35. if (index >= 0) {
  36. baseUrl = baseUrl.substring(0, index);
  37. }
  38. index = baseUrl.indexOf('?');
  39. if (index >= 0) {
  40. baseUrl = baseUrl.substring(0, index);
  41. }
  42. if (baseUrl[baseUrl.length - 1] == '/') {
  43. baseUrl = baseUrl.substring(0, baseUrl.length - 1);
  44. }
  45. $scope.urls = {
  46. workflow: baseUrl + '/workflow/'
  47. };
  48. })
  49. };
  50. $scope.appSelected = function(app) {
  51. if(app.fixedUrl) {
  52. $window.location.href = app.fixedUrl;
  53. }
  54. };
  55. $scope.addAppDefinition = function() {
  56. _internalCreateModal({
  57. template: 'views/modal/add-app-definition-modal.html',
  58. scope: $scope
  59. }, $modal, $scope);
  60. };
  61. $scope.deleteApp = function(app) {
  62. if(app && app.id) {
  63. RuntimeAppDefinitionService.deleteAppDefinition(app.id).then(function() {
  64. $rootScope.addAlertPromise($translate('APP.MESSAGE.DELETED'), 'info')
  65. // Remove app from list
  66. var index = -1;
  67. for(var i=0; i< $scope.model.apps.length; i++) {
  68. if($scope.model.apps[i].id == app.id) {
  69. index = i;
  70. break;
  71. }
  72. }
  73. if(index >= 0) {
  74. $scope.model.apps.splice(index, 1);
  75. }
  76. });
  77. }
  78. };
  79. $scope.loadApps();
  80. }]
  81. );