UNPKG

shadowsocks-manager

Version:

A shadowsocks manager tool for multi user and traffic control.

47 lines (46 loc) 1.18 kB
const app = angular.module('app'); const window = require('window'); const cdn = window.cdn || ''; app.factory('serverChartDialog' , [ '$mdDialog', $mdDialog => { const publicInfo = {}; const hide = () => { return $mdDialog.hide() .then(success => { dialogPromise = null; return; }).catch(err => { dialogPromise = null; return; }); }; publicInfo.hide = hide; let dialogPromise = null; const isDialogShow = () => { if(dialogPromise && !dialogPromise.$$state.status) { return true; } return false; }; const dialog = { templateUrl: `${ cdn }/public/views/dialog/serverChart.html`, escapeToClose: false, locals: { bind: publicInfo }, bindToController: true, controller: ['$scope', 'bind', function($scope, bind) { $scope.publicInfo = bind; }], clickOutsideToClose: true, }; const show = serverChart => { if(isDialogShow()) { return dialogPromise; } publicInfo.serverChart = serverChart; dialogPromise = $mdDialog.show(dialog); return dialogPromise; }; return { show, hide, }; }]);