简体   繁体   English

单个文件中包含独立的Angular脚本和数据

[英]Self-contained Angular script and data in a single file

Background 背景

I'd like to create a "dashboard" to help me keep organized, eg issues I'm working on, issues I've delegated to others, email threads awaiting response, and so on. 我想创建一个“仪表盘”来帮助我保持井井有条, 例如,我正在处理的问题,已委派给他人的问题,等待响应的电子邮件线程等等。 I know about issue tracking and project management software, but I wanted something lightweight and highly customizable, eg flashing red box when a test server goes down (pinged via async call every minute or so), to integrate everything I need to see in a single page. 我知道有关问题跟踪和项目管理软件的信息,但是我想要一些轻巧且高度可定制的东西, 例如,当测试服务器停机时(每分钟左右通过异步调用ping)闪烁的红色框,以便将我需要查看的所有内容集成到一个页。

Question

I'd like to end up with a single HTML file with Angular scripts for adding and removing issues, emails threads, test server IP addresses, etc. Of course the kicker is that I'd like all this data to be saved in the file itself , so the next time I open this HTML file (or if I open it in another tab), my dashboard would always be up-to-date. 我想最后得到一个带有Angular脚本的HTML文件,用于添加和删除问题,电子邮件线程,测试服务器IP地址等。当然,最重要的是我希望所有这些数据都保存在文件中本身 ,因此,下次我打开此HTML文件时(或者如果在其他选项卡中打开它),则仪表板将始终是最新的。 Is this possible to do, or is there some security-related or filesystem-related restriction that makes it impossible? 这是可能做到的,还是有一些与安全性或文件系统相关的限制使其不可能?

Thoughts 思想

I'm not permitted to install anything on our test servers, eg Apache, MySQL, nor on my own desktop at work—I had to fight IT to get something as simple as 7-Zip on my machine. 我不允许在我们的测试服务器( 例如 Apache,MySQL)上安装任何东西,也不能在自己的工作台式机上安装任何东西-我必须与IT部门抗衡才能在计算机上获得像7-Zip这样简单的内容。

I read about HTML5's storage features, but I'm worried that an accidental disk cleanup or browser data cleanup might wipe out my dashboard. 我阅读了有关HTML5的存储功能的信息,但我担心意外的磁盘清理或浏览器数据清理可能会抹掉我的仪表板。

These are the reasons I'm asking about a self-contained solution. 这就是我要一个独立的解决方案的原因。

I only need this to work on my own desktop, I'm willing to use any browser to make it work, and it's okay if I have to grant some kind of permissions each time to make it work, since likely I'll open it once and keep it open until the next Windows Update shuts down my desktop. 我只需要在自己的桌面上运行它,我愿意使用任何浏览器来使其正常工作,并且每次必须授予某种权限才能使其正常运行是可以的,因为可能会打开它一次并保持打开状态,直到下一个Windows Update关闭我的桌面为止。

Answer to your Question 回答你的问题

Since the data in an Angular page is limited to what can be held in the browser you would need to write a custom directive to ping an API to read in the file each time, and some backend to serve up this data. 由于Angular页面中的数据仅限于浏览器中可以保存的内容,因此您需要编写一个自定义指令来ping API每次读取文件中的API,并编写一些后端来提供此数据。 this seems like more work than it is worth. 这似乎是值得的工作。

Answer to Your Problem 回答你的问题

The better solution would be to have an Angular.JS frontend and a Firebase backend. 更好的解决方案是拥有Angular.JS前端和Firebase后端。

Related Info 相关资料

Firebase is a Backend as a Service (BaaS) solution that seems to fit you needs. Firebase是一种似乎很适合您的后端即服务(BaaS)解决方案。 Firebase allows real-time data with very few lines of code. Firebase只需很少的代码行即可实现实时数据。 The free tier is quite adequate for what you are asking for and it would allow you to keep your items up-to-date with ease. 免费套餐足以满足您的要求,并且可以让您轻松地更新商品。 Firebase has free hosting of your solution (with caveats) and since it is owned by Google (as is Angular) they play together nicely (eg they both use 2-way data binding). Firebase可以免费托管您的解决方案(带有警告),并且由于它是Google拥有的(Angular也是如此),因此它们可以很好地协作(例如,它们都使用2向数据绑定)。 What's more is Firebase is a No-sql type solution so you can dynamically adapt the structure of the db objects to fit your needs. 而且,Firebase是一种No-sql类型的解决方案,因此您可以动态调整db对象的结构来满足您的需求。

I would go with that if I were you. 如果我是你,我会同意的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM