diff options
Diffstat (limited to 'apps/settings/js/vue-settings-apps-users-management.js')
-rw-r--r-- | apps/settings/js/vue-settings-apps-users-management.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/apps/settings/js/vue-settings-apps-users-management.js b/apps/settings/js/vue-settings-apps-users-management.js index 4d813889657..2e1fd3a3c9f 100644 --- a/apps/settings/js/vue-settings-apps-users-management.js +++ b/apps/settings/js/vue-settings-apps-users-management.js @@ -64,7 +64,7 @@ t.exports=function(t){return null!=t&&null!=t.constructor&&"function"==typeof t. * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - */o.default.use(Wt);var Xt=new Wt({mode:"history",base:OC.generateUrl(""),linkActiveClass:"active",routes:[{path:"/:index(index.php/)?settings/users",component:Kt,props:!0,name:"users",children:[{path:":selectedGroup(.*)",name:"group",component:Kt}]},{path:"/:index(index.php/)?settings/apps",component:Yt,props:!0,name:"apps",children:[{path:":category",name:"apps-category",component:Yt,children:[{path:":id",name:"apps-details",component:Yt}]}]}]}),Jt=r(131),Qt=r(24),Zt=r.n(Qt),te=r(129),ee=r.n(te),ne=function(t){return t.replace(/\/$/,"")},re=function(){return ee()()},oe=function(t){return Zt.a.get(ne(t))},ie=function(t,e){return Zt.a.post(ne(t),e)},ae=function(t,e){return Zt.a.put(ne(t),e)},se=function(t,e){return Zt.a.delete(ne(t),{data:e})},ue=function(t,e){return 1===e?t.sort((function(t,e){return t.usercount-t.disabled<e.usercount-e.disabled})):t.sort((function(t,e){return t.name.localeCompare(e.name)}))},ce={id:"",name:"",usercount:0,disabled:0,canAdd:!0,canRemove:!0},fe={state:{users:[],groups:[],orderBy:1,minPasswordLength:0,usersOffset:0,usersLimit:25,userCount:0},mutations:{appendUsers:function(t,e){var n=t.users.concat(Object.keys(e).map((function(t){return e[t]})));t.usersOffset+=t.usersLimit,t.users=n},setPasswordPolicyMinLength:function(t,e){t.minPasswordLength=""!==e?e:0},initGroups:function(t,e){var n=e.groups,r=e.orderBy,o=e.userCount;t.groups=n.map((function(t){return Object.assign({},ce,t)})),t.orderBy=r,t.userCount=o,t.groups=ue(t.groups,t.orderBy)},addGroup:function(t,e){var n=e.gid,r=e.displayName;try{if(void 0!==t.groups.find((function(t){return t.id===n})))return;var o=Object.assign({},ce,{id:n,name:r});t.groups.push(o),t.groups=ue(t.groups,t.orderBy)}catch(t){console.error("Can't create group",t)}},removeGroup:function(t,e){var n=t.groups.findIndex((function(t){return t.id===e}));n>=0&&t.groups.splice(n,1)},addUserGroup:function(t,e){var n=e.userid,r=e.gid,o=t.groups.find((function(t){return t.id===r})),i=t.users.find((function(t){return t.id===n}));o&&i.enabled&&t.userCount>0&&o.usercount++,i.groups.push(r),t.groups=ue(t.groups,t.orderBy)},removeUserGroup:function(t,e){var n=e.userid,r=e.gid,o=t.groups.find((function(t){return t.id===r})),i=t.users.find((function(t){return t.id===n}));o&&i.enabled&&t.userCount>0&&o.usercount--;var a=i.groups;a.splice(a.indexOf(r),1),t.groups=ue(t.groups,t.orderBy)},addUserSubAdmin:function(t,e){var n=e.userid,r=e.gid;t.users.find((function(t){return t.id===n})).subadmin.push(r)},removeUserSubAdmin:function(t,e){var n=e.userid,r=e.gid,o=t.users.find((function(t){return t.id===n})).subadmin;o.splice(o.indexOf(r),1)},deleteUser:function(t,e){var n=t.users.findIndex((function(t){return t.id===e}));t.users.splice(n,1)},addUserData:function(t,e){t.users.push(e.data.ocs.data)},enableDisableUser:function(t,e){var n=e.userid,r=e.enabled,o=t.users.find((function(t){return t.id===n}));o.enabled=r,t.userCount>0&&(t.groups.find((function(t){return"disabled"===t.id})).usercount+=r?-1:1,t.userCount+=r?1:-1,o.groups.forEach((function(e){t.groups.find((function(t){return t.id===e})).disabled+=r?-1:1})))},setUserData:function(t,e){var n=e.userid,r=e.key,o=e.value;if("quota"===r){var i=OC.Util.computerFileSize(o);t.users.find((function(t){return t.id===n}))[r][r]=null!==i?i:o}else t.users.find((function(t){return t.id===n}))[r]=o},resetUsers:function(t){t.users=[],t.usersOffset=0}},getters:{getUsers:function(t){return t.users},getGroups:function(t){return t.groups},getSubadminGroups:function(t){return t.groups.filter((function(t){return"admin"!==t.id&&"disabled"!==t.id}))},getPasswordPolicyMinLength:function(t){return t.minPasswordLength},getUsersOffset:function(t){return t.usersOffset},getUsersLimit:function(t){return t.usersLimit},getUserCount:function(t){return t.userCount}},actions:{getUsers:function(t,e){var n=e.offset,r=e.limit,o=e.search,i=e.group;return o="string"==typeof o?o:"",""!==(i="string"==typeof i?i:"")?oe(OC.linkToOCS("cloud/groups/".concat(i,"/users/details?offset=").concat(n,"&limit=").concat(r,"&search=").concat(o),2)).then((function(e){return Object.keys(e.data.ocs.data.users).length>0&&(t.commit("appendUsers",e.data.ocs.data.users),!0)})).catch((function(e){return t.commit("API_FAILURE",e)})):oe(OC.linkToOCS("cloud/users/details?offset=".concat(n,"&limit=").concat(r,"&search=").concat(o),2)).then((function(e){return Object.keys(e.data.ocs.data.users).length>0&&(t.commit("appendUsers",e.data.ocs.data.users),!0)})).catch((function(e){return t.commit("API_FAILURE",e)}))},getGroups:function(t,e){var n=e.offset,r=e.limit,o=e.search;o="string"==typeof o?o:"";var i=-1===r?"":"&limit=".concat(r);return oe(OC.linkToOCS("cloud/groups?offset=".concat(n,"&search=").concat(o).concat(i),2)).then((function(e){return Object.keys(e.data.ocs.data.groups).length>0&&(e.data.ocs.data.groups.forEach((function(e){t.commit("addGroup",{gid:e,displayName:e})})),!0)})).catch((function(e){return t.commit("API_FAILURE",e)}))},getUsersFromList:function(t,e){var n=e.offset,r=e.limit,o=e.search;return o="string"==typeof o?o:"",oe(OC.linkToOCS("cloud/users/details?offset=".concat(n,"&limit=").concat(r,"&search=").concat(o),2)).then((function(e){return Object.keys(e.data.ocs.data.users).length>0&&(t.commit("appendUsers",e.data.ocs.data.users),!0)})).catch((function(e){return t.commit("API_FAILURE",e)}))},getUsersFromGroup:function(t,e){var n=e.groupid,r=e.offset,o=e.limit;return oe(OC.linkToOCS("cloud/users/".concat(n,"/details?offset=").concat(r,"&limit=").concat(o),2)).then((function(e){return t.commit("getUsersFromList",e.data.ocs.data.users)})).catch((function(e){return t.commit("API_FAILURE",e)}))},getPasswordPolicyMinLength:function(t){return!(!OC.getCapabilities().password_policy||!OC.getCapabilities().password_policy.minLength)&&(t.commit("setPasswordPolicyMinLength",OC.getCapabilities().password_policy.minLength),OC.getCapabilities().password_policy.minLength)},addGroup:function(t,e){return re().then((function(n){return ie(OC.linkToOCS("cloud/groups",2),{groupid:e}).then((function(n){return t.commit("addGroup",{gid:e,displayName:e}),{gid:e,displayName:e}})).catch((function(t){throw t}))})).catch((function(n){throw t.commit("API_FAILURE",{gid:e,error:n}),n}))},removeGroup:function(t,e){return re().then((function(n){return se(OC.linkToOCS("cloud/groups/".concat(e),2)).then((function(n){return t.commit("removeGroup",e)})).catch((function(t){throw t}))})).catch((function(n){return t.commit("API_FAILURE",{gid:e,error:n})}))},addUserGroup:function(t,e){var n=e.userid,r=e.gid;return re().then((function(e){return ie(OC.linkToOCS("cloud/users/".concat(n,"/groups"),2),{groupid:r}).then((function(e){return t.commit("addUserGroup",{userid:n,gid:r})})).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{userid:n,error:e})}))},removeUserGroup:function(t,e){var n=e.userid,r=e.gid;return re().then((function(e){return se(OC.linkToOCS("cloud/users/".concat(n,"/groups"),2),{groupid:r}).then((function(e){return t.commit("removeUserGroup",{userid:n,gid:r})})).catch((function(t){throw t}))})).catch((function(e){throw t.commit("API_FAILURE",{userid:n,error:e}),e}))},addUserSubAdmin:function(t,e){var n=e.userid,r=e.gid;return re().then((function(e){return ie(OC.linkToOCS("cloud/users/".concat(n,"/subadmins"),2),{groupid:r}).then((function(e){return t.commit("addUserSubAdmin",{userid:n,gid:r})})).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{userid:n,error:e})}))},removeUserSubAdmin:function(t,e){var n=e.userid,r=e.gid;return re().then((function(e){return se(OC.linkToOCS("cloud/users/".concat(n,"/subadmins"),2),{groupid:r}).then((function(e){return t.commit("removeUserSubAdmin",{userid:n,gid:r})})).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{userid:n,error:e})}))},wipeUserDevices:function(t,e){return re().then((function(t){return ie(OC.linkToOCS("cloud/users/".concat(e,"/wipe"),2)).catch((function(t){throw t}))})).catch((function(n){return t.commit("API_FAILURE",{userid:e,error:n})}))},deleteUser:function(t,e){return re().then((function(n){return se(OC.linkToOCS("cloud/users/".concat(e),2)).then((function(n){return t.commit("deleteUser",e)})).catch((function(t){throw t}))})).catch((function(n){return t.commit("API_FAILURE",{userid:e,error:n})}))},addUser:function(t,e){var n=t.commit,r=t.dispatch,o=e.userid,i=e.password,a=e.displayName,s=e.email,u=e.groups,c=e.subadmin,f=e.quota,l=e.language;return re().then((function(t){return ie(OC.linkToOCS("cloud/users",2),{userid:o,password:i,displayName:a,email:s,groups:u,subadmin:c,quota:f,language:l}).then((function(t){return r("addUserData",o||t.data.ocs.data.id)})).catch((function(t){throw t}))})).catch((function(t){throw n("API_FAILURE",{userid:o,error:t}),t}))},addUserData:function(t,e){return re().then((function(n){return oe(OC.linkToOCS("cloud/users/".concat(e),2)).then((function(e){return t.commit("addUserData",e)})).catch((function(t){throw t}))})).catch((function(n){return t.commit("API_FAILURE",{userid:e,error:n})}))},enableDisableUser:function(t,e){var n=e.userid,r=e.enabled,o=void 0===r||r,i=o?"enable":"disable";return re().then((function(e){return ae(OC.linkToOCS("cloud/users/".concat(n,"/").concat(i),2)).then((function(e){return t.commit("enableDisableUser",{userid:n,enabled:o})})).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{userid:n,error:e})}))},setUserData:function(t,e){var n=e.userid,r=e.key,o=e.value,i=["email","displayname"];return-1!==["email","language","quota","displayname","password"].indexOf(r)&&"string"==typeof o&&(-1===i.indexOf(r)&&o.length>0||-1!==i.indexOf(r))?re().then((function(e){return ae(OC.linkToOCS("cloud/users/".concat(n),2),{key:r,value:o}).then((function(e){return t.commit("setUserData",{userid:n,key:r,value:o})})).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{userid:n,error:e})})):Promise.reject(new Error("Invalid request data"))},sendWelcomeMail:function(t,e){return re().then((function(t){return ie(OC.linkToOCS("cloud/users/".concat(e,"/welcome"),2)).then((function(t){return!0})).catch((function(t){throw t}))})).catch((function(n){return t.commit("API_FAILURE",{userid:e,error:n})}))}}},le={state:{apps:[],categories:[],updateCount:0,loading:{},loadingList:!1},mutations:{APPS_API_FAILURE:function(e,n){OC.Notification.showHtml(t("settings","An error occured during the request. Unable to proceed.")+"<br>"+n.error.response.data.data.message,{timeout:7}),console.error(e,n)},initCategories:function(t,e){var n=e.categories,r=e.updateCount;t.categories=n,t.updateCount=r},setUpdateCount:function(t,e){t.updateCount=e},addCategory:function(t,e){t.categories.push(e)},appendCategories:function(t,e){t.categories=e},setAllApps:function(t,e){t.apps=e},setError:function(t,e){var n=e.appId,r=e.error;Array.isArray(n)||(n=[n]),n.forEach((function(e){t.apps.find((function(t){return t.id===e})).error=r}))},clearError:function(t,e){var n=e.appId;e.error;t.apps.find((function(t){return t.id===n})).error=null},enableApp:function(t,e){var n=e.appId,r=e.groups,o=t.apps.find((function(t){return t.id===n}));o.active=!0,o.groups=r},disableApp:function(t,e){var n=t.apps.find((function(t){return t.id===e}));n.active=!1,n.groups=[],n.removable&&(n.canUnInstall=!0)},uninstallApp:function(t,e){t.apps.find((function(t){return t.id===e})).active=!1,t.apps.find((function(t){return t.id===e})).groups=[],t.apps.find((function(t){return t.id===e})).needsDownload=!0,t.apps.find((function(t){return t.id===e})).installed=!1,t.apps.find((function(t){return t.id===e})).canUnInstall=!1,t.apps.find((function(t){return t.id===e})).canInstall=!0},updateApp:function(t,e){var n=t.apps.find((function(t){return t.id===e})),r=n.update;n.update=null,n.version=r,t.updateCount--},resetApps:function(t){t.apps=[]},reset:function(t){t.apps=[],t.categories=[],t.updateCount=0},startLoading:function(t,e){Array.isArray(e)?e.forEach((function(e){o.default.set(t.loading,e,!0)})):o.default.set(t.loading,e,!0)},stopLoading:function(t,e){Array.isArray(e)?e.forEach((function(e){o.default.set(t.loading,e,!1)})):o.default.set(t.loading,e,!1)}},getters:{loading:function(t){return function(e){return t.loading[e]}},getCategories:function(t){return t.categories},getAllApps:function(t){return t.apps},getUpdateCount:function(t){return t.updateCount}},actions:{enableApp:function(e,n){var r,o=n.appId,i=n.groups;return r=Array.isArray(o)?o:[o],re().then((function(n){return e.commit("startLoading",r),e.commit("startLoading","install"),ie(OC.generateUrl("settings/apps/enable"),{appIds:r,groups:i}).then((function(n){return e.commit("stopLoading",r),e.commit("stopLoading","install"),r.forEach((function(t){e.commit("enableApp",{appId:t,groups:i})})),oe(OC.generateUrl("apps/files")).then((function(){n.data.update_required&&(OC.dialogs.info(t("settings","The app has been enabled but needs to be updated. You will be redirected to the update page in 5 seconds."),t("settings","App update"),(function(){window.location.reload()}),!0),setTimeout((function(){location.reload()}),5e3))})).catch((function(){Array.isArray(o)||e.commit("setError",{appId:r,error:t("settings","Error: This app can not be enabled because it makes the server unstable")})}))})).catch((function(t){e.commit("stopLoading",r),e.commit("stopLoading","install"),e.commit("setError",{appId:r,error:t.response.data.data.message}),e.commit("APPS_API_FAILURE",{appId:o,error:t})}))})).catch((function(t){return e.commit("API_FAILURE",{appId:o,error:t})}))},forceEnableApp:function(t,e){var n,r=e.appId;e.groups;return n=Array.isArray(r)?r:[r],re().then((function(){return t.commit("startLoading",n),t.commit("startLoading","install"),ie(OC.generateUrl("settings/apps/force"),{appId:r}).then((function(t){location.reload()})).catch((function(e){t.commit("stopLoading",n),t.commit("stopLoading","install"),t.commit("setError",{appId:n,error:e.response.data.data.message}),t.commit("APPS_API_FAILURE",{appId:r,error:e})}))})).catch((function(e){return t.commit("API_FAILURE",{appId:r,error:e})}))},disableApp:function(t,e){var n,r=e.appId;return n=Array.isArray(r)?r:[r],re().then((function(e){return t.commit("startLoading",n),ie(OC.generateUrl("settings/apps/disable"),{appIds:n}).then((function(e){return t.commit("stopLoading",n),n.forEach((function(e){t.commit("disableApp",e)})),!0})).catch((function(e){t.commit("stopLoading",n),t.commit("APPS_API_FAILURE",{appId:r,error:e})}))})).catch((function(e){return t.commit("API_FAILURE",{appId:r,error:e})}))},uninstallApp:function(t,e){var n=e.appId;return re().then((function(e){return t.commit("startLoading",n),oe(OC.generateUrl("settings/apps/uninstall/".concat(n))).then((function(e){return t.commit("stopLoading",n),t.commit("uninstallApp",n),!0})).catch((function(e){t.commit("stopLoading",n),t.commit("APPS_API_FAILURE",{appId:n,error:e})}))})).catch((function(e){return t.commit("API_FAILURE",{appId:n,error:e})}))},updateApp:function(t,e){var n=e.appId;return re().then((function(e){return t.commit("startLoading",n),t.commit("startLoading","install"),oe(OC.generateUrl("settings/apps/update/".concat(n))).then((function(e){return t.commit("stopLoading","install"),t.commit("stopLoading",n),t.commit("updateApp",n),!0})).catch((function(e){t.commit("stopLoading",n),t.commit("stopLoading","install"),t.commit("APPS_API_FAILURE",{appId:n,error:e})}))})).catch((function(e){return t.commit("API_FAILURE",{appId:n,error:e})}))},getAllApps:function(t){return t.commit("startLoading","list"),oe(OC.generateUrl("settings/apps/list")).then((function(e){return t.commit("setAllApps",e.data.apps),t.commit("stopLoading","list"),!0})).catch((function(e){return t.commit("API_FAILURE",e)}))},getCategories:function(t){return t.commit("startLoading","categories"),oe(OC.generateUrl("settings/apps/categories")).then((function(e){return e.data.length>0&&(t.commit("appendCategories",e.data),t.commit("stopLoading","categories"),!0)})).catch((function(e){return t.commit("API_FAILURE",e)}))}}},pe={state:{serverData:{}},mutations:{setServerData:function(t,e){t.serverData=e}},getters:{getServerData:function(t){return t.serverData}},actions:{}},de={state:{},mutations:{},getters:{},actions:{setAppConfig:function(t,e){var n=e.app,r=e.key,o=e.value;return re().then((function(t){return ie(OC.linkToOCS("apps/provisioning_api/api/v1/config/apps/".concat(n,"/").concat(r),2),{value:o}).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{app:n,key:r,value:o,error:e})}))}}}; + */o.default.use(Wt);var Xt=new Wt({mode:"history",base:OC.generateUrl(""),linkActiveClass:"active",routes:[{path:"/:index(index.php/)?settings/users",component:Kt,props:!0,name:"users",children:[{path:":selectedGroup(.*)",name:"group",component:Kt}]},{path:"/:index(index.php/)?settings/apps",component:Yt,props:!0,name:"apps",children:[{path:":category",name:"apps-category",component:Yt,children:[{path:":id",name:"apps-details",component:Yt}]}]}]}),Jt=r(131),Qt=r(24),Zt=r.n(Qt),te=r(129),ee=r.n(te),ne=function(t){return t.replace(/\/$/,"")},re=function(){return ee()()},oe=function(t){return Zt.a.get(ne(t))},ie=function(t,e){return Zt.a.post(ne(t),e)},ae=function(t,e){return Zt.a.put(ne(t),e)},se=function(t,e){return Zt.a.delete(ne(t),{data:e})},ue=function(t,e){return 1===e?t.sort((function(t,e){return t.usercount-t.disabled<e.usercount-e.disabled})):t.sort((function(t,e){return t.name.localeCompare(e.name)}))},ce={id:"",name:"",usercount:0,disabled:0,canAdd:!0,canRemove:!0},fe={state:{users:[],groups:[],orderBy:1,minPasswordLength:0,usersOffset:0,usersLimit:25,userCount:0},mutations:{appendUsers:function(t,e){var n=t.users.concat(Object.keys(e).map((function(t){return e[t]})));t.usersOffset+=t.usersLimit,t.users=n},setPasswordPolicyMinLength:function(t,e){t.minPasswordLength=""!==e?e:0},initGroups:function(t,e){var n=e.groups,r=e.orderBy,o=e.userCount;t.groups=n.map((function(t){return Object.assign({},ce,t)})),t.orderBy=r,t.userCount=o,t.groups=ue(t.groups,t.orderBy)},addGroup:function(t,e){var n=e.gid,r=e.displayName;try{if(void 0!==t.groups.find((function(t){return t.id===n})))return;var o=Object.assign({},ce,{id:n,name:r});t.groups.push(o),t.groups=ue(t.groups,t.orderBy)}catch(t){console.error("Can't create group",t)}},removeGroup:function(t,e){var n=t.groups.findIndex((function(t){return t.id===e}));n>=0&&t.groups.splice(n,1)},addUserGroup:function(t,e){var n=e.userid,r=e.gid,o=t.groups.find((function(t){return t.id===r})),i=t.users.find((function(t){return t.id===n}));o&&i.enabled&&t.userCount>0&&o.usercount++,i.groups.push(r),t.groups=ue(t.groups,t.orderBy)},removeUserGroup:function(t,e){var n=e.userid,r=e.gid,o=t.groups.find((function(t){return t.id===r})),i=t.users.find((function(t){return t.id===n}));o&&i.enabled&&t.userCount>0&&o.usercount--;var a=i.groups;a.splice(a.indexOf(r),1),t.groups=ue(t.groups,t.orderBy)},addUserSubAdmin:function(t,e){var n=e.userid,r=e.gid;t.users.find((function(t){return t.id===n})).subadmin.push(r)},removeUserSubAdmin:function(t,e){var n=e.userid,r=e.gid,o=t.users.find((function(t){return t.id===n})).subadmin;o.splice(o.indexOf(r),1)},deleteUser:function(t,e){var n=t.users.findIndex((function(t){return t.id===e}));t.users.splice(n,1)},addUserData:function(t,e){t.users.push(e.data.ocs.data)},enableDisableUser:function(t,e){var n=e.userid,r=e.enabled,o=t.users.find((function(t){return t.id===n}));o.enabled=r,t.userCount>0&&(t.groups.find((function(t){return"disabled"===t.id})).usercount+=r?-1:1,t.userCount+=r?1:-1,o.groups.forEach((function(e){t.groups.find((function(t){return t.id===e})).disabled+=r?-1:1})))},setUserData:function(t,e){var n=e.userid,r=e.key,o=e.value;if("quota"===r){var i=OC.Util.computerFileSize(o);t.users.find((function(t){return t.id===n}))[r][r]=null!==i?i:o}else t.users.find((function(t){return t.id===n}))[r]=o},resetUsers:function(t){t.users=[],t.usersOffset=0}},getters:{getUsers:function(t){return t.users},getGroups:function(t){return t.groups},getSubadminGroups:function(t){return t.groups.filter((function(t){return"admin"!==t.id&&"disabled"!==t.id}))},getPasswordPolicyMinLength:function(t){return t.minPasswordLength},getUsersOffset:function(t){return t.usersOffset},getUsersLimit:function(t){return t.usersLimit},getUserCount:function(t){return t.userCount}},actions:{getUsers:function(t,e){var n=e.offset,r=e.limit,o=e.search,i=e.group;return o="string"==typeof o?o:"",""!==(i="string"==typeof i?i:"")?oe(OC.linkToOCS("cloud/groups/".concat(i,"/users/details?offset=").concat(n,"&limit=").concat(r,"&search=").concat(o),2)).then((function(e){return Object.keys(e.data.ocs.data.users).length>0&&(t.commit("appendUsers",e.data.ocs.data.users),!0)})).catch((function(e){return t.commit("API_FAILURE",e)})):oe(OC.linkToOCS("cloud/users/details?offset=".concat(n,"&limit=").concat(r,"&search=").concat(o),2)).then((function(e){return Object.keys(e.data.ocs.data.users).length>0&&(t.commit("appendUsers",e.data.ocs.data.users),!0)})).catch((function(e){return t.commit("API_FAILURE",e)}))},getGroups:function(t,e){var n=e.offset,r=e.limit,o=e.search;o="string"==typeof o?o:"";var i=-1===r?"":"&limit=".concat(r);return oe(OC.linkToOCS("cloud/groups?offset=".concat(n,"&search=").concat(o).concat(i),2)).then((function(e){return Object.keys(e.data.ocs.data.groups).length>0&&(e.data.ocs.data.groups.forEach((function(e){t.commit("addGroup",{gid:e,displayName:e})})),!0)})).catch((function(e){return t.commit("API_FAILURE",e)}))},getUsersFromList:function(t,e){var n=e.offset,r=e.limit,o=e.search;return o="string"==typeof o?o:"",oe(OC.linkToOCS("cloud/users/details?offset=".concat(n,"&limit=").concat(r,"&search=").concat(o),2)).then((function(e){return Object.keys(e.data.ocs.data.users).length>0&&(t.commit("appendUsers",e.data.ocs.data.users),!0)})).catch((function(e){return t.commit("API_FAILURE",e)}))},getUsersFromGroup:function(t,e){var n=e.groupid,r=e.offset,o=e.limit;return oe(OC.linkToOCS("cloud/users/".concat(n,"/details?offset=").concat(r,"&limit=").concat(o),2)).then((function(e){return t.commit("getUsersFromList",e.data.ocs.data.users)})).catch((function(e){return t.commit("API_FAILURE",e)}))},getPasswordPolicyMinLength:function(t){return!(!OC.getCapabilities().password_policy||!OC.getCapabilities().password_policy.minLength)&&(t.commit("setPasswordPolicyMinLength",OC.getCapabilities().password_policy.minLength),OC.getCapabilities().password_policy.minLength)},addGroup:function(t,e){return re().then((function(n){return ie(OC.linkToOCS("cloud/groups",2),{groupid:e}).then((function(n){return t.commit("addGroup",{gid:e,displayName:e}),{gid:e,displayName:e}})).catch((function(t){throw t}))})).catch((function(n){throw t.commit("API_FAILURE",{gid:e,error:n}),n}))},removeGroup:function(t,e){return re().then((function(n){return se(OC.linkToOCS("cloud/groups/".concat(encodeURIComponent(e)),2)).then((function(n){return t.commit("removeGroup",e)})).catch((function(t){throw t}))})).catch((function(n){return t.commit("API_FAILURE",{gid:e,error:n})}))},addUserGroup:function(t,e){var n=e.userid,r=e.gid;return re().then((function(e){return ie(OC.linkToOCS("cloud/users/".concat(n,"/groups"),2),{groupid:r}).then((function(e){return t.commit("addUserGroup",{userid:n,gid:r})})).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{userid:n,error:e})}))},removeUserGroup:function(t,e){var n=e.userid,r=e.gid;return re().then((function(e){return se(OC.linkToOCS("cloud/users/".concat(n,"/groups"),2),{groupid:r}).then((function(e){return t.commit("removeUserGroup",{userid:n,gid:r})})).catch((function(t){throw t}))})).catch((function(e){throw t.commit("API_FAILURE",{userid:n,error:e}),e}))},addUserSubAdmin:function(t,e){var n=e.userid,r=e.gid;return re().then((function(e){return ie(OC.linkToOCS("cloud/users/".concat(n,"/subadmins"),2),{groupid:r}).then((function(e){return t.commit("addUserSubAdmin",{userid:n,gid:r})})).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{userid:n,error:e})}))},removeUserSubAdmin:function(t,e){var n=e.userid,r=e.gid;return re().then((function(e){return se(OC.linkToOCS("cloud/users/".concat(n,"/subadmins"),2),{groupid:r}).then((function(e){return t.commit("removeUserSubAdmin",{userid:n,gid:r})})).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{userid:n,error:e})}))},wipeUserDevices:function(t,e){return re().then((function(t){return ie(OC.linkToOCS("cloud/users/".concat(e,"/wipe"),2)).catch((function(t){throw t}))})).catch((function(n){return t.commit("API_FAILURE",{userid:e,error:n})}))},deleteUser:function(t,e){return re().then((function(n){return se(OC.linkToOCS("cloud/users/".concat(e),2)).then((function(n){return t.commit("deleteUser",e)})).catch((function(t){throw t}))})).catch((function(n){return t.commit("API_FAILURE",{userid:e,error:n})}))},addUser:function(t,e){var n=t.commit,r=t.dispatch,o=e.userid,i=e.password,a=e.displayName,s=e.email,u=e.groups,c=e.subadmin,f=e.quota,l=e.language;return re().then((function(t){return ie(OC.linkToOCS("cloud/users",2),{userid:o,password:i,displayName:a,email:s,groups:u,subadmin:c,quota:f,language:l}).then((function(t){return r("addUserData",o||t.data.ocs.data.id)})).catch((function(t){throw t}))})).catch((function(t){throw n("API_FAILURE",{userid:o,error:t}),t}))},addUserData:function(t,e){return re().then((function(n){return oe(OC.linkToOCS("cloud/users/".concat(e),2)).then((function(e){return t.commit("addUserData",e)})).catch((function(t){throw t}))})).catch((function(n){return t.commit("API_FAILURE",{userid:e,error:n})}))},enableDisableUser:function(t,e){var n=e.userid,r=e.enabled,o=void 0===r||r,i=o?"enable":"disable";return re().then((function(e){return ae(OC.linkToOCS("cloud/users/".concat(n,"/").concat(i),2)).then((function(e){return t.commit("enableDisableUser",{userid:n,enabled:o})})).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{userid:n,error:e})}))},setUserData:function(t,e){var n=e.userid,r=e.key,o=e.value,i=["email","displayname"];return-1!==["email","language","quota","displayname","password"].indexOf(r)&&"string"==typeof o&&(-1===i.indexOf(r)&&o.length>0||-1!==i.indexOf(r))?re().then((function(e){return ae(OC.linkToOCS("cloud/users/".concat(n),2),{key:r,value:o}).then((function(e){return t.commit("setUserData",{userid:n,key:r,value:o})})).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{userid:n,error:e})})):Promise.reject(new Error("Invalid request data"))},sendWelcomeMail:function(t,e){return re().then((function(t){return ie(OC.linkToOCS("cloud/users/".concat(e,"/welcome"),2)).then((function(t){return!0})).catch((function(t){throw t}))})).catch((function(n){return t.commit("API_FAILURE",{userid:e,error:n})}))}}},le={state:{apps:[],categories:[],updateCount:0,loading:{},loadingList:!1},mutations:{APPS_API_FAILURE:function(e,n){OC.Notification.showHtml(t("settings","An error occured during the request. Unable to proceed.")+"<br>"+n.error.response.data.data.message,{timeout:7}),console.error(e,n)},initCategories:function(t,e){var n=e.categories,r=e.updateCount;t.categories=n,t.updateCount=r},setUpdateCount:function(t,e){t.updateCount=e},addCategory:function(t,e){t.categories.push(e)},appendCategories:function(t,e){t.categories=e},setAllApps:function(t,e){t.apps=e},setError:function(t,e){var n=e.appId,r=e.error;Array.isArray(n)||(n=[n]),n.forEach((function(e){t.apps.find((function(t){return t.id===e})).error=r}))},clearError:function(t,e){var n=e.appId;e.error;t.apps.find((function(t){return t.id===n})).error=null},enableApp:function(t,e){var n=e.appId,r=e.groups,o=t.apps.find((function(t){return t.id===n}));o.active=!0,o.groups=r},disableApp:function(t,e){var n=t.apps.find((function(t){return t.id===e}));n.active=!1,n.groups=[],n.removable&&(n.canUnInstall=!0)},uninstallApp:function(t,e){t.apps.find((function(t){return t.id===e})).active=!1,t.apps.find((function(t){return t.id===e})).groups=[],t.apps.find((function(t){return t.id===e})).needsDownload=!0,t.apps.find((function(t){return t.id===e})).installed=!1,t.apps.find((function(t){return t.id===e})).canUnInstall=!1,t.apps.find((function(t){return t.id===e})).canInstall=!0},updateApp:function(t,e){var n=t.apps.find((function(t){return t.id===e})),r=n.update;n.update=null,n.version=r,t.updateCount--},resetApps:function(t){t.apps=[]},reset:function(t){t.apps=[],t.categories=[],t.updateCount=0},startLoading:function(t,e){Array.isArray(e)?e.forEach((function(e){o.default.set(t.loading,e,!0)})):o.default.set(t.loading,e,!0)},stopLoading:function(t,e){Array.isArray(e)?e.forEach((function(e){o.default.set(t.loading,e,!1)})):o.default.set(t.loading,e,!1)}},getters:{loading:function(t){return function(e){return t.loading[e]}},getCategories:function(t){return t.categories},getAllApps:function(t){return t.apps},getUpdateCount:function(t){return t.updateCount}},actions:{enableApp:function(e,n){var r,o=n.appId,i=n.groups;return r=Array.isArray(o)?o:[o],re().then((function(n){return e.commit("startLoading",r),e.commit("startLoading","install"),ie(OC.generateUrl("settings/apps/enable"),{appIds:r,groups:i}).then((function(n){return e.commit("stopLoading",r),e.commit("stopLoading","install"),r.forEach((function(t){e.commit("enableApp",{appId:t,groups:i})})),oe(OC.generateUrl("apps/files")).then((function(){n.data.update_required&&(OC.dialogs.info(t("settings","The app has been enabled but needs to be updated. You will be redirected to the update page in 5 seconds."),t("settings","App update"),(function(){window.location.reload()}),!0),setTimeout((function(){location.reload()}),5e3))})).catch((function(){Array.isArray(o)||e.commit("setError",{appId:r,error:t("settings","Error: This app can not be enabled because it makes the server unstable")})}))})).catch((function(t){e.commit("stopLoading",r),e.commit("stopLoading","install"),e.commit("setError",{appId:r,error:t.response.data.data.message}),e.commit("APPS_API_FAILURE",{appId:o,error:t})}))})).catch((function(t){return e.commit("API_FAILURE",{appId:o,error:t})}))},forceEnableApp:function(t,e){var n,r=e.appId;e.groups;return n=Array.isArray(r)?r:[r],re().then((function(){return t.commit("startLoading",n),t.commit("startLoading","install"),ie(OC.generateUrl("settings/apps/force"),{appId:r}).then((function(t){location.reload()})).catch((function(e){t.commit("stopLoading",n),t.commit("stopLoading","install"),t.commit("setError",{appId:n,error:e.response.data.data.message}),t.commit("APPS_API_FAILURE",{appId:r,error:e})}))})).catch((function(e){return t.commit("API_FAILURE",{appId:r,error:e})}))},disableApp:function(t,e){var n,r=e.appId;return n=Array.isArray(r)?r:[r],re().then((function(e){return t.commit("startLoading",n),ie(OC.generateUrl("settings/apps/disable"),{appIds:n}).then((function(e){return t.commit("stopLoading",n),n.forEach((function(e){t.commit("disableApp",e)})),!0})).catch((function(e){t.commit("stopLoading",n),t.commit("APPS_API_FAILURE",{appId:r,error:e})}))})).catch((function(e){return t.commit("API_FAILURE",{appId:r,error:e})}))},uninstallApp:function(t,e){var n=e.appId;return re().then((function(e){return t.commit("startLoading",n),oe(OC.generateUrl("settings/apps/uninstall/".concat(n))).then((function(e){return t.commit("stopLoading",n),t.commit("uninstallApp",n),!0})).catch((function(e){t.commit("stopLoading",n),t.commit("APPS_API_FAILURE",{appId:n,error:e})}))})).catch((function(e){return t.commit("API_FAILURE",{appId:n,error:e})}))},updateApp:function(t,e){var n=e.appId;return re().then((function(e){return t.commit("startLoading",n),t.commit("startLoading","install"),oe(OC.generateUrl("settings/apps/update/".concat(n))).then((function(e){return t.commit("stopLoading","install"),t.commit("stopLoading",n),t.commit("updateApp",n),!0})).catch((function(e){t.commit("stopLoading",n),t.commit("stopLoading","install"),t.commit("APPS_API_FAILURE",{appId:n,error:e})}))})).catch((function(e){return t.commit("API_FAILURE",{appId:n,error:e})}))},getAllApps:function(t){return t.commit("startLoading","list"),oe(OC.generateUrl("settings/apps/list")).then((function(e){return t.commit("setAllApps",e.data.apps),t.commit("stopLoading","list"),!0})).catch((function(e){return t.commit("API_FAILURE",e)}))},getCategories:function(t){return t.commit("startLoading","categories"),oe(OC.generateUrl("settings/apps/categories")).then((function(e){return e.data.length>0&&(t.commit("appendCategories",e.data),t.commit("stopLoading","categories"),!0)})).catch((function(e){return t.commit("API_FAILURE",e)}))}}},pe={state:{serverData:{}},mutations:{setServerData:function(t,e){t.serverData=e}},getters:{getServerData:function(t){return t.serverData}},actions:{}},de={state:{},mutations:{},getters:{},actions:{setAppConfig:function(t,e){var n=e.app,r=e.key,o=e.value;return re().then((function(t){return ie(OC.linkToOCS("apps/provisioning_api/api/v1/config/apps/".concat(n,"/").concat(r),2),{value:o}).catch((function(t){throw t}))})).catch((function(e){return t.commit("API_FAILURE",{app:n,key:r,value:o,error:e})}))}}}; /** * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com> * @@ -110,4 +110,4 @@ o.default.use(Jt.a);var he={API_FAILURE:function(e,n){try{var r=n.error.response * */ o.default.use(i.a,{defaultHtml:!1}),Object(a.sync)(ve,Xt),r.nc=btoa(OC.requestToken),r.p=OC.linkTo("settings","js/"),o.default.prototype.t=t,o.default.prototype.OC=OC,o.default.prototype.OCA=OCA,o.default.prototype.oc_userconfig=oc_userconfig;var me=new o.default({router:Xt,store:ve,render:function(t){return t(c)}}).$mount("#content")}]); -//# sourceMappingURL=vue-settings-apps-users-management.js.map?v=9bdbad57494eb1f6b825
\ No newline at end of file +//# sourceMappingURL=vue-settings-apps-users-management.js.map?v=6f99ac5627310d3591f4
\ No newline at end of file |