Added more behavior to servers list

This commit is contained in:
Alejandro Celaya
2018-06-14 20:11:41 +02:00
parent 9ac0811200
commit e4356720d7
7 changed files with 91 additions and 32 deletions

View File

@@ -0,0 +1,19 @@
const PREFIX = 'shlink';
const buildPath = path => `${PREFIX}.${path}`;
export class ServersService {
constructor(storage) {
this.storage = storage;
}
listServers = () => {
return JSON.parse(this.storage.getItem(buildPath('servers')) || '{}');
};
findServerById = serverId => {
const servers = this.listServers();
return servers[serverId];
}
}
export default new ServersService(localStorage);