profile
viewpoint

Ask questionsFeature: UI to add 'user specific' status check

Introduction I thought hard about adding a Service for my office's intranet (which is something we desperately need), but then I realised that such a PR may not be in the interest of the broader community (i.e. polluting the list of services with a service that only we would use). This feature request is meant as a starting point for that discussion.

Feature Instead of adding every service known to man, it may be more useful to add a feature that enables users to create a custom status check just for themselves. The story would look something like this:

(stts user) After opening the settings dropout And pressing a button labelled "+" I'd like to see a new view where I can define a status check on a website of my choosing

Discussion

Does it make more sense to build such a feature, or should I just add a Service?

inket/stts

Answer questions inket

Thank you for the suggestion! I have thought about this and I think it would take a considerable amount of time to implement such a feature. Though I definitely plan to add it in the future.

Are you interested in checking that your intranet is returning "200 OK" or is it using one of the cloud status providers like statuspage?

For now I would say it's easier to add the service and build the app yourself. If you need to check that your intranet is returning 200 it should be as simple as this:

// file: stts/Services/MyIntranet.swift
// make sure it's added to the project file via Xcode
// running the app will automatically add "My Local Intranet" to the services list

import Foundation

class MyIntranet: Service {
    let name = "My Local Intranet"
    let url = URL(string: "https://example.com")!

    override func updateStatus(callback: @escaping (BaseService) -> Void) {
        loadData(with: url) { [weak self] data, resp, error in
            guard let strongSelf = self else { return }

            if let response = resp as? HTTPURLResponse, response.statusCode == 200 {
                self?.status = .good
                self?.message = "Intranet up"
            } else {
                self?.status = .major
                self?.message = "Intranet down"
            }

            callback(strongSelf)
        }
    }
}
useful!

Related questions

No questions were found.
Github User Rank List